2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: DmxPrintJob.C /main/30 1998/07/23 18:11:50 mgreess $ */
30 * RESTRICTED CONFIDENTIAL INFORMATION:
32 * The information in this document is subject to special
33 * restrictions in a confidential disclosure agreement between
34 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
35 * document outside HP, IBM, Sun, USL, SCO, or Univel without
36 * Sun's specific written approval. This document and all copies
37 * and derivative works thereof must be returned or destroyed at
40 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
45 * Common Desktop Environment
47 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
48 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
49 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
50 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
51 * (c) Copyright 1995 Digital Equipment Corp.
52 * (c) Copyright 1995 Fujitsu Limited
53 * (c) Copyright 1995 Hitachi, Ltd.
56 * RESTRICTED RIGHTS LEGEND
58 *Use, duplication, or disclosure by the U.S. Government is subject to
59 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
60 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
61 *for non-DOD U.S. Government Departments and Agencies are as set forth in
62 *FAR 52.227-19(c)(1,2).
64 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
65 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
66 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
67 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
68 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
69 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
70 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
80 #include <sys/param.h>
81 #include <X11/Intrinsic.h>
82 #include <X11/Shell.h>
87 #include "DmxPrintJob.h"
88 #include "DmxPrintOptions.h"
89 #include "DmxPrintOutput.h"
90 #include "DmxPrintSetup.h"
91 #include "DtMailGenDialog.hh"
92 #include "DtMailDialogCallbackData.hh"
99 // Public class methods
102 DmxPrintJob::DmxPrintJob(
104 DtMailBoolean silent,
106 ) : UIComponent( "PrintJob" )
108 _next_msg = (DmxMsg *) NULL;
109 _filename = strdup(filename);
110 _mailbox = (DmxMailbox *) NULL;
112 _print_output = (DmxPrintOutput *) NULL;
113 _print_setup = (DmxPrintSetup *) NULL;
114 _print_data = (DtPrintSetupData *) XtMalloc(sizeof(DtPrintSetupData));
115 memset((void*) _print_data, 0, sizeof(DtPrintSetupData));
116 _pshell = (Widget) NULL;
119 _spool_msg_info = (DmxMsgInfo *) NULL;
120 _spool_nmsgs_done = 0;
121 _spool_nmsgs_total = 0;
122 _spool_npages_done = 0;
123 _spool_npages_total = 0;
124 _w = XtCreateWidget(_name, coreWidgetClass, _parent->baseWidget(), NULL, 0);
125 installDestroyHandler();
127 _nextpage_shell = NULL;
128 _nextpage_button = NULL;
131 DmxPrintJob::~DmxPrintJob (void)
134 // Unregister the fact that we have a print job running so
135 // dtmail can terminate.
138 _parent->unregisterPendingTask();
152 XtFree((char*) _spool_msg_info);
153 _spool_msg_info = NULL;
157 delete _print_output;
158 _print_output = NULL;
167 XtDestroyWidget(_pshell);
172 DtPrintFreeSetupData(_print_data);
173 XtFree((char *) _print_data);
178 XtDestroyWidget(_nextpage_shell);
179 _nextpage_shell = NULL;
184 // Do not destroy this widget.
185 // BasicComponent takes care of this for us.
191 * Name: DmxPrintJob::cancel
193 * Public method used to cancel the print job.
196 DmxPrintJob::cancel(void)
199 _parent->clearStatus();
203 Display *display = XtDisplay(_pshell);
205 theRoamApp.unregisterActivePrintDisplay(display);
206 if (display == theRoamApp.getErrorPrintDisplay())
209 // Need to display an error dialog;
211 DtMailGenDialog *genDialog = new DtMailGenDialog(
213 _parent->baseWidget());
217 "The X Print Server is temporarily out of resources.");
219 genDialog->setToErrorDialog(GETMSG(DT_catd, 1, 6, "Mailer"),
221 genDialog->post_and_return(GETMSG(DT_catd, 3, 9, "OK"), NULL);
224 theRoamApp.setErrorPrintDisplay(NULL);
231 * Name: DmxPrintJob::execute
233 * Public method used to execute the print job.
236 DmxPrintJob::execute (void)
238 theRoamApp.busyAllWindows();
239 _print_setup = new DmxPrintSetup(
240 _parent->baseWidget(),
241 &DmxPrintJob::printCB, (XtPointer) this,
242 &DmxPrintJob::cancelCB, (XtPointer) this,
243 &DmxPrintJob::closeDisplayCB, (XtPointer) this,
244 &DmxPrintJob::pdmSetupCB, (XtPointer) this);
247 // load in the messages
249 _mailbox = new DmxMailbox(_filename);
250 _mailbox->loadMessages();
251 _next_msg = _mailbox->firstMessage();
253 if (_mailbox->numMessages() == 1)
256 char *orig_subject = _next_msg->getMessageHeader(DMXSUBJ);
257 int orig_len = strlen(orig_subject);
258 char *subject = (char*) malloc(orig_len+1);
259 char *filename = (char*) malloc(MAXPATHLEN+1);
262 for (i=0,j=0,last_space=0; i<orig_len; i++)
264 if (isspace(orig_subject[i]))
266 if (last_space < i-1)
270 else if (orig_subject[i] == '/')
273 subject[j++] = orig_subject[i];
276 sprintf(filename, "%s/%s.ps", getenv("HOME"), subject);
278 _print_setup->setPrintToFileName(filename);
283 theRoamApp.unbusyAllWindows();
286 if (DTM_TRUE != _print_setup->getDefaultPrintData(_print_data))
288 // DtPrintSetupDialog is popped up automatically.
295 _print_setup->display();
302 // Private class methods
306 * Name: DmxPrintJob::createPrintShell
308 * Creates the XmPrint Shell widget.
311 DmxPrintJob::createPrintShell (void)
314 DtMail::Session *d_session = theRoamApp.session()->session();
316 if (_pshell != NULL) return;
319 // Create the print shell and
320 // the print output widgets
322 #ifdef PRINT_TO_VIDEO
326 * Create a dialog shell widget on the video display.
328 _pshell = XmCreateDialogShell(_parent->baseWidget(), "PrintVideo", NULL, 0);
330 _nextpage_shell = XtVaCreateWidget(
332 topLevelShellWidgetClass,
333 _parent->baseWidget(),
338 xms = XmStringCreateLocalized("Push for Next Page");
339 _nextpage_button = XtVaCreateManagedWidget(
341 xmPushButtonWidgetClass,
352 &DmxPrintJob::printOnePageCB,
355 XtRealizeWidget(_nextpage_shell);
356 XtManageChild(_nextpage_shell);
359 * Create an XmPrintShell widget on the video display.
361 _pshell = XmPrintSetup(
362 _parent->baseWidget(),
363 XpGetScreenOfContext(
364 _print_data->print_display,
365 _print_data->print_context),
371 XmNpageSetupCallback,
372 &DmxPrintJob::printOnePageCB,
376 XmNpdmNotificationCallback,
377 &DmxPrintJob::pdmNotificationCB,
384 * Name: DmxPrintJob::createOutputWidgets
386 * Creates the DmxPrintOutput object to be used for printing.
389 DmxPrintJob::createOutputWidgets (void)
392 DtMail::Session *d_session = theRoamApp.session()->session();
393 DtMailBoolean parse_error = DTM_FALSE;
399 _print_output = new DmxPrintOutput( _pshell );
400 _print_output->setWrapToFit(_print_setup->useWordWrap());
401 top = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_TOP);
402 right = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_RIGHT);
403 bottom = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_BOTTOM);
404 left = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_LEFT);
405 _print_output->setPageMargins(top, right, bottom, left, &parse_error);
408 DtMailGenDialog *genDialog = new DtMailGenDialog(
410 _parent->baseWidget());
411 char *errMsg = (char *) XtMalloc(1024);
416 "One of the following margin specifiers \n has incorrect syntax: \n %s \n %s \n %s \n %s \nContinue using default margins?"
419 sprintf(errMsg, i18nMsg, top, right, bottom, left);
420 genDialog->setToErrorDialog(
421 GETMSG(DT_catd, 21, 3, "Mailer"),
425 genDialog->post_and_return(
426 GETMSG(DT_catd, 21, 4, "OK"),
431 XtRealizeWidget( _pshell );
438 free((void*) bottom);
444 ok_cb(DtMailGenDialog *genDialog)
450 * Name: DmxPrintJob::doPrint
452 * Creates a DmxMailbox and loads the contents of the message file.
453 * Initializes the mailbox to iterate through the messages.
454 * Calls XmPrintToFile or XpStartJob to initiate printing.
457 DmxPrintJob::doPrint (void)
460 DtMail::Session *d_session = theRoamApp.session()->session();
461 XPSaveData dest = XPSpool;
464 // Notify the user that we're printing
466 if (_parent != NULL) {
467 char *buf = new char[1024];
468 char *msg = GETMSG(DT_catd, 21, 1, "Printing %s ...");
469 sprintf(buf, msg, _filename);
470 _parent->setStatus(buf);
473 // Register the fact that we have a print job running so
474 // dtmail will not terminate in the middle.
476 _parent->registerPendingTask();
481 // load in the messages
483 // Moved to DmxPrintJob::execute
485 //_mailbox = new DmxMailbox(_filename);
486 //_mailbox->loadMessages();
487 //_next_msg = _mailbox->firstMessage();
490 _spool_msg_info = (DmxMsgInfo *) XtCalloc(
491 _mailbox->numMessages(),
494 #ifndef PRINT_TO_VIDEO
495 if (_print_data == NULL) return;
497 if (_print_data->destination == DtPRINT_TO_FILE)
500 theRoamApp.registerActivePrintDisplay(XtDisplay(_pshell));
501 XpStartJob(XtDisplay(_pshell), dest);
502 XFlush(XtDisplay(_pshell));
504 if (_print_data->destination == DtPRINT_TO_FILE)
506 if (FALSE == XmPrintToFile(
508 _print_data->dest_info,
509 (XPFinishProc) &DmxPrintJob::finishedPrintToFile,
512 char *fmt = "%s\n%s: %s";
513 DtMailGenDialog *genDialog;
514 char *appmessage = NULL;
515 char *message = NULL;
516 char *sysmessage = strerror(errno);
517 Widget w = (Widget) this->_parent->baseWidget();
519 XpCancelJob(XtDisplay(_pshell), False);
520 XFlush(XtDisplay(_pshell));
522 genDialog = new DtMailGenDialog("Dialog", w);
523 appmessage = (char *) GETMSG(
525 "'Print to File' was unsuccessful.");
527 if (NULL == sysmessage)
529 message = XtMalloc(strlen(appmessage) + 1);
530 sprintf(message, "%s", appmessage);
537 strlen(_print_data->dest_info) +
541 appmessage, _print_data->dest_info, sysmessage);
544 genDialog->setToErrorDialog(
545 GETMSG(DT_catd, 21, 3, "Mailer"),
548 genDialog->post_and_return(
549 GETMSG(DT_catd, 21, 4, "OK"),
553 genDialog->post((void*) genDialog, (DialogCallback) ok_cb);
566 DmxPrintJob::loadOutputWidgets(void)
571 _print_output->clearContents();
572 _spool_nmsgs_done = 0;
573 _spool_nmsgs_total = 0;
574 _spool_npages_done = 0;
575 _spool_npages_total = 0;
581 DmxPrintOptions::getPrintedHeaders(),
582 (DmxMsg::DmxPrintOutputProc) fprintf,
586 DmxPrintOptions::getPrintedHeaders(),
587 &DmxPrintOutput::appendContents,
588 (XtPointer) _print_output);
590 switch (DmxPrintOptions::getMessageSeparator())
592 case DMX_SEPARATOR_BLANK_LINE:
593 _print_output->appendNewLine();
594 _print_output->appendNewLine();
596 case DMX_SEPARATOR_CHARACTER_LINE:
598 #define DMXPJ_MAX_SEPARATOR_LENGTH 100
600 const char *separator_string;
603 separator_string = DmxPrintOptions::getSeparatorString();
604 len = strlen(separator_string);
605 nchars = _print_output->getCharactersPerLine() - 5;
606 #ifdef PRINT_TO_VIDEO
607 fprintf(stderr, "getCharactersPerLine: <%d>\n", nchars);
609 nchars = (nchars < DMXPJ_MAX_SEPARATOR_LENGTH) ?
610 nchars : DMXPJ_MAX_SEPARATOR_LENGTH;
611 buffer = XtMalloc(nchars+len+1);
613 for (int i=0; i<nchars-1; i+=len)
615 int nbytes = (len < nchars-i) ? len : nchars-i;
616 strncat(buffer, separator_string, nbytes);
618 buffer[nchars-1] = '\0';
620 _print_output->appendNewLine();
621 _print_output->appendContents((void*) _print_output, buffer);
622 _print_output->appendNewLine();
623 _print_output->appendNewLine();
626 if (NULL != separator_string)
627 free((void*) separator_string);
631 case DMX_SEPARATOR_PAGE_BREAK:
632 case DMX_SEPARATOR_NEW_JOB:
633 _print_output->appendPageBreak();
635 case DMX_SEPARATOR_NEW_LINE:
637 _print_output->appendNewLine();
641 assert(_spool_nmsgs_total < _mailbox->numMessages());
642 _spool_msg_info[_spool_nmsgs_total].msg = _next_msg;
643 _spool_msg_info[_spool_nmsgs_total].end_position =
644 _print_output->getLastPosition();
646 _spool_nmsgs_total++;
648 } while ( ( (_next_msg = _mailbox->nextMessage()) != (DmxMsg *) NULL ) &&
649 ( (! _print_setup->printSeparately()) ||
650 (_print_data->destination == DtPRINT_TO_FILE ) )
654 _print_output->setTopPosition(0);
655 _spool_npages_total = _print_output->getNumLines() +
656 _print_output->getLinesPerPage() - 1;
657 _spool_npages_total /= _print_output->getLinesPerPage();
663 DmxPrintJob::printOnePageCB(
665 XtPointer client_data,
668 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
670 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
674 if (thisJob->_print_output == NULL)
677 Dimension width, height;
686 printf("PrintShell in PrintOnePageCB: <W %d - H %d>\n", width, height);
689 if (width < 100 || height < 100)
691 width = 2550; height=3250;
705 printf("PrintShell in PrintOnePageCB: <W %d - H %d>\n",
710 thisJob->createOutputWidgets();
711 if (! thisJob->loadOutputWidgets())
718 #ifndef PRINT_TO_VIDEO
719 if (pscbs->last_page)
721 if (thisJob->_spool_npages_done == thisJob->_spool_npages_total)
727 // This spool job is done.
728 // Try spooling the next one.
730 if (! thisJob->loadOutputWidgets())
732 if (thisJob->_print_data->destination != DtPRINT_TO_FILE)
738 // Register a work proc to print one page at a time
740 #ifndef PRINT_TO_VIDEO
741 if (thisJob->_print_data->destination == DtPRINT_TO_FILE)
744 XpStartJob(XtDisplay(thisJob->_pshell), dest);
745 XFlush(XtDisplay(thisJob->_pshell));
747 if (thisJob->_print_data->destination == DtPRINT_TO_FILE)
749 XtDisplay(thisJob->_pshell),
750 thisJob->_print_data->dest_info,
751 (XPFinishProc) &DmxPrintJob::finishedPrintToFile,
758 if (thisJob->_spool_npages_done == 0)
760 thisJob->_print_output->setTopPosition(0);
762 else if (! thisJob->_print_output->pageDown())
764 #ifndef PRINT_TO_VIDEO
765 pscbs->last_page = TRUE;
771 int top = thisJob->_print_output->getTopPosition();
772 int currmsg_i = thisJob->_spool_nmsgs_done;
775 // Find the index into the ._spool_msg_info array of the
776 // message which will begin the next page. This message
777 // will be used to set the header and footer strings.
779 while (top > thisJob->_spool_msg_info[currmsg_i].end_position &&
780 currmsg_i < thisJob->_spool_nmsgs_total)
783 assert(top <= thisJob->_spool_msg_info[currmsg_i].end_position);
784 thisJob->_spool_nmsgs_done = currmsg_i;
787 currmsg = thisJob->_spool_msg_info[thisJob->_spool_nmsgs_done].msg;
788 assert(currmsg != (DmxMsg *) NULL);
789 if (currmsg == (DmxMsg *) NULL)
791 #ifndef PRINT_TO_VIDEO
792 pscbs->last_page = TRUE;
798 // Update header and footer strings.
800 thisJob->_spool_npages_done++;
801 thisJob->updatePageHeaders(
803 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_HEADER_LEFT),
804 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_HEADER_RIGHT),
805 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_FOOTER_LEFT),
806 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_FOOTER_RIGHT)
809 #ifndef PRINT_TO_VIDEO
810 if (thisJob->_spool_npages_done >= thisJob->_spool_npages_total)
811 pscbs->last_page = TRUE;
817 DmxPrintJob::updatePageHeaders(
819 DmxStringTypeEnum hl_type,
820 DmxStringTypeEnum hr_type,
821 DmxStringTypeEnum fl_type,
822 DmxStringTypeEnum fr_type
830 if (msg == (DmxMsg *) NULL)
833 hl_string = getPageHeaderString(msg, hl_type);
834 hr_string = getPageHeaderString(msg, hr_type);
835 fl_string = getPageHeaderString(msg, fl_type);
836 fr_string = getPageHeaderString(msg, fr_type);
838 _print_output->setHdrFtrStrings(
844 if (DMX_NONE_STRING == hl_type && DMX_NONE_STRING == hr_type)
845 _print_output->hideHeaders();
847 _print_output->showHeaders();
849 if (DMX_NONE_STRING == fl_type && DMX_NONE_STRING == fr_type)
850 _print_output->hideFooters();
852 _print_output->showFooters();
861 DmxPrintJob::getPageHeaderString(
863 DmxStringTypeEnum type
867 *buf = (char *) NULL;
870 if (msg == (DmxMsg *) NULL)
875 case DMX_NONE_STRING:
878 case DMX_CC_HEADER_STRING:
880 char *hdrstr = msg->getMessageHeader(DMXCC);
882 format = GETMSG(DT_catd, 21, 5, "Cc: %s");
883 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
884 if (buf != (char *) NULL)
885 sprintf(buf, format, hdrstr);
890 case DMX_DATE_HEADER_STRING:
892 char *hdrstr = msg->getMessageHeader(DMXDATE);
894 format = GETMSG(DT_catd, 21, 6, "Date: %s");
895 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
896 if (buf != (char *) NULL)
897 sprintf(buf, format, hdrstr);
902 case DMX_FROM_HEADER_STRING:
904 char *hdrstr = msg->getMessageHeader(DMXFROM);
906 format = GETMSG(DT_catd, 21, 7, "From: %s");
907 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
908 if (buf != (char *) NULL)
909 sprintf(buf, format, hdrstr);
914 case DMX_SUBJECT_HEADER_STRING:
916 char *hdrstr = msg->getMessageHeader(DMXSUBJ);
918 format = GETMSG(DT_catd, 21, 8, "Subject: %s");
919 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
920 if (buf != (char *) NULL)
921 sprintf(buf, format, hdrstr);
926 case DMX_TO_HEADER_STRING:
928 char *hdrstr = msg->getMessageHeader(DMXTO);
930 format = GETMSG(DT_catd, 21, 9, "To: %s");
931 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
932 if (buf != (char *) NULL)
933 sprintf(buf, format, hdrstr);
938 case DMX_PAGE_NUMBER_STRING:
940 // Allocate space for the format and the translated page number.
943 format = GETMSG(DT_catd, 21, 10, "Page %d of %d");
944 buf = (char *) malloc(strlen(format) + 16);
945 if (buf != (char *) NULL)
946 sprintf(buf, format, _spool_npages_done, _spool_npages_total);
949 case DMX_USER_NAME_STRING:
951 // Allocate space for the format and the username.
956 format = GETMSG(DT_catd, 21, 11, "Mail For: %s");
957 pw = getpwuid(getuid());
958 buf = (char *) malloc(strlen(format) + strlen(pw->pw_name) + 1);
959 if (buf != (char *) NULL)
960 sprintf(buf, format, pw->pw_name);
964 buf = strdup("DEFAULT not impld");
971 * Name: DmxPrintJob::finishedPrintToFile
975 DmxPrintJob::finishedPrintToFile(
978 XPGetDocStatus status,
979 XPointer client_data)
982 DmxPrintJob *thisJob = (DmxPrintJob*) client_data;
983 Widget w = (Widget) thisJob->_parent->baseWidget();
984 char *message = NULL;
986 if (status != XPGetDocFinished)
988 DtMailGenDialog *genDialog = new DtMailGenDialog("Dialog", w);
990 message = (char *) GETMSG(
992 "'Print to File' was unsuccessful.");
993 genDialog->setToErrorDialog(
994 GETMSG(DT_catd, 21, 3, "Mailer"),
996 genDialog->post_and_return(
997 GETMSG(DT_catd, 21, 4, "OK"),
1001 else if (display != theRoamApp.getErrorPrintDisplay())
1003 DtMailGenDialog *genDialog = new DtMailGenDialog("Dialog", w);
1005 message = (char *) GETMSG(
1007 "'Print to File' completed successfully");
1009 genDialog->setToWarningDialog(
1010 GETMSG(DT_catd, 21, 3, "Mailer"),
1012 genDialog->post_and_return(
1013 GETMSG(DT_catd, 21, 4, "OK"),
1021 * Name: DmxPrintJob::cancelCB
1023 * An XtCallbackProc which can be added to the callback list of
1024 * a widget to cancel the print job passed back as client_data.
1027 DmxPrintJob::cancelCB (Widget, XtPointer client_data, XtPointer)
1029 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1035 * Name: DmxPrintJob::closeDisplayCB
1037 * An XtCallbackProc which can be added to the callback list of
1038 * a widget to react to the print setup closing the display.
1041 DmxPrintJob::closeDisplayCB (Widget, XtPointer client_data, XtPointer call_data)
1043 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1044 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1046 if (thisJob->_pshell != NULL)
1048 XtDestroyWidget(thisJob->_pshell);
1049 thisJob->_pshell = NULL;
1051 DtPrintFreeSetupData(thisJob->_print_data);
1055 * Name: DmxPrintJob::pdmNotificationCB
1057 * XmNpdmNotificationCallback for the XmPrintShell
1060 DmxPrintJob::pdmNotificationCB(
1062 XtPointer client_data,
1063 XtPointer call_data)
1065 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1066 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
1067 char *message = NULL;
1069 switch (pscbs->reason)
1073 case XmCR_PDM_START_ERROR:
1074 case XmCR_PDM_START_VXAUTH:
1075 case XmCR_PDM_START_PXAUTH:
1076 message = (char *) GETMSG(
1078 "Print Dialog Manager error - setup failed.");
1085 if (message != NULL)
1087 DtMailGenDialog *genDialog = new DtMailGenDialog(
1089 thisJob->_parent->baseWidget());
1090 genDialog->setToErrorDialog(
1091 GETMSG(DT_catd, 21, 3, "Mailer"),
1093 genDialog->post_and_return(
1094 GETMSG(DT_catd, 21, 25, "Continue"),
1101 * Name: DmxPrintJob::pdmSetupCB
1103 * An XtCallbackProc which can be added to the callback list of
1104 * a widget to execute the print job passed back as client_data.
1107 DmxPrintJob::pdmSetupCB(
1109 XtPointer client_data,
1110 XtPointer call_data)
1112 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1113 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1115 DtPrintCopySetupData(thisJob->_print_data, pbs->print_data);
1116 thisJob->createPrintShell();
1118 if (thisJob->_pshell)
1120 Widget shell = print_setup;
1122 while (! (shell == NULL || XtIsShell(shell)) )
1123 shell = XtParent(shell);
1126 XmPrintPopupPDM(thisJob->_pshell, shell);
1128 fprintf(stderr, "Internal Error %s: Missing XmPrintShell\n");
1133 * Name: DmxPrintJob::printCB
1135 * An XtCallbackProc which can be added to the callback list of
1136 * a widget to execute the print job passed back as client_data.
1139 DmxPrintJob::printCB (Widget, XtPointer client_data, XtPointer call_data)
1141 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1142 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1144 /* TBD: Save options??? */
1146 DtPrintCopySetupData(thisJob->_print_data, pbs->print_data);
1147 thisJob->createPrintShell();