Print.c 43 KB

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