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)
313 #if defined(PRINTING_SUPPORTED)
315 DtMail::Session *d_session = theRoamApp.session()->session();
317 if (_pshell != NULL) return;
320 // Create the print shell and
321 // the print output widgets
323 #ifdef PRINT_TO_VIDEO
327 * Create a dialog shell widget on the video display.
329 _pshell = XmCreateDialogShell(_parent->baseWidget(), "PrintVideo", NULL, 0);
331 _nextpage_shell = XtVaCreateWidget(
333 topLevelShellWidgetClass,
334 _parent->baseWidget(),
339 xms = XmStringCreateLocalized("Push for Next Page");
340 _nextpage_button = XtVaCreateManagedWidget(
342 xmPushButtonWidgetClass,
353 &DmxPrintJob::printOnePageCB,
356 XtRealizeWidget(_nextpage_shell);
357 XtManageChild(_nextpage_shell);
360 * Create an XmPrintShell widget on the video display.
362 _pshell = XmPrintSetup(
363 _parent->baseWidget(),
364 XpGetScreenOfContext(
365 _print_data->print_display,
366 _print_data->print_context),
372 XmNpageSetupCallback,
373 &DmxPrintJob::printOnePageCB,
377 XmNpdmNotificationCallback,
378 &DmxPrintJob::pdmNotificationCB,
382 #endif /* PRINTING_SUPPORTED */
387 * Name: DmxPrintJob::createOutputWidgets
389 * Creates the DmxPrintOutput object to be used for printing.
392 DmxPrintJob::createOutputWidgets (void)
395 DtMail::Session *d_session = theRoamApp.session()->session();
396 DtMailBoolean parse_error = DTM_FALSE;
402 _print_output = new DmxPrintOutput( _pshell );
403 _print_output->setWrapToFit(_print_setup->useWordWrap());
404 top = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_TOP);
405 right = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_RIGHT);
406 bottom = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_BOTTOM);
407 left = DmxPrintOptions::getMarginSpec(DTPRINT_OPTION_MARGIN_LEFT);
408 _print_output->setPageMargins(top, right, bottom, left, &parse_error);
411 DtMailGenDialog *genDialog = new DtMailGenDialog(
413 _parent->baseWidget());
414 char *errMsg = (char *) XtMalloc(1024);
419 "One of the following margin specifiers \n has incorrect syntax: \n %s \n %s \n %s \n %s \nContinue using default margins?"
422 sprintf(errMsg, i18nMsg, top, right, bottom, left);
423 genDialog->setToErrorDialog(
424 GETMSG(DT_catd, 21, 3, "Mailer"),
428 genDialog->post_and_return(
429 GETMSG(DT_catd, 21, 4, "OK"),
434 XtRealizeWidget( _pshell );
441 free((void*) bottom);
447 ok_cb(DtMailGenDialog *genDialog)
453 * Name: DmxPrintJob::doPrint
455 * Creates a DmxMailbox and loads the contents of the message file.
456 * Initializes the mailbox to iterate through the messages.
457 * Calls XmPrintToFile or XpStartJob to initiate printing.
460 DmxPrintJob::doPrint (void)
462 #if defined(PRINTING_SUPPORTED)
464 DtMail::Session *d_session = theRoamApp.session()->session();
465 XPSaveData dest = XPSpool;
468 // Notify the user that we're printing
470 if (_parent != NULL) {
471 char *buf = new char[1024];
472 char *msg = GETMSG(DT_catd, 21, 1, "Printing %s ...");
473 sprintf(buf, msg, _filename);
474 _parent->setStatus(buf);
477 // Register the fact that we have a print job running so
478 // dtmail will not terminate in the middle.
480 _parent->registerPendingTask();
485 // load in the messages
487 // Moved to DmxPrintJob::execute
489 //_mailbox = new DmxMailbox(_filename);
490 //_mailbox->loadMessages();
491 //_next_msg = _mailbox->firstMessage();
494 _spool_msg_info = (DmxMsgInfo *) XtCalloc(
495 _mailbox->numMessages(),
498 #ifndef PRINT_TO_VIDEO
499 if (_print_data == NULL) return;
501 if (_print_data->destination == DtPRINT_TO_FILE)
504 theRoamApp.registerActivePrintDisplay(XtDisplay(_pshell));
505 XpStartJob(XtDisplay(_pshell), dest);
506 XFlush(XtDisplay(_pshell));
508 if (_print_data->destination == DtPRINT_TO_FILE)
510 if (FALSE == XmPrintToFile(
512 _print_data->dest_info,
513 (XPFinishProc) &DmxPrintJob::finishedPrintToFile,
516 char *fmt = "%s\n%s: %s";
517 DtMailGenDialog *genDialog;
518 char *appmessage = NULL;
519 char *message = NULL;
520 char *sysmessage = strerror(errno);
521 Widget w = (Widget) this->_parent->baseWidget();
523 XpCancelJob(XtDisplay(_pshell), False);
524 XFlush(XtDisplay(_pshell));
526 genDialog = new DtMailGenDialog("Dialog", w);
527 appmessage = (char *) GETMSG(
529 "'Print to File' was unsuccessful.");
531 if (NULL == sysmessage)
533 message = XtMalloc(strlen(appmessage) + 1);
534 sprintf(message, "%s", appmessage);
541 strlen(_print_data->dest_info) +
545 appmessage, _print_data->dest_info, sysmessage);
548 genDialog->setToErrorDialog(
549 GETMSG(DT_catd, 21, 3, "Mailer"),
552 genDialog->post_and_return(
553 GETMSG(DT_catd, 21, 4, "OK"),
557 genDialog->post((void*) genDialog, (DialogCallback) ok_cb);
565 #endif /* PRINTING_SUPPORTED */
571 DmxPrintJob::loadOutputWidgets(void)
576 _print_output->clearContents();
577 _spool_nmsgs_done = 0;
578 _spool_nmsgs_total = 0;
579 _spool_npages_done = 0;
580 _spool_npages_total = 0;
586 DmxPrintOptions::getPrintedHeaders(),
587 (DmxMsg::DmxPrintOutputProc) fprintf,
591 DmxPrintOptions::getPrintedHeaders(),
592 &DmxPrintOutput::appendContents,
593 (XtPointer) _print_output);
595 switch (DmxPrintOptions::getMessageSeparator())
597 case DMX_SEPARATOR_BLANK_LINE:
598 _print_output->appendNewLine();
599 _print_output->appendNewLine();
601 case DMX_SEPARATOR_CHARACTER_LINE:
603 #define DMXPJ_MAX_SEPARATOR_LENGTH 100
605 const char *separator_string;
608 separator_string = DmxPrintOptions::getSeparatorString();
609 len = strlen(separator_string);
610 nchars = _print_output->getCharactersPerLine() - 5;
611 #ifdef PRINT_TO_VIDEO
612 fprintf(stderr, "getCharactersPerLine: <%d>\n", nchars);
614 nchars = (nchars < DMXPJ_MAX_SEPARATOR_LENGTH) ?
615 nchars : DMXPJ_MAX_SEPARATOR_LENGTH;
616 buffer = XtMalloc(nchars+len+1);
618 for (int i=0; i<nchars-1; i+=len)
620 int nbytes = (len < nchars-i) ? len : nchars-i;
621 strncat(buffer, separator_string, nbytes);
623 buffer[nchars-1] = '\0';
625 _print_output->appendNewLine();
626 _print_output->appendContents((void*) _print_output, buffer);
627 _print_output->appendNewLine();
628 _print_output->appendNewLine();
631 if (NULL != separator_string)
632 free((void*) separator_string);
636 case DMX_SEPARATOR_PAGE_BREAK:
637 case DMX_SEPARATOR_NEW_JOB:
638 _print_output->appendPageBreak();
640 case DMX_SEPARATOR_NEW_LINE:
642 _print_output->appendNewLine();
646 assert(_spool_nmsgs_total < _mailbox->numMessages());
647 _spool_msg_info[_spool_nmsgs_total].msg = _next_msg;
648 _spool_msg_info[_spool_nmsgs_total].end_position =
649 _print_output->getLastPosition();
651 _spool_nmsgs_total++;
653 } while ( ( (_next_msg = _mailbox->nextMessage()) != (DmxMsg *) NULL ) &&
654 ( (! _print_setup->printSeparately()) ||
655 (_print_data->destination == DtPRINT_TO_FILE ) )
659 _print_output->setTopPosition(0);
660 _spool_npages_total = _print_output->getNumLines() +
661 _print_output->getLinesPerPage() - 1;
662 _spool_npages_total /= _print_output->getLinesPerPage();
668 DmxPrintJob::printOnePageCB(
670 XtPointer client_data,
673 #if defined(PRINTING_SUPPORTED)
674 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
676 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
680 if (thisJob->_print_output == NULL)
683 XtArgVal /* Dimension */ width, height;
692 printf("PrintShell in PrintOnePageCB: <W %d - H %d>\n", width, height);
695 if (width < 100 || height < 100)
697 width = 2550; height=3250;
711 printf("PrintShell in PrintOnePageCB: <W %d - H %d>\n",
716 thisJob->createOutputWidgets();
717 if (! thisJob->loadOutputWidgets())
724 #ifndef PRINT_TO_VIDEO
725 if (pscbs->last_page)
727 if (thisJob->_spool_npages_done == thisJob->_spool_npages_total)
733 // This spool job is done.
734 // Try spooling the next one.
736 if (! thisJob->loadOutputWidgets())
738 if (thisJob->_print_data->destination != DtPRINT_TO_FILE)
744 // Register a work proc to print one page at a time
746 #ifndef PRINT_TO_VIDEO
747 if (thisJob->_print_data->destination == DtPRINT_TO_FILE)
750 XpStartJob(XtDisplay(thisJob->_pshell), dest);
751 XFlush(XtDisplay(thisJob->_pshell));
753 if (thisJob->_print_data->destination == DtPRINT_TO_FILE)
755 XtDisplay(thisJob->_pshell),
756 thisJob->_print_data->dest_info,
757 (XPFinishProc) &DmxPrintJob::finishedPrintToFile,
764 if (thisJob->_spool_npages_done == 0)
766 thisJob->_print_output->setTopPosition(0);
768 else if (! thisJob->_print_output->pageDown())
770 #ifndef PRINT_TO_VIDEO
771 pscbs->last_page = TRUE;
777 int top = thisJob->_print_output->getTopPosition();
778 int currmsg_i = thisJob->_spool_nmsgs_done;
781 // Find the index into the ._spool_msg_info array of the
782 // message which will begin the next page. This message
783 // will be used to set the header and footer strings.
785 while (top > thisJob->_spool_msg_info[currmsg_i].end_position &&
786 currmsg_i < thisJob->_spool_nmsgs_total)
789 assert(top <= thisJob->_spool_msg_info[currmsg_i].end_position);
790 thisJob->_spool_nmsgs_done = currmsg_i;
793 currmsg = thisJob->_spool_msg_info[thisJob->_spool_nmsgs_done].msg;
794 assert(currmsg != (DmxMsg *) NULL);
795 if (currmsg == (DmxMsg *) NULL)
797 #ifndef PRINT_TO_VIDEO
798 pscbs->last_page = TRUE;
804 // Update header and footer strings.
806 thisJob->_spool_npages_done++;
807 thisJob->updatePageHeaders(
809 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_HEADER_LEFT),
810 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_HEADER_RIGHT),
811 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_FOOTER_LEFT),
812 DmxPrintOptions::getHdrFtrSpec(DTPRINT_OPTION_FOOTER_RIGHT)
815 #ifndef PRINT_TO_VIDEO
816 if (thisJob->_spool_npages_done >= thisJob->_spool_npages_total)
817 pscbs->last_page = TRUE;
819 #endif /* PRINTING_SUPPORTED */
824 DmxPrintJob::updatePageHeaders(
826 DmxStringTypeEnum hl_type,
827 DmxStringTypeEnum hr_type,
828 DmxStringTypeEnum fl_type,
829 DmxStringTypeEnum fr_type
837 if (msg == (DmxMsg *) NULL)
840 hl_string = getPageHeaderString(msg, hl_type);
841 hr_string = getPageHeaderString(msg, hr_type);
842 fl_string = getPageHeaderString(msg, fl_type);
843 fr_string = getPageHeaderString(msg, fr_type);
845 _print_output->setHdrFtrStrings(
851 if (DMX_NONE_STRING == hl_type && DMX_NONE_STRING == hr_type)
852 _print_output->hideHeaders();
854 _print_output->showHeaders();
856 if (DMX_NONE_STRING == fl_type && DMX_NONE_STRING == fr_type)
857 _print_output->hideFooters();
859 _print_output->showFooters();
868 DmxPrintJob::getPageHeaderString(
870 DmxStringTypeEnum type
874 *buf = (char *) NULL;
877 if (msg == (DmxMsg *) NULL)
882 case DMX_NONE_STRING:
885 case DMX_CC_HEADER_STRING:
887 char *hdrstr = msg->getMessageHeader(DMXCC);
889 format = GETMSG(DT_catd, 21, 5, "Cc: %s");
890 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
891 if (buf != (char *) NULL)
892 sprintf(buf, format, hdrstr);
897 case DMX_DATE_HEADER_STRING:
899 char *hdrstr = msg->getMessageHeader(DMXDATE);
901 format = GETMSG(DT_catd, 21, 6, "Date: %s");
902 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
903 if (buf != (char *) NULL)
904 sprintf(buf, format, hdrstr);
909 case DMX_FROM_HEADER_STRING:
911 char *hdrstr = msg->getMessageHeader(DMXFROM);
913 format = GETMSG(DT_catd, 21, 7, "From: %s");
914 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
915 if (buf != (char *) NULL)
916 sprintf(buf, format, hdrstr);
921 case DMX_SUBJECT_HEADER_STRING:
923 char *hdrstr = msg->getMessageHeader(DMXSUBJ);
925 format = GETMSG(DT_catd, 21, 8, "Subject: %s");
926 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
927 if (buf != (char *) NULL)
928 sprintf(buf, format, hdrstr);
933 case DMX_TO_HEADER_STRING:
935 char *hdrstr = msg->getMessageHeader(DMXTO);
937 format = GETMSG(DT_catd, 21, 9, "To: %s");
938 buf = (char *) malloc(strlen(format) + strlen(hdrstr) + 1);
939 if (buf != (char *) NULL)
940 sprintf(buf, format, hdrstr);
945 case DMX_PAGE_NUMBER_STRING:
947 // Allocate space for the format and the translated page number.
950 format = GETMSG(DT_catd, 21, 10, "Page %d of %d");
951 buf = (char *) malloc(strlen(format) + 16);
952 if (buf != (char *) NULL)
953 sprintf(buf, format, _spool_npages_done, _spool_npages_total);
956 case DMX_USER_NAME_STRING:
958 // Allocate space for the format and the username.
963 format = GETMSG(DT_catd, 21, 11, "Mail For: %s");
964 pw = getpwuid(getuid());
965 buf = (char *) malloc(strlen(format) + strlen(pw->pw_name) + 1);
966 if (buf != (char *) NULL)
967 sprintf(buf, format, pw->pw_name);
971 buf = strdup("DEFAULT not impld");
978 * Name: DmxPrintJob::finishedPrintToFile
982 DmxPrintJob::finishedPrintToFile(
985 XPGetDocStatus status,
986 XPointer client_data)
989 DmxPrintJob *thisJob = (DmxPrintJob*) client_data;
990 Widget w = (Widget) thisJob->_parent->baseWidget();
991 char *message = NULL;
993 if (status != XPGetDocFinished)
995 DtMailGenDialog *genDialog = new DtMailGenDialog("Dialog", w);
997 message = (char *) GETMSG(
999 "'Print to File' was unsuccessful.");
1000 genDialog->setToErrorDialog(
1001 GETMSG(DT_catd, 21, 3, "Mailer"),
1003 genDialog->post_and_return(
1004 GETMSG(DT_catd, 21, 4, "OK"),
1008 else if (display != theRoamApp.getErrorPrintDisplay())
1010 DtMailGenDialog *genDialog = new DtMailGenDialog("Dialog", w);
1012 message = (char *) GETMSG(
1014 "'Print to File' completed successfully");
1016 genDialog->setToWarningDialog(
1017 GETMSG(DT_catd, 21, 3, "Mailer"),
1019 genDialog->post_and_return(
1020 GETMSG(DT_catd, 21, 4, "OK"),
1028 * Name: DmxPrintJob::cancelCB
1030 * An XtCallbackProc which can be added to the callback list of
1031 * a widget to cancel the print job passed back as client_data.
1034 DmxPrintJob::cancelCB (Widget, XtPointer client_data, XtPointer)
1036 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1042 * Name: DmxPrintJob::closeDisplayCB
1044 * An XtCallbackProc which can be added to the callback list of
1045 * a widget to react to the print setup closing the display.
1048 DmxPrintJob::closeDisplayCB (Widget, XtPointer client_data, XtPointer call_data)
1050 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1051 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1053 if (thisJob->_pshell != NULL)
1055 XtDestroyWidget(thisJob->_pshell);
1056 thisJob->_pshell = NULL;
1058 DtPrintFreeSetupData(thisJob->_print_data);
1062 * Name: DmxPrintJob::pdmNotificationCB
1064 * XmNpdmNotificationCallback for the XmPrintShell
1067 DmxPrintJob::pdmNotificationCB(
1069 XtPointer client_data,
1070 XtPointer call_data)
1072 #if defined(PRINTING_SUPPORTED)
1073 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1074 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
1075 char *message = NULL;
1077 switch (pscbs->reason)
1081 case XmCR_PDM_START_ERROR:
1082 case XmCR_PDM_START_VXAUTH:
1083 case XmCR_PDM_START_PXAUTH:
1084 message = (char *) GETMSG(
1086 "Print Dialog Manager error - setup failed.");
1093 if (message != NULL)
1095 DtMailGenDialog *genDialog = new DtMailGenDialog(
1097 thisJob->_parent->baseWidget());
1098 genDialog->setToErrorDialog(
1099 GETMSG(DT_catd, 21, 3, "Mailer"),
1101 genDialog->post_and_return(
1102 GETMSG(DT_catd, 21, 25, "Continue"),
1106 #endif /* PRINTING_SUPPORTED */
1110 * Name: DmxPrintJob::pdmSetupCB
1112 * An XtCallbackProc which can be added to the callback list of
1113 * a widget to execute the print job passed back as client_data.
1116 DmxPrintJob::pdmSetupCB(
1118 XtPointer client_data,
1119 XtPointer call_data)
1121 #if defined(PRINTING_SUPPORTED)
1122 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1123 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1125 DtPrintCopySetupData(thisJob->_print_data, pbs->print_data);
1126 thisJob->createPrintShell();
1128 if (thisJob->_pshell)
1130 Widget shell = print_setup;
1132 while (! (shell == NULL || XtIsShell(shell)) )
1133 shell = XtParent(shell);
1136 XmPrintPopupPDM(thisJob->_pshell, shell);
1138 fprintf(stderr, "Internal Error: Missing XmPrintShell\n");
1140 #endif /* PRINTING_SUPPORTED */
1144 * Name: DmxPrintJob::printCB
1146 * An XtCallbackProc which can be added to the callback list of
1147 * a widget to execute the print job passed back as client_data.
1150 DmxPrintJob::printCB (Widget, XtPointer client_data, XtPointer call_data)
1152 DmxPrintJob *thisJob = (DmxPrintJob *) client_data;
1153 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
1155 /* TBD: Save options??? */
1157 DtPrintCopySetupData(thisJob->_print_data, pbs->print_data);
1158 thisJob->createPrintShell();