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