http://ftp.aanet.ru/pub/Linux/X11/apps/xscreensaver-2.31.tar.gz
[xscreensaver] / driver / dialogs-Xaw.c
1 /* dialogs-Xaw.c --- Athena widgets for demo, options, and password dialogs.
2  * xscreensaver, Copyright (c) 1997, 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  * 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 Widget splash_dialog;
77 Widget splash_form;
78 Widget splash_roger_label;
79 Widget splash_label1;
80 Widget splash_label3;
81 Widget splash_demo;
82 Widget splash_prefs;
83 Widget splash_help;
84
85 static Widget buttonbox, textbox, okbox;
86
87
88 void
89 create_passwd_dialog(Widget parent, Visual *visual, Colormap colormap)
90 {
91   Widget box, passwd_label2;
92   int depth = visual_depth(XtScreen(parent), visual);
93
94   passwd_dialog = 
95     XtVaCreatePopupShell("passwd_dialog", transientShellWidgetClass, parent,
96                          XtNtitle, NULL,
97                          XtNoverrideRedirect, TRUE,
98                          XtNvisual, visual,
99                          XtNcolormap, colormap,
100                          XtNdepth, depth,
101                          NULL);
102
103   box = XtVaCreateManagedWidget("box", formWidgetClass, passwd_dialog,
104                             XtNleft, XtChainLeft,
105                             XtNright, XtChainRight,
106                             XtNtop, XtChainTop,
107                             XtNbottom, XtChainBottom,
108                          XtNvisual, visual,
109                          XtNcolormap, colormap,
110                          XtNdepth, depth,
111                             NULL);
112
113   roger_label = XtVaCreateManagedWidget("roger", labelWidgetClass, box,
114                                         XtNlabel, "",
115                                         XtNleft, XtChainLeft,
116                                         XtNright, XtChainRight,
117                                         XtNtop, XtChainTop,
118                                         NULL);
119
120   passwd_label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, box,
121                                           XtNfromHoriz, roger_label,
122                                           XtNright, XtChainRight,
123                                           XtNtop, XtChainTop,
124                                           NULL);
125   passwd_label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, box,
126                                           XtNfromHoriz, roger_label,
127                                           XtNright, XtChainRight,
128                                           XtNfromVert, passwd_label1,
129                                           NULL);
130   passwd_label3 = XtVaCreateManagedWidget("label3", labelWidgetClass, box,
131                                           XtNfromHoriz, roger_label,
132                                           XtNright, XtChainRight,
133                                           XtNfromVert, passwd_label2,
134                                           NULL);
135   
136   passwd_form =
137     XtVaCreateManagedWidget("passwd_form", dialogWidgetClass, box,
138                             XtNfromHoriz, roger_label,
139                             XtNright, XtChainRight,
140                             XtNfromVert, passwd_label3,
141                             NULL);
142 }
143
144
145 void
146 create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
147 {
148   Widget rlabel;
149   int depth = visual_depth(XtScreen(parent), visual);
150
151   resources_dialog = 
152     XtVaCreatePopupShell("resources_dialog", transientShellWidgetClass, parent,
153                          XtNtitle, NULL,
154                          XtNoverrideRedirect, TRUE,
155                          XtNvisual, visual,
156                          XtNcolormap, colormap,
157                          XtNdepth, depth,
158                          NULL);
159
160   resources_form =
161     XtVaCreateManagedWidget("resources_form", formWidgetClass,
162                             resources_dialog,
163                          XtNvisual, visual,
164                          XtNcolormap, colormap,
165                          XtNdepth, depth,
166                             NULL);
167
168   rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, resources_form,
169                                    XtNleft, XtChainLeft,
170                                    XtNright, XtChainRight,
171                                    XtNtop, XtChainTop,
172                                    NULL);
173
174   textbox=
175     XtVaCreateManagedWidget("textbox", formWidgetClass, resources_form,
176                             XtNleft, XtChainLeft,
177                             XtNfromVert, rlabel,
178                             NULL);
179   okbox=
180     XtVaCreateManagedWidget("textbox", boxWidgetClass, resources_form,
181                             XtNleft, XtChainLeft,
182                             XtNright, XtChainRight,
183                             XtNfromVert, textbox,
184                             XtNorientation, XtorientHorizontal,
185                             NULL);
186   timeout_text=
187     XtVaCreateManagedWidget("timeout", dialogWidgetClass, textbox,
188                             XtNleft, XtChainLeft,
189                             XtNright, XtChainRight,
190                             XtNtop, XtChainTop,
191                             NULL);
192   cycle_text=
193     XtVaCreateManagedWidget("cycle", dialogWidgetClass, textbox,
194                             XtNleft, XtChainLeft,
195                             XtNright, XtChainRight,
196                             XtNfromVert, timeout_text,
197                             NULL);
198   fade_text=
199     XtVaCreateManagedWidget("fade", dialogWidgetClass, textbox,
200                             XtNleft, XtChainLeft,
201                             XtNright, XtChainRight,
202                             XtNfromVert, cycle_text,
203                             NULL);
204
205   ticks_text =
206     XtVaCreateManagedWidget("ticks", dialogWidgetClass, textbox,
207                             XtNtop, XtChainTop,
208                             XtNright, XtChainRight,
209                             XtNfromHoriz, timeout_text,
210                             NULL);
211
212   lock_time_text =
213     XtVaCreateManagedWidget("lockTime", dialogWidgetClass, textbox,
214                             XtNfromVert, ticks_text,
215                             XtNright, XtChainRight,
216                             XtNfromHoriz, cycle_text,
217                             NULL);
218
219   passwd_time_text =
220     XtVaCreateManagedWidget("passwdTime", dialogWidgetClass, textbox,
221                             XtNfromVert, lock_time_text,
222                             XtNright, XtChainRight,
223                             XtNfromHoriz, fade_text,
224                             NULL);
225
226   buttonbox=
227     XtVaCreateManagedWidget("buttonbox", boxWidgetClass, resources_form,
228                             XtNfromVert, rlabel,
229                             XtNfromHoriz, textbox,
230                             XtNright, XtChainRight,
231                             XtNorientation, XtorientVertical,
232                             NULL);
233   verbose_toggle =
234     XtVaCreateManagedWidget("verbose", toggleWidgetClass, buttonbox,
235                             NULL);
236   cmap_toggle =
237     XtVaCreateManagedWidget("cmap", toggleWidgetClass, buttonbox,
238                             NULL);
239   fade_toggle =
240     XtVaCreateManagedWidget("fade", toggleWidgetClass, buttonbox,
241                             NULL);
242   unfade_toggle =
243     XtVaCreateManagedWidget("unfade", toggleWidgetClass, buttonbox,
244                             NULL);
245   lock_toggle = 
246     XtVaCreateManagedWidget("lock", toggleWidgetClass, buttonbox,
247                             NULL);
248
249
250   res_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
251                                      NULL);
252   res_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
253                                        NULL);
254 }
255
256 void
257 create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
258 {
259   Widget subform, box, viewport, label2;
260   int depth = visual_depth(XtScreen(parent), visual);
261
262   demo_dialog = 
263     XtVaCreatePopupShell("demo_dialog", transientShellWidgetClass, parent,
264                          XtNtitle, NULL,
265                          XtNoverrideRedirect, TRUE,
266                          XtNvisual, visual,
267                          XtNcolormap, colormap,
268                          XtNdepth, depth,
269                          NULL);
270
271   demo_form =
272     XtVaCreateManagedWidget("demo_form", formWidgetClass, demo_dialog,
273                          XtNvisual, visual,
274                          XtNcolormap, colormap,
275                          XtNdepth, depth,
276                             NULL);
277
278   label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, demo_form,
279                             XtNleft, XtChainLeft,
280                             XtNright, XtChainRight,
281                             XtNtop, XtChainTop,
282                             NULL);
283
284   label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, demo_form,
285                             XtNleft, XtChainLeft,
286                             XtNright, XtChainRight,
287                             XtNfromVert, label1,
288                             NULL);
289
290   subform =
291     XtVaCreateManagedWidget("subform", formWidgetClass, demo_form,
292                             XtNleft, XtChainLeft,
293                             XtNright, XtChainRight,
294                             XtNfromVert, label2,
295                             NULL);
296   viewport =
297     XtVaCreateManagedWidget("viewport", viewportWidgetClass, subform,
298                             XtNtop, XtChainTop,
299                             XtNleft, XtChainLeft,
300                             XtNright, XtChainRight,
301                             XtNallowVert, TRUE,
302                             XtNallowHoriz, TRUE,
303                             XtNforceBars, TRUE,
304                             NULL);
305
306   demo_list = XtVaCreateManagedWidget("demo_list", listWidgetClass, viewport,
307                                       XtNverticalList, TRUE,
308                                       XtNdefaultColumns, 1,
309                                       NULL);
310
311   text_line = XtVaCreateManagedWidget("text", asciiTextWidgetClass, subform,
312                                       XtNleft, XtChainLeft,
313                                       XtNright, XtChainRight,
314                                       XtNfromVert, viewport,
315                                       XtNbottom, XtChainBottom,
316                                       XtNeditType, XawtextEdit,
317                                       NULL);
318
319   box =
320     XtVaCreateManagedWidget("box", boxWidgetClass, demo_form,
321                             XtNleft, XtChainLeft,
322                             XtNfromVert, subform,
323                             XtNbottom, XtChainBottom,
324                             XtNright, XtChainRight,
325                             XtNorientation, XtEhorizontal,
326                             NULL);
327   next = XtVaCreateManagedWidget("next", commandWidgetClass, box, NULL);
328   prev = XtVaCreateManagedWidget("prev", commandWidgetClass, box, NULL);
329   edit = XtVaCreateManagedWidget("edit", commandWidgetClass, box, NULL);
330   restart = XtVaCreateManagedWidget("restart", commandWidgetClass, box, NULL);
331   done = XtVaCreateManagedWidget("done", commandWidgetClass, box, NULL);
332 }
333
334
335 void
336 create_splash_dialog(Widget parent, Visual *visual, Colormap colormap)
337 {
338   Widget box, splash_label2;
339   int depth = visual_depth(XtScreen(parent), visual);
340
341   splash_dialog = 
342     XtVaCreatePopupShell("splash_dialog", transientShellWidgetClass, parent,
343                          XtNtitle, NULL,
344                          XtNoverrideRedirect, TRUE,
345                          XtNvisual, visual,
346                          XtNcolormap, colormap,
347                          XtNdepth, depth,
348                          NULL);
349
350   box = XtVaCreateManagedWidget("box", formWidgetClass, splash_dialog,
351                                 XtNleft, XtChainLeft,
352                                 XtNright, XtChainRight,
353                                 XtNtop, XtChainTop,
354                                 XtNbottom, XtChainBottom,
355                                 XtNvisual, visual,
356                                 XtNcolormap, colormap,
357                                 XtNdepth, depth,
358                                 NULL);
359
360   splash_roger_label = XtVaCreateManagedWidget("roger", labelWidgetClass, box,
361                                                XtNlabel, "",
362                                                XtNleft, XtChainLeft,
363                                                XtNright, XtChainRight,
364                                                XtNtop, XtChainTop,
365                                                NULL);
366
367   splash_label1 = XtVaCreateManagedWidget("splashLabel1", labelWidgetClass,
368                                           box,
369                                           XtNfromHoriz, splash_roger_label,
370                                           XtNright, XtChainRight,
371                                           XtNtop, XtChainTop,
372                                           NULL);
373   splash_label2 = XtVaCreateManagedWidget("splashLabel2", labelWidgetClass,
374                                           box,
375                                           XtNfromHoriz, splash_roger_label,
376                                           XtNright, XtChainRight,
377                                           XtNfromVert, splash_label1,
378                                           NULL);
379   splash_label3 = XtVaCreateManagedWidget("splashLabel3", labelWidgetClass,
380                                           box,
381                                           XtNfromHoriz, splash_roger_label,
382                                           XtNright, XtChainRight,
383                                           XtNfromVert, splash_label2,
384                                           NULL);
385   
386   splash_form =
387     XtVaCreateManagedWidget("splash_form", dialogWidgetClass, box,
388                             XtNfromHoriz, splash_roger_label,
389                             XtNright, XtChainRight,
390                             XtNfromVert, splash_label3,
391                             NULL);
392 }