179381368744020672add8f2a0dad31de5e2086b
[xscreensaver] / driver / dialogs-Xaw.c
1 /* dialogs-Xaw.c --- Athena widgets for demo, options, and password dialogs.
2  * xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@netscape.com>
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  * Most of this code contributed by Jon A. Christopher <jac8782@tamu.edu>
13  * Copyright 1997, with the same permissions as above.
14  */
15
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
19
20 #include <X11/Intrinsic.h>
21 #include <X11/StringDefs.h>
22 #include <X11/Shell.h>
23 #include <X11/Xaw/Form.h>
24 #include <X11/Xaw/Box.h>
25 #include <X11/Xaw/List.h>
26 #include <X11/Xaw/Command.h>
27 #include <X11/Xaw/Toggle.h>
28 #include <X11/Xaw/Viewport.h>
29 #include <X11/Xaw/Dialog.h>
30
31 #include <stdio.h>
32
33 #include "visual.h"     /* for visual_depth() */
34
35 Widget passwd_dialog;
36 Widget passwd_form;
37 Widget roger_label;
38 Widget passwd_label1;
39 Widget passwd_label3;
40 /*Widget passwd_text;*/
41 /*Widget passwd_done;*/
42 /*Widget passwd_cancel;*/
43
44 Widget resources_dialog;
45 Widget resources_form;
46 Widget timeout_text;
47 Widget cycle_text;
48 Widget fade_text;
49 Widget ticks_text;
50 Widget lock_time_text;
51 Widget passwd_time_text;
52 Widget verbose_toggle;
53 Widget cmap_toggle;
54 Widget fade_toggle;
55 Widget unfade_toggle;
56 Widget lock_toggle;
57 Widget res_done;
58 Widget res_cancel;
59
60 Widget demo_dialog;
61 Widget demo_form;
62 Widget label1;
63 /*Widget label2;*/
64 /*Widget text_area;*/
65 Widget demo_list;
66 Widget text_line;
67 /*Widget vline;*/
68 Widget next;
69 Widget prev;
70 Widget edit;
71 Widget done;
72 Widget restart;
73 /*Widget spacer;*/
74
75
76 static Widget buttonbox, textbox, okbox;
77
78
79 void
80 create_passwd_dialog(Widget parent, Visual *visual, Colormap colormap)
81 {
82   Widget box, passwd_label2;
83   int depth = visual_depth(XtScreen(parent), visual);
84
85   passwd_dialog = 
86     XtVaCreatePopupShell("passwd_dialog", transientShellWidgetClass, parent,
87                          XtNtitle, NULL,
88                          XtNoverrideRedirect, TRUE,
89                          XtNvisual, visual,
90                          XtNcolormap, colormap,
91                          XtNdepth, depth,
92                          NULL);
93
94   box = XtVaCreateManagedWidget("box", formWidgetClass, passwd_dialog,
95                             XtNleft, XtChainLeft,
96                             XtNright, XtChainRight,
97                             XtNtop, XtChainTop,
98                             XtNbottom, XtChainBottom,
99                          XtNvisual, visual,
100                          XtNcolormap, colormap,
101                          XtNdepth, depth,
102                             NULL);
103
104   roger_label = XtVaCreateManagedWidget("roger", labelWidgetClass, box,
105                                         XtNlabel, "",
106                                         XtNleft, XtChainLeft,
107                                         XtNright, XtChainRight,
108                                         XtNtop, XtChainTop,
109                                         NULL);
110
111   passwd_label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, box,
112                                           XtNfromHoriz, roger_label,
113                                           XtNright, XtChainRight,
114                                           XtNtop, XtChainTop,
115                                           NULL);
116   passwd_label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, box,
117                                           XtNfromHoriz, roger_label,
118                                           XtNright, XtChainRight,
119                                           XtNfromVert, passwd_label1,
120                                           NULL);
121   passwd_label3 = XtVaCreateManagedWidget("label3", labelWidgetClass, box,
122                                           XtNfromHoriz, roger_label,
123                                           XtNright, XtChainRight,
124                                           XtNfromVert, passwd_label2,
125                                           NULL);
126   
127   passwd_form =
128     XtVaCreateManagedWidget("passwd_form", dialogWidgetClass, box,
129                             XtNfromHoriz, roger_label,
130                             XtNright, XtChainRight,
131                             XtNfromVert, passwd_label3,
132                             NULL);
133 }
134
135
136 void
137 create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
138 {
139   Widget rlabel;
140   int depth = visual_depth(XtScreen(parent), visual);
141
142   resources_dialog = 
143     XtVaCreatePopupShell("resources_dialog", transientShellWidgetClass, parent,
144                          XtNtitle, NULL,
145                          XtNoverrideRedirect, TRUE,
146                          XtNvisual, visual,
147                          XtNcolormap, colormap,
148                          XtNdepth, depth,
149                          NULL);
150
151   resources_form =
152     XtVaCreateManagedWidget("resources_form", formWidgetClass,
153                             resources_dialog,
154                          XtNvisual, visual,
155                          XtNcolormap, colormap,
156                          XtNdepth, depth,
157                             NULL);
158
159   rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, resources_form,
160                                    XtNleft, XtChainLeft,
161                                    XtNright, XtChainRight,
162                                    XtNtop, XtChainTop,
163                                    NULL);
164
165   textbox=
166     XtVaCreateManagedWidget("textbox", formWidgetClass, resources_form,
167                             XtNleft, XtChainLeft,
168                             XtNfromVert, rlabel,
169                             NULL);
170   okbox=
171     XtVaCreateManagedWidget("textbox", boxWidgetClass, resources_form,
172                             XtNleft, XtChainLeft,
173                             XtNright, XtChainRight,
174                             XtNfromVert, textbox,
175                             XtNorientation, XtorientHorizontal,
176                             NULL);
177   timeout_text=
178     XtVaCreateManagedWidget("timeout", dialogWidgetClass, textbox,
179                             XtNleft, XtChainLeft,
180                             XtNright, XtChainRight,
181                             XtNtop, XtChainTop,
182                             NULL);
183   cycle_text=
184     XtVaCreateManagedWidget("cycle", dialogWidgetClass, textbox,
185                             XtNleft, XtChainLeft,
186                             XtNright, XtChainRight,
187                             XtNfromVert, timeout_text,
188                             NULL);
189   fade_text=
190     XtVaCreateManagedWidget("fade", dialogWidgetClass, textbox,
191                             XtNleft, XtChainLeft,
192                             XtNright, XtChainRight,
193                             XtNfromVert, cycle_text,
194                             NULL);
195
196   ticks_text =
197     XtVaCreateManagedWidget("ticks", dialogWidgetClass, textbox,
198                             XtNtop, XtChainTop,
199                             XtNright, XtChainRight,
200                             XtNfromHoriz, timeout_text,
201                             NULL);
202
203   lock_time_text =
204     XtVaCreateManagedWidget("lockTime", dialogWidgetClass, textbox,
205                             XtNfromVert, ticks_text,
206                             XtNright, XtChainRight,
207                             XtNfromHoriz, cycle_text,
208                             NULL);
209
210   passwd_time_text =
211     XtVaCreateManagedWidget("passwdTime", dialogWidgetClass, textbox,
212                             XtNfromVert, lock_time_text,
213                             XtNright, XtChainRight,
214                             XtNfromHoriz, fade_text,
215                             NULL);
216
217   buttonbox=
218     XtVaCreateManagedWidget("buttonbox", boxWidgetClass, resources_form,
219                             XtNfromVert, rlabel,
220                             XtNfromHoriz, textbox,
221                             XtNright, XtChainRight,
222                             XtNorientation, XtorientVertical,
223                             NULL);
224   verbose_toggle =
225     XtVaCreateManagedWidget("verbose", toggleWidgetClass, buttonbox,
226                             NULL);
227   cmap_toggle =
228     XtVaCreateManagedWidget("cmap", toggleWidgetClass, buttonbox,
229                             NULL);
230   fade_toggle =
231     XtVaCreateManagedWidget("fade", toggleWidgetClass, buttonbox,
232                             NULL);
233   unfade_toggle =
234     XtVaCreateManagedWidget("unfade", toggleWidgetClass, buttonbox,
235                             NULL);
236   lock_toggle = 
237     XtVaCreateManagedWidget("lock", toggleWidgetClass, buttonbox,
238                             NULL);
239
240
241   res_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
242                                      NULL);
243   res_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
244                                        NULL);
245 }
246
247 void
248 create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
249 {
250   Widget subform, box, viewport, label2;
251   int depth = visual_depth(XtScreen(parent), visual);
252
253   demo_dialog = 
254     XtVaCreatePopupShell("demo_dialog", transientShellWidgetClass, parent,
255                          XtNtitle, NULL,
256                          XtNoverrideRedirect, TRUE,
257                          XtNvisual, visual,
258                          XtNcolormap, colormap,
259                          XtNdepth, depth,
260                          NULL);
261
262   demo_form =
263     XtVaCreateManagedWidget("demo_form", formWidgetClass, demo_dialog,
264                          XtNvisual, visual,
265                          XtNcolormap, colormap,
266                          XtNdepth, depth,
267                             NULL);
268
269   label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, demo_form,
270                             XtNleft, XtChainLeft,
271                             XtNright, XtChainRight,
272                             XtNtop, XtChainTop,
273                             NULL);
274
275   label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, demo_form,
276                             XtNleft, XtChainLeft,
277                             XtNright, XtChainRight,
278                             XtNfromVert, label1,
279                             NULL);
280
281   subform=
282     XtVaCreateManagedWidget("subform", formWidgetClass, demo_form,
283                             XtNleft, XtChainLeft,
284                             XtNright, XtChainRight,
285                             XtNfromVert, label2,
286                             XtNbottom, XtChainBottom,
287                             NULL);
288   viewport=
289     XtVaCreateManagedWidget("viewport", viewportWidgetClass, subform,
290                             XtNallowVert, TRUE,
291                             XtNallowHoriz, TRUE,
292                             XtNforceBars, TRUE,
293                             NULL);
294
295   demo_list = XtVaCreateManagedWidget("demo_list", listWidgetClass, viewport,
296                                     XtNverticalList, TRUE,
297                                     XtNdefaultColumns, 1,
298                                     NULL);
299   box=
300     XtVaCreateManagedWidget("box", boxWidgetClass, demo_form,
301                             XtNfromHoriz, subform,
302                             XtNfromVert, label2,
303                             XtNbottom, XtChainBottom,
304                             XtNright, XtChainRight,
305                             NULL);
306   prev = XtVaCreateManagedWidget("prev", commandWidgetClass, box, NULL);
307   next = XtVaCreateManagedWidget("next", commandWidgetClass, box, NULL);
308   edit = XtVaCreateManagedWidget("edit", commandWidgetClass, box, NULL);
309   restart = XtVaCreateManagedWidget("restart", commandWidgetClass, box, NULL);
310   done = XtVaCreateManagedWidget("done", commandWidgetClass, box, NULL);
311 }