Fix to compile warnings.
[oweals/cde.git] / cde / lib / DtHelp / Print.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $TOG: Print.c /main/10 1999/02/09 19:45:00 mgreess $ */
24 /************************************<+>*************************************
25  ****************************************************************************
26  **
27  **   File:        Print.c
28  **
29  **   Project:     Cache Creek (Rivers) Project
30  **
31  **   Description: Builds and displays an instance of a Cache Creek Print
32  **                Dialog.  
33  ** 
34  **  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
35  **
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.
40  **
41  **
42  ****************************************************************************
43  ************************************<+>*************************************/
44 #include <sys/param.h>
45 #include <stdio.h>
46 #include <stdlib.h>   /* for getenv() */
47 #include <string.h>
48 #include <unistd.h>
49
50
51 #include <Xm/Xm.h>
52 #include <Xm/XmP.h>
53 #include <Xm/Form.h>
54 #include <Xm/Frame.h>
55 #include <Xm/Label.h>
56 #include <Xm/LabelG.h>
57 #include <Xm/TextF.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>
66
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>
72
73 /*
74  * private includes
75  */
76 #include "DisplayAreaI.h"
77 #include "DisplayAreaP.h"
78
79 #include "bufioI.h"
80 #include "Access.h"
81 #include "AccessI.h"
82 #include "MessagesP.h"
83 #include "FormatI.h"
84 #include "HelpI.h"
85 #include "HelposI.h"
86 #include "HelpUtilI.h"
87 #include "HelpAccessI.h"
88 #include "HelpDialogI.h"
89 #include "HelpDialogP.h"
90 #include "PrintI.h"
91
92
93 /***** helper structures ****/
94 typedef struct _DtHelpPrintCBRec {
95    Widget                       widget;
96    _DtHelpDisplayWidgetStuff *  display;
97    _DtHelpCommonHelpStuff *     help;
98    _DtHelpPrintStuff *          print;
99 } _DtHelpPrintCBRec;
100
101 /***** Global Variables ****/
102 char _DtHelpDefaultHelpPrint[] = "/usr/dt/bin/dthelpprint";
103
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",
109     "help_papersize_a4",
110     "help_papersize_b5",
111 };
112 int _DtHelpPaperSizeNamesCnt = (sizeof(_DtHelpPaperSizeNames) / sizeof(char *));
113
114 /***** Constants ******/
115 #define EOS     '\0'    /* end of string */
116 #define EMPTYSTR   s_EmptyStr
117
118 #define PRSET   4       /* msg catalog set for print dialog */
119
120 #define PrintMessage001  _DtHelpMsg_0004
121
122 /***** Static Variables ******/
123 static char s_EmptyStr[] = "";
124
125 /****** Protos ******/
126 static void ClosePrintCB (
127     Widget w,
128     XtPointer clientData,
129     XtPointer callData);
130 static void StartPrintingCB (
131     Widget w,
132     XtPointer clientData,
133     XtPointer callData);
134 static void CreatePrintDialog(
135    Widget               widget,
136    _DtHelpPrintStuff *  print,
137    _DtHelpDisplayWidgetStuff * display,
138    _DtHelpCommonHelpStuff * help);
139
140 /************************************************************************
141  * Function: CreatePrintCBRec()
142  *
143  *      Create the data required by a print callback 
144  *
145  * This routine allocates memory for the callback record using XtCalloc().
146  * When the record is no longer needed, free it with XtFree().
147  ************************************************************************/
148 static
149 _DtHelpPrintCBRec * CreatePrintCBRec(
150    Widget                       widget,
151    _DtHelpDisplayWidgetStuff *  display,
152    _DtHelpCommonHelpStuff *     help,
153    _DtHelpPrintStuff *          print)
154 {
155    _DtHelpPrintCBRec * rec = NULL;
156  
157    rec = (_DtHelpPrintCBRec *) XtCalloc(1,sizeof(_DtHelpPrintCBRec));
158    if (NULL == rec) return NULL;
159    rec->widget = widget;
160    rec->display = display;
161    rec->help = help;
162    rec->print = print;
163    return rec;
164 }
165
166
167 /************************************************************************
168  * Function: _DtHelpInitPrintStuff()
169  *
170  *      Init print-related data
171  *
172  ************************************************************************/
173 void _DtHelpInitPrintStuff (
174     _DtHelpPrintStuff * print)
175 {
176     /* Set our print display stuff to initial values */
177     if (print->printer != NULL)
178       print->printer = XtNewString(print->printer);
179   
180     if (print->helpPrint != _DtHelpDefaultHelpPrint)
181       print->helpPrint = XtNewString(print->helpPrint);
182   
183     print->paperSize      = DtHELP_PAPERSIZE_LETTER;
184     print->printVolume    = NULL;
185   
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;
194     print->b5Btn = NULL;
195     print->a4Btn     = 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;
203 }
204
205
206 /************************************************************************
207  * Function: _DtHelpFreePrintStuff()
208  *
209  *      Init print-related data
210  *
211  ************************************************************************/
212 void _DtHelpFreePrintStuff (
213     _DtHelpPrintStuff * print,
214     int                 cleanUpKind)
215 {
216      XtFree(print->printVolume);
217      print->printVolume = NULL;
218
219      if (print->printForm != NULL)
220      {
221           XtUnmanageChild(print->printForm);
222      }
223
224     if (cleanUpKind == DtCLEAN_FOR_DESTROY)
225     {
226        if (print->helpPrint != _DtHelpDefaultHelpPrint)
227            XtFree(print->helpPrint);
228        print->helpPrint = NULL;
229
230        XtFree(print->printer);
231        print->printer = NULL;
232     }
233 }
234
235
236 /************************************************************************
237  * Function: _DtHelpPrintSetValues()
238  *
239  *      set print-related data
240  *
241  ************************************************************************/
242 void _DtHelpPrintSetValues (
243     _DtHelpPrintStuff * currentPrint,
244     _DtHelpPrintStuff * newPrint,
245     _DtHelpDisplayWidgetStuff * newDisplay,
246     _DtHelpCommonHelpStuff * newCommonHelp)
247 {
248   /* Check DtNhelpPrint resource for change */
249   if (currentPrint->helpPrint != newPrint->helpPrint)
250     {
251       newPrint->helpPrint = XtNewString(newPrint->helpPrint);
252
253       if (currentPrint->helpPrint != _DtHelpDefaultHelpPrint)
254         XtFree(currentPrint->helpPrint);
255     }
256
257   /* Check DtNprinter resource for change */
258   if (currentPrint->printer != newPrint->printer)
259     {
260       newPrint->printer = XtNewString(newPrint->printer);
261       XtFree(currentPrint->printer);
262     }
263
264
265   /* Do NOT check DtNpaperSize resource for change */
266   /* It is a C-only resource */
267 }
268
269
270
271 /************************************************************************
272  * Function: ClosePrintCB()
273  *
274  *      Close the Print dialog.
275  *
276  ************************************************************************/
277 static void ClosePrintCB (
278     Widget w,
279     XtPointer clientData,
280     XtPointer callData)
281 {
282   _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
283  
284   /* We unmap the print dialog */
285   XtUnmanageChild(printrec->print->printForm);
286 }
287
288
289 /************************************************************************
290  * Function: DestroyDialogCB()
291  *
292  *      Free allocated memory
293  *
294  ************************************************************************/
295 static void DestroyDialogCB(
296     Widget w,
297     XtPointer clientData,
298     XtPointer callData)
299 {
300    _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
301    XtFree((char *)printrec);
302 }
303
304 /************************************************************************
305  * Function: CheckCopiesCB()
306  *
307  *      Check whether the copies in the copies field is valid
308  *
309  ************************************************************************/
310 static void CheckCopiesCB(
311     Widget w,
312     XtPointer clientData,
313     XtPointer callData)
314 {
315 /*   _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;  */
316 }
317
318
319 /************************************************************************
320  * Function: CheckPrinterCB()
321  *
322  *      Check whether the printer in the printer field is valid
323  *      and store a valid printer string in printPrinter.
324  *
325  ************************************************************************/
326 static void CheckPrinterCB(
327     Widget w,
328     XtPointer clientData,
329     XtPointer callData)
330 {
331 /*   _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;  */
332 }
333
334
335 /************************************************************************
336  * Function: StartPrintingCB()
337  *
338  *      Start printing and close the PRINT Dialog
339  *
340  ************************************************************************/
341 static void StartPrintingCB(
342     Widget w,
343     XtPointer clientData,
344     XtPointer callData)
345 {
346    _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
347    int printType=0;
348    char *printTopic=NULL;
349    char *topicTitle=NULL;
350    Boolean printAll=False;
351    Boolean printSub=False;
352    Boolean printTocIndex=False;
353    char * printer;
354    XmString titleLbl = NULL;
355    int    paperSize;
356    int    copyCnt;
357    char * copies;
358    Widget dfltSize = NULL;
359    Arg args[5];
360
361    /* Determine the current selected print type */
362
363    if (XmToggleButtonGetState(printrec->print->allTopicsBtn))
364      {
365        printType = _DtPRINT_ALL;
366        printTopic = printrec->help->topLevelId;
367        printAll = True;
368      }
369    else
370    if (XmToggleButtonGetState(printrec->print->tocBtn))
371      {
372        printType = _DtPRINT_TOC;
373        printTopic = NULL;
374        printTocIndex = True;
375      }
376    else
377    if (XmToggleButtonGetState(printrec->print->subTopicsBtn))
378      {
379        printType = _DtPRINT_SUB;
380        printTopic = printrec->display->locationId;
381        printSub = True;
382      }
383    else
384    if (XmToggleButtonGetState(printrec->print->curTopicBtn))
385      {
386        printType = _DtPRINT_CURRENT;
387        switch (printrec->display->helpType)
388          {
389             case DtHELP_TYPE_TOPIC:
390               printTopic = printrec->display->locationId;
391             break;
392
393             case DtHELP_TYPE_MAN_PAGE:
394               printTopic = printrec->display->manPage;
395             break;
396
397             case DtHELP_TYPE_FILE:
398                printTopic = printrec->display->helpFile;
399                titleLbl   = printrec->display->topicTitleLbl;
400             break;
401
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;
407             break;
408    
409           }  /* End Switch Statement */
410      }
411
412    /*
413     * change the XmString into a char *.
414     */
415   if (titleLbl != NULL)
416     {
417       int                len;
418       int                newLen = 0;
419       XmStringContext    theContext;
420       XmStringCharSet    theSet;
421       XmStringDirection  theDir;
422       char              *newTxt;
423       Boolean            theSep;
424
425       if (XmStringInitContext(&theContext, titleLbl) == True)
426         {
427           while (XmStringGetNextSegment(theContext,
428                                         &newTxt,
429                                         &theSet,
430                                         &theDir,
431                                         &theSep) == True)
432             {
433               len = strlen(newTxt);
434               if (len > 0)
435                 {
436                   topicTitle = XtRealloc(topicTitle, len + 1);
437                   if (topicTitle != NULL)
438                     {
439                       strcpy(&topicTitle[newLen], newTxt);
440                       newLen += len;
441                     }
442                 }
443             }
444           XmStringFreeContext(theContext);
445         }
446     }
447
448    /* get printer */
449    printer = XmTextFieldGetString(printrec->print->printerField);
450    if (printer && printer[0] == EOS) 
451      { XtFree(printer); printer = NULL; }
452
453    /* get copies */
454    copies = XmTextFieldGetString(printrec->print->copiesField);
455    copyCnt = 1;
456    if (   NULL == copies
457        || (copies && copies[0] == EOS) 
458        || (copies && sscanf(copies,"%d",&copyCnt) != 1 )
459        || (copyCnt < 0 || copyCnt > 500) )
460      { XtFree(copies);  copies = XtNewString("1"); }
461
462    /* get paper size */
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;
474     else
475        paperSize = DtHELP_PAPERSIZE_LETTER;
476
477    if (printType != 0)
478    {
479        /* Call the print setup routine to start the print job */
480        _DtHelpPrintJob(
481                     printrec->widget,
482                     printrec->print->helpPrint,
483                     printer,
484                     paperSize,
485                     copies,
486                     printrec->print->printVolume,
487                     printrec->display->helpType,
488                     printTopic,
489                     printAll,
490                     printSub,
491                     printTocIndex,
492                     topicTitle);
493    }
494
495    XtFree(printer);
496    XtFree(copies);
497    XtFree(topicTitle);
498
499    /* We unmap the print dialog */
500    XtUnmanageChild(printrec->print->printForm);
501 }
502
503
504
505 /*****************************************************************************
506  * Function:      void _DtHelpUpdatePrintDialog();
507  *
508  *
509  * Parameters:      new      Specifies the help widget.
510  *
511  * Return Value:
512  *
513  * Purpose:       Updates the print dialog to reflect current topic
514  *
515  *****************************************************************************/
516 void _DtHelpUpdatePrintDialog(
517     _DtHelpPrintStuff *       print,
518     _DtHelpDisplayWidgetStuff * display,
519     _DtHelpCommonHelpStuff *  help,
520     Boolean                   setDefaults)
521 {
522    int n;
523    Arg args[5];
524    char * titleStr;
525    XmString labelString=NULL;
526    XmString volumeString=NULL;
527    XmFontList fontList = NULL;
528    Boolean mod = False;
529    char buf[400];
530
531    /* only work on print dialog if we need to */
532    if (print->printForm == NULL) return;
533
534    /* Set the proper default toggle button value */
535    if ( setDefaults )
536    {
537       if(print->curTopicBtn)
538          XmToggleButtonSetState(print->curTopicBtn, True, False);
539       if(print->subTopicsBtn)
540          XmToggleButtonSetState(print->subTopicsBtn,False,False);
541       if(print->tocBtn)
542          XmToggleButtonSetState(print->tocBtn,False,False);
543       if(print->allTopicsBtn)
544          XmToggleButtonSetState(print->allTopicsBtn,False,False);
545    }
546
547    /* adj where the TopicsBtn separator is attached */
548    /* if attached to the PaperTopics separator, the topics are hidden */
549    n = 0;
550    if ( display->helpType == DtHELP_TYPE_TOPIC )
551    {
552 #if 1
553       XtSetSensitive(print->topicsFrame,True);
554 #else
555       XtManageChild(print->topicsFrame);
556       XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET);          n++;
557       XtSetArg (args[n], XmNtopWidget, print->topicsFrame);           n++;
558 #endif
559    }
560    else
561    {
562 #if 1
563       XtSetSensitive(print->topicsFrame,False);
564 #else
565       XtUnmanageChild(print->topicsFrame);
566       XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET);          n++;
567       XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator);  n++;
568 #endif
569    }
570    XtSetValues (print->topicsBtnsSeparator, args, n);
571
572    /* update the dialog's print subject label string */
573    switch ( display->helpType )
574    {
575       /* coming out of the case, volumeString & titleStr should be set */
576       case DtHELP_TYPE_TOPIC:
577          titleStr = _DTGETMESSAGE(PRSET, 50,"Help Volume: ");
578
579          /* get volume title and allow for localized fonts */
580
581          /* get the font list of the label */
582          XtSetArg (args[0], XmNfontList, &fontList);
583          XtGetValues (print->subject, args, 1);
584
585 #if defined(DONT_USE_CDExc22774)
586          /* Don't need to copy, _DtHelpFormatVolumeTitle copies 
587           * before modifying.
588           */
589
590          /* copy the list before passing it in for modification */
591          /* we must free this now */
592          fontList = XmFontListCopy (fontList);
593 #endif
594
595          /* get formatted volume title; volumeString is owned by caller */
596          _DtHelpFormatVolumeTitle(help->pDisplayArea,display->volumeHandle,
597                                     &volumeString,&fontList,&mod);
598  
599          /* if volumeString caused a font list change, add it back */
600          if (mod)
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);
605          }
606
607          break;
608       case DtHELP_TYPE_STRING:
609       case DtHELP_TYPE_DYNAMIC_STRING:
610          titleStr = _DTGETMESSAGE(PRSET, 51,"Help Message");
611          break;
612       case DtHELP_TYPE_FILE:
613          titleStr = _DTGETMESSAGE(PRSET, 52,"Help File");
614          break;
615       case DtHELP_TYPE_MAN_PAGE:
616          /* assumption: buf won't overflow */
617          sprintf(buf,"%s%s", _DTGETMESSAGE(PRSET, 53,"Manual Page: "),
618                  display->manPage);
619          titleStr = buf;
620          break;
621       default:
622          titleStr = _DTGETMESSAGE(PRSET, 54,"Error message");
623          break;
624    }
625
626    /* at this point, titleStr and volumeString are set */
627
628    /* set the dialog label strings only if needed */
629    labelString = XmStringCreateLocalized(titleStr);
630
631    /* if there is a valid volumeString, concatenate it */
632    if (volumeString)
633    {
634      XmString fullTitle;
635      fullTitle = XmStringConcat(labelString,volumeString);
636      XmStringFree(labelString);
637      XmStringFree(volumeString);
638      labelString = fullTitle;
639    }
640
641       /* set the dialog label string */
642       XtSetArg (args[0], XmNlabelString, labelString);
643       XtSetValues (print->subject, args, 1);
644    XmStringFree (labelString);
645
646    XmUpdateDisplay(print->printForm);
647 }
648
649
650
651 /*****************************************************************************
652  * Function:        void _DtHelpDisplayPrintDialog();
653  *                             
654  * 
655  * Parameters:  
656  *      new             Specifies the help widget.
657  *      print           print stuff
658  *      display         display widget stuff
659  *      help            common help stuff
660  *
661  * Return Value:
662  *
663  * Purpose:         Creates and displays an instance of the print dialog.
664  *
665  *****************************************************************************/
666 void _DtHelpDisplayPrintDialog(
667    Widget               widget,
668    _DtHelpPrintStuff *  print,
669    _DtHelpDisplayWidgetStuff * display,
670    _DtHelpCommonHelpStuff * help)
671 {
672    Arg args[5];
673    Widget dfltSize = NULL;
674
675    /* Build a print dialog if we need to */
676    if (print->printForm == NULL)
677    {
678       CreatePrintDialog(widget,print,display,help);
679
680       /*** Only init the values if creating dialog for first time ***/
681
682       switch(print->paperSize)
683       {
684          case DtHELP_PAPERSIZE_LEGAL:
685              dfltSize = print->legalBtn;
686              break;
687          case DtHELP_PAPERSIZE_EXECUTIVE:
688              dfltSize = print->execBtn;
689              break;
690          case DtHELP_PAPERSIZE_A4:
691              dfltSize = print->a4Btn;
692              break;
693          case DtHELP_PAPERSIZE_B5:
694              dfltSize = print->b5Btn;
695              break;
696          case DtHELP_PAPERSIZE_LETTER:
697          default:
698              dfltSize = print->letterBtn;
699              break;
700       }
701       /* Set the default size */
702       XtSetArg (args[0], XmNmenuHistory, dfltSize); 
703       XtSetValues (print->paperSizeOptMenu, args, 1);
704
705       /* update the variable contents of the dialog; do set defaults */
706       _DtHelpUpdatePrintDialog(print,display,help,True);
707    }
708    else
709    {
710       /* update the variable contents of the dialog; don't set defaults */
711       _DtHelpUpdatePrintDialog(print,display,help,False);
712    }
713
714
715    if ( XtIsManaged(print->printForm) == False )
716    {
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));
721    }
722    else
723    {
724       /* raise the window to top of the stack */
725       Widget parent = XtParent(print->printForm);
726       XRaiseWindow ( XtDisplay(parent), XtWindow(parent) );
727    }
728 }
729
730
731
732 /*****************************************************************************
733  * Function:        Widget CreatePrintDialog(Widget nw);
734  *                             
735  * 
736  * Parameters:      
737  *
738  * Return Value:
739  *
740  * Purpose:         Creates  an instance of the print dialog.
741  *
742  *****************************************************************************/
743 static void CreatePrintDialog(
744    Widget               widget,
745    _DtHelpPrintStuff *  print,
746    _DtHelpDisplayWidgetStuff * display,
747    _DtHelpCommonHelpStuff * help)
748 {
749    Widget printShell;
750    Widget printForm;
751    Widget topicsForm;
752    Widget menupane;
753    Widget frameTitle;
754    Widget printerLabel;
755    Widget copiesLabel;
756    Widget radioBox;
757    Widget separator;
758    Widget okBtn, cancelBtn, helpBtn;
759    XmString labelString;
760    char * chrStr;
761    DtHelpListStruct *pHelpInfo;
762    _DtHelpPrintCBRec * printCBRec = NULL;
763    int n;
764    Arg args[20];
765
766    /*  Create the shell and form used for the dialog.  */
767    chrStr = XtNewString(((char *)_DTGETMESSAGE(PRSET, 1, "Help - Print")));
768    n = 0;
769    XtSetArg (args[n], XmNtitle, chrStr);                                n++;
770    printShell = XmCreateDialogShell(widget, "printShell", args, n);
771    XtFree(chrStr);
772
773    /* Set the useAsyncGeo on the shell */
774    n = 0;
775    XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
776 /*   XtSetValues (XtParent(printShell), args, n);*/
777    XtSetValues (printShell, args, n);
778
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);
783
784    /* create the form in the dialog to hold the contents */
785    n = 0;
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);
792
793    /**** create the printing-related widgets ****/
794
795    /* create print subject label */
796    labelString = XmStringCreateLocalized(EMPTYSTR);
797    n = 0;
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++;
803 #if 0
804    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);                n++;
805    XtSetArg (args[n], XmNrightOffset, 10);                               n++;
806 #endif
807    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING);             n++;
808    print->subject = 
809                     XmCreateLabelGadget (printForm, "printSubject", args, n);
810    XtManageChild (print->subject);
811    XmStringFree (labelString);
812
813    /* create printer label */
814    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
815                         (PRSET, 10,"Printer:")));
816    n = 0;
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);
827
828    /* create the printer name text field */
829    n = 0;
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);
852
853    /* create copies label */
854    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
855                         (PRSET, 11,"Copies:")));
856    n = 0;
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);
868
869    /* create the copies text field */
870    n = 0;
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++;
881    print->copiesField = 
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);
888
889    /* papersize option menu */
890   /*******************************************************
891    * Menupane:  Papersize buttons
892    * No callback on each button is needed because we compare widget ptrs 
893    *******************************************************/
894  
895    n = 0;
896    XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
897    XtSetArg(args[n], XmNmarginHeight, 0);        ++n;
898    menupane = XmCreatePulldownMenu(printForm, "paperSizeMenu", args, n);
899  
900    /* Letter button */
901    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 21,"Letter 8.5 x 11 in")));
902    n = 0;
903    XtSetArg(args[n], XmNlabelString, labelString); n++;
904    print->letterBtn = XmCreatePushButtonGadget(menupane, "letter", args, n);
905    XtManageChild(print->letterBtn);
906    XmStringFree(labelString);
907  
908    /* Legal button */
909    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 22,"Legal 8.5 x 14 in")));
910    n = 0;
911    XtSetArg(args[n], XmNlabelString, labelString); n++;
912    print->legalBtn = XmCreatePushButtonGadget(menupane, "legal", args, n);
913    XtManageChild(print->legalBtn);
914    XmStringFree(labelString);
915  
916    /* Executive button */
917    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 23,"Executive 7.25 x 10.5 in")));
918    n = 0;
919    XtSetArg(args[n], XmNlabelString, labelString); n++;
920    print->execBtn = XmCreatePushButtonGadget(menupane, "executive", args, n);
921    XtManageChild(print->execBtn);
922    XmStringFree(labelString);
923  
924    /* A4 button */
925    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 24,"A4 210 x 297 mm")));
926    n = 0;
927    XtSetArg(args[n], XmNlabelString, labelString); n++;
928    print->a4Btn = XmCreatePushButtonGadget(menupane, "A4", args, n);
929    XtManageChild(print->a4Btn);
930    XmStringFree(labelString);
931  
932    /* B5 button */
933    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 25,"B5 182 x 257 mm")));
934    n = 0;
935    XtSetArg(args[n], XmNlabelString, labelString); n++;
936    print->b5Btn = XmCreatePushButtonGadget(menupane, "B5", args, n);
937    XtManageChild(print->b5Btn);
938    XmStringFree(labelString);
939
940    /* Option Menu */
941    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 20,"Paper Size:")));
942    n = 0;
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);
958
959    /* the DtNpaperSize resource is used to set the default item
960       in _DtHelpDisplayPrintDialog() */
961
962    /*  Create a separator between the paper size and topic range selection/buttons  */
963    n = 0;
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);
973
974    /* if currently showing a topic, display the topic selection box */
975    /****** Create the topics selection frame ******/
976    n = 0;
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*/
987    print->topicsFrame = 
988                           XmCreateFrame(printForm, "topicsFrame", args, n);
989    XtManageChild (print->topicsFrame);
990
991    /* FIX: consider eliminating the form and just putting the RowColumn
992            RadioBox inside the frame */
993
994    /* unused message catalog entries: 8: Executive, 9: Legal */
995
996    /* put form inside frame */
997    topicsForm = XmCreateForm (
998                    print->topicsFrame,"topicsForm", NULL, 0);
999    XtManageChild (topicsForm);
1000
1001    /* create the frame title */
1002    labelString = XmStringCreateLocalized ((_DTGETMESSAGE(
1003                         PRSET,30,"Topics To Print")));
1004    n = 0;
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);
1012
1013    /* Create the Radio Box widget to hold the toggle buttons */
1014    n = 0;
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);
1020   
1021    /* Create the print current topic button */
1022    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1023                      (PRSET, 31,"Current Topic")));
1024    n = 0;
1025    XtSetArg (args[n], XmNlabelString, labelString);                   n++;
1026    print->curTopicBtn = 
1027            XmCreateToggleButtonGadget(radioBox,"printCurTopicBtn",args,n);
1028    XtManageChild (print->curTopicBtn);
1029    XmStringFree (labelString);
1030
1031    /* Create the print current chapter button */
1032    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1033                      (PRSET, 32,"Current and Subtopics")));
1034    n = 0;
1035    XtSetArg (args[n], XmNlabelString, labelString);                   n++;
1036    print->subTopicsBtn = 
1037            XmCreateToggleButtonGadget(radioBox,"print.subTopicsBtn",args,n);
1038    XtManageChild (print->subTopicsBtn);
1039    XmStringFree (labelString);
1040
1041    /* Create the print TOC buttion */
1042    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1043                      (PRSET, 33,"Table of Contents and Index")));
1044    n = 0;
1045    XtSetArg (args[n], XmNlabelString, labelString);                   n++;
1046    print->tocBtn = XmCreateToggleButtonGadget 
1047                        (radioBox, "printTocBtn", args, n);
1048    XtManageChild (print->tocBtn);
1049    XmStringFree (labelString);
1050
1051    /* Create the print all topics buttion */
1052    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1053                      (PRSET, 34,"Entire Volume")));
1054    n = 0;
1055    XtSetArg (args[n], XmNlabelString, labelString);                   n++;
1056    print->allTopicsBtn = XmCreateToggleButtonGadget 
1057                        (radioBox, "printAllTopicsBtn", args, n);
1058    XtManageChild (print->allTopicsBtn);
1059    XmStringFree (labelString);
1060
1061    /* create a separator */
1062    n = 0;
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);
1071
1072    /* for easy ref */
1073    separator = print->topicsBtnsSeparator;
1074
1075    /*  Create the action buttons along the bottom */
1076    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1077                             (PRSET, 40,"Print")));
1078    n = 0;
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++;
1087 #if 0
1088    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM);              n++;
1089 #endif
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);
1097
1098    /* Build the Cancel Button */
1099    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1100                             (PRSET, 41,"Cancel")));
1101    n = 0;
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);
1116
1117    /* Build the Help button */
1118    labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1119                             (PRSET, 42,"Help")));
1120    n = 0;
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);
1137
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 */
1142    n = 0;
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);
1147
1148    /*  Adjust the decorations for the dialog shell of the dialog  */
1149    n = 0;
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);
1154
1155    /* Add the popup position callback to our print  dialog */
1156    XtAddCallback (printShell, XmNpopupCallback, (XtCallbackProc) _DtHelpMapCB,
1157                   (XtPointer) XtParent(widget));
1158
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);
1164
1165    /* Assign our new print dialog to our widget instance */
1166    print->printForm = printForm;
1167
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);
1177 }
1178
1179
1180
1181 \f
1182 /*****************************************************************************
1183  * Function:        void _DtHelpPrintJob(
1184  *                   
1185  *                            
1186  *
1187  * Parameters:  
1188  *
1189  * Return Value:    Void.
1190  *
1191  * Purpose:         Sets up and forks off a print job to helpprint
1192  *
1193  *****************************************************************************/
1194 void _DtHelpPrintJob(
1195     Widget      widget,
1196     char *      printExec,
1197     char *      printer,
1198     int         paperSize,
1199     char *      copies,
1200     char *      helpVolume,
1201     int         helpType,
1202     char *      helpData,
1203     Boolean     printAll,
1204     Boolean     printSub,
1205     Boolean     printTocIndex,
1206     char *      topicTitle)
1207 {
1208   char * argv[40];
1209   char * quotes="''";
1210   int    i;
1211   int    pid;
1212   char   tmpHelpType[4];
1213
1214    /* Setup the helpprint command and let it go */
1215    i = 0;
1216    argv[i++] = printExec;
1217
1218    if (printer != NULL && printer[0] != EOS)
1219    {
1220         argv[i++] = "-printer";
1221         argv[i++] = printer;
1222    }
1223  
1224    if (copies != NULL && copies[0] != EOS)
1225    {
1226         argv[i++] = "-copies";
1227         argv[i++] = copies;
1228    }
1229  
1230    if (NULL != topicTitle)
1231    {
1232       argv[i++] = "-topicTitle";
1233       argv[i++] = topicTitle;
1234    }
1235
1236    if (paperSize >= _DtHelpPaperSizeNamesCnt) paperSize = 0;
1237    argv[i++] = "-paperSize";
1238    argv[i++] = _DtHelpPaperSizeNames[paperSize];
1239  
1240    argv[i++] = "-display";
1241    argv[i++] = (char*)XDisplayString(XtDisplay(widget));
1242  
1243    argv[i++] = "-helpType";
1244    sprintf(tmpHelpType, "%d", helpType);
1245    argv[i++] = tmpHelpType;
1246  
1247    if (printAll)
1248       argv[i++] = "-allTopics";
1249   
1250    if (printSub)
1251       argv[i++] = "-subTopics";
1252   
1253    if (printTocIndex)
1254    {
1255       argv[i++] = "-toc";
1256       argv[i++] = "-index";
1257       argv[i++] = "-frontMatter";
1258    }
1259   
1260    if (!printSub && !printAll && !printTocIndex)
1261       argv[i++] = "-oneTopic";
1262
1263    if (NULL == helpData) helpData = quotes;
1264    switch (helpType)
1265    {
1266      case DtHELP_TYPE_TOPIC:
1267         argv[i++] = "-locationId";
1268         argv[i++] = helpData;
1269         argv[i++] = "-helpVolume";
1270         argv[i++] = helpVolume;
1271         break;
1272  
1273      case DtHELP_TYPE_MAN_PAGE:
1274         argv[i++] = "-manPage";
1275         argv[i++] = helpData;
1276         break;
1277  
1278      case DtHELP_TYPE_FILE:
1279          argv[i++] = "-helpFile";
1280          argv[i++] = helpData;
1281          break;
1282  
1283       case DtHELP_TYPE_STRING:
1284       case DtHELP_TYPE_DYNAMIC_STRING:
1285          argv[i++] = "-stringData";
1286          argv[i++] = helpData;
1287          break;
1288     
1289       default:  
1290          /* ERROR-MESSAGE */
1291          /* We should never get here, but just in case... */
1292          XmeWarning(widget, (char*)PrintMessage001);
1293          break;
1294    }  /* End Switch Statement */
1295  
1296    argv[i++] = NULL;
1297         
1298 #if 0   /* DBG */
1299    { /* for debugging, print out the command line */
1300      char * * tmpargv;
1301      for ( tmpargv = argv; *tmpargv; tmpargv++ ) fprintf(stderr,"%s ", *tmpargv);
1302      fprintf(stderr,"\n");
1303    }
1304 #endif
1305
1306 #ifdef __hpux
1307    pid = vfork();
1308 #else
1309    pid = fork();
1310 #endif /* __hpux */
1311  
1312    if (pid == 0)
1313    {
1314       (void) execvp (argv[0], argv);
1315       _exit (1);
1316    }
1317  
1318   /* Return an error if bad pid? */
1319 }
1320
1321