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 libraries 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>
65 #include <Xm/ToggleB.h>
67 #include <X11/Intrinsic.h>
68 #include <X11/Shell.h>
69 #include <X11/ShellP.h>
70 #include <X11/Xutil.h>
71 #include <X11/keysymdef.h>
76 #include "DisplayAreaI.h"
77 #include "DisplayAreaP.h"
82 #include "MessagesP.h"
86 #include "HelpUtilI.h"
87 #include "HelpAccessI.h"
88 #include "HelpDialogI.h"
89 #include "HelpDialogP.h"
93 /***** helper structures ****/
94 typedef struct _DtHelpPrintCBRec {
96 _DtHelpDisplayWidgetStuff * display;
97 _DtHelpCommonHelpStuff * help;
98 _DtHelpPrintStuff * print;
101 /***** Global Variables ****/
102 char _DtHelpDefaultHelpPrint[] = "/usr/dt/bin/dthelpprint";
104 /* The order of these names must match the constants DtHELP_PAPERSIZE_xxx */
105 char *_DtHelpPaperSizeNames[] =
106 { "help_papersize_letter",
107 "help_papersize_legal",
108 "help_papersize_executive",
112 int _DtHelpPaperSizeNamesCnt = (sizeof(_DtHelpPaperSizeNames) / sizeof(char *));
114 /***** Constants ******/
115 #define EOS '\0' /* end of string */
116 #define EMPTYSTR s_EmptyStr
118 #define PRSET 4 /* msg catalog set for print dialog */
120 #define PrintMessage001 _DtHelpMsg_0004
122 /***** Static Variables ******/
123 static char s_EmptyStr[] = "";
125 /****** Protos ******/
126 static void ClosePrintCB (
128 XtPointer clientData,
130 static void StartPrintingCB (
132 XtPointer clientData,
134 static void CreatePrintDialog(
136 _DtHelpPrintStuff * print,
137 _DtHelpDisplayWidgetStuff * display,
138 _DtHelpCommonHelpStuff * help);
140 /************************************************************************
141 * Function: CreatePrintCBRec()
143 * Create the data required by a print callback
145 * This routine allocates memory for the callback record using XtCalloc().
146 * When the record is no longer needed, free it with XtFree().
147 ************************************************************************/
149 _DtHelpPrintCBRec * CreatePrintCBRec(
151 _DtHelpDisplayWidgetStuff * display,
152 _DtHelpCommonHelpStuff * help,
153 _DtHelpPrintStuff * print)
155 _DtHelpPrintCBRec * rec = NULL;
157 rec = (_DtHelpPrintCBRec *) XtCalloc(1,sizeof(_DtHelpPrintCBRec));
158 if (NULL == rec) return NULL;
159 rec->widget = widget;
160 rec->display = display;
167 /************************************************************************
168 * Function: _DtHelpInitPrintStuff()
170 * Init print-related data
172 ************************************************************************/
173 void _DtHelpInitPrintStuff (
174 _DtHelpPrintStuff * print)
176 /* Set our print display stuff to initial values */
177 if (print->printer != NULL)
178 print->printer = XtNewString(print->printer);
180 if (print->helpPrint != _DtHelpDefaultHelpPrint)
181 print->helpPrint = XtNewString(print->helpPrint);
183 print->paperSize = DtHELP_PAPERSIZE_LETTER;
184 print->printVolume = NULL;
186 /* print dialog widgets */
187 print->printForm = NULL;
188 print->subject = NULL;
189 print->printerField = NULL;
190 print->copiesField = NULL;
191 print->letterBtn = NULL;
192 print->legalBtn = NULL;
193 print->execBtn = NULL;
196 print->topicsFrame = NULL;
197 print->curTopicBtn = NULL;
198 print->subTopicsBtn = NULL;
199 print->tocBtn = NULL;
200 print->allTopicsBtn = NULL;
201 print->paperTopicsSeparator = NULL;
202 print->topicsBtnsSeparator = NULL;
206 /************************************************************************
207 * Function: _DtHelpFreePrintStuff()
209 * Init print-related data
211 ************************************************************************/
212 void _DtHelpFreePrintStuff (
213 _DtHelpPrintStuff * print,
216 XtFree(print->printVolume);
217 print->printVolume = NULL;
219 if (print->printForm != NULL)
221 XtUnmanageChild(print->printForm);
224 if (cleanUpKind == DtCLEAN_FOR_DESTROY)
226 if (print->helpPrint != _DtHelpDefaultHelpPrint)
227 XtFree(print->helpPrint);
228 print->helpPrint = NULL;
230 XtFree(print->printer);
231 print->printer = NULL;
236 /************************************************************************
237 * Function: _DtHelpPrintSetValues()
239 * set print-related data
241 ************************************************************************/
242 void _DtHelpPrintSetValues (
243 _DtHelpPrintStuff * currentPrint,
244 _DtHelpPrintStuff * newPrint,
245 _DtHelpDisplayWidgetStuff * newDisplay,
246 _DtHelpCommonHelpStuff * newCommonHelp)
248 /* Check DtNhelpPrint resource for change */
249 if (currentPrint->helpPrint != newPrint->helpPrint)
251 newPrint->helpPrint = XtNewString(newPrint->helpPrint);
253 if (currentPrint->helpPrint != _DtHelpDefaultHelpPrint)
254 XtFree(currentPrint->helpPrint);
257 /* Check DtNprinter resource for change */
258 if (currentPrint->printer != newPrint->printer)
260 newPrint->printer = XtNewString(newPrint->printer);
261 XtFree(currentPrint->printer);
265 /* Do NOT check DtNpaperSize resource for change */
266 /* It is a C-only resource */
271 /************************************************************************
272 * Function: ClosePrintCB()
274 * Close the Print dialog.
276 ************************************************************************/
277 static void ClosePrintCB (
279 XtPointer clientData,
282 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
284 /* We unmap the print dialog */
285 XtUnmanageChild(printrec->print->printForm);
289 /************************************************************************
290 * Function: DestroyDialogCB()
292 * Free allocated memory
294 ************************************************************************/
295 static void DestroyDialogCB(
297 XtPointer clientData,
300 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
301 XtFree((char *)printrec);
304 /************************************************************************
305 * Function: CheckCopiesCB()
307 * Check whether the copies in the copies field is valid
309 ************************************************************************/
310 static void CheckCopiesCB(
312 XtPointer clientData,
315 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
319 /************************************************************************
320 * Function: CheckPrinterCB()
322 * Check whether the printer in the printer field is valid
323 * and store a valid printer string in printPrinter.
325 ************************************************************************/
326 static void CheckPrinterCB(
328 XtPointer clientData,
331 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
335 /************************************************************************
336 * Function: StartPrintingCB()
338 * Start printing and close the PRINT Dialog
340 ************************************************************************/
341 static void StartPrintingCB(
343 XtPointer clientData,
346 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
348 char *printTopic=NULL;
349 char *topicTitle=NULL;
350 Boolean printAll=False;
351 Boolean printSub=False;
352 Boolean printTocIndex=False;
354 XmString titleLbl = NULL;
358 Widget dfltSize = NULL;
361 /* Determine the current selected print type */
363 if (XmToggleButtonGetState(printrec->print->allTopicsBtn))
365 printType = _DtPRINT_ALL;
366 printTopic = printrec->help->topLevelId;
370 if (XmToggleButtonGetState(printrec->print->tocBtn))
372 printType = _DtPRINT_TOC;
374 printTocIndex = True;
377 if (XmToggleButtonGetState(printrec->print->subTopicsBtn))
379 printType = _DtPRINT_SUB;
380 printTopic = printrec->display->locationId;
384 if (XmToggleButtonGetState(printrec->print->curTopicBtn))
386 printType = _DtPRINT_CURRENT;
387 switch (printrec->display->helpType)
389 case DtHELP_TYPE_TOPIC:
390 printTopic = printrec->display->locationId;
393 case DtHELP_TYPE_MAN_PAGE:
394 printTopic = printrec->display->manPage;
397 case DtHELP_TYPE_FILE:
398 printTopic = printrec->display->helpFile;
399 titleLbl = printrec->display->topicTitleLbl;
402 case DtHELP_TYPE_STRING:
403 case DtHELP_TYPE_DYNAMIC_STRING:
404 /* ??? Full support for dynamic string types */
405 printTopic = printrec->display->stringData;
406 titleLbl = printrec->display->topicTitleLbl;
409 } /* End Switch Statement */
413 * change the XmString into a char *.
415 if (titleLbl != NULL)
419 XmStringContext theContext;
420 XmStringCharSet theSet;
421 XmStringDirection theDir;
425 if (XmStringInitContext(&theContext, titleLbl) == True)
427 while (XmStringGetNextSegment(theContext,
433 len = strlen(newTxt);
436 topicTitle = XtRealloc(topicTitle, len + 1);
437 if (topicTitle != NULL)
439 strcpy(&topicTitle[newLen], newTxt);
444 XmStringFreeContext(theContext);
449 printer = XmTextFieldGetString(printrec->print->printerField);
450 if (printer && printer[0] == EOS)
451 { XtFree(printer); printer = NULL; }
454 copies = XmTextFieldGetString(printrec->print->copiesField);
457 || (copies && copies[0] == EOS)
458 || (copies && sscanf(copies,"%d",©Cnt) != 1 )
459 || (copyCnt < 0 || copyCnt > 500) )
460 { XtFree(copies); copies = XtNewString("1"); }
463 /* Get the chosen size */
464 XtSetArg (args[0], XmNmenuHistory, &dfltSize);
465 XtGetValues (printrec->print->paperSizeOptMenu, args, 1);
466 if (dfltSize == printrec->print->legalBtn)
467 paperSize = DtHELP_PAPERSIZE_LEGAL;
468 else if (dfltSize == printrec->print->execBtn)
469 paperSize = DtHELP_PAPERSIZE_EXECUTIVE;
470 else if (dfltSize == printrec->print->a4Btn)
471 paperSize = DtHELP_PAPERSIZE_A4;
472 else if (dfltSize == printrec->print->b5Btn)
473 paperSize = DtHELP_PAPERSIZE_B5;
475 paperSize = DtHELP_PAPERSIZE_LETTER;
479 /* Call the print setup routine to start the print job */
482 printrec->print->helpPrint,
486 printrec->print->printVolume,
487 printrec->display->helpType,
499 /* We unmap the print dialog */
500 XtUnmanageChild(printrec->print->printForm);
505 /*****************************************************************************
506 * Function: void _DtHelpUpdatePrintDialog();
509 * Parameters: new Specifies the help widget.
513 * Purpose: Updates the print dialog to reflect current topic
515 *****************************************************************************/
516 void _DtHelpUpdatePrintDialog(
517 _DtHelpPrintStuff * print,
518 _DtHelpDisplayWidgetStuff * display,
519 _DtHelpCommonHelpStuff * help,
525 XmString labelString=NULL;
526 XmString volumeString=NULL;
527 XmFontList fontList = NULL;
531 /* only work on print dialog if we need to */
532 if (print->printForm == NULL) return;
534 /* Set the proper default toggle button value */
537 if(print->curTopicBtn)
538 XmToggleButtonSetState(print->curTopicBtn, True, False);
539 if(print->subTopicsBtn)
540 XmToggleButtonSetState(print->subTopicsBtn,False,False);
542 XmToggleButtonSetState(print->tocBtn,False,False);
543 if(print->allTopicsBtn)
544 XmToggleButtonSetState(print->allTopicsBtn,False,False);
547 /* adj where the TopicsBtn separator is attached */
548 /* if attached to the PaperTopics separator, the topics are hidden */
550 if ( display->helpType == DtHELP_TYPE_TOPIC )
553 XtSetSensitive(print->topicsFrame,True);
555 XtManageChild(print->topicsFrame);
556 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
557 XtSetArg (args[n], XmNtopWidget, print->topicsFrame); n++;
563 XtSetSensitive(print->topicsFrame,False);
565 XtUnmanageChild(print->topicsFrame);
566 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
567 XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator); n++;
570 XtSetValues (print->topicsBtnsSeparator, args, n);
572 /* update the dialog's print subject label string */
573 switch ( display->helpType )
575 /* coming out of the case, volumeString & titleStr should be set */
576 case DtHELP_TYPE_TOPIC:
577 titleStr = _DTGETMESSAGE(PRSET, 50,"Help Volume: ");
579 /* get volume title and allow for localized fonts */
581 /* get the font list of the label */
582 XtSetArg (args[0], XmNfontList, &fontList);
583 XtGetValues (print->subject, args, 1);
585 #if defined(DONT_USE_CDExc22774)
586 /* Don't need to copy, _DtHelpFormatVolumeTitle copies
590 /* copy the list before passing it in for modification */
591 /* we must free this now */
592 fontList = XmFontListCopy (fontList);
595 /* get formatted volume title; volumeString is owned by caller */
596 _DtHelpFormatVolumeTitle(help->pDisplayArea,display->volumeHandle,
597 &volumeString,&fontList,&mod);
599 /* if volumeString caused a font list change, add it back */
601 { /* Add the title's font to the label */
602 XtSetArg (args[0], XmNfontList, fontList);
603 XtSetValues (print->subject, args, 1);
604 if (fontList) XmFontListFree(fontList);
608 case DtHELP_TYPE_STRING:
609 case DtHELP_TYPE_DYNAMIC_STRING:
610 titleStr = _DTGETMESSAGE(PRSET, 51,"Help Message");
612 case DtHELP_TYPE_FILE:
613 titleStr = _DTGETMESSAGE(PRSET, 52,"Help File");
615 case DtHELP_TYPE_MAN_PAGE:
616 /* assumption: buf won't overflow */
617 sprintf(buf,"%s%s", _DTGETMESSAGE(PRSET, 53,"Manual Page: "),
622 titleStr = _DTGETMESSAGE(PRSET, 54,"Error message");
626 /* at this point, titleStr and volumeString are set */
628 /* set the dialog label strings only if needed */
629 labelString = XmStringCreateLocalized(titleStr);
631 /* if there is a valid volumeString, concatenate it */
635 fullTitle = XmStringConcat(labelString,volumeString);
636 XmStringFree(labelString);
637 XmStringFree(volumeString);
638 labelString = fullTitle;
641 /* set the dialog label string */
642 XtSetArg (args[0], XmNlabelString, labelString);
643 XtSetValues (print->subject, args, 1);
644 XmStringFree (labelString);
646 XmUpdateDisplay(print->printForm);
651 /*****************************************************************************
652 * Function: void _DtHelpDisplayPrintDialog();
656 * new Specifies the help widget.
658 * display display widget stuff
659 * help common help stuff
663 * Purpose: Creates and displays an instance of the print dialog.
665 *****************************************************************************/
666 void _DtHelpDisplayPrintDialog(
668 _DtHelpPrintStuff * print,
669 _DtHelpDisplayWidgetStuff * display,
670 _DtHelpCommonHelpStuff * help)
673 Widget dfltSize = NULL;
675 /* Build a print dialog if we need to */
676 if (print->printForm == NULL)
678 CreatePrintDialog(widget,print,display,help);
680 /*** Only init the values if creating dialog for first time ***/
682 switch(print->paperSize)
684 case DtHELP_PAPERSIZE_LEGAL:
685 dfltSize = print->legalBtn;
687 case DtHELP_PAPERSIZE_EXECUTIVE:
688 dfltSize = print->execBtn;
690 case DtHELP_PAPERSIZE_A4:
691 dfltSize = print->a4Btn;
693 case DtHELP_PAPERSIZE_B5:
694 dfltSize = print->b5Btn;
696 case DtHELP_PAPERSIZE_LETTER:
698 dfltSize = print->letterBtn;
701 /* Set the default size */
702 XtSetArg (args[0], XmNmenuHistory, dfltSize);
703 XtSetValues (print->paperSizeOptMenu, args, 1);
705 /* update the variable contents of the dialog; do set defaults */
706 _DtHelpUpdatePrintDialog(print,display,help,True);
710 /* update the variable contents of the dialog; don't set defaults */
711 _DtHelpUpdatePrintDialog(print,display,help,False);
715 if ( XtIsManaged(print->printForm) == False )
717 /* Make sure the Print Dialog is managed */
718 /* recall that the printForm is the form inside the dlg shell */
719 XtManageChild(print->printForm);
720 XtMapWidget(XtParent((Widget)print->printForm));
724 /* raise the window to top of the stack */
725 Widget parent = XtParent(print->printForm);
726 XRaiseWindow ( XtDisplay(parent), XtWindow(parent) );
732 /*****************************************************************************
733 * Function: Widget CreatePrintDialog(Widget nw);
740 * Purpose: Creates an instance of the print dialog.
742 *****************************************************************************/
743 static void CreatePrintDialog(
745 _DtHelpPrintStuff * print,
746 _DtHelpDisplayWidgetStuff * display,
747 _DtHelpCommonHelpStuff * help)
758 Widget okBtn, cancelBtn, helpBtn;
759 XmString labelString;
761 DtHelpListStruct *pHelpInfo;
762 _DtHelpPrintCBRec * printCBRec = NULL;
766 /* Create the shell and form used for the dialog. */
767 chrStr = XtNewString(((char *)_DTGETMESSAGE(PRSET, 1, "Help - Print")));
769 XtSetArg (args[n], XmNtitle, chrStr); n++;
770 printShell = XmCreateDialogShell(widget, "printShell", args, n);
773 /* Set the useAsyncGeo on the shell */
775 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
776 /* XtSetValues (XtParent(printShell), args, n);*/
777 XtSetValues (printShell, args, n);
779 /* Allocate the printRec and arrange to free it when dialog destroyed */
780 printCBRec = CreatePrintCBRec(widget,display,help,print);
781 XtAddCallback (printShell, XmNdestroyCallback,
782 DestroyDialogCB, (XtPointer) printCBRec);
784 /* create the form in the dialog to hold the contents */
786 XtSetArg (args[n], XmNmarginWidth, 1); n++;
787 XtSetArg (args[n], XmNmarginHeight, 1); n++;
788 XtSetArg (args[n], XmNshadowThickness, 1); n++;
789 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
790 XtSetArg (args[n], XmNautoUnmanage, False); n++;
791 printForm = XmCreateForm (printShell, "printForm", args, n);
793 /**** create the printing-related widgets ****/
795 /* create print subject label */
796 labelString = XmStringCreateLocalized(EMPTYSTR);
798 XtSetArg (args[n], XmNlabelString, labelString); n++;
799 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
800 XtSetArg (args[n], XmNtopOffset, 10); n++;
801 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
802 XtSetArg (args[n], XmNleftOffset, 15); n++;
804 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
805 XtSetArg (args[n], XmNrightOffset, 10); n++;
807 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
809 XmCreateLabelGadget (printForm, "printSubject", args, n);
810 XtManageChild (print->subject);
811 XmStringFree (labelString);
813 /* create printer label */
814 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
815 (PRSET, 10,"Printer:")));
817 XtSetArg (args[n], XmNlabelString, labelString); n++;
818 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
819 XtSetArg (args[n], XmNtopWidget, print->subject); n++;
820 XtSetArg (args[n], XmNtopOffset, 15); n++;
821 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
822 XtSetArg (args[n], XmNleftOffset, 15); n++;
823 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
824 printerLabel = XmCreateLabelGadget (printForm, "printerLabel", args, n);
825 XtManageChild (printerLabel);
826 XmStringFree (labelString);
828 /* create the printer name text field */
830 /* get the printer value from printer resource, LPDEST, or leave blank */
831 if ( print->printer != NULL && print->printer[0] != EOS )
832 chrStr = print->printer;
833 else if ( (chrStr = getenv("LPDEST")) == NULL || chrStr[0] == EOS)
834 chrStr = (char *)_DTGETMESSAGE(PRSET, 60,""); /* dflt printer value */
835 XtSetArg (args[n], XmNvalue, chrStr ); n++;
836 XtSetArg (args[n], XmNcursorPosition, strlen(chrStr) ); n++;
837 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
838 XtSetArg (args[n], XmNtopWidget, print->subject); n++;
839 XtSetArg (args[n], XmNtopOffset, 10); n++;
840 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
841 XtSetArg (args[n], XmNleftWidget, printerLabel); n++;
842 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
843 XtSetArg (args[n], XmNrightPosition, 60); n++;
844 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
845 print->printerField =
846 XmCreateTextField (printForm,"printerField",args, n);
847 XtManageChild (print->printerField);
848 XtAddCallback (print->printerField, XmNactivateCallback,
849 CheckPrinterCB, (XtPointer) printCBRec);
850 XtAddCallback (print->printerField, XmNvalueChangedCallback,
851 CheckPrinterCB, (XtPointer) printCBRec);
853 /* create copies label */
854 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
855 (PRSET, 11,"Copies:")));
857 XtSetArg (args[n], XmNlabelString, labelString); n++;
858 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
859 XtSetArg (args[n], XmNtopWidget,print->subject); n++;
860 XtSetArg (args[n], XmNtopOffset, 15); n++;
861 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
862 XtSetArg (args[n], XmNleftOffset, 10); n++;
863 XtSetArg (args[n], XmNleftWidget, print->printerField); n++;
864 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
865 copiesLabel = XmCreateLabelGadget (printForm, "copiesLabel", args, n);
866 XtManageChild (copiesLabel);
867 XmStringFree (labelString);
869 /* create the copies text field */
871 XtSetArg (args[n], XmNvalue,(char *)_DTGETMESSAGE(PRSET, 61,"1")); n++;/*dflt copy cnt*/
872 XtSetArg (args[n], XmNcursorPosition, 1 ); /* 1=strlen("1") */ n++;
873 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
874 XtSetArg (args[n], XmNtopWidget,print->subject); n++;
875 XtSetArg (args[n], XmNtopOffset, 10); n++;
876 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
877 XtSetArg (args[n], XmNleftWidget, copiesLabel); n++;
878 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
879 XtSetArg (args[n], XmNrightOffset, 10); n++;
880 XtSetArg(args[n], XmNhighlightOnEnter, True); n++;
882 XmCreateTextField (printForm,"copiesField",args, n);
883 XtManageChild (print->copiesField);
884 XtAddCallback (print->copiesField, XmNactivateCallback,
885 CheckCopiesCB, (XtPointer) printCBRec);
886 XtAddCallback (print->copiesField, XmNvalueChangedCallback,
887 CheckCopiesCB, (XtPointer) printCBRec);
889 /* papersize option menu */
890 /*******************************************************
891 * Menupane: Papersize buttons
892 * No callback on each button is needed because we compare widget ptrs
893 *******************************************************/
896 XtSetArg(args[n], XmNmarginWidth, 0); ++n;
897 XtSetArg(args[n], XmNmarginHeight, 0); ++n;
898 menupane = XmCreatePulldownMenu(printForm, "paperSizeMenu", args, n);
901 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 21,"Letter 8.5 x 11 in")));
903 XtSetArg(args[n], XmNlabelString, labelString); n++;
904 print->letterBtn = XmCreatePushButtonGadget(menupane, "letter", args, n);
905 XtManageChild(print->letterBtn);
906 XmStringFree(labelString);
909 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 22,"Legal 8.5 x 14 in")));
911 XtSetArg(args[n], XmNlabelString, labelString); n++;
912 print->legalBtn = XmCreatePushButtonGadget(menupane, "legal", args, n);
913 XtManageChild(print->legalBtn);
914 XmStringFree(labelString);
916 /* Executive button */
917 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 23,"Executive 7.25 x 10.5 in")));
919 XtSetArg(args[n], XmNlabelString, labelString); n++;
920 print->execBtn = XmCreatePushButtonGadget(menupane, "executive", args, n);
921 XtManageChild(print->execBtn);
922 XmStringFree(labelString);
925 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 24,"A4 210 x 297 mm")));
927 XtSetArg(args[n], XmNlabelString, labelString); n++;
928 print->a4Btn = XmCreatePushButtonGadget(menupane, "A4", args, n);
929 XtManageChild(print->a4Btn);
930 XmStringFree(labelString);
933 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 25,"B5 182 x 257 mm")));
935 XtSetArg(args[n], XmNlabelString, labelString); n++;
936 print->b5Btn = XmCreatePushButtonGadget(menupane, "B5", args, n);
937 XtManageChild(print->b5Btn);
938 XmStringFree(labelString);
941 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 20,"Paper Size:")));
943 XtSetArg(args[n], XmNlabelString, labelString); n++;
944 XtSetArg(args[n], XmNsubMenuId, menupane); n++;
945 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
946 XtSetArg (args[n], XmNtopWidget,printerLabel); n++;
947 XtSetArg (args[n], XmNtopOffset, 15); n++;
948 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
949 XtSetArg (args[n], XmNrightOffset, 5); n++;
950 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
951 XtSetArg (args[n], XmNleftOffset, 10); n++;
952 XtSetArg (args[n], XmNmarginWidth, 5); n++;
953 XtSetArg (args[n], XmNmarginHeight, 2); n++;
954 print->paperSizeOptMenu = XmCreateOptionMenu(printForm,
955 "paperSizeOptionMenu", args, n);
956 XtManageChild(print->paperSizeOptMenu);
957 XmStringFree(labelString);
959 /* the DtNpaperSize resource is used to set the default item
960 in _DtHelpDisplayPrintDialog() */
962 /* Create a separator between the paper size and topic range selection/buttons */
964 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
965 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
966 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
967 XtSetArg (args[n], XmNtopWidget, print->paperSizeOptMenu); n++;
968 XtSetArg (args[n], XmNtopOffset, 0); n++;
969 XtSetArg (args[n], XmNseparatorType, XmNO_LINE); n++;
970 print->paperTopicsSeparator =
971 XmCreateSeparatorGadget (printForm, "separator", args, n);
972 XtManageChild (print->paperTopicsSeparator);
974 /* if currently showing a topic, display the topic selection box */
975 /****** Create the topics selection frame ******/
977 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
978 XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator); n++;
979 XtSetArg (args[n], XmNtopOffset, 5); n++;
980 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
981 XtSetArg (args[n], XmNrightOffset, 5); n++;
982 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
983 XtSetArg (args[n], XmNleftOffset, 5); n++;
984 XtSetArg (args[n], XmNmarginWidth, 5); n++;
985 XtSetArg (args[n], XmNmarginHeight, 2); n++;
986 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;/*EXP*/
988 XmCreateFrame(printForm, "topicsFrame", args, n);
989 XtManageChild (print->topicsFrame);
991 /* FIX: consider eliminating the form and just putting the RowColumn
992 RadioBox inside the frame */
994 /* unused message catalog entries: 8: Executive, 9: Legal */
996 /* put form inside frame */
997 topicsForm = XmCreateForm (
998 print->topicsFrame,"topicsForm", NULL, 0);
999 XtManageChild (topicsForm);
1001 /* create the frame title */
1002 labelString = XmStringCreateLocalized ((_DTGETMESSAGE(
1003 PRSET,30,"Topics To Print")));
1005 XtSetArg (args[n], XmNlabelString, labelString); n++;
1006 XtSetArg (args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
1007 XtSetArg (args[n], XmNtraversalOn, False); n++;
1008 frameTitle = XmCreateLabelGadget(
1009 print->topicsFrame,"topicsFrameTitle",args,n);
1010 XtManageChild (frameTitle);
1011 XmStringFree (labelString);
1013 /* Create the Radio Box widget to hold the toggle buttons */
1015 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1016 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1017 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1018 radioBox = XmCreateRadioBox(topicsForm, "radioBox", args, n);
1019 XtManageChild (radioBox);
1021 /* Create the print current topic button */
1022 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1023 (PRSET, 31,"Current Topic")));
1025 XtSetArg (args[n], XmNlabelString, labelString); n++;
1026 print->curTopicBtn =
1027 XmCreateToggleButtonGadget(radioBox,"printCurTopicBtn",args,n);
1028 XtManageChild (print->curTopicBtn);
1029 XmStringFree (labelString);
1031 /* Create the print current chapter button */
1032 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1033 (PRSET, 32,"Current and Subtopics")));
1035 XtSetArg (args[n], XmNlabelString, labelString); n++;
1036 print->subTopicsBtn =
1037 XmCreateToggleButtonGadget(radioBox,"print.subTopicsBtn",args,n);
1038 XtManageChild (print->subTopicsBtn);
1039 XmStringFree (labelString);
1041 /* Create the print TOC buttion */
1042 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1043 (PRSET, 33,"Table of Contents and Index")));
1045 XtSetArg (args[n], XmNlabelString, labelString); n++;
1046 print->tocBtn = XmCreateToggleButtonGadget
1047 (radioBox, "printTocBtn", args, n);
1048 XtManageChild (print->tocBtn);
1049 XmStringFree (labelString);
1051 /* Create the print all topics buttion */
1052 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1053 (PRSET, 34,"Entire Volume")));
1055 XtSetArg (args[n], XmNlabelString, labelString); n++;
1056 print->allTopicsBtn = XmCreateToggleButtonGadget
1057 (radioBox, "printAllTopicsBtn", args, n);
1058 XtManageChild (print->allTopicsBtn);
1059 XmStringFree (labelString);
1061 /* create a separator */
1063 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1064 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1065 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1066 XtSetArg (args[n], XmNtopWidget, print->topicsFrame); n++;
1067 XtSetArg (args[n], XmNtopOffset, 10); n++;
1068 print->topicsBtnsSeparator =
1069 XmCreateSeparatorGadget (printForm, "separator", args, n);
1070 XtManageChild (print->topicsBtnsSeparator);
1073 separator = print->topicsBtnsSeparator;
1075 /* Create the action buttons along the bottom */
1076 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1077 (PRSET, 40,"Print")));
1079 XtSetArg (args[n], XmNlabelString, labelString); n++;
1080 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1081 XtSetArg (args[n], XmNleftPosition, 3); n++;
1082 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1083 XtSetArg (args[n], XmNrightPosition, 32); n++;
1084 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1085 XtSetArg (args[n], XmNtopWidget, separator); n++;
1086 XtSetArg (args[n], XmNtopOffset, 5); n++;
1088 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1090 XtSetArg (args[n], XmNbottomOffset, 5); n++;
1091 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1092 okBtn = XmCreatePushButtonGadget (printForm, "okBtn", args, n);
1093 XtAddCallback(okBtn, XmNactivateCallback, StartPrintingCB,
1094 (XtPointer) printCBRec);
1095 XtManageChild (okBtn);
1096 XmStringFree (labelString);
1098 /* Build the Cancel Button */
1099 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1100 (PRSET, 41,"Cancel")));
1102 XtSetArg (args[n], XmNlabelString, labelString); n++;
1103 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1104 XtSetArg (args[n], XmNleftPosition, 35); n++;
1105 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1106 XtSetArg (args[n], XmNrightPosition, 64); n++;
1107 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1108 XtSetArg (args[n], XmNtopWidget, separator); n++;
1109 XtSetArg (args[n], XmNtopOffset, 5); n++;
1110 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1111 cancelBtn = XmCreatePushButtonGadget (printForm, "cancelBtn", args, n);
1112 XtAddCallback(cancelBtn, XmNactivateCallback, ClosePrintCB,
1113 (XtPointer) printCBRec);
1114 XtManageChild (cancelBtn);
1115 XmStringFree (labelString);
1117 /* Build the Help button */
1118 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1119 (PRSET, 42,"Help")));
1121 XtSetArg (args[n], XmNlabelString, labelString); n++;
1122 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
1123 XtSetArg (args[n], XmNleftPosition, 68); n++;
1124 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
1125 XtSetArg (args[n], XmNrightPosition, 97); n++;
1126 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1127 XtSetArg (args[n], XmNtopWidget, separator); n++;
1128 XtSetArg (args[n], XmNtopOffset, 5); n++;
1129 XtSetArg (args[n], XmNmarginHeight, 4); n++;
1130 helpBtn = XmCreatePushButtonGadget (printForm, "helpBtn", args, n);
1131 XtManageChild (helpBtn);
1132 pHelpInfo = _DtHelpListAdd(DtHELP_printHelpBtn_STR,
1133 widget, help, &help->pHelpListHead);
1134 XtAddCallback(helpBtn, XmNactivateCallback,
1135 _DtHelpCB, (XtPointer) pHelpInfo);
1136 XmStringFree (labelString);
1138 /*** now do some setup ***/
1139 /* make OK the default btn btn */
1140 /* make Cancel the cancel (KCancel) btn */
1141 /* set focus on the printer field */
1143 XtSetArg (args[n], XmNdefaultButton, okBtn); n++;
1144 XtSetArg (args[n], XmNcancelButton, cancelBtn); n++;
1145 XtSetArg (args[n], XmNinitialFocus, print->printerField); n++;
1146 XtSetValues (printForm,args,n);
1148 /* Adjust the decorations for the dialog shell of the dialog */
1150 XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_MOVE); n++;
1151 XtSetArg (args[n], XmNmwmDecorations,
1152 MWM_DECOR_BORDER | MWM_DECOR_TITLE); n++;
1153 XtSetValues (printShell, args, n);
1155 /* Add the popup position callback to our print dialog */
1156 XtAddCallback (printShell, XmNpopupCallback, (XtCallbackProc) _DtHelpMapCB,
1157 (XtPointer) XtParent(widget));
1159 /* Add the proper help callback to the print dialog shell "F1" support */
1160 pHelpInfo = _DtHelpListAdd(DtHELP_printShell_STR,
1161 widget, help, &help->pHelpListHead);
1162 XtAddCallback(printForm, XmNhelpCallback,
1163 _DtHelpCB, (XtPointer) pHelpInfo);
1165 /* Assign our new print dialog to our widget instance */
1166 print->printForm = printForm;
1168 /* Set the tab navigation order */
1169 XtSetArg (args[0], XmNnavigationType, XmSTICKY_TAB_GROUP);
1170 XtSetValues (print->printerField,args,1);
1171 XtSetValues (print->copiesField,args,1);
1172 XtSetValues (print->paperSizeOptMenu,args,1);
1173 XtSetValues (print->topicsFrame,args,1);
1174 XtSetValues (okBtn,args,1);
1175 XtSetValues (cancelBtn,args,1);
1176 XtSetValues (helpBtn,args,1);
1182 /*****************************************************************************
1183 * Function: void _DtHelpPrintJob(
1189 * Return Value: Void.
1191 * Purpose: Sets up and forks off a print job to helpprint
1193 *****************************************************************************/
1194 void _DtHelpPrintJob(
1205 Boolean printTocIndex,
1212 char tmpHelpType[4];
1214 /* Setup the helpprint command and let it go */
1216 argv[i++] = printExec;
1218 if (printer != NULL && printer[0] != EOS)
1220 argv[i++] = "-printer";
1221 argv[i++] = printer;
1224 if (copies != NULL && copies[0] != EOS)
1226 argv[i++] = "-copies";
1230 if (NULL != topicTitle)
1232 argv[i++] = "-topicTitle";
1233 argv[i++] = topicTitle;
1236 if (paperSize >= _DtHelpPaperSizeNamesCnt) paperSize = 0;
1237 argv[i++] = "-paperSize";
1238 argv[i++] = _DtHelpPaperSizeNames[paperSize];
1240 argv[i++] = "-display";
1241 argv[i++] = (char*)XDisplayString(XtDisplay(widget));
1243 argv[i++] = "-helpType";
1244 sprintf(tmpHelpType, "%d", helpType);
1245 argv[i++] = tmpHelpType;
1248 argv[i++] = "-allTopics";
1251 argv[i++] = "-subTopics";
1256 argv[i++] = "-index";
1257 argv[i++] = "-frontMatter";
1260 if (!printSub && !printAll && !printTocIndex)
1261 argv[i++] = "-oneTopic";
1263 if (NULL == helpData) helpData = quotes;
1266 case DtHELP_TYPE_TOPIC:
1267 argv[i++] = "-locationId";
1268 argv[i++] = helpData;
1269 argv[i++] = "-helpVolume";
1270 argv[i++] = helpVolume;
1273 case DtHELP_TYPE_MAN_PAGE:
1274 argv[i++] = "-manPage";
1275 argv[i++] = helpData;
1278 case DtHELP_TYPE_FILE:
1279 argv[i++] = "-helpFile";
1280 argv[i++] = helpData;
1283 case DtHELP_TYPE_STRING:
1284 case DtHELP_TYPE_DYNAMIC_STRING:
1285 argv[i++] = "-stringData";
1286 argv[i++] = helpData;
1291 /* We should never get here, but just in case... */
1292 XmeWarning(widget, (char*)PrintMessage001);
1294 } /* End Switch Statement */
1299 { /* for debugging, print out the command line */
1301 for ( tmpargv = argv; *tmpargv; tmpargv++ ) fprintf(stderr,"%s ", *tmpargv);
1302 fprintf(stderr,"\n");
1314 (void) execvp (argv[0], argv);
1318 /* Return an error if bad pid? */