printSetup.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: printSetup.c /main/14 1996/10/25 13:37:55 mgreess $ */
  24. /**********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: printSetup.c
  28. **
  29. ** Project: HP DT dtpad, a memo maker type editor based on the
  30. ** Dt Editor widget.
  31. **
  32. ** Description: Routines which manipulate the print setup dialog
  33. **
  34. **************************************************************************
  35. **********************************<+>*************************************/
  36. /*
  37. * Common Desktop Environment
  38. *
  39. * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
  40. * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
  41. * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
  42. * (c) Copyright 1993, 1994, 1995 Novell, Inc.
  43. * (c) Copyright 1995 Digital Equipment Corp.
  44. * (c) Copyright 1995 Fujitsu Limited
  45. * (c) Copyright 1995 Hitachi, Ltd.
  46. *
  47. *
  48. * RESTRICTED RIGHTS LEGEND
  49. *
  50. *Use, duplication, or disclosure by the U.S. Government is subject to
  51. *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  52. *Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
  53. *for non-DOD U.S. Government Departments and Agencies are as set forth in
  54. *FAR 52.227-19(c)(1,2).
  55. *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
  56. *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
  57. *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
  58. *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
  59. *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
  60. *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
  61. *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
  62. */
  63. #define REUSE_PRINT_SETUP_DIALOGS
  64. #include <stdio.h>
  65. #include <sys/param.h>
  66. #include <X11/Intrinsic.h>
  67. #include <Xm/DialogS.h>
  68. #include <Xm/Form.h>
  69. #include <Xm/MwmUtil.h>
  70. #include <Xm/ToggleB.h>
  71. #include <Dt/DtPStrings.h>
  72. #include <Dt/HelpDialog.h>
  73. #include <Dt/Print.h>
  74. #include <Dt/Session.h>
  75. #include "dtpad.h"
  76. static char *_psGetResourceFileName(
  77. PrintSetup *pSetup);
  78. static void _psSetupToSource(
  79. PrintSetup *pSetup);
  80. static void _psSourceToSetup(
  81. PrintSetup *pSetup,
  82. Boolean wordWrap);
  83. static void _psSetupToUi(
  84. PrintSetup *pSetup);
  85. static void _psUiToSetup(
  86. PrintSetup *pSetup);
  87. static Boolean _psUiSpecsAreValid(
  88. PrintSetup *pSetup);
  89. static void _psAttachPrintSetupDialog(
  90. PrintSetup *pSetup,
  91. Editor *pPad);
  92. static Widget _psCreatePrintSetupDialog(
  93. Widget parent,
  94. Editor *pPad);
  95. static void _psPrintSetupCancelCB(
  96. Widget dtprintSetup,
  97. XtPointer client_data,
  98. XtPointer call_data);
  99. static void _psPrintSetupDestroyCB(
  100. Widget dtprintSetup,
  101. XtPointer client_data,
  102. XtPointer call_data);
  103. static void _psPrintSetupPrintCB(
  104. Widget dtprintSetup,
  105. XtPointer client_data,
  106. XtPointer call_data);
  107. static void _psReleasePrintSetupDialog(
  108. PrintSetup *pSetup);
  109. #define PS_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
  110. #define PS_HOME_ENV_VARIABLE "HOME"
  111. #define PS_DEFAULT_RESOURCE_FILE "dtpadrc"
  112. #define PS_RESOURCE_HDRFTR_FORMAT_STRING "Dtpad.%s: %d\n"
  113. #define PS_RESOURCE_MARGIN_FORMAT_STRING "Dtpad.%s: %s\n"
  114. #define PS_RESOURCE_NAME_HEADER_LEFT "headerLeftEnum"
  115. #define PS_RESOURCE_NAME_HEADER_RIGHT "headerRightEnum"
  116. #define PS_RESOURCE_NAME_FOOTER_LEFT "footerLeftEnum"
  117. #define PS_RESOURCE_NAME_FOOTER_RIGHT "footerRightEnum"
  118. #define PS_RESOURCE_NAME_MARGIN_TOP "marginTopSpec"
  119. #define PS_RESOURCE_NAME_MARGIN_RIGHT "marginRightSpec"
  120. #define PS_RESOURCE_NAME_MARGIN_BOTTOM "marginBottomSpec"
  121. #define PS_RESOURCE_NAME_MARGIN_LEFT "marginLeftSpec"
  122. #define PS_RESOURCE_VALUE_NONE "Empty"
  123. #define PS_RESOURCE_VALUE_DATE "Date"
  124. #define PS_RESOURCE_VALUE_DOCNAME "DocName"
  125. #define PS_RESOURCE_VALUE_PAGE_NUMBER "PageNumber"
  126. #define PS_RESOURCE_VALUE_USER_NAME "UserName"
  127. #define PS_RESOURCE_VALUE_DFLT_MARGIN "1.0 in"
  128. typedef struct resource_value
  129. {
  130. PrintStringTypeEnum which;
  131. char *resource_string;
  132. int set_id;
  133. int msg_id;
  134. char *dflt_string;
  135. } ResourceValue;
  136. static ResourceValue _psHdrFtrValues[] =
  137. {
  138. { PRINT_NONE_STRING_TYPE_ENUM,
  139. PS_RESOURCE_VALUE_NONE,
  140. 15, 1, "None"
  141. },
  142. { PRINT_DATE_STRING_TYPE_ENUM,
  143. PS_RESOURCE_VALUE_DATE,
  144. 15, 2, "Date"
  145. },
  146. { PRINT_DOCNAME_STRING_TYPE_ENUM,
  147. PS_RESOURCE_VALUE_DOCNAME,
  148. 15, 3, "Document Name"
  149. },
  150. { PRINT_PAGE_NUMBER_STRING_TYPE_ENUM,
  151. PS_RESOURCE_VALUE_PAGE_NUMBER,
  152. 15, 4, "Page Number"
  153. },
  154. { PRINT_USER_NAME_STRING_TYPE_ENUM,
  155. PS_RESOURCE_VALUE_USER_NAME,
  156. 15, 5, "User Name"
  157. }
  158. };
  159. static Widget _psDefaultPrintSetupDialog = (Widget) NULL;
  160. static char *_psDefaultMargin = PS_RESOURCE_VALUE_DFLT_MARGIN;
  161. static XtResource _psResources[] = {
  162. {PS_RESOURCE_NAME_FOOTER_LEFT, "FooterLeftEnum", XmRInt, sizeof(int),
  163. XtOffset(PrintOptions*, footerLeft),
  164. XmRImmediate, (XtPointer) PRINT_NONE_STRING_TYPE_ENUM,
  165. },
  166. {PS_RESOURCE_NAME_FOOTER_RIGHT, "FooterRightEnum", XmRInt, sizeof(int),
  167. XtOffset(PrintOptions*, footerRight),
  168. XmRImmediate, (XtPointer) PRINT_PAGE_NUMBER_STRING_TYPE_ENUM,
  169. },
  170. {PS_RESOURCE_NAME_HEADER_LEFT, "HeaderLeftEnum", XmRInt, sizeof(int),
  171. XtOffset(PrintOptions*, headerLeft),
  172. XmRImmediate, (XtPointer) PRINT_NONE_STRING_TYPE_ENUM,
  173. },
  174. {PS_RESOURCE_NAME_HEADER_RIGHT, "HeaderRightEnum", XmRInt, sizeof(int),
  175. XtOffset(PrintOptions*, headerRight),
  176. XmRImmediate, (XtPointer) PRINT_DOCNAME_STRING_TYPE_ENUM,
  177. },
  178. {PS_RESOURCE_NAME_MARGIN_BOTTOM, "MarginBottomSpec", XmRString, sizeof(String),
  179. XtOffset(PrintOptions*, marginBottom),
  180. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  181. },
  182. {PS_RESOURCE_NAME_MARGIN_LEFT, "MarginLeftSpec", XmRString, sizeof(String),
  183. XtOffset(PrintOptions*, marginLeft),
  184. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  185. },
  186. {PS_RESOURCE_NAME_MARGIN_RIGHT, "MarginRightSpec", XmRString, sizeof(String),
  187. XtOffset(PrintOptions*, marginRight),
  188. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  189. },
  190. {PS_RESOURCE_NAME_MARGIN_TOP, "MarginTopSpec", XmRString, sizeof(String),
  191. XtOffset(PrintOptions*, marginTop),
  192. XmRString, (XtPointer) PS_RESOURCE_VALUE_DFLT_MARGIN,
  193. }
  194. };
  195. /************************************************************************
  196. * PrintSetupCreate
  197. * Class constructor.
  198. * Adds dtpad specific items to the passed print setup box.
  199. * The document file name is presented in the bottom work area.
  200. ************************************************************************/
  201. PrintSetup *
  202. PrintSetupCreate(
  203. Widget parent,
  204. char *docName,
  205. Boolean wordWrap,
  206. Editor *pPad,
  207. XtCallbackProc cancelCB, XtPointer cancelClosure,
  208. XtCallbackProc closeDisplayCB, XtPointer closeDisplayClosure,
  209. XtCallbackProc printCB, XtPointer printClosure,
  210. XtCallbackProc setupCB, XtPointer setupClosure
  211. )
  212. {
  213. Widget w;
  214. XmString xms;
  215. unsigned char is_set;
  216. PrintSetup *pSetup;
  217. Widget *menu_buttons;
  218. int nitems;
  219. char **strings;
  220. void **data;
  221. int i;
  222. pSetup = (PrintSetup *) XtMalloc( sizeof(PrintSetup) );
  223. pSetup->parent = parent;
  224. pSetup->docName = strdup(docName);
  225. pSetup->cancelCB = cancelCB;
  226. pSetup->closeDisplayCB = closeDisplayCB;
  227. pSetup->printCB = printCB;
  228. pSetup->setupCB = setupCB;
  229. pSetup->cancelClosure = cancelClosure;
  230. pSetup->closeDisplayClosure = closeDisplayClosure;
  231. pSetup->printClosure = printClosure;
  232. pSetup->setupClosure = setupClosure;
  233. pSetup->pPad = pPad;
  234. pSetup->dtprintSetup = (Widget) NULL;
  235. pSetup->widgets = (psWidgets *) NULL;
  236. /*
  237. * Get the current default values for the app-specific printing options.
  238. */
  239. _psSourceToSetup(pSetup, wordWrap);
  240. /*
  241. * Get a print setup dialog.
  242. */
  243. _psAttachPrintSetupDialog(pSetup, pPad);
  244. return pSetup;
  245. }
  246. /************************************************************************
  247. * PrintSetupDestroy
  248. * Class destructor.
  249. ************************************************************************/
  250. void
  251. PrintSetupDestroy(PrintSetup *pSetup)
  252. {
  253. if (pSetup == NULL) return;
  254. if (pSetup->docName)
  255. free(pSetup->docName);
  256. if (pSetup->dtprintSetup);
  257. _psReleasePrintSetupDialog(pSetup);
  258. XtFree((char*) pSetup);
  259. }
  260. /************************************************************************
  261. * PrintSetupDisplay
  262. * Displays the specified print setup GUI.
  263. ************************************************************************/
  264. void
  265. PrintSetupDisplay(PrintSetup *pSetup)
  266. {
  267. if (pSetup == NULL) return;
  268. /*
  269. * Initialize the print setup Ui.
  270. */
  271. _psSetupToUi(pSetup);
  272. XtManageChild(pSetup->dtprintSetup);
  273. XtMapWidget(pSetup->dtprintSetup);
  274. }
  275. /************************************************************************
  276. * PrintSetupHide
  277. * Hides the specified print setup GUI.
  278. ************************************************************************/
  279. void
  280. PrintSetupHide(PrintSetup *pSetup)
  281. {
  282. if (pSetup == NULL) return;
  283. if (pSetup->dtprintSetup == NULL) return;
  284. XtUnmanageChild(pSetup->dtprintSetup);
  285. XtUnmapWidget(pSetup->dtprintSetup);
  286. }
  287. /************************************************************************
  288. * PrintSetupGetHdrFtrSpec
  289. * Returns the current value of the specified header/footer print option.
  290. ************************************************************************/
  291. PrintStringTypeEnum
  292. PrintSetupGetHdrFtrSpec(PrintSetup *pSetup, _DtPrintHdrFtrEnum which)
  293. {
  294. PrintStringTypeEnum rtn;
  295. if (pSetup == NULL) return PRINT_NONE_STRING_TYPE_ENUM;
  296. switch (which)
  297. {
  298. case DTPRINT_OPTION_HEADER_LEFT:
  299. rtn = pSetup->options.headerLeft;
  300. break;
  301. case DTPRINT_OPTION_HEADER_RIGHT:
  302. rtn = pSetup->options.headerRight;
  303. break;
  304. case DTPRINT_OPTION_FOOTER_LEFT:
  305. rtn = pSetup->options.footerLeft;
  306. break;
  307. case DTPRINT_OPTION_FOOTER_RIGHT:
  308. default:
  309. rtn = pSetup->options.footerRight;
  310. break;
  311. }
  312. return rtn;
  313. }
  314. /************************************************************************
  315. * PrintSetupGetMarginSpec
  316. * Returns the current value of the specified margin print option.
  317. ************************************************************************/
  318. char *
  319. PrintSetupGetMarginSpec(PrintSetup *pSetup, _DtPrintMarginEnum which)
  320. {
  321. char *rtn;
  322. if (pSetup == NULL) return _psDefaultMargin;
  323. switch (which)
  324. {
  325. case DTPRINT_OPTION_MARGIN_TOP:
  326. rtn = pSetup->options.marginTop;
  327. break;
  328. case DTPRINT_OPTION_MARGIN_RIGHT:
  329. rtn = pSetup->options.marginRight;
  330. break;
  331. case DTPRINT_OPTION_MARGIN_BOTTOM:
  332. rtn = pSetup->options.marginBottom;
  333. break;
  334. case DTPRINT_OPTION_MARGIN_LEFT:
  335. default:
  336. rtn = pSetup->options.marginLeft;
  337. break;
  338. }
  339. return rtn;
  340. }
  341. /************************************************************************
  342. * PrintSetupGetDefaultPrintData
  343. * Returns the current value of the print data in the pData variable.
  344. ************************************************************************/
  345. Boolean
  346. PrintSetupGetDefaultPrintData(PrintSetup *pSetup, DtPrintSetupData *pData)
  347. {
  348. if (pSetup == NULL || pData == NULL) return FALSE;
  349. return (DtPRINT_SUCCESS == DtPrintFillSetupData(
  350. pSetup->dtprintSetup,
  351. pData));
  352. }
  353. /************************************************************************
  354. * PrintSetupUseWordWrap
  355. * Returns the current value of word wrap print option.
  356. ************************************************************************/
  357. Boolean
  358. PrintSetupUseWordWrap(PrintSetup *pSetup)
  359. {
  360. if (pSetup == NULL) return TRUE;
  361. return pSetup->options.wordWrap;
  362. }
  363. /*******************************************************************************
  364. *******************************************************************************
  365. *
  366. * Static Functions
  367. *
  368. *******************************************************************************
  369. ******************************************************************************/
  370. /************************************************************************
  371. * _psGetResourceFileName
  372. ************************************************************************/
  373. static char*
  374. _psGetResourceFileName(PrintSetup *pSetup)
  375. {
  376. #define BUFFER_SIZE 256
  377. extern Widget topLevelWithWmCommand;
  378. static char buffer[BUFFER_SIZE];
  379. static char *dtpadrc = NULL;
  380. char *savePath, *saveFile;
  381. #ifdef hpV4
  382. return XtNewString("/tmp/dtpadrc");
  383. #else
  384. if (dtpadrc != NULL) return XtNewString(dtpadrc);
  385. savePath = NULL;
  386. saveFile = PS_DEFAULT_RESOURCE_FILE;
  387. if (! DtSessionSavePath(topLevelWithWmCommand, &savePath, &saveFile))
  388. {
  389. sprintf(
  390. buffer, "%s/%s/%s",
  391. getenv(PS_HOME_ENV_VARIABLE),
  392. DtPERSONAL_TMP_DIRECTORY,
  393. PS_DEFAULT_RESOURCE_FILE);
  394. savePath = buffer;
  395. }
  396. dtpadrc = XtNewString(savePath);
  397. return XtNewString(dtpadrc);
  398. #endif
  399. }
  400. /************************************************************************
  401. * _psSourceToSetup
  402. ************************************************************************/
  403. static void
  404. _psSourceToSetup(PrintSetup *pSetup, Boolean wordWrap)
  405. {
  406. XrmDatabase database;
  407. char *dtpadrc;
  408. PrintOptions pOption;
  409. if (pSetup == NULL) return;
  410. dtpadrc = _psGetResourceFileName(pSetup);
  411. database = XtDatabase(XtDisplay(pSetup->parent));
  412. XrmCombineFileDatabase(dtpadrc, &database, TRUE);
  413. XtFree(dtpadrc);
  414. /* Get the application resources */
  415. XtGetApplicationResources(
  416. pSetup->parent, &pOption,
  417. _psResources, XtNumber(_psResources),
  418. NULL, 0);
  419. pSetup->options.footerLeft = pOption.footerLeft;
  420. pSetup->options.footerRight = pOption.footerRight;
  421. pSetup->options.headerLeft = pOption.headerLeft;
  422. pSetup->options.headerRight = pOption.headerRight;
  423. pSetup->options.marginBottom = XtNewString(pOption.marginBottom);
  424. pSetup->options.marginLeft = XtNewString(pOption.marginLeft);
  425. pSetup->options.marginRight = XtNewString(pOption.marginRight);
  426. pSetup->options.marginTop = XtNewString(pOption.marginTop);
  427. pSetup->options.wordWrap = wordWrap;
  428. }
  429. /************************************************************************
  430. * _psSetupToSource
  431. ************************************************************************/
  432. static void
  433. _psSetupToSource(PrintSetup *pSetup)
  434. {
  435. PrintOptions *pOption;
  436. FILE *fp;
  437. char *dtpadrc;
  438. if (pSetup == NULL) return;
  439. pOption = &pSetup->options;
  440. dtpadrc = _psGetResourceFileName(pSetup);
  441. fp = fopen(dtpadrc, "wb");
  442. if (fp == NULL)
  443. {
  444. /* TBD: Error message. */
  445. fprintf(
  446. stderr,
  447. "_psSetupToSource: Cannot open resource file '%s'\n",
  448. dtpadrc);
  449. return;
  450. }
  451. XtFree(dtpadrc);
  452. fprintf(
  453. fp,
  454. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  455. PS_RESOURCE_NAME_HEADER_LEFT,
  456. pOption->headerLeft
  457. );
  458. fprintf(
  459. fp,
  460. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  461. PS_RESOURCE_NAME_HEADER_RIGHT,
  462. pOption->headerRight
  463. );
  464. fprintf(
  465. fp,
  466. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  467. PS_RESOURCE_NAME_FOOTER_LEFT,
  468. pOption->footerLeft
  469. );
  470. fprintf(
  471. fp,
  472. PS_RESOURCE_HDRFTR_FORMAT_STRING,
  473. PS_RESOURCE_NAME_FOOTER_RIGHT,
  474. pOption->footerRight
  475. );
  476. fprintf(
  477. fp,
  478. PS_RESOURCE_MARGIN_FORMAT_STRING,
  479. PS_RESOURCE_NAME_MARGIN_TOP,
  480. pOption->marginTop
  481. );
  482. fprintf(
  483. fp,
  484. PS_RESOURCE_MARGIN_FORMAT_STRING,
  485. PS_RESOURCE_NAME_MARGIN_RIGHT,
  486. pOption->marginRight
  487. );
  488. fprintf(
  489. fp,
  490. PS_RESOURCE_MARGIN_FORMAT_STRING,
  491. PS_RESOURCE_NAME_MARGIN_BOTTOM,
  492. pOption->marginBottom
  493. );
  494. fprintf(
  495. fp,
  496. PS_RESOURCE_MARGIN_FORMAT_STRING,
  497. PS_RESOURCE_NAME_MARGIN_LEFT,
  498. pOption->marginLeft
  499. );
  500. fclose(fp);
  501. }
  502. /************************************************************************
  503. * _psSetupToUi
  504. ************************************************************************/
  505. static void
  506. _psSetupToUi(PrintSetup *pSetup)
  507. {
  508. unsigned char isSet;
  509. Widget frame, w;
  510. PrintOptions *pOption;
  511. if (pSetup == NULL ||
  512. pSetup->dtprintSetup == NULL ||
  513. pSetup->widgets == NULL)
  514. return;
  515. pOption = &pSetup->options;
  516. isSet = (pOption->wordWrap) ? XmSET : XmUNSET;
  517. XtVaSetValues(pSetup->widgets->wordWrapTB, XmNset, isSet, NULL);
  518. frame = pSetup->widgets->hdrftrFrame;
  519. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_LEFT);
  520. _DtPrintSetHdrFtrByData(w, (void*) pOption->headerLeft);
  521. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_RIGHT);
  522. _DtPrintSetHdrFtrByData(w, (void*) pOption->headerRight);
  523. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_LEFT);
  524. _DtPrintSetHdrFtrByData(w, (void*) pOption->footerLeft);
  525. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_RIGHT);
  526. _DtPrintSetHdrFtrByData(w, (void*) pOption->footerRight);
  527. frame = pSetup->widgets->marginFrame;
  528. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  529. _DtPrintSetMarginSpec(w, pOption->marginTop);
  530. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  531. _DtPrintSetMarginSpec(w, pOption->marginRight);
  532. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  533. _DtPrintSetMarginSpec(w, pOption->marginBottom);
  534. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  535. _DtPrintSetMarginSpec(w, pOption->marginLeft);
  536. }
  537. /************************************************************************
  538. * _psUiToSetup
  539. ************************************************************************/
  540. static void
  541. _psUiToSetup(PrintSetup *pSetup)
  542. {
  543. XtArgVal isSet;
  544. Widget frame, w;
  545. PrintOptions *pOption;
  546. char *marginSpec;
  547. Boolean error = FALSE;
  548. if (pSetup == NULL ||
  549. pSetup->dtprintSetup == NULL ||
  550. pSetup->widgets == NULL)
  551. return;
  552. pOption = &pSetup->options;
  553. XtVaGetValues(pSetup->widgets->wordWrapTB, XmNset, &isSet, NULL);
  554. pOption->wordWrap = (isSet == XmUNSET) ? FALSE : TRUE;
  555. frame = pSetup->widgets->hdrftrFrame;
  556. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_LEFT);
  557. pOption->headerLeft = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  558. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_HEADER_RIGHT);
  559. pOption->headerRight = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  560. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_LEFT);
  561. pOption->footerLeft = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  562. w = _DtPrintHdrFtrFrameEnumToWidget(frame, DTPRINT_OPTION_FOOTER_RIGHT);
  563. pOption->footerRight = (PrintStringTypeEnum) _DtPrintGetHdrFtrData(w);
  564. frame = pSetup->widgets->marginFrame;
  565. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  566. marginSpec = _DtPrintGetMarginSpec(w);
  567. if (pOption->marginTop != NULL)
  568. XtFree(pOption->marginTop);
  569. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  570. pOption->marginTop = XtNewString(_psDefaultMargin);
  571. else
  572. pOption->marginTop = marginSpec;
  573. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  574. marginSpec = _DtPrintGetMarginSpec(w);
  575. if (pOption->marginRight != NULL)
  576. XtFree(pOption->marginRight);
  577. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  578. pOption->marginRight = XtNewString(_psDefaultMargin);
  579. else
  580. pOption->marginRight = marginSpec;
  581. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  582. marginSpec = _DtPrintGetMarginSpec(w);
  583. if (pOption->marginBottom != NULL)
  584. XtFree(pOption->marginBottom);
  585. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  586. pOption->marginBottom = XtNewString(_psDefaultMargin);
  587. else
  588. pOption->marginBottom = marginSpec;
  589. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  590. marginSpec = _DtPrintGetMarginSpec(w);
  591. if (pOption->marginLeft != NULL)
  592. XtFree(pOption->marginLeft);
  593. if (marginSpec == NULL || strcmp("", marginSpec) == 0)
  594. pOption->marginLeft = XtNewString(_psDefaultMargin);
  595. else
  596. pOption->marginLeft = marginSpec;
  597. }
  598. /************************************************************************
  599. * _psUiSpecsAreValid
  600. ************************************************************************/
  601. static Boolean
  602. _psUiSpecsAreValid(PrintSetup *pSetup)
  603. {
  604. unsigned char isSet;
  605. Widget frame, w;
  606. PrintOptions *pOption;
  607. char *marginSpec;
  608. if (pSetup == NULL ||
  609. pSetup->dtprintSetup == NULL ||
  610. pSetup->widgets == NULL)
  611. return 0;
  612. pOption = &pSetup->options;
  613. frame = pSetup->widgets->marginFrame;
  614. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_TOP);
  615. marginSpec = _DtPrintGetMarginSpec(w);
  616. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  617. {
  618. XtEnum parseError = FALSE;
  619. (void) XmConvertStringToUnits(
  620. XtScreenOfObject(pSetup->parent),
  621. marginSpec,
  622. XmVERTICAL,
  623. XmPIXELS,
  624. &parseError);
  625. if (parseError)
  626. {
  627. char *i18nMsg;
  628. char *errMsg;
  629. i18nMsg = GETMESSAGE(15, 6, "Top Margin specifier is invalid: ");
  630. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  631. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  632. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  633. XtFree(errMsg);
  634. return FALSE;
  635. }
  636. }
  637. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_RIGHT);
  638. marginSpec = _DtPrintGetMarginSpec(w);
  639. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  640. {
  641. XtEnum parseError = FALSE;
  642. (void) XmConvertStringToUnits(
  643. XtScreenOfObject(pSetup->parent),
  644. marginSpec,
  645. XmHORIZONTAL,
  646. XmPIXELS,
  647. &parseError);
  648. if (parseError)
  649. {
  650. char *i18nMsg;
  651. char *errMsg;
  652. i18nMsg =
  653. GETMESSAGE(15, 7, "Right Margin specifier is invalid: ");
  654. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  655. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  656. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  657. XtFree(errMsg);
  658. return FALSE;
  659. }
  660. }
  661. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_BOTTOM);
  662. marginSpec = _DtPrintGetMarginSpec(w);
  663. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  664. {
  665. XtEnum parseError = FALSE;
  666. (void) XmConvertStringToUnits(
  667. XtScreenOfObject(pSetup->parent),
  668. marginSpec,
  669. XmVERTICAL,
  670. XmPIXELS,
  671. &parseError);
  672. if (parseError)
  673. {
  674. char *i18nMsg;
  675. char *errMsg;
  676. i18nMsg =
  677. GETMESSAGE(15, 8, "Bottom Margin specifier is invalid: ");
  678. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  679. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  680. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  681. XtFree(errMsg);
  682. return FALSE;
  683. }
  684. }
  685. w = _DtPrintMarginFrameEnumToWidget(frame, DTPRINT_OPTION_MARGIN_LEFT);
  686. marginSpec = _DtPrintGetMarginSpec(w);
  687. if (marginSpec != NULL && strcmp("", marginSpec) != 0)
  688. {
  689. XtEnum parseError = FALSE;
  690. (void) XmConvertStringToUnits(
  691. XtScreenOfObject(pSetup->parent),
  692. marginSpec,
  693. XmHORIZONTAL,
  694. XmPIXELS,
  695. &parseError);
  696. if (parseError)
  697. {
  698. char *i18nMsg;
  699. char *errMsg;
  700. i18nMsg = GETMESSAGE(15, 9, "Left Margin specifier is invalid: ");
  701. errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
  702. sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
  703. Warning(pSetup->pPad, (char *) errMsg, XmDIALOG_WARNING);
  704. XtFree(errMsg);
  705. return FALSE;
  706. }
  707. }
  708. return TRUE;
  709. }
  710. /*
  711. * _psAttachPrintSetupDialog
  712. * Creates the widgets for the Setup Dialog.
  713. */
  714. static void
  715. _psAttachPrintSetupDialog(PrintSetup *pSetup, Editor *pPad)
  716. {
  717. char *title, *titlePrefix, *titleParent;
  718. XmString xms;
  719. Widget dialog;
  720. unsigned char is_set;
  721. #ifdef REUSE_PRINT_SETUP_DIALOGS
  722. if (_psDefaultPrintSetupDialog != NULL)
  723. {
  724. /*
  725. * Attempt to reuse the last print setup and print display connection.
  726. */
  727. pSetup->dtprintSetup = _psDefaultPrintSetupDialog;
  728. _psDefaultPrintSetupDialog = NULL;
  729. }
  730. else
  731. #endif
  732. {
  733. char *dirname;
  734. pSetup->dtprintSetup = _psCreatePrintSetupDialog(pSetup->parent, pPad);
  735. dirname = getenv("HOME");
  736. if (dirname)
  737. {
  738. char path[MAXPATHLEN+1];
  739. char *filename;
  740. filename = strrchr(pSetup->docName, '/');
  741. if (NULL == filename)
  742. filename = pSetup->docName;
  743. else
  744. filename++;
  745. sprintf(path, "%s/%s.ps", dirname, filename);
  746. XtVaSetValues(pSetup->dtprintSetup, DtNfileName, path, NULL);
  747. }
  748. }
  749. /*
  750. * Copy the information about the widgets into the setup.
  751. */
  752. XtVaGetValues(pSetup->dtprintSetup, XmNuserData, &pSetup->widgets, NULL);
  753. /*
  754. * Add the setup-specific callbacks.
  755. */
  756. XtAddCallback(
  757. pSetup->dtprintSetup,
  758. DtNcancelCallback,
  759. _psPrintSetupCancelCB,
  760. (XtPointer) pSetup);
  761. XtAddCallback(
  762. pSetup->dtprintSetup,
  763. DtNclosePrintDisplayCallback,
  764. pSetup->closeDisplayCB,
  765. (XtPointer) pSetup->closeDisplayClosure);
  766. XtAddCallback(
  767. pSetup->dtprintSetup,
  768. DtNprintCallback,
  769. _psPrintSetupPrintCB,
  770. (XtPointer) pSetup);
  771. XtAddCallback(
  772. pSetup->dtprintSetup,
  773. DtNsetupCallback,
  774. pSetup->setupCB,
  775. (XtPointer) pSetup->setupClosure);
  776. xms = XmStringCreateLocalized(pSetup->docName);
  777. XtVaSetValues(pSetup->widgets->docNameLabel, XmNlabelString, xms, NULL);
  778. XmStringFree(xms);
  779. dialog = XtParent(pSetup->widgets->dtprintSetup);
  780. if (NULL != dialog && XtIsShell(dialog))
  781. {
  782. titleParent = (char*) GETMESSAGE(7, 2, "Text Editor - ");
  783. titlePrefix = (char*) GETMESSAGE(14, 23, "Print Setup - ");
  784. title =
  785. (char*) XtMalloc(strlen(titleParent) + strlen(titlePrefix) + strlen(pSetup->docName) + 1);
  786. sprintf(title, "%s%s%s", titleParent, titlePrefix, pSetup->docName);
  787. XtVaSetValues(dialog, XmNtitle, title, NULL);
  788. XtFree(title);
  789. }
  790. else
  791. {
  792. fprintf(stderr, "Print Setup box is not parented to a shell\n");
  793. }
  794. is_set = (pSetup->options.wordWrap) ? XmSET : XmUNSET;
  795. XtVaSetValues(pSetup->widgets->wordWrapTB, XmNset, is_set, NULL);
  796. }
  797. /*
  798. * _psCreatePrintSetupDialog
  799. * Creates the widgets for the Setup Dialog.
  800. */
  801. static Widget
  802. _psCreatePrintSetupDialog(Widget parent, Editor *pPad)
  803. {
  804. Arg args[2];
  805. int nargs;
  806. psWidgets *widgets;
  807. Widget w;
  808. XmString xms;
  809. unsigned char is_set;
  810. int nitems;
  811. char **strings;
  812. void **data;
  813. int i;
  814. /*
  815. * Create the widgets for the Setup Dialog.
  816. */
  817. widgets = (psWidgets *) XtMalloc(sizeof(psWidgets));
  818. /*
  819. * Create the DtPrintSetupDialog and specify that the application
  820. * specific area be located below the generic area.
  821. */
  822. nargs=0;
  823. XtSetArg(args[nargs], XmNautoUnmanage, FALSE); nargs++;
  824. widgets->dtprintSetup =
  825. DtCreatePrintSetupDialog(parent, "DtPrintSetup", args, nargs);
  826. XtVaSetValues(
  827. widgets->dtprintSetup,
  828. DtNworkAreaLocation, DtWORK_AREA_BOTTOM,
  829. XmNuserData, widgets,
  830. NULL);
  831. XtAddCallback(
  832. widgets->dtprintSetup,
  833. XmNhelpCallback,
  834. HelpPrintSetupDialogCB,
  835. (XtPointer) pPad);
  836. XtAddCallback(
  837. widgets->dtprintSetup,
  838. XmNdestroyCallback,
  839. _psPrintSetupDestroyCB,
  840. (XtPointer) widgets);
  841. /*
  842. * Create the dtpad-specific setup dialog in the bottom work area
  843. */
  844. widgets->form = XtVaCreateManagedWidget(
  845. "SetupForm",
  846. xmFormWidgetClass,
  847. widgets->dtprintSetup,
  848. NULL);
  849. XtAddCallback(
  850. widgets->form,
  851. XmNhelpCallback,
  852. HelpPrintSetupAppSpecificCB,
  853. (XtPointer) pPad);
  854. /*
  855. * Create the document name title label
  856. */
  857. xms = XmStringCreateLocalized( GETMESSAGE(14, 12, "Document Name: ") );
  858. widgets->docLabel = XtVaCreateManagedWidget(
  859. "DocumentLable",
  860. xmLabelGadgetClass,
  861. widgets->form,
  862. XmNleftAttachment, XmATTACH_FORM,
  863. XmNtopAttachment, XmATTACH_FORM,
  864. XmNlabelString, xms,
  865. NULL);
  866. XmStringFree(xms);
  867. /*
  868. * Create the document name label
  869. */
  870. widgets->docNameLabel = XtVaCreateManagedWidget(
  871. "DocumentName",
  872. xmLabelGadgetClass,
  873. widgets->form,
  874. XmNleftAttachment, XmATTACH_WIDGET,
  875. XmNleftWidget, widgets->docLabel,
  876. #if 0
  877. XmNrightAttachment, XmATTACH_FORM,
  878. #endif
  879. XmNtopAttachment, XmATTACH_FORM,
  880. NULL);
  881. xms = XmStringCreateLocalized(GETMESSAGE(14, 13, "Wrap To Fit"));
  882. widgets->wordWrapTB = XtVaCreateManagedWidget(
  883. "WrapToFit",
  884. xmToggleButtonWidgetClass,
  885. widgets->form,
  886. XmNalignment, XmALIGNMENT_BEGINNING,
  887. XmNlabelString, xms,
  888. XmNleftAttachment, XmATTACH_FORM,
  889. XmNrightAttachment, XmATTACH_FORM,
  890. XmNtopAttachment, XmATTACH_WIDGET,
  891. XmNtopWidget, widgets->docLabel,
  892. NULL);
  893. XmStringFree(xms);
  894. /*
  895. * Create GUI for the Header/Footer options
  896. */
  897. nitems = PS_ARRAY_SIZE(_psHdrFtrValues);
  898. strings = (char **) XtMalloc( nitems * sizeof(char*) );
  899. data = (void **) XtMalloc( nitems * sizeof(void*) );
  900. for (i=0; i<nitems; i++)
  901. {
  902. data[i] = (void*) _psHdrFtrValues[i].which;
  903. strings[i] = GETMESSAGE(
  904. _psHdrFtrValues[i].set_id,
  905. _psHdrFtrValues[i].msg_id,
  906. _psHdrFtrValues[i].dflt_string
  907. );
  908. }
  909. #if 0
  910. /*
  911. * Create GUI for the Header/Footer options
  912. */
  913. widgets->hdrftrFrame =
  914. _DtPrintCreateHdrFtrFrame(widgets->form, nitems, strings, data);
  915. XtVaSetValues(
  916. widgets->hdrftrFrame,
  917. XmNtopAttachment, XmATTACH_WIDGET,
  918. XmNtopWidget, widgets->wordWrapTB,
  919. XmNleftAttachment, XmATTACH_FORM,
  920. NULL);
  921. XtManageChild(widgets->hdrftrFrame);
  922. /*
  923. * Create GUI for the Margin options
  924. */
  925. widgets->marginFrame = _DtPrintCreateMarginFrame(widgets->form);
  926. XtVaSetValues(
  927. widgets->marginFrame,
  928. XmNtopAttachment, XmATTACH_WIDGET,
  929. XmNtopWidget, widgets->hdrftrFrame,
  930. XmNleftAttachment, XmATTACH_FORM,
  931. NULL);
  932. XtManageChild(widgets->marginFrame);
  933. #else
  934. /*
  935. * Create GUI for the Margin options
  936. */
  937. widgets->marginFrame = _DtPrintCreateMarginFrame(widgets->form);
  938. XtVaSetValues(
  939. widgets->marginFrame,
  940. XmNtopAttachment, XmATTACH_WIDGET,
  941. XmNtopWidget, widgets->wordWrapTB,
  942. XmNleftAttachment, XmATTACH_FORM,
  943. NULL);
  944. XtManageChild(widgets->marginFrame);
  945. /*
  946. * Create GUI for the Header/Footer options
  947. */
  948. widgets->hdrftrFrame =
  949. _DtPrintCreateHdrFtrFrame(widgets->form, nitems, strings, data);
  950. XtVaSetValues(
  951. widgets->hdrftrFrame,
  952. XmNtopAttachment, XmATTACH_WIDGET,
  953. XmNtopWidget, widgets->wordWrapTB,
  954. XmNtopWidget, widgets->marginFrame,
  955. XmNleftAttachment, XmATTACH_FORM,
  956. NULL);
  957. XtManageChild(widgets->hdrftrFrame);
  958. #endif
  959. XtAddCallback(
  960. widgets->hdrftrFrame,
  961. XmNhelpCallback,
  962. HelpPrintSetupPageHeadersFootersCB,
  963. (XtPointer) pPad);
  964. XtAddCallback(
  965. widgets->marginFrame,
  966. XmNhelpCallback,
  967. HelpPrintSetupPageMargins,
  968. (XtPointer) pPad);
  969. XtRealizeWidget(widgets->dtprintSetup);
  970. return widgets->dtprintSetup;
  971. }
  972. /*
  973. * _psReleasePrintSetupDialog
  974. * Removes setup-specific callbacks.
  975. */
  976. static void
  977. _psReleasePrintSetupDialog(PrintSetup *pSetup)
  978. {
  979. /*
  980. * Remove the setup-specific callbacks.
  981. */
  982. XtRemoveCallback(
  983. pSetup->dtprintSetup,
  984. DtNcancelCallback,
  985. _psPrintSetupCancelCB,
  986. (XtPointer) pSetup);
  987. XtRemoveCallback(
  988. pSetup->dtprintSetup,
  989. DtNclosePrintDisplayCallback,
  990. pSetup->closeDisplayCB,
  991. (XtPointer) pSetup->closeDisplayClosure);
  992. XtRemoveCallback(
  993. pSetup->dtprintSetup,
  994. DtNprintCallback,
  995. _psPrintSetupPrintCB,
  996. (XtPointer) pSetup);
  997. XtRemoveCallback(
  998. pSetup->dtprintSetup,
  999. DtNsetupCallback,
  1000. pSetup->setupCB,
  1001. (XtPointer) pSetup->setupClosure);
  1002. #ifdef REUSE_PRINT_SETUP_DIALOGS
  1003. if (_psDefaultPrintSetupDialog != NULL)
  1004. {
  1005. /*
  1006. * Attempt to reuse the last print setup and print display connection.
  1007. */
  1008. XtDestroyWidget(_psDefaultPrintSetupDialog);
  1009. _psDefaultPrintSetupDialog = NULL;
  1010. }
  1011. _psDefaultPrintSetupDialog = pSetup->dtprintSetup;
  1012. #else
  1013. XtDestroyWidget(pSetup->dtprintSetup);
  1014. #endif
  1015. }
  1016. /*
  1017. * _psPrintSetupCancelCB
  1018. */
  1019. static void
  1020. _psPrintSetupCancelCB(
  1021. Widget dtprintSetup,
  1022. XtPointer client_data,
  1023. XtPointer call_data)
  1024. {
  1025. PrintSetup *pSetup = (PrintSetup*) client_data;
  1026. PrintSetupHide(pSetup);
  1027. pSetup->cancelCB(dtprintSetup, pSetup->cancelClosure, call_data);
  1028. }
  1029. /*
  1030. * _psPrintSetupDestroyCB
  1031. */
  1032. static void
  1033. _psPrintSetupDestroyCB(
  1034. Widget dtprintSetup,
  1035. XtPointer client_data,
  1036. XtPointer call_data)
  1037. {
  1038. psWidgets *widgets;
  1039. XtVaGetValues(dtprintSetup, XmNuserData, &widgets, NULL);
  1040. XtFree((XtPointer) widgets);
  1041. }
  1042. /*
  1043. * _psPrintSetupPrintCB
  1044. */
  1045. static void
  1046. _psPrintSetupPrintCB(
  1047. Widget dtprintSetup,
  1048. XtPointer client_data,
  1049. XtPointer call_data)
  1050. {
  1051. PrintSetup *pSetup = (PrintSetup*) client_data;
  1052. Boolean error = FALSE;
  1053. if (! _psUiSpecsAreValid(pSetup)) return;
  1054. PrintSetupHide(pSetup);
  1055. _psUiToSetup(pSetup);
  1056. _psSetupToSource(pSetup);
  1057. pSetup->printCB(dtprintSetup, pSetup->printClosure, call_data);
  1058. }