Print.c 43 KB

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