http://ftp.x.org/contrib/applications/xscreensaver-2.34.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 resources_dialog;
37 Widget resources_form;
38 Widget timeout_text;
39 Widget cycle_text;
40 Widget fade_text;
41 Widget ticks_text;
42 Widget lock_time_text;
43 Widget passwd_time_text;
44 Widget verbose_toggle;
45 Widget cmap_toggle;
46 Widget fade_toggle;
47 Widget unfade_toggle;
48 Widget lock_toggle;
49 Widget res_done;
50 Widget res_cancel;
51
52 Widget demo_dialog;
53 Widget demo_form;
54 Widget label1;
55 /*Widget label2;*/
56 /*Widget text_area;*/
57 Widget demo_list;
58 Widget text_line;
59 /*Widget vline;*/
60 Widget next;
61 Widget prev;
62 Widget edit;
63 Widget done;
64 Widget restart;
65 /*Widget spacer;*/
66
67 static Widget buttonbox, textbox, okbox;
68
69
70 void
71 create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
72 {
73   Widget rlabel;
74   int depth = visual_depth(XtScreen(parent), visual);
75
76   resources_dialog = 
77     XtVaCreatePopupShell("resources_dialog", transientShellWidgetClass, parent,
78                          XtNtitle, NULL,
79                          XtNoverrideRedirect, TRUE,
80                          XtNvisual, visual,
81                          XtNcolormap, colormap,
82                          XtNdepth, depth,
83                          NULL);
84
85   resources_form =
86     XtVaCreateManagedWidget("resources_form", formWidgetClass,
87                             resources_dialog,
88                          XtNvisual, visual,
89                          XtNcolormap, colormap,
90                          XtNdepth, depth,
91                             NULL);
92
93   rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, resources_form,
94                                    XtNleft, XtChainLeft,
95                                    XtNright, XtChainRight,
96                                    XtNtop, XtChainTop,
97                                    NULL);
98
99   textbox=
100     XtVaCreateManagedWidget("textbox", formWidgetClass, resources_form,
101                             XtNleft, XtChainLeft,
102                             XtNfromVert, rlabel,
103                             NULL);
104   okbox=
105     XtVaCreateManagedWidget("textbox", boxWidgetClass, resources_form,
106                             XtNleft, XtChainLeft,
107                             XtNright, XtChainRight,
108                             XtNfromVert, textbox,
109                             XtNorientation, XtorientHorizontal,
110                             NULL);
111   timeout_text=
112     XtVaCreateManagedWidget("timeout", dialogWidgetClass, textbox,
113                             XtNleft, XtChainLeft,
114                             XtNright, XtChainRight,
115                             XtNtop, XtChainTop,
116                             NULL);
117   cycle_text=
118     XtVaCreateManagedWidget("cycle", dialogWidgetClass, textbox,
119                             XtNleft, XtChainLeft,
120                             XtNright, XtChainRight,
121                             XtNfromVert, timeout_text,
122                             NULL);
123   fade_text=
124     XtVaCreateManagedWidget("fade", dialogWidgetClass, textbox,
125                             XtNleft, XtChainLeft,
126                             XtNright, XtChainRight,
127                             XtNfromVert, cycle_text,
128                             NULL);
129
130   ticks_text =
131     XtVaCreateManagedWidget("ticks", dialogWidgetClass, textbox,
132                             XtNtop, XtChainTop,
133                             XtNright, XtChainRight,
134                             XtNfromHoriz, timeout_text,
135                             NULL);
136
137   lock_time_text =
138     XtVaCreateManagedWidget("lockTime", dialogWidgetClass, textbox,
139                             XtNfromVert, ticks_text,
140                             XtNright, XtChainRight,
141                             XtNfromHoriz, cycle_text,
142                             NULL);
143
144   passwd_time_text =
145     XtVaCreateManagedWidget("passwdTime", dialogWidgetClass, textbox,
146                             XtNfromVert, lock_time_text,
147                             XtNright, XtChainRight,
148                             XtNfromHoriz, fade_text,
149                             NULL);
150
151   buttonbox=
152     XtVaCreateManagedWidget("buttonbox", boxWidgetClass, resources_form,
153                             XtNfromVert, rlabel,
154                             XtNfromHoriz, textbox,
155                             XtNright, XtChainRight,
156                             XtNorientation, XtorientVertical,
157                             NULL);
158   verbose_toggle =
159     XtVaCreateManagedWidget("verbose", toggleWidgetClass, buttonbox,
160                             NULL);
161   cmap_toggle =
162     XtVaCreateManagedWidget("cmap", toggleWidgetClass, buttonbox,
163                             NULL);
164   fade_toggle =
165     XtVaCreateManagedWidget("fade", toggleWidgetClass, buttonbox,
166                             NULL);
167   unfade_toggle =
168     XtVaCreateManagedWidget("unfade", toggleWidgetClass, buttonbox,
169                             NULL);
170   lock_toggle = 
171     XtVaCreateManagedWidget("lock", toggleWidgetClass, buttonbox,
172                             NULL);
173
174
175   res_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
176                                      NULL);
177   res_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
178                                        NULL);
179 }
180
181 void
182 create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
183 {
184   Widget subform, box, viewport, label2;
185   int depth = visual_depth(XtScreen(parent), visual);
186
187   demo_dialog = 
188     XtVaCreatePopupShell("demo_dialog", transientShellWidgetClass, parent,
189                          XtNtitle, NULL,
190                          XtNoverrideRedirect, TRUE,
191                          XtNvisual, visual,
192                          XtNcolormap, colormap,
193                          XtNdepth, depth,
194                          NULL);
195
196   demo_form =
197     XtVaCreateManagedWidget("demo_form", formWidgetClass, demo_dialog,
198                          XtNvisual, visual,
199                          XtNcolormap, colormap,
200                          XtNdepth, depth,
201                             NULL);
202
203   label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, demo_form,
204                             XtNleft, XtChainLeft,
205                             XtNright, XtChainRight,
206                             XtNtop, XtChainTop,
207                             NULL);
208
209   label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, demo_form,
210                             XtNleft, XtChainLeft,
211                             XtNright, XtChainRight,
212                             XtNfromVert, label1,
213                             NULL);
214
215   subform =
216     XtVaCreateManagedWidget("subform", formWidgetClass, demo_form,
217                             XtNleft, XtChainLeft,
218                             XtNright, XtChainRight,
219                             XtNfromVert, label2,
220                             NULL);
221   viewport =
222     XtVaCreateManagedWidget("viewport", viewportWidgetClass, subform,
223                             XtNtop, XtChainTop,
224                             XtNleft, XtChainLeft,
225                             XtNright, XtChainRight,
226                             XtNallowVert, TRUE,
227                             XtNallowHoriz, TRUE,
228                             XtNforceBars, TRUE,
229                             NULL);
230
231   demo_list = XtVaCreateManagedWidget("demo_list", listWidgetClass, viewport,
232                                       XtNverticalList, TRUE,
233                                       XtNdefaultColumns, 1,
234                                       NULL);
235
236   text_line = XtVaCreateManagedWidget("text", asciiTextWidgetClass, subform,
237                                       XtNleft, XtChainLeft,
238                                       XtNright, XtChainRight,
239                                       XtNfromVert, viewport,
240                                       XtNbottom, XtChainBottom,
241                                       XtNeditType, XawtextEdit,
242                                       NULL);
243
244   box =
245     XtVaCreateManagedWidget("box", boxWidgetClass, demo_form,
246                             XtNleft, XtChainLeft,
247                             XtNfromVert, subform,
248                             XtNbottom, XtChainBottom,
249                             XtNright, XtChainRight,
250                             XtNorientation, XtEhorizontal,
251                             NULL);
252   next = XtVaCreateManagedWidget("next", commandWidgetClass, box, NULL);
253   prev = XtVaCreateManagedWidget("prev", commandWidgetClass, box, NULL);
254   edit = XtVaCreateManagedWidget("edit", commandWidgetClass, box, NULL);
255   restart = XtVaCreateManagedWidget("restart", commandWidgetClass, box, NULL);
256   done = XtVaCreateManagedWidget("done", commandWidgetClass, box, NULL);
257 }