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