PrintDlgMgr.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. /* $XConsortium: PrintDlgMgr.c /main/7 1996/08/12 18:40:50 cde-hp $ */
  24. /*
  25. * DtPrint/PrintDlgMgr.c
  26. */
  27. /*
  28. * (c) Copyright 1996 Digital Equipment Corporation.
  29. * (c) Copyright 1996 Hewlett-Packard Company.
  30. * (c) Copyright 1996 International Business Machines Corp.
  31. * (c) Copyright 1996 Sun Microsystems, Inc.
  32. * (c) Copyright 1996 Novell, Inc.
  33. * (c) Copyright 1996 FUJITSU LIMITED.
  34. * (c) Copyright 1996 Hitachi.
  35. */
  36. #include <Dt/PrintDlgMgrP.h>
  37. #include <Dt/PrintMsgsP.h>
  38. #include <Xm/XmAll.h>
  39. #define SEND_MAIL_LABEL DTPRINT_GETMESSAGE( \
  40. MS_PrintDlgMgrSet, DTPDM_SEND_MAIL_LABEL, _DtPrMsgPrintDlgMgr_0000)
  41. #define BANNER_LABEL DTPRINT_GETMESSAGE( \
  42. MS_PrintDlgMgrSet, DTPDM_BANNER_LABEL, _DtPrMsgPrintDlgMgr_0001)
  43. #define SPOOL_OPTS_LABEL DTPRINT_GETMESSAGE( \
  44. MS_PrintDlgMgrSet, DTPDM_SPOOL_OPTS_LABEL, _DtPrMsgPrintDlgMgr_0002)
  45. Widget _DtCreatePDMJobSetup(Widget parent)
  46. {
  47. Widget manager;
  48. Widget send_mail, banner_label, banner, spool_opts_label, spool_opts;
  49. XmString label;
  50. Dimension banner_label_width, banner_label_height;
  51. Dimension banner_height;
  52. Dimension spool_opts_label_width, spool_opts_label_height;
  53. Dimension spool_opts_height;
  54. Position offset; /* vertical offset between text fields and their labels */
  55. Dimension vspace = 10; /* space between the "rows" */
  56. /*
  57. * create the manager for the Job Setup Box
  58. */
  59. manager =
  60. XtVaCreateManagedWidget("JobSetup", xmFormWidgetClass, parent,
  61. XmNallowOverlap, False,
  62. NULL);
  63. /*
  64. * send mail control
  65. */
  66. label = XmStringCreateLocalized(SEND_MAIL_LABEL);
  67. send_mail =
  68. XmVaCreateSimpleCheckBox(manager, "SendMail", NULL,
  69. XmVaCHECKBUTTON, label, NULL, NULL, NULL,
  70. NULL);
  71. XmStringFree(label);
  72. XtManageChild(send_mail);
  73. /*
  74. * banner page title
  75. */
  76. label = XmStringCreateLocalized(BANNER_LABEL);
  77. banner_label =
  78. XtVaCreateManagedWidget("BannerLabel",
  79. xmLabelWidgetClass,
  80. manager,
  81. XmNlabelString, label,
  82. XmNalignment, XmALIGNMENT_END,
  83. NULL);
  84. XmStringFree(label);
  85. banner =
  86. XtVaCreateManagedWidget("Banner",
  87. xmTextFieldWidgetClass,
  88. manager,
  89. NULL);
  90. /*
  91. * spooler command options
  92. */
  93. label = XmStringCreateLocalized(SPOOL_OPTS_LABEL);
  94. spool_opts_label =
  95. XtVaCreateManagedWidget("OptionsLabel",
  96. xmLabelWidgetClass,
  97. manager,
  98. XmNlabelString, label,
  99. XmNalignment, XmALIGNMENT_END,
  100. NULL);
  101. XmStringFree(label);
  102. spool_opts =
  103. XtVaCreateManagedWidget("Options",
  104. xmTextFieldWidgetClass,
  105. manager,
  106. NULL);
  107. /*
  108. * retrieve various dimensions of form children
  109. */
  110. XtVaGetValues(banner_label,
  111. XmNwidth, &banner_label_width,
  112. XmNheight, &banner_label_height,
  113. NULL);
  114. XtVaGetValues(banner,
  115. XmNheight, &banner_height,
  116. NULL);
  117. XtVaGetValues(spool_opts_label,
  118. XmNwidth, &spool_opts_label_width,
  119. XmNheight, &spool_opts_label_height,
  120. NULL);
  121. XtVaGetValues(spool_opts,
  122. XmNheight, &spool_opts_height,
  123. NULL);
  124. /*
  125. * set the width of the shorter text field to match the longest
  126. */
  127. if(banner_label_width < spool_opts_label_width)
  128. XtVaSetValues(banner_label,
  129. XmNwidth, spool_opts_label_width,
  130. XmNrecomputeSize, False,
  131. NULL);
  132. else
  133. XtVaSetValues(spool_opts_label,
  134. XmNwidth, banner_label_width,
  135. XmNrecomputeSize, False,
  136. NULL);
  137. /*
  138. * layout the form children
  139. */
  140. XtVaSetValues(send_mail,
  141. XmNleftAttachment, XmATTACH_FORM,
  142. XmNtopAttachment, XmATTACH_FORM,
  143. NULL);
  144. offset = ((Position)banner_height - (Position)banner_label_height) / 2;
  145. XtVaSetValues(banner_label,
  146. XmNleftAttachment, XmATTACH_FORM,
  147. XmNtopAttachment, XmATTACH_WIDGET,
  148. XmNtopWidget, send_mail,
  149. XmNtopOffset, vspace + (offset > 0 ? offset : 0),
  150. NULL);
  151. XtVaSetValues(banner,
  152. XmNleftAttachment, XmATTACH_WIDGET,
  153. XmNleftWidget, banner_label,
  154. XmNrightAttachment, XmATTACH_FORM,
  155. XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
  156. XmNtopWidget, banner_label,
  157. XmNtopOffset, -offset,
  158. NULL);
  159. offset =
  160. ((Position)spool_opts_height - (Position)spool_opts_label_height) / 2;
  161. XtVaSetValues(spool_opts_label,
  162. XmNleftAttachment, XmATTACH_FORM,
  163. XmNtopAttachment, XmATTACH_WIDGET,
  164. XmNtopWidget, banner_label,
  165. XmNtopOffset, vspace + (offset > 0 ? offset : 0),
  166. NULL);
  167. XtVaSetValues(spool_opts,
  168. XmNleftAttachment, XmATTACH_WIDGET,
  169. XmNleftWidget, spool_opts_label,
  170. XmNrightAttachment, XmATTACH_FORM,
  171. XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
  172. XmNtopWidget, spool_opts_label,
  173. XmNtopOffset, -offset,
  174. NULL);
  175. /*
  176. * return the new Job Setup Box
  177. */
  178. return manager;
  179. }