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: Print.c /main/10 1999/02/09 19:45:00 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cache Creek (Rivers) Project
31 ** Description: Builds and displays an instance of a Cache Creek Print
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
44 #include <sys/param.h>
46 #include <stdlib.h> /* for getenv() */
56 #include <Xm/LabelG.h>
58 #include <Xm/SeparatoG.h>
59 #include <Xm/PushBG.h>
60 #include <Xm/DialogS.h>
61 #include <Xm/ToggleBG.h>
62 #include <Xm/RowColumn.h>
63 #include <Xm/MwmUtil.h>
64 #include <Xm/Protocols.h>
66 #include <X11/Intrinsic.h>
67 #include <X11/Shell.h>
68 #include <X11/ShellP.h>
69 #include <X11/Xutil.h>
70 #include <X11/keysymdef.h>
75 #include "DisplayAreaI.h"
77 #include "MessagesP.h"
80 #include "HelpUtilI.h"
81 #include "HelpAccessI.h"
82 #include "HelpDialogI.h"
83 #include "HelpDialogP.h"
87 /***** helper structures ****/
88 typedef struct _DtHelpPrintCBRec {
90 _DtHelpDisplayWidgetStuff * display;
91 _DtHelpCommonHelpStuff * help;
92 _DtHelpPrintStuff * print;
95 /***** Global Variables ****/
96 char _DtHelpDefaultHelpPrint[] = "/usr/dt/bin/dthelpprint";
98 /* The order of these names must match the constants DtHELP_PAPERSIZE_xxx */
99 char *_DtHelpPaperSizeNames[] =
100 { "help_papersize_letter",
101 "help_papersize_legal",
102 "help_papersize_executive",
106 int _DtHelpPaperSizeNamesCnt = (sizeof(_DtHelpPaperSizeNames) / sizeof(char *));
108 /***** Constants ******/
109 #define EOS '\0' /* end of string */
110 #define EMPTYSTR s_EmptyStr
112 #define PRSET 4 /* msg catalog set for print dialog */
114 #define PrintMessage001 _DtHelpMsg_0004
116 /***** Static Variables ******/
117 static char s_EmptyStr[] = "";
119 /****** Protos ******/
120 static void ClosePrintCB (
122 XtPointer clientData,
124 static void StartPrintingCB (
126 XtPointer clientData,
128 static void CreatePrintDialog(
130 _DtHelpPrintStuff * print,
131 _DtHelpDisplayWidgetStuff * display,
132 _DtHelpCommonHelpStuff * help);
134 /************************************************************************
135 * Function: CreatePrintCBRec()
137 * Create the data required by a print callback
139 * This routine allocates memory for the callback record using XtCalloc().
140 * When the record is no longer needed, free it with XtFree().
141 ************************************************************************/
143 _DtHelpPrintCBRec * CreatePrintCBRec(
145 _DtHelpDisplayWidgetStuff * display,
146 _DtHelpCommonHelpStuff * help,
147 _DtHelpPrintStuff * print)
149 _DtHelpPrintCBRec * rec = NULL;
151 rec = (_DtHelpPrintCBRec *) XtCalloc(1,sizeof(_DtHelpPrintCBRec));
152 if (NULL == rec) return NULL;
153 rec->widget = widget;
154 rec->display = display;
161 /************************************************************************
162 * Function: _DtHelpInitPrintStuff()
164 * Init print-related data
166 ************************************************************************/
167 void _DtHelpInitPrintStuff (
168 _DtHelpPrintStuff * print)
170 /* Set our print display stuff to initial values */
171 if (print->printer != NULL)
172 print->printer = XtNewString(print->printer);
174 if (print->helpPrint != _DtHelpDefaultHelpPrint)
175 print->helpPrint = XtNewString(print->helpPrint);
177 print->paperSize = DtHELP_PAPERSIZE_LETTER;
178 print->printVolume = NULL;
180 /* print dialog widgets */
181 print->printForm = NULL;
182 print->subject = NULL;
183 print->printerField = NULL;
184 print->copiesField = NULL;
185 print->letterBtn = NULL;
186 print->legalBtn = NULL;
187 print->execBtn = NULL;
190 print->topicsFrame = NULL;
191 print->curTopicBtn = NULL;
192 print->subTopicsBtn = NULL;
193 print->tocBtn = NULL;
194 print->allTopicsBtn = NULL;
195 print->paperTopicsSeparator = NULL;
196 print->topicsBtnsSeparator = NULL;
200 /************************************************************************
201 * Function: _DtHelpFreePrintStuff()
203 * Init print-related data
205 ************************************************************************/
206 void _DtHelpFreePrintStuff (
207 _DtHelpPrintStuff * print,
210 XtFree(print->printVolume);
211 print->printVolume = NULL;
213 if (print->printForm != NULL)
215 XtUnmanageChild(print->printForm);
218 if (cleanUpKind == DtCLEAN_FOR_DESTROY)
220 if (print->helpPrint != _DtHelpDefaultHelpPrint)
221 XtFree(print->helpPrint);
222 print->helpPrint = NULL;
224 XtFree(print->printer);
225 print->printer = NULL;
230 /************************************************************************
231 * Function: _DtHelpPrintSetValues()
233 * set print-related data
235 ************************************************************************/
236 void _DtHelpPrintSetValues (
237 _DtHelpPrintStuff * currentPrint,
238 _DtHelpPrintStuff * newPrint,
239 _DtHelpDisplayWidgetStuff * newDisplay,
240 _DtHelpCommonHelpStuff * newCommonHelp)
242 /* Check DtNhelpPrint resource for change */
243 if (currentPrint->helpPrint != newPrint->helpPrint)
245 newPrint->helpPrint = XtNewString(newPrint->helpPrint);
247 if (currentPrint->helpPrint != _DtHelpDefaultHelpPrint)
248 XtFree(currentPrint->helpPrint);
251 /* Check DtNprinter resource for change */
252 if (currentPrint->printer != newPrint->printer)
254 newPrint->printer = XtNewString(newPrint->printer);
255 XtFree(currentPrint->printer);
259 /* Do NOT check DtNpaperSize resource for change */
260 /* It is a C-only resource */
265 /************************************************************************
266 * Function: ClosePrintCB()
268 * Close the Print dialog.
270 ************************************************************************/
271 static void ClosePrintCB (
273 XtPointer clientData,
276 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
278 /* We unmap the print dialog */
279 XtUnmanageChild(printrec->print->printForm);
283 /************************************************************************
284 * Function: DestroyDialogCB()
286 * Free allocated memory
288 ************************************************************************/
289 static void DestroyDialogCB(
291 XtPointer clientData,
294 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
295 XtFree((char *)printrec);
298 /************************************************************************
299 * Function: CheckCopiesCB()
301 * Check whether the copies in the copies field is valid
303 ************************************************************************/
304 static void CheckCopiesCB(
306 XtPointer clientData,
309 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
313 /************************************************************************
314 * Function: CheckPrinterCB()
316 * Check whether the printer in the printer field is valid
317 * and store a valid printer string in printPrinter.
319 ************************************************************************/
320 static void CheckPrinterCB(
322 XtPointer clientData,
325 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
329 /************************************************************************
330 * Function: StartPrintingCB()
332 * Start printing and close the PRINT Dialog
334 ************************************************************************/
335 static void StartPrintingCB(
337 XtPointer clientData,
340 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
342 char *printTopic=NULL;
343 char *topicTitle=NULL;
344 Boolean printAll=False;
345 Boolean printSub=False;
346 Boolean printTocIndex=False;
348 XmString titleLbl = NULL;
352 Widget dfltSize = NULL;
355 /* Determine the current selected print type */
357 if (XmToggleButtonGetState(printrec->print->allTopicsBtn))
359 printType = _DtPRINT_ALL;
360 printTopic = printrec->help->topLevelId;
364 if (XmToggleButtonGetState(printrec->print->tocBtn))
366 printType = _DtPRINT_TOC;
368 printTocIndex = True;
371 if (XmToggleButtonGetState(printrec->print->subTopicsBtn))
373 printType = _DtPRINT_SUB;
374 printTopic = printrec->display->locationId;
378 if (XmToggleButtonGetState(printrec->print->curTopicBtn))
380 printType = _DtPRINT_CURRENT;
381 switch (printrec->display->helpType)
383 case DtHELP_TYPE_TOPIC:
384 printTopic = printrec->display->locationId;
387 case DtHELP_TYPE_MAN_PAGE:
388 printTopic = printrec->display->manPage;
391 case DtHELP_TYPE_FILE:
392 printTopic = printrec->display->helpFile;
393 titleLbl = printrec->display->topicTitleLbl;
396 case DtHELP_TYPE_STRING:
397 case DtHELP_TYPE_DYNAMIC_STRING:
398 /* ??? Full support for dynamic string types */
399 printTopic = printrec->display->stringData;
400 titleLbl = printrec->display->topicTitleLbl;
403 } /* End Switch Statement */
407 * change the XmString into a char *.
409 if (titleLbl != NULL)
413 XmStringContext theContext;
414 XmStringCharSet theSet;
415 XmStringDirection theDir;
419 if (XmStringInitContext(&theContext, titleLbl) == True)
421 while (XmStringGetNextSegment(theContext,
427 len = strlen(newTxt);
430 topicTitle = XtRealloc(topicTitle, len + 1);
431 if (topicTitle != NULL)
433 strcpy(&topicTitle[newLen], newTxt);
438 XmStringFreeContext(theContext);
443 printer = XmTextFieldGetString(printrec->print->printerField);
444 if (printer && printer[0] == EOS)
445 { XtFree(printer); printer = NULL; }
448 copies = XmTextFieldGetString(printrec->print->copiesField);
451 || (copies && copies[0] == EOS)
452 || (copies && sscanf(copies,"%d",©Cnt) != 1 )
453 || (copyCnt < 0 || copyCnt > 500) )
454 { XtFree(copies); copies = XtNewString("1"); }
457 /* Get the chosen size */
458 XtSetArg (args[0], XmNmenuHistory, &dfltSize);
459 XtGetValues (printrec->print->paperSizeOptMenu, args, 1);
460 if (dfltSize == printrec->print->legalBtn)
461 paperSize = DtHELP_PAPERSIZE_LEGAL;
462 else if (dfltSize == printrec->print->execBtn)
463 paperSize = DtHELP_PAPERSIZE_EXECUTIVE;
464 else if (dfltSize == printrec->print->a4Btn)
465 paperSize = DtHELP_PAPERSIZE_A4;
466 else if (dfltSize == printrec->print->b5Btn)
467 paperSize = DtHELP_PAPERSIZE_B5;
469 paperSize = DtHELP_PAPERSIZE_LETTER;
473 /* Call the print setup routine to start the print job */
476 printrec->print->helpPrint,
480 printrec->print->printVolume,
481 printrec->display->helpType,
493 /* We unmap the print dialog */
494 XtUnmanageChild(printrec->print->printForm);
499 /*****************************************************************************
500 * Function: void _DtHelpUpdatePrintDialog();
503 * Parameters: new Specifies the help widget.
507 * Purpose: Updates the print dialog to reflect current topic
509 *****************************************************************************/
510 void _DtHelpUpdatePrintDialog(
511 _DtHelpPrintStuff * print,
512 _DtHelpDisplayWidgetStuff * display,
513 _DtHelpCommonHelpStuff * help,
519 XmString labelString=NULL;
520 XmString volumeString=NULL;
521 XmFontList fontList = NULL;
525 /* only work on print dialog if we need to */
526 if (print->printForm == NULL) return;
528 /* Set the proper default toggle button value */
531 if(print->curTopicBtn)
532 XmToggleButtonSetState(print->curTopicBtn, True, False);
533 if(print->subTopicsBtn)
534 XmToggleButtonSetState(print->subTopicsBtn,False,False);
536 XmToggleButtonSetState(print->tocBtn,False,False);
537 if(print->allTopicsBtn)
538 XmToggleButtonSetState(print->allTopicsBtn,False,False);
541 /* adj where the TopicsBtn separator is attached */
542 /* if attached to the PaperTopics separator, the topics are hidden */
544 if ( display->helpType == DtHELP_TYPE_TOPIC )
547 XtSetSensitive(print->topicsFrame,True);
549 XtManageChild(print->topicsFrame);
550 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
551 XtSetArg (args[n], XmNtopWidget, print->topicsFrame); n++;
557 XtSetSensitive(print->topicsFrame,False);
559 XtUnmanageChild(print->topicsFrame);
560 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
561 XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator); n++;
564 XtSetValues (print->topicsBtnsSeparator, args, n);
566 /* update the dialog's print subject label string */
567 switch ( display->helpType )
569 /* coming out of the case, volumeString & titleStr should be set */
570 case DtHELP_TYPE_TOPIC:
571 titleStr = _DTGETMESSAGE(PRSET, 50,"Help Volume: ");
573 /* get volume title and allow for localized fonts */
575 /* get the font list of the label */
576 XtSetArg (args[0], XmNfontList, &fontList);
577 XtGetValues (print->subject, args, 1);
579 #if defined(DONT_USE_CDExc22774)
580 /* Don't need to copy, _DtHelpFormatVolumeTitle copies
584 /* copy the list before passing it in for modification */
585 /* we must free this now */
586 fontList = XmFontListCopy (fontList);
589 /* get formated volume title; volumeString is owned by caller */
590 _DtHelpFormatVolumeTitle(help->pDisplayArea,display->volumeHandle,
591 &volumeString,&fontList,&mod);
593 /* if volumeString caused a font list change, add it back */
595 { /* Add the title's font to the label */
596 XtSetArg (args[0], XmNfontList, fontList);
597 XtSetValues (print->subject, args, 1);
598 if (fontList) XmFontListFree(fontList);
602 case DtHELP_TYPE_STRING:
603 case DtHELP_TYPE_DYNAMIC_STRING:
604 titleStr = _DTGETMESSAGE(PRSET, 51,"Help Message");
606 case DtHELP_TYPE_FILE:
607 titleStr = _DTGETMESSAGE(PRSET, 52,"Help File");
609 case DtHELP_TYPE_MAN_PAGE:
610 /* assumption: buf won't overflow */
611 sprintf(buf,"%s%s", _DTGETMESSAGE(PRSET, 53,"Manual Page: "),
616 titleStr = _DTGETMESSAGE(PRSET, 54,"Error message");
620 /* at this point, titleStr and volumeString are set */
622 /* set the dialog label strings only if needed */
623 labelString = XmStringCreateLocalized(titleStr);
625 /* if there is a valid volumeString, concatenate it */
629 fullTitle = XmStringConcat(labelString,volumeString);
630 XmStringFree(labelString);
631 XmStringFree(volumeString);
632 labelString = fullTitle;
635 /* set the dialog label string */
636 XtSetArg (args[0], XmNlabelString, labelString);
637 XtSetValues (print->subject, args, 1);
638 XmStringFree (labelString);
640 XmUpdateDisplay(print->printForm);
645 /*****************************************************************************
646 * Function: void _DtHelpDisplayPrintDialog();
650 * new Specifies the help widget.
652 * display display widget stuff
653 * help common help stuff
657 * Purpose: Creates and displays an instance of the print dialog.
659 *****************************************************************************/
660 void _DtHelpDisplayPrintDialog(
662 _DtHelpPrintStuff * print,
663 _DtHelpDisplayWidgetStuff * display,
664 _DtHelpCommonHelpStuff * help)
667 Widget dfltSize = NULL;
669 /* Build a print dialog if we need to */
670 if (print->printForm == NULL)
672 CreatePrintDialog(widget,print,display,help);
674 /*** Only init the values if creating dialog for first time ***/
676 switch(print->paperSize)
678 case DtHELP_PAPERSIZE_LEGAL:
679 dfltSize = print->legalBtn;
681 case DtHELP_PAPERSIZE_EXECUTIVE:
682 dfltSize = print->execBtn;
684 case DtHELP_PAPERSIZE_A4:
685 dfltSize = print->a4Btn;
687 case DtHELP_PAPERSIZE_B5:
688 dfltSize = print->b5Btn;
690 case DtHELP_PAPERSIZE_LETTER:
692 dfltSize = print->letterBtn;
695 /* Set the default size */
696 XtSetArg (args[0], XmNmenuHistory, dfltSize);
697 XtSetValues (print->paperSizeOptMenu, args, 1);
699 /* update the variable contents of the dialog; do set defaults */
700 _DtHelpUpdatePrintDialog(print,display,help,True);
704 /* update the variable contents of the dialog; dont set defaults */
705 _DtHelpUpdatePrintDialog(print,display,help,False);
709 if ( XtIsManaged(print->printForm) == False )
711 /* Make sure the Print Dialog is managed */
712 /* recall that the printForm is the form inside the dlg shell */
713 XtManageChild(print->printForm);
714 XtMapWidget(XtParent((Widget)print->printForm));
718 /* raise the window to top of the stack */
719 Widget parent = XtParent(print->printForm);
720 XRaiseWindow ( XtDisplay(parent), XtWindow(parent) );
726 /*****************************************************************************
727 * Function: Widget CreatePrintDialog(Widget nw);
734 * Purpose: Creates an instance of the print dialog.
736 *****************************************************************************/
737 static void CreatePrintDialog(
739 _DtHelpPrintStuff * print,
740 _DtHelpDisplayWidgetStuff * display,
741 _DtHelpCommonHelpStuff * help)
752 Widget okBtn, cancelBtn, helpBtn;
753 XmString labelString;
755 DtHelpListStruct *pHelpInfo;
756 _DtHelpPrintCBRec * printCBRec = NULL;
760 /* Create the shell and form used for the dialog. */
761 chrStr = XtNewString(((char *)_DTGETMESSAGE(PRSET, 1, "Help - Print")));
763 XtSetArg (args[n], XmNtitle, chrStr); n++;
764 printShell = XmCreateDialogShell(widget, "printShell", args, n);
767 /* Set the useAsyncGeo on the shell */
769 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
770 /* XtSetValues (XtParent(printShell), args, n);*/
771 XtSetValues (printShell, args, n);
773 /* Allocate the printRec and arrange to free it when dialog destroyed */
774 printCBRec = CreatePrintCBRec(widget,display,help,print);
775 XtAddCallback (printShell, XmNdestroyCallback,
776 DestroyDialogCB, (XtPointer) printCBRec);
778 /* create the form in the dialog to hold the contents */
780 XtSetArg (args[n], XmNmarginWidth, 1); n++;
781 XtSetArg (args[n], XmNmarginHeight, 1); n++;
782 XtSetArg (args[n], XmNshadowThickness, 1); n++;
783 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
784 XtSetArg (args[n], XmNautoUnmanage, False); n++;
785 printForm = XmCreateForm (printShell, "printForm", args, n);
787 /**** create the printing-related widgets ****/
789 /* create print subject label */
790 labelString = XmStringCreateLocalized(EMPTYSTR);
792 XtSetArg (args[n], XmNlabelString, labelString); n++;
793 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
794 XtSetArg (args[n], XmNtopOffset, 10); n++;
795 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
796 XtSetArg (args[n], XmNleftOffset, 15); n++;
798 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
799 XtSetArg (args[n], XmNrightOffset, 10); n++;
801 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
803 XmCreateLabelGadget (printForm, "printSubject", args, n);
804 XtManageChild (print->subject);
805 XmStringFree (labelString);
807 /* create printer label */
808 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
809 (PRSET, 10,"Printer:")));
811 XtSetArg (args[n], XmNlabelString, labelString); n++;
812 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
813 XtSetArg (args[n], XmNtopWidget, print->subject); n++;
814 XtSetArg (args[n], XmNtopOffset, 15); n++;
815 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
816 XtSetArg (args[n], XmNleftOffset, 15); n++;
817 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
818 printerLabel = XmCreateLabelGadget (printForm, "printerLabel", args, n);
819 XtManageChild (printerLabel);
820 XmStringFree (labelString);
822 /* create the printer name text field */
824 /* get the printer value from printer resource, LPDEST, or leave blank */
825 if ( print->printer != NULL && print->printer[0] != EOS )
826 chrStr = print->printer;
827 else if ( (chrStr = getenv("LPDEST")) == NULL || chrStr[0] == EOS)
828 chrStr = (char *)_DTGETMESSAGE(PRSET, 60,""); /* dflt printer value */
829 XtSetArg (args[n], XmNvalue, chrStr ); n++;
830 XtSetArg (args[n], XmNcursorPosition, strlen(chrStr) ); n++;
831 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
832 XtSetArg (args[n], XmNtopWidget, print->subject); n++;
833 XtSetArg (args[n], XmNtopOffset, 10); n++;
834 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
835 XtSetArg (args[n], XmNleftWidget, printerLabel); n++;
836 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
837 XtSetArg (args[n], XmNrightPosition, 60); n++;
838 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
839 print->printerField =
840 XmCreateTextField (printForm,"printerField",args, n);
841 XtManageChild (print->printerField);
842 XtAddCallback (print->printerField, XmNactivateCallback,
843 CheckPrinterCB, (XtPointer) printCBRec);
844 XtAddCallback (print->printerField, XmNvalueChangedCallback,
845 CheckPrinterCB, (XtPointer) printCBRec);
847 /* create copies label */
848 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
849 (PRSET, 11,"Copies:")));
851 XtSetArg (args[n], XmNlabelString, labelString); n++;
852 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
853 XtSetArg (args[n], XmNtopWidget,print->subject); n++;
854 XtSetArg (args[n], XmNtopOffset, 15); n++;
855 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
856 XtSetArg (args[n], XmNleftOffset, 10); n++;
857 XtSetArg (args[n], XmNleftWidget, print->printerField); n++;
858 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
859 copiesLabel = XmCreateLabelGadget (printForm, "copiesLabel", args, n);
860 XtManageChild (copiesLabel);
861 XmStringFree (labelString);
863 /* create the copies text field */
865 XtSetArg (args[n], XmNvalue,(char *)_DTGETMESSAGE(PRSET, 61,"1")); n++;/*dflt copy cnt*/
866 XtSetArg (args[n], XmNcursorPosition, 1 ); /* 1=strlen("1") */ n++;
867 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
868 XtSetArg (args[n], XmNtopWidget,print->subject); n++;
869 XtSetArg (args[n], XmNtopOffset, 10); n++;
870 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
871 XtSetArg (args[n], XmNleftWidget, copiesLabel); n++;
872 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
873 XtSetArg (args[n], XmNrightOffset, 10); n++;
874 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
876 XmCreateTextField (printForm,"copiesField",args, n);
877 XtManageChild (print->copiesField);
878 XtAddCallback (print->copiesField, XmNactivateCallback,
879 CheckCopiesCB, (XtPointer) printCBRec);
880 XtAddCallback (print->copiesField, XmNvalueChangedCallback,
881 CheckCopiesCB, (XtPointer) printCBRec);
883 /* papersize option menu */
884 /*******************************************************
885 * Menupane: Papersize buttons
886 * No callback on each button is needed because we compare widget ptrs
887 *******************************************************/
890 XtSetArg(args[n], XmNmarginWidth, 0); ++n;
891 XtSetArg(args[n], XmNmarginHeight, 0); ++n;
892 menupane = XmCreatePulldownMenu(printForm, "paperSizeMenu", args, n);
895 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 21,"Letter 8.5 x 11 in")));
897 XtSetArg(args[n], XmNlabelString, labelString); n++;
898 print->letterBtn = XmCreatePushButtonGadget(menupane, "letter", args, n);
899 XtManageChild(print->letterBtn);
900 XmStringFree(labelString);
903 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 22,"Legal 8.5 x 14 in")));
905 XtSetArg(args[n], XmNlabelString, labelString); n++;
906 print->legalBtn = XmCreatePushButtonGadget(menupane, "legal", args, n);
907 XtManageChild(print->legalBtn);
908 XmStringFree(labelString);
910 /* Executive button */
911 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 23,"Executive 7.25 x 10.5 in")));
913 XtSetArg(args[n], XmNlabelString, labelString); n++;
914 print->execBtn = XmCreatePushButtonGadget(menupane, "executive", args, n);
915 XtManageChild(print->execBtn);
916 XmStringFree(labelString);
919 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 24,"A4 210 x 297 mm")));
921 XtSetArg(args[n], XmNlabelString, labelString); n++;
922 print->a4Btn = XmCreatePushButtonGadget(menupane, "A4", args, n);
923 XtManageChild(print->a4Btn);
924 XmStringFree(labelString);
927 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 25,"B5 182 x 257 mm")));
929 XtSetArg(args[n], XmNlabelString, labelString); n++;
930 print->b5Btn = XmCreatePushButtonGadget(menupane, "B5", args, n);
931 XtManageChild(print->b5Btn);
932 XmStringFree(labelString);
935 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 20,"Paper Size:")));
937 XtSetArg(args[n], XmNlabelString, labelString); n++;
938 XtSetArg(args[n], XmNsubMenuId, menupane); n++;
939 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
940 XtSetArg (args[n], XmNtopWidget,printerLabel); n++;
941 XtSetArg (args[n], XmNtopOffset, 15); n++;
942 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
943 XtSetArg (args[n], XmNrightOffset, 5); n++;
944 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
945 XtSetArg (args[n], XmNleftOffset, 10); n++;
946 XtSetArg (args[n], XmNmarginWidth, 5); n++;
947 XtSetArg (args[n], XmNmarginHeight, 2); n++;
948 print->paperSizeOptMenu = XmCreateOptionMenu(printForm,
949 "paperSizeOptionMenu", args, n);
950 XtManageChild(print->paperSizeOptMenu);
951 XmStringFree(labelString);
953 /* the DtNpaperSize resource is used to set the default item
954 in _DtHelpDisplayPrintDialog() */
956 /* Create a separator between the paper size and topic range selection/buttons */
958 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
959 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
960 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
961 XtSetArg (args[n], XmNtopWidget, print->paperSizeOptMenu); n++;
962 XtSetArg (args[n], XmNtopOffset, 0); n++;
963 XtSetArg (args[n], XmNseparatorType, XmNO_LINE); n++;
964 print->paperTopicsSeparator =
965 XmCreateSeparatorGadget (printForm, "separator", args, n);
966 XtManageChild (print->paperTopicsSeparator);
968 /* if currently showing a topic, display the topic selection box */
969 /****** Create the topics selection frame ******/
971 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
972 XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator); n++;
973 XtSetArg (args[n], XmNtopOffset, 5); n++;
974 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
975 XtSetArg (args[n], XmNrightOffset, 5); n++;
976 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
977 XtSetArg (args[n], XmNleftOffset, 5); n++;
978 XtSetArg (args[n], XmNmarginWidth, 5); n++;
979 XtSetArg (args[n], XmNmarginHeight, 2); n++;
980 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;/*EXP*/
982 XmCreateFrame(printForm, "topicsFrame", args, n);
983 XtManageChild (print->topicsFrame);
985 /* FIX: consider eliminating the form and just putting the RowColumn
986 RadioBox inside the frame */
988 /* unused message catalog entries: 8: Executive, 9: Legal */
990 /* put form inside frame */
991 topicsForm = XmCreateForm (
992 print->topicsFrame,"topicsForm", NULL, 0);
993 XtManageChild (topicsForm);
995 /* create the frame title */
996 labelString = XmStringCreateLocalized ((_DTGETMESSAGE(
997 PRSET,30,"Topics To Print")));
999 XtSetArg (args[n], XmNlabelString, labelString); n++;
1000 XtSetArg (args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
1001 XtSetArg (args[n], XmNtraversalOn, False); n++;
1002 frameTitle = XmCreateLabelGadget(
1003 print->topicsFrame,"topicsFrameTitle",args,n);
1004 XtManageChild (frameTitle);
1005 XmStringFree (labelString);
1007 /* Create the Radio Box widget to hold the toggle buttons */
1009 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1010 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1011 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1012 radioBox = XmCreateRadioBox(topicsForm, "radioBox", args, n);
1013 XtManageChild (radioBox);
1015 /* Create the print current topic button */
1016 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1017 (PRSET, 31,"Current Topic")));
1019 XtSetArg (args[n], XmNlabelString, labelString); n++;
1020 print->curTopicBtn =
1021 XmCreateToggleButtonGadget(radioBox,"printCurTopicBtn",args,n);
1022 XtManageChild (print->curTopicBtn);
1023 XmStringFree (labelString);
1025 /* Create the print current chapter button */
1026 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1027 (PRSET, 32,"Current and Subtopics")));
1029 XtSetArg (args[n], XmNlabelString, labelString); n++;
1030 print->subTopicsBtn =
1031 XmCreateToggleButtonGadget(radioBox,"print.subTopicsBtn",args,n);
1032 XtManageChild (print->subTopicsBtn);
1033 XmStringFree (labelString);
1035 /* Create the print TOC buttion */
1036 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1037 (PRSET, 33,"Table of Contents and Index")));
1039 XtSetArg (args[n], XmNlabelString, labelString); n++;
1040 print->tocBtn = XmCreateToggleButtonGadget
1041 (radioBox, "printTocBtn", args, n);
1042 XtManageChild (print->tocBtn);
1043 XmStringFree (labelString);
1045 /* Create the print all topics buttion */
1046 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1047 (PRSET, 34,"Entire Volume")));
1049 XtSetArg (args[n], XmNlabelString, labelString); n++;
1050 print->allTopicsBtn = XmCreateToggleButtonGadget
1051 (radioBox, "printAllTopicsBtn", args, n);
1052 XtManageChild (print->allTopicsBtn);
1053 XmStringFree (labelString);
1055 /* create a separator */
1057 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1058 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1059 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1060 XtSetArg (args[n], XmNtopWidget, print->topicsFrame); n++;
1061 XtSetArg (args[n], XmNtopOffset, 10); n++;
1062 print->topicsBtnsSeparator =
1063 XmCreateSeparatorGadget (printForm, "separator", args, n);
1064 XtManageChild (print->topicsBtnsSeparator);
1067 separator = print->topicsBtnsSeparator;
1069 /* Create the action buttons along the bottom */
1070 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1071 (PRSET, 40,"Print")));
1073 XtSetArg (args[n], XmNlabelString, labelString); n++;
1074 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1075 XtSetArg (args[n], XmNleftPosition, 3); n++;
1076 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1077 XtSetArg (args[n], XmNrightPosition, 32); n++;
1078 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1079 XtSetArg (args[n], XmNtopWidget, separator); n++;
1080 XtSetArg (args[n], XmNtopOffset, 5); n++;
1082 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1084 XtSetArg (args[n], XmNbottomOffset, 5); n++;
1085 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1086 okBtn = XmCreatePushButtonGadget (printForm, "okBtn", args, n);
1087 XtAddCallback(okBtn, XmNactivateCallback, StartPrintingCB,
1088 (XtPointer) printCBRec);
1089 XtManageChild (okBtn);
1090 XmStringFree (labelString);
1092 /* Build the Cancel Button */
1093 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1094 (PRSET, 41,"Cancel")));
1096 XtSetArg (args[n], XmNlabelString, labelString); n++;
1097 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1098 XtSetArg (args[n], XmNleftPosition, 35); n++;
1099 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1100 XtSetArg (args[n], XmNrightPosition, 64); n++;
1101 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1102 XtSetArg (args[n], XmNtopWidget, separator); n++;
1103 XtSetArg (args[n], XmNtopOffset, 5); n++;
1104 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1105 cancelBtn = XmCreatePushButtonGadget (printForm, "cancelBtn", args, n);
1106 XtAddCallback(cancelBtn, XmNactivateCallback, ClosePrintCB,
1107 (XtPointer) printCBRec);
1108 XtManageChild (cancelBtn);
1109 XmStringFree (labelString);
1111 /* Build the Help button */
1112 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1113 (PRSET, 42,"Help")));
1115 XtSetArg (args[n], XmNlabelString, labelString); n++;
1116 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1117 XtSetArg (args[n], XmNleftPosition, 68); n++;
1118 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1119 XtSetArg (args[n], XmNrightPosition, 97); n++;
1120 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1121 XtSetArg (args[n], XmNtopWidget, separator); n++;
1122 XtSetArg (args[n], XmNtopOffset, 5); n++;
1123 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1124 helpBtn = XmCreatePushButtonGadget (printForm, "helpBtn", args, n);
1125 XtManageChild (helpBtn);
1126 pHelpInfo = _DtHelpListAdd(DtHELP_printHelpBtn_STR,
1127 widget, help, &help->pHelpListHead);
1128 XtAddCallback(helpBtn, XmNactivateCallback,
1129 _DtHelpCB, (XtPointer) pHelpInfo);
1130 XmStringFree (labelString);
1132 /*** now do some setup ***/
1133 /* make OK the default btn btn */
1134 /* make Cancel the cancel (KCancel) btn */
1135 /* set focus on the printer field */
1137 XtSetArg (args[n], XmNdefaultButton, okBtn); n++;
1138 XtSetArg (args[n], XmNcancelButton, cancelBtn); n++;
1139 XtSetArg (args[n], XmNinitialFocus, print->printerField); n++;
1140 XtSetValues (printForm,args,n);
1142 /* Adjust the decorations for the dialog shell of the dialog */
1144 XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_MOVE); n++;
1145 XtSetArg (args[n], XmNmwmDecorations,
1146 MWM_DECOR_BORDER | MWM_DECOR_TITLE); n++;
1147 XtSetValues (printShell, args, n);
1149 /* Add the popup position callback to our print dialog */
1150 XtAddCallback (printShell, XmNpopupCallback, (XtCallbackProc) _DtHelpMapCB,
1151 (XtPointer) XtParent(widget));
1153 /* Add the proper help callback to the print dialog shell "F1" support */
1154 pHelpInfo = _DtHelpListAdd(DtHELP_printShell_STR,
1155 widget, help, &help->pHelpListHead);
1156 XtAddCallback(printForm, XmNhelpCallback,
1157 _DtHelpCB, (XtPointer) pHelpInfo);
1159 /* Assign our new print dialog to our widget instance */
1160 print->printForm = printForm;
1162 /* Set the tab navigation order */
1163 XtSetArg (args[0], XmNnavigationType, XmSTICKY_TAB_GROUP);
1164 XtSetValues (print->printerField,args,1);
1165 XtSetValues (print->copiesField,args,1);
1166 XtSetValues (print->paperSizeOptMenu,args,1);
1167 XtSetValues (print->topicsFrame,args,1);
1168 XtSetValues (okBtn,args,1);
1169 XtSetValues (cancelBtn,args,1);
1170 XtSetValues (helpBtn,args,1);
1176 /*****************************************************************************
1177 * Function: void _DtHelpPrintJob(
1183 * Return Value: Void.
1185 * Purpose: Sets up and forks off a print job to helpprint
1187 *****************************************************************************/
1188 void _DtHelpPrintJob(
1199 Boolean printTocIndex,
1206 char tmpHelpType[4];
1208 /* Setup the helpprint command and let it go */
1210 argv[i++] = printExec;
1212 if (printer != NULL && printer[0] != EOS)
1214 argv[i++] = "-printer";
1215 argv[i++] = printer;
1218 if (copies != NULL && copies[0] != EOS)
1220 argv[i++] = "-copies";
1224 if (NULL != topicTitle)
1226 argv[i++] = "-topicTitle";
1227 argv[i++] = topicTitle;
1230 if (paperSize >= _DtHelpPaperSizeNamesCnt) paperSize = 0;
1231 argv[i++] = "-paperSize";
1232 argv[i++] = _DtHelpPaperSizeNames[paperSize];
1234 argv[i++] = "-display";
1235 argv[i++] = (char*)XDisplayString(XtDisplay(widget));
1237 argv[i++] = "-helpType";
1238 sprintf(tmpHelpType, "%d", helpType);
1239 argv[i++] = tmpHelpType;
1242 argv[i++] = "-allTopics";
1245 argv[i++] = "-subTopics";
1250 argv[i++] = "-index";
1251 argv[i++] = "-frontMatter";
1254 if (!printSub && !printAll && !printTocIndex)
1255 argv[i++] = "-oneTopic";
1257 if (NULL == helpData) helpData = quotes;
1260 case DtHELP_TYPE_TOPIC:
1261 argv[i++] = "-locationId";
1262 argv[i++] = helpData;
1263 argv[i++] = "-helpVolume";
1264 argv[i++] = helpVolume;
1267 case DtHELP_TYPE_MAN_PAGE:
1268 argv[i++] = "-manPage";
1269 argv[i++] = helpData;
1272 case DtHELP_TYPE_FILE:
1273 argv[i++] = "-helpFile";
1274 argv[i++] = helpData;
1277 case DtHELP_TYPE_STRING:
1278 case DtHELP_TYPE_DYNAMIC_STRING:
1279 argv[i++] = "-stringData";
1280 argv[i++] = helpData;
1285 /* We should never get here, but just in case... */
1286 XmeWarning(widget, (char*)PrintMessage001);
1288 } /* End Switch Statement */
1293 { /* for debugging, print out the command line */
1295 for ( tmpargv = argv; *tmpargv; tmpargv++ ) fprintf(stderr,"%s ", *tmpargv);
1296 fprintf(stderr,"\n");
1308 (void) execvp (argv[0], argv);
1312 /* Return an error if bad pid? */