http://ftp.aanet.ru/pub/Linux/X11/apps/xscreensaver-2.31.tar.gz
[xscreensaver] / driver / dialogs-Xm.c
1 /* dialogs-Xm.c --- Motif widgets for demo, options, and password dialogs.
2  * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation.  No representations are made about the suitability of this
9  * software for any purpose.  It is provided "as is" without express or 
10  * implied warranty.
11  */
12
13 /* The code in this file started off its life as the output of XDesigner,
14    but I've since hacked it by hand...  It's a mess, avert your eyes.
15  */
16
17 #ifdef HAVE_CONFIG_H
18 # include "config.h"
19 #endif
20
21 #include <X11/Xatom.h>
22 #include <X11/Intrinsic.h>
23 #include <X11/Shell.h>
24
25 #include <Xm/Xm.h>
26 #include <Xm/DialogS.h>
27 #include <Xm/DrawnB.h>
28 #include <Xm/Form.h>
29 #include <Xm/Label.h>
30 #include <Xm/List.h>
31 #include <Xm/PushB.h>
32 #include <Xm/ScrollBar.h>
33 #include <Xm/Separator.h>
34 #include <Xm/TextF.h>
35 #include <Xm/ToggleB.h>
36
37 #include <Xm/SelectioB.h>
38
39 #include <stdio.h>
40
41 #include "visual.h"     /* for visual_depth() */
42
43 Widget passwd_dialog;
44 Widget passwd_form;
45 Widget roger_label;
46 Widget passwd_label1;
47 Widget passwd_label3;
48 Widget passwd_text;
49 Widget passwd_done;
50 Widget passwd_cancel;
51
52 Widget resources_dialog;
53 Widget resources_form;
54 Widget timeout_text;
55 Widget cycle_text;
56 Widget fade_text;
57 Widget ticks_text;
58 Widget lock_time_text;
59 Widget passwd_time_text;
60 Widget verbose_toggle;
61 Widget cmap_toggle;
62 Widget fade_toggle;
63 Widget unfade_toggle;
64 Widget lock_toggle;
65 Widget res_done;
66 Widget res_cancel;
67
68 Widget demo_dialog;
69 Widget demo_form;
70 Widget label1;
71 Widget label2;
72 Widget text_area;
73 Widget demo_list;
74 Widget text_line;
75 Widget vline;
76 Widget next;
77 Widget prev;
78 Widget edit;
79 Widget done;
80 Widget restart;
81 Widget spacer;
82
83 Widget splash_dialog;
84 Widget splash_form;
85 Widget splash_roger_label;
86 Widget splash_label1;
87 Widget splash_label3;
88 Widget splash_demo;
89 Widget splash_prefs;
90 Widget splash_help;
91
92 void
93 create_passwd_dialog(Widget parent, Visual *visual, Colormap colormap)
94 {
95   Widget shell;
96   Widget  form1;
97   Widget   roger;
98   Widget   dialog;
99   Widget    form2;
100   Widget     label1, label2, label3;
101   Widget    text;
102   Widget    ok, cancel;
103   Widget w;
104   Arg al[64];
105   int ac = 0;
106
107   ac = 0;
108   XtSetArg (al[ac], XmNvisual, visual); ac++;
109   XtSetArg (al[ac], XmNcolormap, colormap); ac++;
110   XtSetArg (al[ac], XmNdepth, visual_depth(XtScreen(parent), visual)); ac++;
111
112   shell = XmCreateDialogShell (parent, "passwdDialog", al, ac);
113
114   form1 = XmCreateForm (shell, "form", 0, 0);
115
116   roger = XmCreateDrawnButton (form1, "rogerLabel", 0, 0);
117
118   dialog = XmCreateSelectionBox (form1, "passwdForm", al, ac);
119
120   form2 = XmCreateForm ( dialog, "form", 0, 0);
121   label1 = XmCreateLabel ( form2, "passwdLabel1", 0, 0);
122   label2 = XmCreateLabel ( form2, "passwdLabel2", 0, 0);
123   label3 = XmCreateLabel ( form2, "passwdLabel3", 0, 0);
124
125   text = XmSelectionBoxGetChild (dialog, XmDIALOG_TEXT);
126   ok = XmSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON);
127   cancel = XmSelectionBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON);
128
129   w = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST_LABEL);
130   if (w) XtUnmanageChild (w);
131   w = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST);
132   if (w) XtUnmanageChild (XtParent(w));
133   w = XmSelectionBoxGetChild (dialog, XmDIALOG_SELECTION_LABEL);
134   if (w) XtUnmanageChild (w);
135   w = XmSelectionBoxGetChild (dialog, XmDIALOG_SEPARATOR);
136   if (w) XtUnmanageChild (w);
137   w = XmSelectionBoxGetChild (dialog, XmDIALOG_APPLY_BUTTON);
138   if (w) XtUnmanageChild (w);
139   w = XmSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
140   if (w) XtUnmanageChild (w);
141
142   XtVaSetValues(label1,
143                 XmNtopAttachment, XmATTACH_FORM,
144                 XmNleftAttachment, XmATTACH_FORM,
145                 XmNrightAttachment, XmATTACH_FORM,
146                 XmNbottomAttachment, XmATTACH_NONE,
147                 0);
148   XtVaSetValues(label2,
149                 XmNtopAttachment, XmATTACH_WIDGET,
150                 XmNtopWidget, label1,
151                 XmNleftAttachment, XmATTACH_FORM,
152                 XmNrightAttachment, XmATTACH_FORM,
153                 XmNbottomAttachment, XmATTACH_NONE,
154                 0);
155   XtVaSetValues(label3,
156                 XmNtopAttachment, XmATTACH_WIDGET,
157                 XmNtopWidget, label2,
158                 XmNleftAttachment, XmATTACH_FORM,
159                 XmNrightAttachment, XmATTACH_FORM,
160                 XmNbottomAttachment, XmATTACH_FORM,
161                 0);
162
163   XtVaSetValues(roger,
164                 XmNsensitive, FALSE,
165                 XmNtopAttachment, XmATTACH_FORM,
166                 XmNleftAttachment, XmATTACH_FORM,
167                 XmNrightAttachment, XmATTACH_NONE,
168                 XmNbottomAttachment, XmATTACH_FORM,
169                 0);
170   XtVaSetValues(dialog,
171                 XmNtopAttachment, XmATTACH_FORM,
172                 XmNleftAttachment, XmATTACH_WIDGET,
173                 XmNleftWidget, roger,
174                 XmNrightAttachment, XmATTACH_FORM,
175                 XmNbottomAttachment, XmATTACH_FORM,
176                 0);
177
178   XtManageChild(label1);
179   XtManageChild(label2);
180   XtManageChild(label3);
181
182   XtManageChild(form2);
183   XtManageChild(text);
184   XtManageChild(ok);
185   XtManageChild(cancel);
186
187   XtManageChild(roger);
188   XtManageChild(dialog);
189
190   {
191     Dimension width = 0, height = 0;
192     XtRealizeWidget(form1);
193     XtVaGetValues(roger, XmNwidth, &width, XmNheight, &height, 0);
194     if (width == height)
195       ;
196     else if (width > height)
197       XtVaSetValues(roger, XmNwidth, width, XmNheight, width, 0);
198     else
199       XtVaSetValues(roger, XmNwidth, height, XmNheight, height, 0);
200   }
201
202   passwd_dialog = shell;
203   passwd_form = form1;
204   roger_label = roger;
205   passwd_label1 = label1;
206   passwd_label3 = label3;
207   passwd_text = text;
208   passwd_done = ok;
209   passwd_cancel = cancel;
210 }
211
212
213
214 void
215 create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
216 {
217   Widget children[22];      /* Children to manage */
218   Arg al[64];           /* Arg List */
219   register int ac = 0;      /* Arg Count */
220   Widget widget12;
221   Widget widget13;
222   Widget widget14;
223   Widget widget15;
224   Widget widget16;
225   Widget widget17;
226   Widget widget18;
227   Widget widget48;
228   Widget widget29;
229
230   Widget real_dialog;
231   Widget w;
232
233   ac = 0;
234   XtSetArg (al[ac], XmNvisual, visual); ac++;
235   XtSetArg (al[ac], XmNcolormap, colormap); ac++;
236   XtSetArg (al[ac], XmNdepth, visual_depth(XtScreen(parent), visual)); ac++;
237
238   real_dialog = XmCreatePromptDialog (parent, "resourcesForm", al, ac);
239   resources_dialog = XtParent(real_dialog);
240
241   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_SEPARATOR);
242   if (w) XtUnmanageChild (w);
243   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_TEXT);
244   if (w) XtUnmanageChild (w);
245   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_SELECTION_LABEL);
246   if (w) XtUnmanageChild (w);
247   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_HELP_BUTTON);
248   if (w) XtUnmanageChild (w);
249
250   ac = 0;
251   XtSetArg (al [ac], XmNtopAttachment, XmATTACH_FORM); ac++;
252   XtSetArg (al [ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
253   XtSetArg (al [ac], XmNleftAttachment, XmATTACH_FORM); ac++;
254   XtSetArg (al [ac], XmNrightAttachment, XmATTACH_FORM); ac++;
255   resources_form = XmCreateForm (real_dialog, "form", al, ac);
256   XtManageChild (resources_form);
257
258   ac = 0;
259
260   widget12 = XmCreateLabel ( resources_form, "resourcesLabel", al, ac );
261   widget13 = XmCreateSeparator ( resources_form, "separator", al, ac );
262   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
263   widget14 = XmCreateLabel ( resources_form, "timeoutLabel", al, ac );
264   ac = 0;
265   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
266   widget15 = XmCreateLabel ( resources_form, "cycleLabel", al, ac );
267   ac = 0;
268   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
269   widget16 = XmCreateLabel ( resources_form, "fadeSecondsLabel", al, ac );
270   ac = 0;
271   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
272   widget17 = XmCreateLabel ( resources_form, "fadeTicksLabel", al, ac );
273   ac = 0;
274   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
275   widget18 = XmCreateLabel ( resources_form, "lockLabel", al, ac );
276   ac = 0;
277   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
278   widget48 = XmCreateLabel ( resources_form, "passwdLabel", al, ac );
279   ac = 0;
280   timeout_text = XmCreateTextField ( resources_form, "timeoutText", al, ac );
281   cycle_text = XmCreateTextField ( resources_form, "cycleText", al, ac );
282   fade_text = XmCreateTextField ( resources_form, "fadeSecondsText", al, ac );
283   ticks_text = XmCreateTextField ( resources_form, "fadeTicksText", al, ac );
284   lock_time_text = XmCreateTextField ( resources_form, "passwdText", al, ac );
285   passwd_time_text = XmCreateTextField ( resources_form, "lockText", al, ac );
286   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
287   verbose_toggle = XmCreateToggleButton ( resources_form, "verboseToggle", al, ac );
288   ac = 0;
289   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
290   cmap_toggle = XmCreateToggleButton ( resources_form, "cmapToggle", al, ac );
291   ac = 0;
292   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
293   fade_toggle = XmCreateToggleButton ( resources_form, "fadeToggle", al, ac );
294   ac = 0;
295   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
296   unfade_toggle = XmCreateToggleButton ( resources_form, "unfadeToggle", al, ac );
297   ac = 0;
298   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
299   lock_toggle = XmCreateToggleButton ( resources_form, "lockToggle", al, ac );
300   ac = 0;
301   widget29 = XmCreateSeparator ( resources_form, "separator", al, ac );
302
303   res_done = XmSelectionBoxGetChild (real_dialog, XmDIALOG_OK_BUTTON);
304   res_cancel = XmSelectionBoxGetChild (real_dialog, XmDIALOG_CANCEL_BUTTON);
305
306   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
307   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
308   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
309   XtSetArg(al[ac], XmNleftOffset, 4); ac++;
310   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
311   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
312   XtSetValues ( widget12,al, ac );
313   ac = 0;
314
315   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
316   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
317   XtSetArg(al[ac], XmNtopWidget, widget12); ac++;
318   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
319   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
320   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
321   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
322   XtSetArg(al[ac], XmNrightOffset, 0); ac++;
323   XtSetValues ( widget13,al, ac );
324   ac = 0;
325
326   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
327   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
328   XtSetArg(al[ac], XmNtopWidget, widget13); ac++;
329   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
330   XtSetArg(al[ac], XmNbottomWidget, timeout_text); ac++;
331   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
332   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
333   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
334   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
335   XtSetArg(al[ac], XmNrightWidget, timeout_text); ac++;
336   XtSetValues ( widget14,al, ac );
337   ac = 0;
338
339   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
340   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
341   XtSetArg(al[ac], XmNtopWidget, cycle_text); ac++;
342   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
343   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
344   XtSetArg(al[ac], XmNbottomWidget, cycle_text); ac++;
345   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
346   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
347   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
348   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
349   XtSetArg(al[ac], XmNrightWidget, cycle_text); ac++;
350   XtSetValues ( widget15,al, ac );
351   ac = 0;
352
353   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
354   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
355   XtSetArg(al[ac], XmNtopWidget, fade_text); ac++;
356   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
357   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
358   XtSetArg(al[ac], XmNbottomWidget, fade_text); ac++;
359   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
360   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
361   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
362   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
363   XtSetArg(al[ac], XmNrightWidget, fade_text); ac++;
364   XtSetValues ( widget16,al, ac );
365   ac = 0;
366
367   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
368   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
369   XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
370   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
371   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
372   XtSetArg(al[ac], XmNbottomWidget, ticks_text); ac++;
373   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
374   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
375   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
376   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
377   XtSetArg(al[ac], XmNrightWidget, ticks_text); ac++;
378   XtSetValues ( widget17,al, ac );
379   ac = 0;
380
381   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
382   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
383   XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
384   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
385   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
386   XtSetArg(al[ac], XmNbottomWidget, lock_time_text); ac++;
387   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
388   XtSetArg(al[ac], XmNleftOffset, 19); ac++;
389   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
390   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
391   XtSetArg(al[ac], XmNrightWidget, lock_time_text); ac++;
392   XtSetValues ( widget18,al, ac );
393   ac = 0;
394
395   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
396   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
397   XtSetArg(al[ac], XmNtopWidget, passwd_time_text); ac++;
398   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
399   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
400   XtSetArg(al[ac], XmNbottomWidget, passwd_time_text); ac++;
401   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
402   XtSetArg(al[ac], XmNleftOffset, 14); ac++;
403   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
404   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
405   XtSetArg(al[ac], XmNrightWidget, passwd_time_text); ac++;
406   XtSetValues ( widget48,al, ac );
407   ac = 0;
408
409   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
410   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
411   XtSetArg(al[ac], XmNtopWidget, widget13); ac++;
412   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
413   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
414   XtSetArg(al[ac], XmNleftOffset, 141); ac++;
415   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
416   XtSetValues ( timeout_text,al, ac );
417   ac = 0;
418
419   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
420   XtSetArg(al[ac], XmNtopOffset, 2); ac++;
421   XtSetArg(al[ac], XmNtopWidget, timeout_text); ac++;
422   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
423   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
424   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
425   XtSetArg(al[ac], XmNleftWidget, timeout_text); ac++;
426   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
427   XtSetValues ( cycle_text,al, ac );
428   ac = 0;
429
430   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
431   XtSetArg(al[ac], XmNtopOffset, 2); ac++;
432   XtSetArg(al[ac], XmNtopWidget, cycle_text); ac++;
433   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
434   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
435   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
436   XtSetArg(al[ac], XmNleftWidget, cycle_text); ac++;
437   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
438   XtSetValues ( fade_text,al, ac );
439   ac = 0;
440
441   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
442   XtSetArg(al[ac], XmNtopOffset, 2); ac++;
443   XtSetArg(al[ac], XmNtopWidget, fade_text); ac++;
444   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
445   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
446   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
447   XtSetArg(al[ac], XmNleftWidget, fade_text); ac++;
448   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
449   XtSetValues ( ticks_text,al, ac );
450   ac = 0;
451
452   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
453   XtSetArg(al[ac], XmNtopOffset, 2); ac++;
454   XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
455   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
456   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
457   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
458   XtSetArg(al[ac], XmNleftWidget, ticks_text); ac++;
459   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
460   XtSetValues ( lock_time_text,al, ac );
461   ac = 0;
462
463   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
464   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
465   XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
466   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
467   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
468   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
469   XtSetArg(al[ac], XmNleftWidget, lock_time_text); ac++;
470   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
471   XtSetValues ( passwd_time_text,al, ac );
472   ac = 0;
473
474   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
475   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
476   XtSetArg(al[ac], XmNtopWidget, widget13); ac++;
477   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
478   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
479   XtSetArg(al[ac], XmNbottomWidget, timeout_text); ac++;
480   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
481   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
482   XtSetArg(al[ac], XmNleftWidget, timeout_text); ac++;
483   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
484   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
485   XtSetValues ( verbose_toggle,al, ac );
486   ac = 0;
487
488   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
489   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
490   XtSetArg(al[ac], XmNtopWidget, cycle_text); ac++;
491   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
492   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
493   XtSetArg(al[ac], XmNbottomWidget, cycle_text); ac++;
494   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
495   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
496   XtSetArg(al[ac], XmNleftWidget, verbose_toggle); ac++;
497   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
498   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
499   XtSetValues ( cmap_toggle,al, ac );
500   ac = 0;
501
502   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
503   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
504   XtSetArg(al[ac], XmNtopWidget, fade_text); ac++;
505   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
506   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
507   XtSetArg(al[ac], XmNbottomWidget, fade_text); ac++;
508   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
509   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
510   XtSetArg(al[ac], XmNleftWidget, cmap_toggle); ac++;
511   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
512   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
513   XtSetValues ( fade_toggle,al, ac );
514   ac = 0;
515
516   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
517   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
518   XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
519   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
520   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
521   XtSetArg(al[ac], XmNbottomWidget, ticks_text); ac++;
522   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
523   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
524   XtSetArg(al[ac], XmNleftWidget, fade_toggle); ac++;
525   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
526   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
527   XtSetValues ( unfade_toggle,al, ac );
528   ac = 0;
529
530   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
531   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
532   XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
533   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
534   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
535   XtSetArg(al[ac], XmNbottomWidget, lock_time_text); ac++;
536   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
537   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
538   XtSetArg(al[ac], XmNleftWidget, unfade_toggle); ac++;
539   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
540   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
541   XtSetValues ( lock_toggle,al, ac );
542   ac = 0;
543
544   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
545   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
546   XtSetArg(al[ac], XmNtopWidget, passwd_time_text); ac++;
547
548   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
549   XtSetArg(al[ac], XmNbottomOffset, 4); ac++;
550
551   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
552   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
553   XtSetValues ( widget29,al, ac );
554   ac = 0;
555
556
557
558   ac = 0;
559   children[ac++] = widget12;
560   children[ac++] = widget13;
561   children[ac++] = widget14;
562   children[ac++] = widget15;
563   children[ac++] = widget16;
564   children[ac++] = widget17;
565   children[ac++] = widget18;
566   children[ac++] = widget48;
567   children[ac++] = timeout_text;
568   children[ac++] = cycle_text;
569   children[ac++] = fade_text;
570   children[ac++] = ticks_text;
571   children[ac++] = lock_time_text;
572   children[ac++] = passwd_time_text;
573   children[ac++] = verbose_toggle;
574   children[ac++] = cmap_toggle;
575   children[ac++] = fade_toggle;
576   children[ac++] = unfade_toggle;
577   children[ac++] = lock_toggle;
578   children[ac++] = widget29;
579
580   XtManageChildren(children, ac);
581   ac = 0;
582
583   resources_form = real_dialog;
584 }
585
586
587 void
588 create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
589 {
590   Arg al[64];           /* Arg List */
591   register int ac = 0;      /* Arg Count */
592
593   Widget real_dialog;
594   Widget w;
595
596
597   ac = 0;
598   XtSetArg (al[ac], XmNvisual, visual); ac++;
599   XtSetArg (al[ac], XmNcolormap, colormap); ac++;
600   XtSetArg (al[ac], XmNdepth, visual_depth(XtScreen(parent), visual)); ac++;
601
602
603   real_dialog = XmCreatePromptDialog (parent, "demoForm", al, ac);
604   demo_dialog = XtParent(real_dialog);
605
606   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_SEPARATOR);
607   if (w) XtUnmanageChild (w);
608   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_TEXT);
609   if (w) XtUnmanageChild (w);
610   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_SELECTION_LABEL);
611   if (w) XtUnmanageChild (w);
612   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_OK_BUTTON);
613   if (w) XtUnmanageChild (w);
614   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_CANCEL_BUTTON);
615   if (w) XtUnmanageChild (w);
616   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_HELP_BUTTON);
617   if (w) XtUnmanageChild (w);
618
619   ac = 0;
620   XtSetArg (al [ac], XmNtopAttachment, XmATTACH_FORM); ac++;
621   XtSetArg (al [ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
622   XtSetArg (al [ac], XmNleftAttachment, XmATTACH_FORM); ac++;
623   XtSetArg (al [ac], XmNrightAttachment, XmATTACH_FORM); ac++;
624   demo_form = XmCreateForm (real_dialog, "form", al, ac);
625   XtManageChild (demo_form);
626
627   label1 = XmCreateLabel ( demo_form, "label1", al, ac );
628   label2 = XmCreateLabel ( demo_form, "label2", al, ac );
629   demo_list = XmCreateScrolledList ( demo_form, "demoList", al, ac );
630   text_area = XtParent ( demo_list );
631
632   ac = 0;
633   text_line = XmSelectionBoxGetChild (real_dialog, XmDIALOG_TEXT);
634   XtManageChild(text_line);
635
636   /* #### ARRGH!  This is apparently the only way to make hitting return in
637      the text field not *ALSO* activate the most-recently-selected button!
638
639      This has the unfortunate side effect of making the buttons not be
640      keyboard-traversable, but that's less bad than not being able to try
641      out new switches by typing them into the text field.
642
643      XmSelectionBox(3M) says in the "Additional Behavior" section:
644           KActivate:
645                     Calls the activate callbacks for the button with
646                     the keyboard focus.  [... ]  In a List widget or
647                     single-line Text widget, the List or Text action
648                     associated with KActivate is called before the
649                     SelectionBox actions associated with KActivate."
650
651      So they take it as a given that when running activateCallback on a single-
652      line Text widget, you'll also want to run activateCallback on whatever the
653      currently-focussed button is as well!  Morons!  Villains!  Shitheads!
654
655      (Perhaps there's some way to override XmSelectionBox's KActivate behavior.
656      I doubt it, but if there is, I don't know it.)
657   */
658   ac = 0;
659   XtSetArg(al[ac], XmNtraversalOn, False); ac++;
660
661   next = XmCreatePushButton ( real_dialog, "next", al, ac );
662   prev = XmCreatePushButton ( real_dialog, "prev", al, ac );
663   edit = XmCreatePushButton ( real_dialog, "edit", al, ac );
664   done = XmCreatePushButton ( real_dialog, "done", al, ac );
665   restart = XmCreatePushButton ( real_dialog, "restart", al, ac );
666   XtManageChild(next);
667   XtManageChild(prev);
668   XtManageChild(edit);
669   XtManageChild(done);
670   XtManageChild(restart);
671
672   ac = 0;
673   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
674   XtSetArg(al[ac], XmNtopOffset, 5); ac++;
675   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
676   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
677   XtSetArg(al[ac], XmNleftOffset, 4); ac++;
678   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
679   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
680   XtSetValues ( label1,al, ac );
681   ac = 0;
682
683   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
684   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
685   XtSetArg(al[ac], XmNtopWidget, label1); ac++;
686   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
687   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
688   XtSetArg(al[ac], XmNleftOffset, 4); ac++;
689   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
690   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
691   XtSetValues ( label2,al, ac );
692   ac = 0;
693
694   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
695   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
696   XtSetArg(al[ac], XmNtopWidget, label2); ac++;
697   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
698   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
699   XtSetArg(al[ac], XmNleftOffset, 4); ac++;
700   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
701   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
702   XtSetValues ( text_area,al, ac );
703
704   XtManageChild(demo_list);
705   XtManageChild(label1);
706   XtManageChild(label2);
707
708   demo_form = real_dialog;
709 }
710
711
712 void
713 create_splash_dialog(Widget parent, Visual *visual, Colormap colormap)
714 {
715   Widget shell;
716   Widget  form1;
717   Widget   roger;
718   Widget   dialog;
719   Widget    form2;
720   Widget     label1, label2, label3;
721   Widget    demo, prefs, help;
722   Widget w;
723   Arg al[64];
724   int ac = 0;
725
726   ac = 0;
727   XtSetArg (al[ac], XmNvisual, visual); ac++;
728   XtSetArg (al[ac], XmNcolormap, colormap); ac++;
729   XtSetArg (al[ac], XmNdepth, visual_depth(XtScreen(parent), visual)); ac++;
730
731   shell = XmCreateDialogShell (parent, "splashDialog", al, ac);
732
733   form1 = XmCreateForm (shell, "form", 0, 0);
734
735   roger = XmCreateDrawnButton (form1, "rogerLabel", 0, 0);
736
737   dialog = XmCreateSelectionBox (form1, "splashForm", al, ac);
738
739   form2 = XmCreateForm ( dialog, "form", 0, 0);
740   label1 = XmCreateLabel ( form2, "splashLabel1", 0, 0);
741   label2 = XmCreateLabel ( form2, "splashLabel2", 0, 0);
742   label3 = XmCreateLabel ( form2, "splashLabel3", 0, 0);
743
744   ac = 0;
745   XtSetArg(al[ac], XmNtraversalOn, False); ac++;
746
747   demo = XmCreatePushButton (dialog, "splashDemo", al, ac);
748   prefs = XmCreatePushButton (dialog, "splashPrefs", al, ac);
749   help = XmSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
750   XtSetValues(help, al, ac);
751
752   w = XmSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON);
753   if (w) XtUnmanageChild (w);
754   w = XmSelectionBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON);
755   if (w) XtUnmanageChild (w);
756   w = XmSelectionBoxGetChild (dialog, XmDIALOG_APPLY_BUTTON);
757   if (w) XtUnmanageChild (w);
758   w = XmSelectionBoxGetChild (dialog, XmDIALOG_TEXT);
759   if (w) XtUnmanageChild (w);
760   w = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST_LABEL);
761   if (w) XtUnmanageChild (w);
762   w = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST);
763   if (w) XtUnmanageChild (XtParent(w));
764   w = XmSelectionBoxGetChild (dialog, XmDIALOG_SELECTION_LABEL);
765   if (w) XtUnmanageChild (w);
766   w = XmSelectionBoxGetChild (dialog, XmDIALOG_SEPARATOR);
767   if (w) XtUnmanageChild (w);
768   w = XmSelectionBoxGetChild (dialog, XmDIALOG_APPLY_BUTTON);
769   if (w) XtUnmanageChild (w);
770
771   XtVaSetValues(label1,
772                 XmNtopAttachment, XmATTACH_FORM,
773                 XmNleftAttachment, XmATTACH_FORM,
774                 XmNrightAttachment, XmATTACH_FORM,
775                 XmNbottomAttachment, XmATTACH_NONE,
776                 0);
777   XtVaSetValues(label2,
778                 XmNtopAttachment, XmATTACH_WIDGET,
779                 XmNtopWidget, label1,
780                 XmNleftAttachment, XmATTACH_FORM,
781                 XmNrightAttachment, XmATTACH_FORM,
782                 XmNbottomAttachment, XmATTACH_NONE,
783                 0);
784   XtVaSetValues(label3,
785                 XmNtopAttachment, XmATTACH_WIDGET,
786                 XmNtopWidget, label2,
787                 XmNleftAttachment, XmATTACH_FORM,
788                 XmNrightAttachment, XmATTACH_FORM,
789                 XmNbottomAttachment, XmATTACH_FORM,
790                 0);
791
792   XtVaSetValues(roger,
793                 XmNsensitive, FALSE,
794                 XmNtopAttachment, XmATTACH_FORM,
795                 XmNleftAttachment, XmATTACH_FORM,
796                 XmNrightAttachment, XmATTACH_NONE,
797                 XmNbottomAttachment, XmATTACH_FORM,
798                 0);
799   XtVaSetValues(dialog,
800                 XmNtopAttachment, XmATTACH_FORM,
801                 XmNleftAttachment, XmATTACH_WIDGET,
802                 XmNleftWidget, roger,
803                 XmNrightAttachment, XmATTACH_FORM,
804                 XmNbottomAttachment, XmATTACH_FORM,
805                 0);
806
807   XtManageChild(label1);
808   XtManageChild(label2);
809   XtManageChild(label3);
810
811   XtManageChild(form2);
812   XtManageChild(demo);
813   XtManageChild(prefs);
814   XtManageChild(help);
815
816   XtManageChild(roger);
817   XtManageChild(dialog);
818
819   {
820     Dimension width = 0, height = 0;
821     XtRealizeWidget(form1);
822     XtVaGetValues(roger, XmNwidth, &width, XmNheight, &height, 0);
823     if (width == height)
824       ;
825     else if (width > height)
826       XtVaSetValues(roger, XmNwidth, width, XmNheight, width, 0);
827     else
828       XtVaSetValues(roger, XmNwidth, height, XmNheight, height, 0);
829   }
830
831   splash_dialog = shell;
832   splash_form = form1;
833   splash_roger_label = roger;
834   splash_label1 = label1;
835   splash_label3 = label3;
836   splash_demo = demo;
837   splash_prefs = prefs;
838   splash_help = help;
839 }