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: printJob.c /main/29 1997/08/01 14:32:04 samborn $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: HP DT dtpad, a memo maker type editor based on the
32 ** Description: Routines which manipulate the print setup dialog
34 **************************************************************************
35 **********************************<+>*************************************/
37 * Common Desktop Environment
39 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
40 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
41 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
42 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
43 * (c) Copyright 1995 Digital Equipment Corp.
44 * (c) Copyright 1995 Fujitsu Limited
45 * (c) Copyright 1995 Hitachi, Ltd.
48 * RESTRICTED RIGHTS LEGEND
50 *Use, duplication, or disclosure by the U.S. Government is subject to
51 *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
52 *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
53 *for non-DOD U.S. Government Departments and Agencies are as set forth in
54 *FAR 52.227-19(c)(1,2).
56 *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
57 *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
58 *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
59 *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
60 *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
61 *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
62 *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
70 #include <sys/types.h>
73 #include <X11/Intrinsic.h>
74 #include <X11/Shell.h>
76 #include <Xm/DialogS.h>
80 #include <Dt/Editor.h>
85 static void _pjCreatePrintShell(PrintJob *pJob);
86 static void _pjCreateOutputWidgets(PrintJob *pJob);
87 static void _pjDoPrint(PrintJob*);
88 static void _pjUpdatePageHeaders(
94 static void _pjFinishedPrintToFile(
99 static char * _pjGetPageHeaderString(PrintJob*, PrintStringTypeEnum);
101 static void _pjCancelCB (Widget, XtPointer client_data, XtPointer);
102 static void _pjCloseDisplayCB (Widget, XtPointer client_data, XtPointer);
103 static void _pjPdmSetupCB (Widget, XtPointer client_data, XtPointer);
104 static void _pjPdmNotificationCB (Widget, XtPointer client_data, XtPointer);
105 static void _pjPrintCB (Widget, XtPointer client_data, XtPointer);
106 static void _pjPrintOnePageCB(Widget, XtPointer, XtPointer);
108 static void _pjRegisterActivePrintDisplay(Display*);
109 static void _pjUnregisterActivePrintDisplay(Display*);
111 static Display *_pjErrorPrintDisplay = NULL;
112 static Display **_pjActivePrintDisplay = NULL;
113 static int _pjMaxActivePrintDisplay = 0;
115 /************************************************************************
117 * Creates a new print job for the specified document file.
118 ************************************************************************/
129 pJob = (PrintJob *) XtMalloc( sizeof(PrintJob) );
130 memset(pJob, 0, sizeof(PrintJob));
133 pJob->parentShell = pPad->app_shell;
134 pJob->documentName = strdup(documentName);
135 pJob->tempFileName = strdup(tempFileName);
136 pJob->silent = silent;
138 pJob->pOutput = NULL;
141 pJob->printData = (DtPrintSetupData*) XtMalloc(sizeof(DtPrintSetupData));
142 memset(pJob->printData, 0, sizeof(DtPrintSetupData));
144 pJob->npagesDone = 0;
145 pJob->npagesTotal = 0;
147 pJob->nextpageShell = NULL;
148 pJob->nextpageButton = NULL;
153 /************************************************************************
155 * Destroys the specified PrintJob.
156 ************************************************************************/
158 PrintJobDestroy(PrintJob *pJob)
165 pJob->pPad->numPendingTasks--;
166 ClearStatusMessage(pJob->pPad);
167 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.printBtn, True);
169 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.silentPrintBtn, True);
172 if (pJob->documentName != NULL)
174 free((char*) pJob->documentName);
175 pJob->documentName = NULL;
177 if (pJob->tempFileName != NULL)
179 free((char*) pJob->tempFileName);
180 pJob->tempFileName = NULL;
182 if (pJob->pOutput != NULL)
184 PrintOutputDestroy(pJob->pOutput);
185 pJob->pOutput = NULL;
187 if (pJob->pShell != NULL)
189 _pjRegisterActivePrintDisplay(XtDisplay(pJob->pShell));
190 if (XtDisplay(pJob->pShell) == PrintJobGetErrorPrintDisplay())
195 * Need to display an error dialog;
200 "The X Print Server is temporarily out of resources.");
202 Warning(pJob->pPad, (char *) errMsg, XmDIALOG_ERROR);
203 PrintJobSetErrorPrintDisplay(NULL);
206 XtDestroyWidget(pJob->pShell);
209 if (pJob->pSetup != NULL)
211 PrintSetupDestroy(pJob->pSetup);
216 DtPrintFreeSetupData(pJob->printData);
217 XtFree((XtPointer) pJob->printData);
218 pJob->printData = NULL;
220 if (pJob->nextpageShell)
222 XtDestroyWidget(pJob->nextpageShell);
223 pJob->nextpageShell = NULL;
226 XtFree((char *) pJob);
229 /************************************************************************
231 * Executes the specified PrintJob
232 ************************************************************************/
234 PrintJobExecute(PrintJob *pJob)
236 if (pJob == NULL) return;
238 pJob->pSetup = PrintSetupCreate(
241 pJob->pPad->xrdb.wordWrap,
243 (XtCallbackProc) _pjCancelCB, pJob,
244 (XtCallbackProc) _pjCloseDisplayCB, pJob,
245 (XtCallbackProc) _pjPrintCB, pJob,
246 (XtCallbackProc) _pjPdmSetupCB, pJob);
250 * The DtPrintSetupDialog will display itself automatically
251 * along with an error message in the event of an error.
253 if (FALSE == PrintSetupGetDefaultPrintData(
258 _pjCreatePrintShell(pJob);
262 PrintSetupDisplay(pJob->pSetup);
265 /************************************************************************
267 * Cancels and deletes the specified print job.
268 ************************************************************************/
270 PrintJobCancel(PrintJob *pJob)
272 PrintJobDestroy(pJob);
276 /************************************************************************
277 * PrintJobGetErrorPrintDisplay
278 * Returns the last print display on which an error occured.
279 ************************************************************************/
281 PrintJobGetErrorPrintDisplay()
283 return _pjErrorPrintDisplay;
286 /************************************************************************
287 * PrintJobSetErrorPrintDisplay
288 * Save a pointer to the print display on which an error occured.
289 ************************************************************************/
291 PrintJobSetErrorPrintDisplay(Display *display)
293 _pjErrorPrintDisplay = display;
296 /************************************************************************
297 * PrintJobIsActivePrintDisplay
298 * Save a pointer to the print display on which an error occured.
299 ************************************************************************/
301 PrintJobIsActivePrintDisplay(Display *display)
305 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
306 if (display == _pjActivePrintDisplay[i])
312 /************************************************************************
313 * _pjRegisterActivePrintDisplay
314 * Save the Display pointer for an active print display connection
315 ************************************************************************/
317 _pjRegisterActivePrintDisplay(Display *display)
322 if (0 == _pjMaxActivePrintDisplay)
324 _pjMaxActivePrintDisplay = 10;
325 size = _pjMaxActivePrintDisplay * sizeof(Display*);
326 _pjActivePrintDisplay = (Display**) malloc(size);
327 memset((char*) _pjActivePrintDisplay, 0, size);
330 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
332 if (NULL == _pjActivePrintDisplay[i])
334 _pjActivePrintDisplay[i] = display;
339 size = _pjMaxActivePrintDisplay * sizeof(Display*);
340 _pjActivePrintDisplay =
341 (Display**) realloc((void*) _pjActivePrintDisplay, 2*size);
342 memset((char*) (_pjActivePrintDisplay + size), 0, size);
343 _pjActivePrintDisplay[_pjMaxActivePrintDisplay] = display;
344 _pjMaxActivePrintDisplay *= 2;
347 /************************************************************************
348 * _pjUnregisterActivePrintDisplay
349 * Delete the Display pointer for an active print display connection
350 ************************************************************************/
352 _pjUnregisterActivePrintDisplay(Display *display)
356 for (i = 0; i < _pjMaxActivePrintDisplay; i++)
357 if (display == _pjActivePrintDisplay[i])
358 _pjActivePrintDisplay[i] = NULL;
362 /************************************************************************
363 * _pjCreatePrintShell
364 * Creates the print shell (XmPrintShell or XmDialogShell) to control
366 ************************************************************************/
368 _pjCreatePrintShell(PrintJob *pJob)
370 DtPrintSetupData *psd = NULL;
373 pJob->pShell != NULL ||
374 pJob->parentShell == NULL ||
375 pJob->pSetup == NULL) return;
377 #if defined(PRINTING_SUPPORTED)
380 * Create the print shell and
381 * the print output widgets
383 #ifdef PRINT_TO_VIDEO
385 * Create a dialog shell widget on the video display.
387 pJob->pShell = XmCreateDialogShell(
394 pJob->nextpageShell = XmCreateDialogShell(
399 xms = XmStringCreateLocalized("Push for Next Page");
400 pJob->nextpageButton = XtVaCreateManagedWidget(
402 xmPushButtonWidgetClass,
411 pJob->nextpageButton,
416 XtManageChild(pJob->nextpageShell);
417 XtRealizeWidget(pJob->nextpageShell);
422 * Create an XmPrintShell widget on the print display.
424 psd = pJob->printData;
426 pJob->pShell = XmPrintSetup(
428 XpGetScreenOfContext(psd->print_display, psd->print_context),
434 XmNpageSetupCallback,
439 XmNpdmNotificationCallback,
440 _pjPdmNotificationCB,
444 if (pJob->pShell == NULL) return;
445 #endif /* PRINTING_SUPPORTED */
451 /************************************************************************
452 * _pjCreateOutputWidgets
453 * Actually run the specified PrintJob.
454 * Creates the PrintOutput object to be used for printing.
455 * Initializes the mailbox to iterate through the messages.
456 * Calls spoolOne to send a print job to the Xp server.
457 ************************************************************************/
459 _pjCreateOutputWidgets(PrintJob *pJob)
461 DtEditorErrorCode errorCode;
463 DtPrintSetupData *psd = NULL;
467 * Notify the user that we're printing
469 /* TBD: Is there a status bar on pPad? */
471 if (pJob->pShell == NULL)
473 {/* TBD error dialog */}
474 PrintJobDestroy(pJob);
478 pJob->pOutput = PrintOutputCreate(pJob->pShell);
479 PrintOutputSetWordWrap(pJob->pOutput, PrintSetupUseWordWrap(pJob->pSetup));
480 PrintOutputSetPageMargins(
482 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_TOP),
483 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_RIGHT),
484 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_BOTTOM),
485 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_LEFT),
491 * Display an error dialog.
492 DtMailGenDialog *genDialog = new DtMailGenDialog(
494 _parent->baseWidget());
499 i18nMsg = GETMESSAGE(
501 "One of the following margin specifiers \n has incorrect syntax: \n %s \n %s \n %s \n %s \nContinue using default margins?"
504 errMsg = (char *) XtMalloc(1024);
508 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_TOP),
509 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_RIGHT),
510 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_BOTTOM),
511 PrintSetupGetMarginSpec(pJob->pSetup, DTPRINT_OPTION_MARGIN_LEFT)
514 Warning(pJob->pPad, (char *) errMsg, XmDIALOG_WARNING);
521 errorCode = PrintOutputLoadFile(pJob->pOutput, pJob->tempFileName);
524 case DtEDITOR_NO_ERRORS:
525 case DtEDITOR_READ_ONLY_FILE:
527 case DtEDITOR_NONEXISTENT_FILE:
530 (char *) GETMESSAGE(14, 2, "File does not exist."),
533 case DtEDITOR_DIRECTORY:
536 (char *) GETMESSAGE(14, 3, "Specified file is a directory."),
539 case DtEDITOR_CHAR_SPECIAL_FILE:
540 case DtEDITOR_BLOCK_MODE_FILE:
543 (char *) GETMESSAGE(14, 4, "File type error."),
546 case DtEDITOR_NULLS_REMOVED:
549 (char *) GETMESSAGE(14, 5, "File contains NULL characters."),
552 case DtEDITOR_INSUFFICIENT_MEMORY:
556 GETMESSAGE(14, 6, "Unable to load file (insufficient memory)."),
559 case DtEDITOR_NO_FILE_ACCESS:
560 case DtEDITOR_UNREADABLE_FILE:
565 GETMESSAGE(14, 7, "File does not have read permissions"),
570 XtRealizeWidget( pJob->pShell );
572 PrintOutputFirstPage(pJob->pOutput);
573 pJob->npagesTotal = PrintOutputGetNumLines(pJob->pOutput) +
574 PrintOutputGetLinesPerPage(pJob->pOutput) - 1;
575 pJob->npagesTotal /= PrintOutputGetLinesPerPage(pJob->pOutput);
576 pJob->npagesDone = 0;
582 /************************************************************************
584 * Actually run the specified PrintJob.
585 * Creates the PrintOutput object to be used for printing.
586 * Initializes the mailbox to iterate through the messages.
587 * Calls spoolOne to send a print job to the Xp server.
588 ************************************************************************/
590 _pjDoPrint(PrintJob *pJob)
592 #if defined(PRINTING_SUPPORTED)
594 static char buf[1024];
596 DtPrintSetupData *psd = NULL;
600 * Notify the user that we're printing
602 if (pJob->pPad != NULL) {
603 pJob->pPad->numPendingTasks++;
604 format = GETMESSAGE(14, 21, "Printing %s ...");
605 sprintf(buf, format, pJob->documentName);
606 SetStatusMessage(pJob->pPad, buf);
607 XtSetSensitive(pJob->pPad->fileStuff.fileWidgets.printBtn, False);
610 #ifndef PRINT_TO_VIDEO
611 psd = pJob->printData;
613 if (psd->destination == DtPRINT_TO_FILE)
616 _pjRegisterActivePrintDisplay(XtDisplay(pJob->pShell));
617 XpStartJob(XtDisplay(pJob->pShell), dest);
618 XFlush(XtDisplay(pJob->pShell));
620 if (psd->destination == DtPRINT_TO_FILE)
622 if (FALSE == XmPrintToFile(
623 XtDisplay(pJob->pShell),
625 _pjFinishedPrintToFile,
628 char *fmt = "%s\n%s: %s";
630 char *appmessage = NULL;
631 char *sysmessage = strerror(errno);
633 appmessage = (char *) GETMESSAGE(
635 "'Print to File' was unsuccessful.");
637 if (NULL == sysmessage)
639 message = XtMalloc(strlen(appmessage) + 1);
640 sprintf(message, "%s", appmessage);
647 strlen(psd->dest_info) +
649 sprintf(message, fmt, appmessage, psd->dest_info, sysmessage);
652 Warning(pJob->pPad, message, XmDIALOG_WARNING);
655 XpCancelJob(XtDisplay(pJob->pShell), False);
656 PrintJobDestroy(pJob);
660 #endif /* PRINTING_SUPPORTED */
665 /************************************************************************
666 * _pjUpdatePageHeaders
667 * Configures the header and footer string in the PrintOutput.
668 ************************************************************************/
670 _pjUpdatePageHeaders(
672 PrintStringTypeEnum hl_type,
673 PrintStringTypeEnum hr_type,
674 PrintStringTypeEnum fl_type,
675 PrintStringTypeEnum fr_type
683 if (pJob == (PrintJob *) NULL) return;
685 hl_string = _pjGetPageHeaderString(pJob, hl_type);
686 hr_string = _pjGetPageHeaderString(pJob, hr_type);
687 fl_string = _pjGetPageHeaderString(pJob, fl_type);
688 fr_string = _pjGetPageHeaderString(pJob, fr_type);
690 if (PRINT_NONE_STRING_TYPE_ENUM == hl_type &&
691 PRINT_NONE_STRING_TYPE_ENUM == hr_type)
692 PrintOutputHideHeaders(pJob->pOutput);
694 PrintOutputShowHeaders(pJob->pOutput);
696 if (PRINT_NONE_STRING_TYPE_ENUM == fl_type &&
697 PRINT_NONE_STRING_TYPE_ENUM == fr_type)
698 PrintOutputHideFooters(pJob->pOutput);
700 PrintOutputShowFooters(pJob->pOutput);
703 PrintOutputSetHdrFtrStrings(
716 /************************************************************************
717 * _pjGetPageHeaderString
718 * Returns a header and footer string of the specified type.
719 ************************************************************************/
721 _pjGetPageHeaderString(PrintJob *pJob, PrintStringTypeEnum type)
724 *buf = (char *) NULL;
728 case PRINT_NONE_STRING_TYPE_ENUM:
731 case PRINT_DATE_STRING_TYPE_ENUM:
736 clock = time((time_t*) NULL);
737 date = ctime(&clock);
738 /* Strip off the trailing newline. */
739 date[strlen(date)-1] = '\0';
740 format = GETMESSAGE(14, 8, "Date: %s");
741 buf = (char *) malloc(strlen(format) + strlen(date) + 1);
742 if (buf != (char *) NULL)
743 sprintf(buf, format, date);
746 case PRINT_DOCNAME_STRING_TYPE_ENUM:
750 format = GETMESSAGE(14, 9, "Document: %s");
751 buflen = strlen(format) + strlen(pJob->documentName) + 1;
752 buf = (char *) malloc(buflen);
753 if (buf != (char *) NULL)
754 sprintf(buf, format, pJob->documentName);
757 case PRINT_PAGE_NUMBER_STRING_TYPE_ENUM:
759 * Allocate space for the format and the translated page number.
762 format = GETMESSAGE(14, 10, "Page %d of %d");
763 buf = (char *) malloc(strlen(format) + 16);
764 if (buf != (char *) NULL)
765 sprintf(buf, format, pJob->npagesDone, pJob->npagesTotal);
768 case PRINT_USER_NAME_STRING_TYPE_ENUM:
770 * Allocate space for the format and the username.
775 format = GETMESSAGE(14, 11, "Document For: %s");
776 pw = getpwuid(getuid());
777 buf = (char *) malloc(strlen(format) + strlen(pw->pw_name) + 1);
778 if (buf != (char *) NULL)
779 sprintf(buf, format, pw->pw_name);
783 buf = strdup("DEFAULT not impld");
792 * Name: _pjFinishedPrintToFile
796 * App-specific print data holder allocate function.
799 static void _pjFinishedPrintToFile(
802 XPGetDocStatus status,
803 XPointer client_data)
805 char *message = NULL;
806 PrintJob *pJob = (PrintJob *) client_data;
807 Editor *pPad = pJob->pPad;
809 if (status != XPGetDocFinished)
812 message = (char *) GETMESSAGE(
814 "'Print to File' was unsuccessful.");
815 Warning(pPad, message, XmDIALOG_WARNING);
817 else if (display != PrintJobGetErrorPrintDisplay())
820 message = (char *) GETMESSAGE(
822 "'Print to File' completed successfully.");
823 Warning(pPad, message, XmDIALOG_INFORMATION);
825 PrintJobDestroy(pJob);
832 * An XtCallbackProc which can be added to the callback list of
833 * a widget to cancel the print job passed back as client_data.
836 _pjCancelCB (Widget widget, XtPointer client_data, XtPointer call_data)
838 PrintJob *pJob = (PrintJob *) client_data;
840 PrintJobDestroy(pJob);
844 * Name: _pjCloseDisplayCB
846 * An XtCallbackProc which can be added to the callback list of
847 * a widget to cancel the print job passed back as client_data.
850 _pjCloseDisplayCB (Widget widget, XtPointer client_data, XtPointer call_data)
852 PrintJob *pJob = (PrintJob *) client_data;
853 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
855 if (pJob->pShell != NULL)
857 XtDestroyWidget(pJob->pShell);
860 DtPrintFreeSetupData(pJob->printData);
866 * An XtCallbackProc which can be added to the callback list of
867 * a widget to execute the print job passed back as client_data.
870 _pjPrintCB (Widget widget, XtPointer client_data, XtPointer call_data)
872 PrintJob *pJob = (PrintJob *) client_data;
873 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct *) call_data;
875 DtPrintCopySetupData(pJob->printData, pbs->print_data);
876 _pjCreatePrintShell(pJob);
882 * Name: _pjPdmSetupCB
884 * An XtCallbackProc which can be added to the callback list of
885 * a widget to popup the PDM for the print job.
888 _pjPdmSetupCB(Widget print_setup, XtPointer client_data, XtPointer call_data)
890 #if defined(PRINTING_SUPPORTED)
891 char *pname = "_pjPdmSetupCB";
892 PrintJob *pJob = (PrintJob *) client_data;
893 DtPrintSetupCallbackStruct
894 *pbs = (DtPrintSetupCallbackStruct *) call_data;
896 DtPrintCopySetupData(pJob->printData, pbs->print_data);
897 _pjCreatePrintShell(pJob);
902 Widget shell = print_setup;
904 while (! (shell == NULL || XtIsShell(shell)) )
905 shell = XtParent(shell);
908 XmPrintPopupPDM(pJob->pShell, shell);
910 fprintf(stderr, "Internal Error %s: Missing XmPrintShell.", pname);
912 #endif /* PRINTING_SUPPORTED */
916 /************************************************************************
917 * _pjPdmNotificationCB
918 * XmNpdmNotificationCallback for the XmPrintShell
919 ************************************************************************/
921 _pjPdmNotificationCB (Widget widget, XtPointer client_data, XtPointer call_data)
923 #if defined(PRINTING_SUPPORTED)
924 PrintJob *pJob = (PrintJob*) client_data;
925 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
926 char *message = NULL;
928 switch (pscbs->reason)
932 case XmCR_PDM_START_ERROR:
933 case XmCR_PDM_START_VXAUTH:
934 case XmCR_PDM_START_PXAUTH:
935 message = (char *) GETMESSAGE(
937 "Print Dialog Manager error - setup failed.");
945 Warning( pJob->pPad, message, XmDIALOG_WARNING);
946 #endif /* PRINTING_SUPPORTED */
951 /************************************************************************
953 * XmNpageSetupCallback for the XmPrintShell
954 ************************************************************************/
958 XtPointer client_data,
962 #if defined(PRINTING_SUPPORTED)
963 PrintJob *pJob = (PrintJob *) client_data;
965 XmPrintShellCallbackStruct *pscbs = (XmPrintShellCallbackStruct*)call_data;
968 if (pJob->pOutput == NULL)
970 XtArgVal width0, height0;
971 Dimension width, height;
979 width = (Dimension)width0;
980 height = (Dimension)height0;
982 #if defined(PRINT_TO_VIDEO)
983 printf("PrintShell in _pjPrintOnePageCB: <W %d - H %d>\n",width,height);
986 if (width < 100 || height < 100)
988 width = 2550; height=3250;
1000 #if defined(PRINT_TO_VIDEO)
1002 "PrintShell in _pjPrintOnePageCB: <W %d - H %d>\n",width,height);
1005 _pjCreateOutputWidgets(pJob);
1008 #ifdef PRINT_TO_VIDEO
1009 if (pJob->npagesDone > 0 && pJob->npagesDone == pJob->npagesTotal)
1011 if (pscbs->last_page)
1014 DtPrintSetupData *psd = pJob->printData;
1017 * This spool job is done. Clean up.
1018 * If this is a print to file job,
1019 * clean up in the job finished callback.
1021 if (psd->destination != DtPRINT_TO_FILE)
1022 PrintJobDestroy(pJob);
1026 if (pJob->npagesDone > 0 && PrintOutputPageDown(pJob->pOutput) == FALSE)
1028 #ifndef PRINT_TO_VIDEO
1029 pscbs->last_page = TRUE;
1035 * Update header and footer strings.
1038 _pjUpdatePageHeaders(
1040 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_HEADER_LEFT),
1041 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_HEADER_RIGHT),
1042 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_FOOTER_LEFT),
1043 PrintSetupGetHdrFtrSpec(pJob->pSetup, DTPRINT_OPTION_FOOTER_RIGHT)
1047 * Notify the user that we're printing
1049 if (pJob->pPad != NULL)
1051 static char buf[1024];
1054 format = GETMESSAGE(14, 22, "Printing %s: page %d of %d ...");
1055 sprintf(buf, format,
1059 SetStatusMessage(pJob->pPad, buf);
1062 #ifndef PRINT_TO_VIDEO
1063 if (pJob->npagesDone >= pJob->npagesTotal)
1064 pscbs->last_page = TRUE;
1067 #endif /* PRINTING_SUPPORTED */