From http://www.jwz.org/xscreensaver/xscreensaver-5.27.tar.gz
[xscreensaver] / driver / demo-Xm-widgets.c
1 /* demo-Xm.c --- implements the interactive demo-mode and options dialogs.
2  * xscreensaver, Copyright (c) 1999, 2003 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 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17 #include <X11/Xatom.h>
18 #include <X11/Intrinsic.h>
19
20 #include <X11/IntrinsicP.h>  /* just for debug info */
21 #include <X11/ShellP.h>
22
23 #include <X11/Shell.h>
24 #include <Xm/Xm.h>
25 #include <Xm/MainW.h>
26 #include <Xm/Form.h>
27 #include <Xm/Frame.h>
28 #include <Xm/ScrolledW.h>
29 #include <Xm/List.h>
30 #include <Xm/PushB.h>
31 #include <Xm/PushBG.h>
32 #include <Xm/Text.h>
33 #include <Xm/TextF.h>
34 #include <Xm/ToggleBG.h>
35 #include <Xm/CascadeBG.h>
36 #include <Xm/RowColumn.h>
37 #include <Xm/LabelG.h>
38 #include <Xm/SeparatoG.h>
39 #include <Xm/SelectioB.h>
40
41 #ifdef HAVE_XMCOMBOBOX          /* a Motif 2.0 widget */
42 # include <Xm/ComboBox.h>
43 # ifndef XmNtextField           /* Lesstif 0.89.4 bug */
44 #  undef HAVE_XMCOMBOBOX
45 # endif
46 #endif /* HAVE_XMCOMBOBOX */
47
48 #include <stdio.h>
49 #include <stdlib.h>
50
51
52
53 const char *visual_menu[] = {
54   "Any", "Best", "Default", "Default-N", "GL", "TrueColor", "PseudoColor",
55   "StaticGray", "GrayScale", "DirectColor", "Color", "Gray", "Mono", 0 
56 };
57
58
59
60 static Widget create_demos_page (Widget parent);
61 static Widget create_options_page (Widget parent);
62
63 static void
64 tab_cb (Widget button, XtPointer client_data, XtPointer ignored)
65 {
66   Widget parent = XtParent(button);
67   Widget tabber = XtNameToWidget (parent, "*folder");
68   Widget this_tab = (Widget) client_data;
69   Widget *kids = 0;
70   Cardinal nkids = 0;
71   if (!tabber) abort();
72   
73   XtVaGetValues (tabber, XmNnumChildren, &nkids, XmNchildren, &kids, NULL);
74   if (!kids) abort();
75   if (nkids > 0)
76     XtUnmanageChildren (kids, nkids);
77
78   XtManageChild (this_tab);
79 }
80
81
82 Widget
83 create_xscreensaver_demo (Widget parent)
84 {
85   /* MainWindow
86        Form
87          Menubar
88          DemoTab
89          OptionsTab
90          HR
91          Tabber
92            (demo page)
93            (options page)
94    */
95
96   Widget mainw, form, menubar;
97   Widget demo_tab, options_tab, hr, tabber, demos, options;
98   Arg av[100];
99   int ac = 0;
100
101   mainw = XmCreateMainWindow (parent, "demoForm", av, ac);
102   form = XmCreateForm (mainw, "form", av, ac);
103   menubar = XmCreateSimpleMenuBar (form, "menubar", av, ac);
104   XtVaSetValues (menubar,
105                  XmNtopAttachment, XmATTACH_FORM,
106                  XmNleftAttachment, XmATTACH_FORM,
107                  XmNrightAttachment, XmATTACH_FORM,
108                  NULL);
109
110   {
111     Widget menu = 0, item = 0;
112     char *menus[] = {
113       "*file", "blank", "lock", "kill", "restart", "-", "exit",
114       "*edit", "cut", "copy", "paste",
115       "*help", "about", "docMenu" };
116     int i;
117     for (i = 0; i < sizeof(menus)/sizeof(*menus); i++)
118       {
119         ac = 0;
120         if (menus[i][0] == '-')
121           item = XmCreateSeparatorGadget (menu, "separator", av, ac);
122         else if (menus[i][0] != '*')
123           item = XmCreatePushButtonGadget (menu, menus[i], av, ac);
124         else
125           {
126             menu = XmCreatePulldownMenu (parent, menus[i]+1, av, ac);
127             XtSetArg (av [ac], XmNsubMenuId, menu); ac++;
128             item = XmCreateCascadeButtonGadget (menubar, menus[i]+1, av, ac);
129
130             if (!strcmp (menus[i]+1, "help"))
131               XtVaSetValues(menubar, XmNmenuHelpWidget, item, NULL);
132           }
133         XtManageChild (item);
134       }
135     ac = 0;
136   }
137
138   demo_tab = XmCreatePushButtonGadget (form, "demoTab", av, ac);
139   XtVaSetValues (demo_tab,
140                  XmNleftAttachment, XmATTACH_FORM,
141                  XmNtopAttachment, XmATTACH_WIDGET,
142                  XmNtopWidget, menubar,
143                  NULL);
144
145   options_tab = XmCreatePushButtonGadget (form, "optionsTab", av, ac);
146   XtVaSetValues (options_tab,
147                  XmNleftAttachment, XmATTACH_WIDGET,
148                  XmNleftWidget, demo_tab,
149                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
150                  XmNtopWidget, demo_tab,
151                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
152                  XmNbottomWidget, demo_tab,
153                  NULL);
154
155   hr = XmCreateSeparatorGadget (form, "hr", av, ac);
156   XtVaSetValues (hr,
157                  XmNleftAttachment, XmATTACH_FORM,
158                  XmNrightAttachment, XmATTACH_FORM,
159                  XmNtopAttachment, XmATTACH_WIDGET,
160                  XmNtopWidget, demo_tab,
161                  NULL);
162
163   tabber = XmCreateForm (form, "folder", av, ac);
164   XtVaSetValues (tabber,
165                  XmNtopAttachment, XmATTACH_WIDGET,
166                  XmNtopWidget, hr,
167                  XmNleftAttachment, XmATTACH_FORM,
168                  XmNrightAttachment, XmATTACH_FORM,
169                  XmNbottomAttachment, XmATTACH_FORM,
170                  NULL);
171
172   demos = create_demos_page (tabber);
173   options = create_options_page (tabber);
174
175   XtAddCallback (demo_tab, XmNactivateCallback, tab_cb, demos);
176   XtAddCallback (options_tab, XmNactivateCallback, tab_cb, options);
177
178   XtManageChild (demos);
179   XtManageChild (options);
180
181   XtManageChild (demo_tab);
182   XtManageChild (options_tab);
183   XtManageChild (hr);
184   XtManageChild (menubar);
185   XtManageChild (tabber);
186   XtManageChild (form);
187
188 #if 1
189   XtUnmanageChild (options);
190   XtManageChild (demos);
191 #endif
192
193   return mainw;
194 }
195
196
197 static Widget
198 create_demos_page (Widget parent)
199 {
200   /* Form1 (horizontal)
201        Form2 (vertical)
202          Scroller
203            List
204          ButtonBox1 (vertical)
205            Button ("Down")
206            Button ("Up")
207        Form3 (vertical)
208          Frame
209            Label
210            TextArea (doc)
211          Label
212          Text ("Command Line")
213          Form4 (horizontal)
214            Checkbox ("Enabled")
215            Label ("Visual")
216            ComboBox
217          HR
218          ButtonBox2 (vertical)
219            Button ("Demo")
220            Button ("Documentation")
221    */
222   Widget form1, form2, form3, form4;
223   Widget scroller, list, buttonbox1, down, up;
224   Widget frame, frame_label, doc, cmd_label, cmd_text, enabled, vis_label;
225   Widget   combo;
226   Widget hr, buttonbox2, demo, man;
227   Arg av[100];
228   int ac = 0;
229   int i;
230
231   form1 = XmCreateForm (parent, "form1", av, ac);
232   form2 = XmCreateForm (form1, "form2", av, ac);
233   XtVaSetValues (form2,
234                  XmNtopAttachment, XmATTACH_FORM,
235                  XmNleftAttachment, XmATTACH_FORM,
236                  XmNbottomAttachment, XmATTACH_FORM,
237                  NULL);
238
239   scroller = XmCreateScrolledWindow (form2, "scroller", av, ac);
240   XtVaSetValues (scroller,
241                  XmNtopAttachment, XmATTACH_FORM,
242                  XmNleftAttachment, XmATTACH_FORM,
243                  XmNrightAttachment, XmATTACH_FORM,
244                  XmNbottomAttachment, XmATTACH_WIDGET,
245                  NULL);
246   list = XmCreateList (scroller, "list", av, ac);
247
248   buttonbox1 = XmCreateForm (form2, "buttonbox1", av, ac);
249   XtVaSetValues (buttonbox1,
250                  XmNleftAttachment, XmATTACH_FORM,
251                  XmNrightAttachment, XmATTACH_FORM,
252                  XmNbottomAttachment, XmATTACH_FORM,
253                  NULL);
254   XtVaSetValues (scroller, XmNbottomWidget, buttonbox1, NULL);
255
256   down = XmCreatePushButton (buttonbox1, "down", av, ac);
257   XtVaSetValues (down,
258                  XmNleftAttachment, XmATTACH_FORM,
259                  XmNtopAttachment, XmATTACH_FORM,
260                  XmNbottomAttachment, XmATTACH_FORM,
261                  NULL);
262   up = XmCreatePushButton (buttonbox1, "up", av, ac);
263   XtVaSetValues (up,
264                  XmNleftAttachment, XmATTACH_WIDGET,
265                  XmNleftWidget, down,
266                  XmNtopAttachment, XmATTACH_FORM,
267                  XmNbottomAttachment, XmATTACH_FORM,
268                  NULL);
269
270   form3 = XmCreateForm (form1, "form3", av, ac);
271   XtVaSetValues (form3,
272                  XmNtopAttachment, XmATTACH_FORM,
273                  XmNleftAttachment, XmATTACH_WIDGET,
274                  XmNleftWidget, form2,
275                  XmNrightAttachment, XmATTACH_FORM,
276                  XmNbottomAttachment, XmATTACH_FORM,
277                  NULL);
278   frame = XmCreateFrame (form3, "frame", av, ac);
279
280   ac = 0;
281   XtSetArg (av [ac], XmNchildType, XmFRAME_TITLE_CHILD); ac++;
282   frame_label = XmCreateLabelGadget (frame, "frameLabel", av, ac);
283
284   ac = 0;
285   XtVaSetValues (frame,
286                  XmNtopAttachment, XmATTACH_FORM,
287                  XmNleftAttachment, XmATTACH_FORM,
288                  XmNrightAttachment, XmATTACH_FORM,
289                  XmNbottomAttachment, XmATTACH_WIDGET,
290                  NULL);
291
292   ac = 0;
293   XtSetArg (av [ac], XmNchildType, XmFRAME_WORKAREA_CHILD); ac++;
294   doc = XmCreateText (frame, "doc", av, ac);
295
296   ac = 0;
297   XtVaSetValues (doc,
298                  XmNeditable, FALSE,
299                  XmNcursorPositionVisible, FALSE,
300                  XmNwordWrap, TRUE,
301                  XmNeditMode, XmMULTI_LINE_EDIT,
302                  XmNshadowThickness, 0,
303                  NULL);
304
305   cmd_label = XmCreateLabelGadget (form3, "cmdLabel", av, ac);
306   XtVaSetValues (cmd_label,
307                  XmNleftAttachment, XmATTACH_FORM,
308                  XmNrightAttachment, XmATTACH_FORM,
309                  XmNbottomAttachment, XmATTACH_WIDGET,
310                  NULL);
311   XtVaSetValues (frame, XmNbottomWidget, cmd_label, NULL);
312
313   cmd_text = XmCreateTextField (form3, "cmdText", av, ac);
314   XtVaSetValues (cmd_text,
315                  XmNleftAttachment, XmATTACH_FORM,
316                  XmNrightAttachment, XmATTACH_FORM,
317                  XmNbottomAttachment, XmATTACH_WIDGET,
318                  NULL);
319   XtVaSetValues (cmd_label, XmNbottomWidget, cmd_text, NULL);
320
321   form4 = XmCreateForm (form3, "form4", av, ac);
322   XtVaSetValues (form4,
323                  XmNleftAttachment, XmATTACH_FORM,
324                  XmNrightAttachment, XmATTACH_FORM,
325                  XmNbottomAttachment, XmATTACH_WIDGET,
326                  NULL);
327   XtVaSetValues (cmd_text, XmNbottomWidget, form4, NULL);
328
329   enabled = XmCreateToggleButtonGadget (form4, "enabled", av, ac);
330   XtVaSetValues (enabled,
331                  XmNtopAttachment, XmATTACH_FORM,
332                  XmNleftAttachment, XmATTACH_FORM,
333                  XmNbottomAttachment, XmATTACH_FORM,
334                  NULL);
335   vis_label = XmCreateLabelGadget (form4, "visLabel", av, ac);
336   XtVaSetValues (vis_label,
337                  XmNtopAttachment, XmATTACH_FORM,
338                  XmNleftAttachment, XmATTACH_WIDGET,
339                  XmNleftWidget, enabled,
340                  XmNbottomAttachment, XmATTACH_FORM,
341                  NULL);
342 #ifdef HAVE_XMCOMBOBOX
343   {
344     Widget list;
345     ac = 0;
346     XtSetArg (av [ac], XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); ac++;
347     combo = XmCreateComboBox (form4, "combo", av, ac);
348     for (i = 0; visual_menu[i]; i++)
349       {
350         XmString xs = XmStringCreate ((char *) visual_menu[i],
351                                       XmSTRING_DEFAULT_CHARSET);
352         XmComboBoxAddItem (combo, xs, 0, False);
353         XmStringFree (xs);
354       }
355     XtVaGetValues (combo, XmNlist, &list, NULL);
356     XtVaSetValues (list, XmNvisibleItemCount, i, NULL);
357   }
358 #else /* !HAVE_XMCOMBOBOX */
359   {
360     Widget popup_menu = XmCreatePulldownMenu (parent, "menu", av, ac);
361     Widget kids[100];
362     for (i = 0; visual_menu[i]; i++)
363       {
364         XmString xs = XmStringCreate ((char *) visual_menu[i],
365                                       XmSTRING_DEFAULT_CHARSET);
366         ac = 0;
367         XtSetArg (av [ac], XmNlabelString, xs); ac++;
368         kids[i] = XmCreatePushButtonGadget (popup_menu, "button", av, ac);
369         /* XtAddCallback (combo, XmNactivateCallback, visual_popup_cb,
370            combo); */
371         XmStringFree (xs);
372       }
373     XtManageChildren (kids, i);
374
375     ac = 0;
376     XtSetArg (av [ac], XmNsubMenuId, popup_menu); ac++;
377     combo = XmCreateOptionMenu (form4, "combo", av, ac);
378     ac = 0;
379   }
380 #endif /* !HAVE_XMCOMBOBOX */
381
382   XtVaSetValues (combo,
383                  XmNtopAttachment, XmATTACH_FORM,
384                  XmNleftAttachment, XmATTACH_WIDGET,
385                  XmNleftWidget, vis_label,
386                  XmNbottomAttachment, XmATTACH_FORM,
387                  NULL);
388
389   hr = XmCreateSeparatorGadget (form3, "hr", av, ac);
390   XtVaSetValues (hr,
391                  XmNleftAttachment, XmATTACH_FORM,
392                  XmNrightAttachment, XmATTACH_FORM,
393                  XmNbottomAttachment, XmATTACH_WIDGET,
394                  NULL);
395   XtVaSetValues (form4, XmNbottomWidget, hr, NULL);
396
397   buttonbox2 = XmCreateForm (form3, "buttonbox2", av, ac);
398   XtVaSetValues (buttonbox2,
399                  XmNleftAttachment, XmATTACH_FORM,
400                  XmNrightAttachment, XmATTACH_FORM,
401                  XmNbottomAttachment, XmATTACH_FORM,
402                  NULL);
403   XtVaSetValues (hr, XmNbottomWidget, buttonbox2, NULL);
404
405   demo = XmCreatePushButtonGadget (buttonbox2, "demo", av, ac);
406   XtVaSetValues (demo,
407                  XmNleftAttachment, XmATTACH_FORM,
408                  XmNtopAttachment, XmATTACH_FORM,
409                  XmNbottomAttachment, XmATTACH_FORM,
410                  NULL);
411   man = XmCreatePushButtonGadget (buttonbox2, "man", av, ac);
412   XtVaSetValues (man,
413                  XmNrightAttachment, XmATTACH_FORM,
414                  XmNtopAttachment, XmATTACH_FORM,
415                  XmNbottomAttachment, XmATTACH_FORM,
416                  NULL);
417
418   XtManageChild (demo);
419   XtManageChild (man);
420   XtManageChild (buttonbox2);
421   XtManageChild (hr);
422
423   XtManageChild (combo);
424   XtManageChild (vis_label);
425   XtManageChild (enabled);
426   XtManageChild (form4);
427
428   XtManageChild (cmd_text);
429   XtManageChild (cmd_label);
430
431   XtManageChild (doc);
432   XtManageChild (frame_label);
433   XtManageChild (frame);
434   XtManageChild (form3);
435
436   XtManageChild (up);
437   XtManageChild (down);
438   XtManageChild (buttonbox1);
439
440   XtManageChild (list);
441   XtManageChild (scroller);
442   XtManageChild (form2);
443
444   XtManageChild (form1);
445
446   XtVaSetValues (form1,
447                  XmNleftAttachment, XmATTACH_FORM,
448                  XmNrightAttachment, XmATTACH_FORM,
449                  XmNtopAttachment, XmATTACH_FORM,
450                  XmNbottomAttachment, XmATTACH_FORM,
451                  NULL);
452
453   return form1;
454 }
455
456
457
458 static Widget
459 create_options_page (Widget parent)
460 {
461   /* This is what the layout is today:
462
463      Form (horizontal)
464        Label ("Saver Timeout")
465        Label ("Cycle Timeout")
466        Label ("Fade Duration")
467        Label ("Fade Ticks")
468        Label ("Lock Timeout")
469        Label ("Password Timeout")
470
471        Text (timeout)
472        Text (cycle)
473        Text (fade seconds)
474        Text (fade ticks)
475        Text (lock)
476        Text (passwd)
477
478        Toggle ("Verbose")
479        Toggle ("Install Colormap")
480        Toggle ("Fade Colormap")
481        Toggle ("Unfade Colormap")
482        Toggle ("Require Password")
483
484        HR
485        Button ("OK")
486        Button ("Cancel")
487    */
488
489   /* This is what it should be:
490
491      Form (horizontal)
492        Form (vertical) ("column1")
493          Frame
494            Label ("Blanking and Locking")
495            Form
496              Label ("Blank After")
497              Label ("Cycle After")
498              Text ("Blank After")
499              Text ("Cycle After")
500              HR
501              Checkbox ("Require Password")
502              Label ("Lock After")
503              Text ("Lock After")
504          Frame
505            Label ("Image Manipulation")
506            Form
507              Checkbox ("Grab Desktop Images")
508              Checkbox ("Grab Video Frames")
509              Checkbox ("Choose Random Image")
510              Text (pathname)
511              Button ("Browse")
512          Frame
513            Label ("Diagnostics")
514            Form
515              Checkbox ("Verbose Diagnostics")
516              Checkbox ("Display Subprocess Errors")
517              Checkbox ("Display Splash Screen at Startup")
518        Form (vertical) ("column2")
519          Frame
520            Label ("Display Power Management")
521            Form
522              Checkbox ("Power Management Enabled")
523              Label ("Standby After")
524              Label ("Suspend After")
525              Label ("Off After")
526              Text ("Standby After")
527              Text ("Suspend After")
528              Text ("Off After")
529          Frame
530            Label ("Colormaps")
531            Form
532              Checkbox ("Install Colormap")
533              HR
534              Checkbox ("Fade To Black When Blanking")
535              Checkbox ("Fade From Black When Unblanking")
536              Label ("Fade Duration")
537              Text ("Fade Duration")
538
539        timeoutLabel
540        cycleLabel
541        fadeSecondsLabel
542        fadeTicksLabel
543        lockLabel
544        passwdLabel
545
546        timeoutText
547        cycleText
548        fadeSecondsText
549        fadeTicksText
550        lockText
551        passwdText
552
553        verboseToggle
554        cmapToggle
555        fadeToggle
556        unfadeToggle
557        lockToggle
558
559        separator
560        OK
561        Cancel
562    */
563
564
565
566   Arg av[64];
567   int ac = 0;
568   Widget children[100];
569   Widget timeout_label, cycle_label, fade_seconds_label, fade_ticks_label;
570   Widget lock_label, passwd_label, hr;
571   Widget preferences_form;
572
573   Widget timeout_text, cycle_text, fade_text, fade_ticks_text;
574   Widget lock_timeout_text, passwd_timeout_text, verbose_toggle;
575   Widget install_cmap_toggle, fade_toggle, unfade_toggle;
576   Widget lock_toggle, prefs_done, prefs_cancel;
577
578   ac = 0;
579   XtSetArg (av [ac], XmNdialogType, XmDIALOG_PROMPT); ac++;
580
581   ac = 0;
582   XtSetArg (av [ac], XmNtopAttachment, XmATTACH_FORM); ac++;
583   XtSetArg (av [ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
584   XtSetArg (av [ac], XmNleftAttachment, XmATTACH_FORM); ac++;
585   XtSetArg (av [ac], XmNrightAttachment, XmATTACH_FORM); ac++;
586   preferences_form = XmCreateForm (parent, "preferencesForm", av, ac);
587   XtManageChild (preferences_form);
588
589   ac = 0;
590
591   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
592   timeout_label = XmCreateLabelGadget (preferences_form, "timeoutLabel",
593                                        av, ac);
594   ac = 0;
595   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
596   cycle_label = XmCreateLabelGadget (preferences_form, "cycleLabel",
597                                      av, ac);
598   ac = 0;
599   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
600   fade_seconds_label = XmCreateLabelGadget (preferences_form,
601                                             "fadeSecondsLabel", av, ac);
602   ac = 0;
603   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
604   fade_ticks_label = XmCreateLabelGadget (preferences_form, "fadeTicksLabel",
605                                           av, ac);
606   ac = 0;
607   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
608   lock_label = XmCreateLabelGadget (preferences_form, "lockLabel", av, ac);
609   ac = 0;
610   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_END); ac++;
611   passwd_label = XmCreateLabelGadget (preferences_form, "passwdLabel", av, ac);
612   ac = 0;
613   timeout_text = XmCreateTextField (preferences_form, "timeoutText", av, ac);
614   cycle_text = XmCreateTextField (preferences_form, "cycleText", av, ac);
615   fade_text = XmCreateTextField (preferences_form, "fadeSecondsText", av, ac);
616   fade_ticks_text = XmCreateTextField (preferences_form, "fadeTicksText",
617                                        av, ac);
618   lock_timeout_text = XmCreateTextField (preferences_form, "lockText",
619                                          av, ac);
620   passwd_timeout_text = XmCreateTextField (preferences_form, "passwdText",
621                                            av, ac);
622   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
623   verbose_toggle = XmCreateToggleButtonGadget (preferences_form,
624                                                "verboseToggle", av, ac);
625   ac = 0;
626   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
627   install_cmap_toggle = XmCreateToggleButtonGadget (preferences_form,
628                                                     "cmapToggle", av, ac);
629   ac = 0;
630   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
631   fade_toggle = XmCreateToggleButtonGadget (preferences_form, "fadeToggle",
632                                             av, ac);
633   ac = 0;
634   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
635   unfade_toggle = XmCreateToggleButtonGadget (preferences_form, "unfadeToggle",
636                                               av,ac);
637   ac = 0;
638   XtSetArg(av[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
639   lock_toggle = XmCreateToggleButtonGadget (preferences_form, "lockToggle",
640                                             av, ac);
641   ac = 0;
642   hr = XmCreateSeparatorGadget (preferences_form, "separator", av, ac);
643
644   prefs_done = XmCreatePushButtonGadget (preferences_form, "OK", av, ac);
645   prefs_cancel = XmCreatePushButtonGadget (preferences_form, "Cancel", av, ac);
646
647   XtVaSetValues (timeout_label,
648                  XmNtopAttachment, XmATTACH_FORM,
649                  XmNtopOffset, 4,
650                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
651                  XmNbottomWidget, timeout_text,
652                  XmNleftAttachment, XmATTACH_FORM,
653                  XmNleftOffset, 20,
654                  XmNrightAttachment, XmATTACH_WIDGET,
655                  XmNrightOffset, 4,
656                  XmNrightWidget, timeout_text,
657                  NULL);
658
659   XtVaSetValues (cycle_label,
660                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
661                  XmNtopOffset, 0,
662                  XmNtopWidget, cycle_text,
663                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
664                  XmNbottomOffset, 0,
665                  XmNbottomWidget, cycle_text,
666                  XmNleftAttachment, XmATTACH_FORM,
667                  XmNleftOffset, 20,
668                  XmNrightAttachment, XmATTACH_WIDGET,
669                  XmNrightOffset, 4,
670                  XmNrightWidget, cycle_text,
671                  NULL);
672
673   XtVaSetValues (fade_seconds_label,
674                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
675                  XmNtopOffset, 0,
676                  XmNtopWidget, fade_text,
677                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
678                  XmNbottomOffset, 0,
679                  XmNbottomWidget, fade_text,
680                  XmNleftAttachment, XmATTACH_FORM,
681                  XmNleftOffset, 20,
682                  XmNrightAttachment, XmATTACH_WIDGET,
683                  XmNrightOffset, 4,
684                  XmNrightWidget, fade_text,
685                  NULL);
686
687   XtVaSetValues (fade_ticks_label,
688                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
689                  XmNtopOffset, 0,
690                  XmNtopWidget, fade_ticks_text,
691                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
692                  XmNbottomOffset, 0,
693                  XmNbottomWidget, fade_ticks_text,
694                  XmNleftAttachment, XmATTACH_FORM,
695                  XmNleftOffset, 20,
696                  XmNrightAttachment, XmATTACH_WIDGET,
697                  XmNrightOffset, 4,
698                  XmNrightWidget, fade_ticks_text,
699                  NULL);
700
701   XtVaSetValues (lock_label,
702                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
703                  XmNtopOffset, 0,
704                  XmNtopWidget, lock_timeout_text,
705                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
706                  XmNbottomOffset, 0,
707                  XmNbottomWidget, lock_timeout_text,
708                  XmNleftAttachment, XmATTACH_FORM,
709                  XmNleftOffset, 19,
710                  XmNrightAttachment, XmATTACH_WIDGET,
711                  XmNrightOffset, 4,
712                  XmNrightWidget, lock_timeout_text,
713                  NULL);
714
715   XtVaSetValues (passwd_label,
716                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
717                  XmNtopOffset, 0,
718                  XmNtopWidget, passwd_timeout_text,
719                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
720                  XmNbottomOffset, 0,
721                  XmNbottomWidget, passwd_timeout_text,
722                  XmNleftAttachment, XmATTACH_FORM,
723                  XmNleftOffset, 14,
724                  XmNrightAttachment, XmATTACH_WIDGET,
725                  XmNrightOffset, 4,
726                  XmNrightWidget, passwd_timeout_text,
727                  NULL);
728
729   XtVaSetValues (timeout_text,
730                  XmNtopAttachment, XmATTACH_FORM,
731                  XmNtopOffset, 4,
732                  XmNleftAttachment, XmATTACH_FORM,
733                  XmNleftOffset, 141,
734                  NULL);
735
736   XtVaSetValues (cycle_text,
737                  XmNtopAttachment, XmATTACH_WIDGET,
738                  XmNtopOffset, 2,
739                  XmNtopWidget, timeout_text,
740                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
741                  XmNleftOffset, 0,
742                  XmNleftWidget, timeout_text,
743                  NULL);
744
745   XtVaSetValues (fade_text,
746                  XmNtopAttachment, XmATTACH_WIDGET,
747                  XmNtopOffset, 2,
748                  XmNtopWidget, cycle_text,
749                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
750                  XmNleftOffset, 0,
751                  XmNleftWidget, cycle_text,
752                  NULL);
753
754   XtVaSetValues (fade_ticks_text,
755                  XmNtopAttachment, XmATTACH_WIDGET,
756                  XmNtopOffset, 2,
757                  XmNtopWidget, fade_text,
758                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
759                  XmNleftOffset, 0,
760                  XmNleftWidget, fade_text,
761                  NULL);
762
763   XtVaSetValues (lock_timeout_text,
764                  XmNtopAttachment, XmATTACH_WIDGET,
765                  XmNtopOffset, 2,
766                  XmNtopWidget, fade_ticks_text,
767                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
768                  XmNleftOffset, 0,
769                  XmNleftWidget, fade_ticks_text,
770                  NULL);
771
772   XtVaSetValues (passwd_timeout_text,
773                  XmNtopAttachment, XmATTACH_WIDGET,
774                  XmNtopOffset, 4,
775                  XmNtopWidget, lock_timeout_text,
776                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
777                  XmNleftOffset, 0,
778                  XmNleftWidget, lock_timeout_text,
779                  NULL);
780
781   XtVaSetValues (verbose_toggle,
782                  XmNtopAttachment, XmATTACH_FORM,
783                  XmNtopOffset, 4,
784                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
785                  XmNbottomOffset, 0,
786                  XmNbottomWidget, timeout_text,
787                  XmNleftAttachment, XmATTACH_WIDGET,
788                  XmNleftOffset, 20,
789                  XmNleftWidget, timeout_text,
790                  XmNrightAttachment, XmATTACH_FORM,
791                  XmNrightOffset, 20,
792                  NULL);
793
794   XtVaSetValues (install_cmap_toggle,
795                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
796                  XmNtopOffset, 0,
797                  XmNtopWidget, cycle_text,
798                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
799                  XmNbottomOffset, 0,
800                  XmNbottomWidget, cycle_text,
801                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
802                  XmNleftOffset, 0,
803                  XmNleftWidget, verbose_toggle,
804                  XmNrightAttachment, XmATTACH_FORM,
805                  XmNrightOffset, 20,
806                  NULL);
807
808   XtVaSetValues (fade_toggle,
809                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
810                  XmNtopOffset, 0,
811                  XmNtopWidget, fade_text,
812                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
813                  XmNbottomOffset, 0,
814                  XmNbottomWidget, fade_text,
815                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
816                  XmNleftOffset, 0,
817                  XmNleftWidget, install_cmap_toggle,
818                  XmNrightAttachment, XmATTACH_FORM,
819                  XmNrightOffset, 20,
820                  NULL);
821
822   XtVaSetValues (unfade_toggle,
823                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
824                  XmNtopOffset, 0,
825                  XmNtopWidget, fade_ticks_text,
826                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
827                  XmNbottomOffset, 0,
828                  XmNbottomWidget, fade_ticks_text,
829                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
830                  XmNleftOffset, 0,
831                  XmNleftWidget, fade_toggle,
832                  XmNrightAttachment, XmATTACH_FORM,
833                  XmNrightOffset, 20,
834                  NULL);
835
836   XtVaSetValues (lock_toggle,
837                  XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
838                  XmNtopOffset, 0,
839                  XmNtopWidget, lock_timeout_text,
840                  XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
841                  XmNbottomOffset, 0,
842                  XmNbottomWidget, lock_timeout_text,
843                  XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
844                  XmNleftOffset, 0,
845                  XmNleftWidget, unfade_toggle,
846                  XmNrightAttachment, XmATTACH_FORM,
847                  XmNrightOffset, 20,
848                  NULL);
849
850   XtVaSetValues (hr,
851                  XmNtopWidget, passwd_timeout_text,
852                  XmNbottomAttachment, XmATTACH_FORM,
853                  XmNbottomOffset, 4,
854                  XmNleftAttachment, XmATTACH_FORM,
855                  XmNrightAttachment, XmATTACH_FORM,
856                  NULL);
857
858   XtVaSetValues (prefs_done,
859                  XmNleftAttachment, XmATTACH_FORM,
860                  XmNbottomAttachment, XmATTACH_FORM,
861                  NULL);
862   XtVaSetValues (prefs_cancel,
863                  XmNrightAttachment, XmATTACH_FORM,
864                  XmNbottomAttachment, XmATTACH_FORM,
865                  NULL);
866   XtVaSetValues (hr,
867                  XmNbottomAttachment, XmATTACH_WIDGET,
868                  XmNbottomWidget, prefs_done,
869                  NULL);
870
871   ac = 0;
872   children[ac++] = timeout_label;
873   children[ac++] = cycle_label;
874   children[ac++] = fade_seconds_label;
875   children[ac++] = fade_ticks_label;
876   children[ac++] = lock_label;
877   children[ac++] = passwd_label;
878   children[ac++] = timeout_text;
879   children[ac++] = cycle_text;
880   children[ac++] = fade_text;
881   children[ac++] = fade_ticks_text;
882   children[ac++] = lock_timeout_text;
883   children[ac++] = passwd_timeout_text;
884   children[ac++] = verbose_toggle;
885   children[ac++] = install_cmap_toggle;
886   children[ac++] = fade_toggle;
887   children[ac++] = unfade_toggle;
888   children[ac++] = lock_toggle;
889   children[ac++] = hr;
890
891   XtManageChildren(children, ac);
892   ac = 0;
893
894   XtManageChild (prefs_done);
895   XtManageChild (prefs_cancel);
896
897   XtManageChild (preferences_form);
898
899   XtVaSetValues (preferences_form,
900                  XmNleftAttachment, XmATTACH_FORM,
901                  XmNrightAttachment, XmATTACH_FORM,
902                  XmNtopAttachment, XmATTACH_FORM,
903                  XmNbottomAttachment, XmATTACH_FORM,
904                  NULL);
905
906   return preferences_form;
907 }