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