2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: Print.c /main/10 1999/02/09 19:45:00 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cache Creek (Rivers) Project
31 ** Description: Builds and displays an instance of a Cache Creek Print
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
44 #include <sys/param.h>
46 #include <stdlib.h> /* for getenv() */
56 #include <Xm/LabelG.h>
58 #include <Xm/SeparatoG.h>
59 #include <Xm/PushBG.h>
60 #include <Xm/DialogS.h>
61 #include <Xm/ToggleBG.h>
62 #include <Xm/RowColumn.h>
63 #include <Xm/MwmUtil.h>
64 #include <Xm/Protocols.h>
65 #include <Xm/ToggleB.h>
67 #include <X11/Intrinsic.h>
68 #include <X11/Shell.h>
69 #include <X11/ShellP.h>
70 #include <X11/Xutil.h>
71 #include <X11/keysymdef.h>
76 #include "DisplayAreaI.h"
81 #include "MessagesP.h"
85 #include "HelpUtilI.h"
86 #include "HelpAccessI.h"
87 #include "HelpDialogI.h"
88 #include "HelpDialogP.h"
92 /***** helper structures ****/
93 typedef struct _DtHelpPrintCBRec {
95 _DtHelpDisplayWidgetStuff * display;
96 _DtHelpCommonHelpStuff * help;
97 _DtHelpPrintStuff * print;
100 /***** Global Variables ****/
101 char _DtHelpDefaultHelpPrint[] = "/usr/dt/bin/dthelpprint";
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",
111 int _DtHelpPaperSizeNamesCnt = (sizeof(_DtHelpPaperSizeNames) / sizeof(char *));
113 /***** Constants ******/
114 #define EOS '\0' /* end of string */
115 #define EMPTYSTR s_EmptyStr
117 #define PRSET 4 /* msg catalog set for print dialog */
119 #define PrintMessage001 _DtHelpMsg_0004
121 /***** Static Variables ******/
122 static char s_EmptyStr[] = "";
124 /****** Protos ******/
125 static void ClosePrintCB (
127 XtPointer clientData,
129 static void StartPrintingCB (
131 XtPointer clientData,
133 static void CreatePrintDialog(
135 _DtHelpPrintStuff * print,
136 _DtHelpDisplayWidgetStuff * display,
137 _DtHelpCommonHelpStuff * help);
139 /************************************************************************
140 * Function: CreatePrintCBRec()
142 * Create the data required by a print callback
144 * This routine allocates memory for the callback record using XtCalloc().
145 * When the record is no longer needed, free it with XtFree().
146 ************************************************************************/
148 _DtHelpPrintCBRec * CreatePrintCBRec(
150 _DtHelpDisplayWidgetStuff * display,
151 _DtHelpCommonHelpStuff * help,
152 _DtHelpPrintStuff * print)
154 _DtHelpPrintCBRec * rec = NULL;
156 rec = (_DtHelpPrintCBRec *) XtCalloc(1,sizeof(_DtHelpPrintCBRec));
157 if (NULL == rec) return NULL;
158 rec->widget = widget;
159 rec->display = display;
166 /************************************************************************
167 * Function: _DtHelpInitPrintStuff()
169 * Init print-related data
171 ************************************************************************/
172 void _DtHelpInitPrintStuff (
173 _DtHelpPrintStuff * print)
175 /* Set our print display stuff to initial values */
176 if (print->printer != NULL)
177 print->printer = XtNewString(print->printer);
179 if (print->helpPrint != _DtHelpDefaultHelpPrint)
180 print->helpPrint = XtNewString(print->helpPrint);
182 print->paperSize = DtHELP_PAPERSIZE_LETTER;
183 print->printVolume = NULL;
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;
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;
205 /************************************************************************
206 * Function: _DtHelpFreePrintStuff()
208 * Init print-related data
210 ************************************************************************/
211 void _DtHelpFreePrintStuff (
212 _DtHelpPrintStuff * print,
215 XtFree(print->printVolume);
216 print->printVolume = NULL;
218 if (print->printForm != NULL)
220 XtUnmanageChild(print->printForm);
223 if (cleanUpKind == DtCLEAN_FOR_DESTROY)
225 if (print->helpPrint != _DtHelpDefaultHelpPrint)
226 XtFree(print->helpPrint);
227 print->helpPrint = NULL;
229 XtFree(print->printer);
230 print->printer = NULL;
235 /************************************************************************
236 * Function: _DtHelpPrintSetValues()
238 * set print-related data
240 ************************************************************************/
241 void _DtHelpPrintSetValues (
242 _DtHelpPrintStuff * currentPrint,
243 _DtHelpPrintStuff * newPrint,
244 _DtHelpDisplayWidgetStuff * newDisplay,
245 _DtHelpCommonHelpStuff * newCommonHelp)
247 /* Check DtNhelpPrint resource for change */
248 if (currentPrint->helpPrint != newPrint->helpPrint)
250 newPrint->helpPrint = XtNewString(newPrint->helpPrint);
252 if (currentPrint->helpPrint != _DtHelpDefaultHelpPrint)
253 XtFree(currentPrint->helpPrint);
256 /* Check DtNprinter resource for change */
257 if (currentPrint->printer != newPrint->printer)
259 newPrint->printer = XtNewString(newPrint->printer);
260 XtFree(currentPrint->printer);
264 /* Do NOT check DtNpaperSize resource for change */
265 /* It is a C-only resource */
270 /************************************************************************
271 * Function: ClosePrintCB()
273 * Close the Print dialog.
275 ************************************************************************/
276 static void ClosePrintCB (
278 XtPointer clientData,
281 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
283 /* We unmap the print dialog */
284 XtUnmanageChild(printrec->print->printForm);
288 /************************************************************************
289 * Function: DestroyDialogCB()
291 * Free allocated memory
293 ************************************************************************/
294 static void DestroyDialogCB(
296 XtPointer clientData,
299 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
300 XtFree((char *)printrec);
303 /************************************************************************
304 * Function: CheckCopiesCB()
306 * Check whether the copies in the copies field is valid
308 ************************************************************************/
309 static void CheckCopiesCB(
311 XtPointer clientData,
314 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
318 /************************************************************************
319 * Function: CheckPrinterCB()
321 * Check whether the printer in the printer field is valid
322 * and store a valid printer string in printPrinter.
324 ************************************************************************/
325 static void CheckPrinterCB(
327 XtPointer clientData,
330 /* _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData; */
334 /************************************************************************
335 * Function: StartPrintingCB()
337 * Start printing and close the PRINT Dialog
339 ************************************************************************/
340 static void StartPrintingCB(
342 XtPointer clientData,
345 _DtHelpPrintCBRec * printrec = (_DtHelpPrintCBRec *) clientData;
347 char *printTopic=NULL;
348 char *topicTitle=NULL;
349 Boolean printAll=False;
350 Boolean printSub=False;
351 Boolean printTocIndex=False;
353 XmString titleLbl = NULL;
357 Widget dfltSize = NULL;
360 /* Determine the current selected print type */
362 if (XmToggleButtonGetState(printrec->print->allTopicsBtn))
364 printType = _DtPRINT_ALL;
365 printTopic = printrec->help->topLevelId;
369 if (XmToggleButtonGetState(printrec->print->tocBtn))
371 printType = _DtPRINT_TOC;
373 printTocIndex = True;
376 if (XmToggleButtonGetState(printrec->print->subTopicsBtn))
378 printType = _DtPRINT_SUB;
379 printTopic = printrec->display->locationId;
383 if (XmToggleButtonGetState(printrec->print->curTopicBtn))
385 printType = _DtPRINT_CURRENT;
386 switch (printrec->display->helpType)
388 case DtHELP_TYPE_TOPIC:
389 printTopic = printrec->display->locationId;
392 case DtHELP_TYPE_MAN_PAGE:
393 printTopic = printrec->display->manPage;
396 case DtHELP_TYPE_FILE:
397 printTopic = printrec->display->helpFile;
398 titleLbl = printrec->display->topicTitleLbl;
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;
408 } /* End Switch Statement */
412 * change the XmString into a char *.
414 if (titleLbl != NULL)
418 XmStringContext theContext;
419 XmStringCharSet theSet;
420 XmStringDirection theDir;
424 if (XmStringInitContext(&theContext, titleLbl) == True)
426 while (XmStringGetNextSegment(theContext,
432 len = strlen(newTxt);
435 topicTitle = XtRealloc(topicTitle, len + 1);
436 if (topicTitle != NULL)
438 strcpy(&topicTitle[newLen], newTxt);
443 XmStringFreeContext(theContext);
448 printer = XmTextFieldGetString(printrec->print->printerField);
449 if (printer && printer[0] == EOS)
450 { XtFree(printer); printer = NULL; }
453 copies = XmTextFieldGetString(printrec->print->copiesField);
456 || (copies && copies[0] == EOS)
457 || (copies && sscanf(copies,"%d",©Cnt) != 1 )
458 || (copyCnt < 0 || copyCnt > 500) )
459 { XtFree(copies); copies = XtNewString("1"); }
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;
474 paperSize = DtHELP_PAPERSIZE_LETTER;
478 /* Call the print setup routine to start the print job */
481 printrec->print->helpPrint,
485 printrec->print->printVolume,
486 printrec->display->helpType,
498 /* We unmap the print dialog */
499 XtUnmanageChild(printrec->print->printForm);
504 /*****************************************************************************
505 * Function: void _DtHelpUpdatePrintDialog();
508 * Parameters: new Specifies the help widget.
512 * Purpose: Updates the print dialog to reflect current topic
514 *****************************************************************************/
515 void _DtHelpUpdatePrintDialog(
516 _DtHelpPrintStuff * print,
517 _DtHelpDisplayWidgetStuff * display,
518 _DtHelpCommonHelpStuff * help,
524 XmString labelString=NULL;
525 XmString volumeString=NULL;
526 XmFontList fontList = NULL;
530 /* only work on print dialog if we need to */
531 if (print->printForm == NULL) return;
533 /* Set the proper default toggle button value */
536 if(print->curTopicBtn)
537 XmToggleButtonSetState(print->curTopicBtn, True, False);
538 if(print->subTopicsBtn)
539 XmToggleButtonSetState(print->subTopicsBtn,False,False);
541 XmToggleButtonSetState(print->tocBtn,False,False);
542 if(print->allTopicsBtn)
543 XmToggleButtonSetState(print->allTopicsBtn,False,False);
546 /* adj where the TopicsBtn separator is attached */
547 /* if attached to the PaperTopics separator, the topics are hidden */
549 if ( display->helpType == DtHELP_TYPE_TOPIC )
552 XtSetSensitive(print->topicsFrame,True);
554 XtManageChild(print->topicsFrame);
555 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
556 XtSetArg (args[n], XmNtopWidget, print->topicsFrame); n++;
562 XtSetSensitive(print->topicsFrame,False);
564 XtUnmanageChild(print->topicsFrame);
565 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
566 XtSetArg (args[n], XmNtopWidget, print->paperTopicsSeparator); n++;
569 XtSetValues (print->topicsBtnsSeparator, args, n);
571 /* update the dialog's print subject label string */
572 switch ( display->helpType )
574 /* coming out of the case, volumeString & titleStr should be set */
575 case DtHELP_TYPE_TOPIC:
576 titleStr = _DTGETMESSAGE(PRSET, 50,"Help Volume: ");
578 /* get volume title and allow for localized fonts */
580 /* get the font list of the label */
581 XtSetArg (args[0], XmNfontList, &fontList);
582 XtGetValues (print->subject, args, 1);
584 #if defined(DONT_USE_CDExc22774)
585 /* Don't need to copy, _DtHelpFormatVolumeTitle copies
589 /* copy the list before passing it in for modification */
590 /* we must free this now */
591 fontList = XmFontListCopy (fontList);
594 /* get formatted volume title; volumeString is owned by caller */
595 _DtHelpFormatVolumeTitle(help->pDisplayArea,display->volumeHandle,
596 &volumeString,&fontList,&mod);
598 /* if volumeString caused a font list change, add it back */
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);
607 case DtHELP_TYPE_STRING:
608 case DtHELP_TYPE_DYNAMIC_STRING:
609 titleStr = _DTGETMESSAGE(PRSET, 51,"Help Message");
611 case DtHELP_TYPE_FILE:
612 titleStr = _DTGETMESSAGE(PRSET, 52,"Help File");
614 case DtHELP_TYPE_MAN_PAGE:
615 /* assumption: buf won't overflow */
616 sprintf(buf,"%s%s", _DTGETMESSAGE(PRSET, 53,"Manual Page: "),
621 titleStr = _DTGETMESSAGE(PRSET, 54,"Error message");
625 /* at this point, titleStr and volumeString are set */
627 /* set the dialog label strings only if needed */
628 labelString = XmStringCreateLocalized(titleStr);
630 /* if there is a valid volumeString, concatenate it */
634 fullTitle = XmStringConcat(labelString,volumeString);
635 XmStringFree(labelString);
636 XmStringFree(volumeString);
637 labelString = fullTitle;
640 /* set the dialog label string */
641 XtSetArg (args[0], XmNlabelString, labelString);
642 XtSetValues (print->subject, args, 1);
643 XmStringFree (labelString);
645 XmUpdateDisplay(print->printForm);
650 /*****************************************************************************
651 * Function: void _DtHelpDisplayPrintDialog();
655 * new Specifies the help widget.
657 * display display widget stuff
658 * help common help stuff
662 * Purpose: Creates and displays an instance of the print dialog.
664 *****************************************************************************/
665 void _DtHelpDisplayPrintDialog(
667 _DtHelpPrintStuff * print,
668 _DtHelpDisplayWidgetStuff * display,
669 _DtHelpCommonHelpStuff * help)
672 Widget dfltSize = NULL;
674 /* Build a print dialog if we need to */
675 if (print->printForm == NULL)
677 CreatePrintDialog(widget,print,display,help);
679 /*** Only init the values if creating dialog for first time ***/
681 switch(print->paperSize)
683 case DtHELP_PAPERSIZE_LEGAL:
684 dfltSize = print->legalBtn;
686 case DtHELP_PAPERSIZE_EXECUTIVE:
687 dfltSize = print->execBtn;
689 case DtHELP_PAPERSIZE_A4:
690 dfltSize = print->a4Btn;
692 case DtHELP_PAPERSIZE_B5:
693 dfltSize = print->b5Btn;
695 case DtHELP_PAPERSIZE_LETTER:
697 dfltSize = print->letterBtn;
700 /* Set the default size */
701 XtSetArg (args[0], XmNmenuHistory, dfltSize);
702 XtSetValues (print->paperSizeOptMenu, args, 1);
704 /* update the variable contents of the dialog; do set defaults */
705 _DtHelpUpdatePrintDialog(print,display,help,True);
709 /* update the variable contents of the dialog; don't set defaults */
710 _DtHelpUpdatePrintDialog(print,display,help,False);
714 if ( XtIsManaged(print->printForm) == False )
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));
723 /* raise the window to top of the stack */
724 Widget parent = XtParent(print->printForm);
725 XRaiseWindow ( XtDisplay(parent), XtWindow(parent) );
731 /*****************************************************************************
732 * Function: Widget CreatePrintDialog(Widget nw);
739 * Purpose: Creates an instance of the print dialog.
741 *****************************************************************************/
742 static void CreatePrintDialog(
744 _DtHelpPrintStuff * print,
745 _DtHelpDisplayWidgetStuff * display,
746 _DtHelpCommonHelpStuff * help)
757 Widget okBtn, cancelBtn, helpBtn;
758 XmString labelString;
760 DtHelpListStruct *pHelpInfo;
761 _DtHelpPrintCBRec * printCBRec = NULL;
765 /* Create the shell and form used for the dialog. */
766 chrStr = XtNewString(((char *)_DTGETMESSAGE(PRSET, 1, "Help - Print")));
768 XtSetArg (args[n], XmNtitle, chrStr); n++;
769 printShell = XmCreateDialogShell(widget, "printShell", args, n);
772 /* Set the useAsyncGeo on the shell */
774 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
775 /* XtSetValues (XtParent(printShell), args, n);*/
776 XtSetValues (printShell, args, n);
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);
783 /* create the form in the dialog to hold the contents */
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);
792 /**** create the printing-related widgets ****/
794 /* create print subject label */
795 labelString = XmStringCreateLocalized(EMPTYSTR);
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++;
803 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
804 XtSetArg (args[n], XmNrightOffset, 10); n++;
806 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
808 XmCreateLabelGadget (printForm, "printSubject", args, n);
809 XtManageChild (print->subject);
810 XmStringFree (labelString);
812 /* create printer label */
813 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
814 (PRSET, 10,"Printer:")));
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);
827 /* create the printer name text field */
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);
852 /* create copies label */
853 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
854 (PRSET, 11,"Copies:")));
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);
868 /* create the copies text field */
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++;
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);
888 /* papersize option menu */
889 /*******************************************************
890 * Menupane: Papersize buttons
891 * No callback on each button is needed because we compare widget ptrs
892 *******************************************************/
895 XtSetArg(args[n], XmNmarginWidth, 0); ++n;
896 XtSetArg(args[n], XmNmarginHeight, 0); ++n;
897 menupane = XmCreatePulldownMenu(printForm, "paperSizeMenu", args, n);
900 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 21,"Letter 8.5 x 11 in")));
902 XtSetArg(args[n], XmNlabelString, labelString); n++;
903 print->letterBtn = XmCreatePushButtonGadget(menupane, "letter", args, n);
904 XtManageChild(print->letterBtn);
905 XmStringFree(labelString);
908 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 22,"Legal 8.5 x 14 in")));
910 XtSetArg(args[n], XmNlabelString, labelString); n++;
911 print->legalBtn = XmCreatePushButtonGadget(menupane, "legal", args, n);
912 XtManageChild(print->legalBtn);
913 XmStringFree(labelString);
915 /* Executive button */
916 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 23,"Executive 7.25 x 10.5 in")));
918 XtSetArg(args[n], XmNlabelString, labelString); n++;
919 print->execBtn = XmCreatePushButtonGadget(menupane, "executive", args, n);
920 XtManageChild(print->execBtn);
921 XmStringFree(labelString);
924 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 24,"A4 210 x 297 mm")));
926 XtSetArg(args[n], XmNlabelString, labelString); n++;
927 print->a4Btn = XmCreatePushButtonGadget(menupane, "A4", args, n);
928 XtManageChild(print->a4Btn);
929 XmStringFree(labelString);
932 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 25,"B5 182 x 257 mm")));
934 XtSetArg(args[n], XmNlabelString, labelString); n++;
935 print->b5Btn = XmCreatePushButtonGadget(menupane, "B5", args, n);
936 XtManageChild(print->b5Btn);
937 XmStringFree(labelString);
940 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(PRSET, 20,"Paper Size:")));
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);
958 /* the DtNpaperSize resource is used to set the default item
959 in _DtHelpDisplayPrintDialog() */
961 /* Create a separator between the paper size and topic range selection/buttons */
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);
973 /* if currently showing a topic, display the topic selection box */
974 /****** Create the topics selection frame ******/
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*/
987 XmCreateFrame(printForm, "topicsFrame", args, n);
988 XtManageChild (print->topicsFrame);
990 /* FIX: consider eliminating the form and just putting the RowColumn
991 RadioBox inside the frame */
993 /* unused message catalog entries: 8: Executive, 9: Legal */
995 /* put form inside frame */
996 topicsForm = XmCreateForm (
997 print->topicsFrame,"topicsForm", NULL, 0);
998 XtManageChild (topicsForm);
1000 /* create the frame title */
1001 labelString = XmStringCreateLocalized ((_DTGETMESSAGE(
1002 PRSET,30,"Topics To Print")));
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);
1012 /* Create the Radio Box widget to hold the toggle buttons */
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);
1020 /* Create the print current topic button */
1021 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1022 (PRSET, 31,"Current Topic")));
1024 XtSetArg (args[n], XmNlabelString, labelString); n++;
1025 print->curTopicBtn =
1026 XmCreateToggleButtonGadget(radioBox,"printCurTopicBtn",args,n);
1027 XtManageChild (print->curTopicBtn);
1028 XmStringFree (labelString);
1030 /* Create the print current chapter button */
1031 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1032 (PRSET, 32,"Current and Subtopics")));
1034 XtSetArg (args[n], XmNlabelString, labelString); n++;
1035 print->subTopicsBtn =
1036 XmCreateToggleButtonGadget(radioBox,"print.subTopicsBtn",args,n);
1037 XtManageChild (print->subTopicsBtn);
1038 XmStringFree (labelString);
1040 /* Create the print TOC buttion */
1041 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1042 (PRSET, 33,"Table of Contents and Index")));
1044 XtSetArg (args[n], XmNlabelString, labelString); n++;
1045 print->tocBtn = XmCreateToggleButtonGadget
1046 (radioBox, "printTocBtn", args, n);
1047 XtManageChild (print->tocBtn);
1048 XmStringFree (labelString);
1050 /* Create the print all topics buttion */
1051 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1052 (PRSET, 34,"Entire Volume")));
1054 XtSetArg (args[n], XmNlabelString, labelString); n++;
1055 print->allTopicsBtn = XmCreateToggleButtonGadget
1056 (radioBox, "printAllTopicsBtn", args, n);
1057 XtManageChild (print->allTopicsBtn);
1058 XmStringFree (labelString);
1060 /* create a separator */
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);
1072 separator = print->topicsBtnsSeparator;
1074 /* Create the action buttons along the bottom */
1075 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1076 (PRSET, 40,"Print")));
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++;
1087 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
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);
1097 /* Build the Cancel Button */
1098 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1099 (PRSET, 41,"Cancel")));
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);
1116 /* Build the Help button */
1117 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
1118 (PRSET, 42,"Help")));
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);
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 */
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);
1147 /* Adjust the decorations for the dialog shell of the dialog */
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);
1154 /* Add the popup position callback to our print dialog */
1155 XtAddCallback (printShell, XmNpopupCallback, (XtCallbackProc) _DtHelpMapCB,
1156 (XtPointer) XtParent(widget));
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);
1164 /* Assign our new print dialog to our widget instance */
1165 print->printForm = printForm;
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);
1181 /*****************************************************************************
1182 * Function: void _DtHelpPrintJob(
1188 * Return Value: Void.
1190 * Purpose: Sets up and forks off a print job to helpprint
1192 *****************************************************************************/
1193 void _DtHelpPrintJob(
1204 Boolean printTocIndex,
1211 char tmpHelpType[4];
1213 /* Setup the helpprint command and let it go */
1215 argv[i++] = printExec;
1217 if (printer != NULL && printer[0] != EOS)
1219 argv[i++] = "-printer";
1220 argv[i++] = printer;
1223 if (copies != NULL && copies[0] != EOS)
1225 argv[i++] = "-copies";
1229 if (NULL != topicTitle)
1231 argv[i++] = "-topicTitle";
1232 argv[i++] = topicTitle;
1235 if (paperSize >= _DtHelpPaperSizeNamesCnt) paperSize = 0;
1236 argv[i++] = "-paperSize";
1237 argv[i++] = _DtHelpPaperSizeNames[paperSize];
1239 argv[i++] = "-display";
1240 argv[i++] = (char*)XDisplayString(XtDisplay(widget));
1242 argv[i++] = "-helpType";
1243 sprintf(tmpHelpType, "%d", helpType);
1244 argv[i++] = tmpHelpType;
1247 argv[i++] = "-allTopics";
1250 argv[i++] = "-subTopics";
1255 argv[i++] = "-index";
1256 argv[i++] = "-frontMatter";
1259 if (!printSub && !printAll && !printTocIndex)
1260 argv[i++] = "-oneTopic";
1262 if (NULL == helpData) helpData = quotes;
1265 case DtHELP_TYPE_TOPIC:
1266 argv[i++] = "-locationId";
1267 argv[i++] = helpData;
1268 argv[i++] = "-helpVolume";
1269 argv[i++] = helpVolume;
1272 case DtHELP_TYPE_MAN_PAGE:
1273 argv[i++] = "-manPage";
1274 argv[i++] = helpData;
1277 case DtHELP_TYPE_FILE:
1278 argv[i++] = "-helpFile";
1279 argv[i++] = helpData;
1282 case DtHELP_TYPE_STRING:
1283 case DtHELP_TYPE_DYNAMIC_STRING:
1284 argv[i++] = "-stringData";
1285 argv[i++] = helpData;
1290 /* We should never get here, but just in case... */
1291 XmeWarning(widget, (char*)PrintMessage001);
1293 } /* End Switch Statement */
1298 { /* for debugging, print out the command line */
1300 for ( tmpargv = argv; *tmpargv; tmpargv++ ) fprintf(stderr,"%s ", *tmpargv);
1301 fprintf(stderr,"\n");
1313 (void) execvp (argv[0], argv);
1317 /* Return an error if bad pid? */