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