ftp://ftp.smr.ru/pub/0/FreeBSD/releases/distfiles/xscreensaver-3.16.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 preferences_dialog;
37 Widget preferences_form;
38 Widget timeout_text;
39 Widget cycle_text;
40 Widget fade_text;
41 Widget fade_ticks_text;
42 Widget lock_timeout_text;
43 Widget passwd_timeout_text;
44 Widget verbose_toggle;
45 Widget install_cmap_toggle;
46 Widget fade_toggle;
47 Widget unfade_toggle;
48 Widget lock_toggle;
49 Widget prefs_done;
50 Widget prefs_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_preferences_dialog(Widget parent, Visual *visual, Colormap colormap)
72 {
73   Widget rlabel;
74   int depth = visual_depth(XtScreen(parent), visual);
75
76   preferences_dialog = 
77     XtVaCreatePopupShell("preferences_dialog", transientShellWidgetClass, parent,
78                          XtNvisual, visual,
79                          XtNcolormap, colormap,
80                          XtNdepth, depth,
81                          NULL);
82
83   preferences_form =
84     XtVaCreateManagedWidget("preferences_form", formWidgetClass,
85                             preferences_dialog,
86                          XtNvisual, visual,
87                          XtNcolormap, colormap,
88                          XtNdepth, depth,
89                             NULL);
90
91   rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, preferences_form,
92                                    XtNleft, XtChainLeft,
93                                    XtNright, XtChainRight,
94                                    XtNtop, XtChainTop,
95                                    NULL);
96
97   textbox=
98     XtVaCreateManagedWidget("textbox", formWidgetClass, preferences_form,
99                             XtNleft, XtChainLeft,
100                             XtNfromVert, rlabel,
101                             NULL);
102   okbox=
103     XtVaCreateManagedWidget("textbox", boxWidgetClass, preferences_form,
104                             XtNleft, XtChainLeft,
105                             XtNright, XtChainRight,
106                             XtNfromVert, textbox,
107                             XtNorientation, XtorientHorizontal,
108                             NULL);
109   timeout_text=
110     XtVaCreateManagedWidget("timeout", dialogWidgetClass, textbox,
111                             XtNleft, XtChainLeft,
112                             XtNright, XtChainRight,
113                             XtNtop, XtChainTop,
114                             NULL);
115   cycle_text=
116     XtVaCreateManagedWidget("cycle", dialogWidgetClass, textbox,
117                             XtNleft, XtChainLeft,
118                             XtNright, XtChainRight,
119                             XtNfromVert, timeout_text,
120                             NULL);
121   fade_text=
122     XtVaCreateManagedWidget("fade", dialogWidgetClass, textbox,
123                             XtNleft, XtChainLeft,
124                             XtNright, XtChainRight,
125                             XtNfromVert, cycle_text,
126                             NULL);
127
128   fade_ticks_text =
129     XtVaCreateManagedWidget("ticks", dialogWidgetClass, textbox,
130                             XtNtop, XtChainTop,
131                             XtNright, XtChainRight,
132                             XtNfromHoriz, timeout_text,
133                             NULL);
134
135   lock_timeout_text =
136     XtVaCreateManagedWidget("lockTime", dialogWidgetClass, textbox,
137                             XtNfromVert, fade_ticks_text,
138                             XtNright, XtChainRight,
139                             XtNfromHoriz, cycle_text,
140                             NULL);
141
142   passwd_timeout_text =
143     XtVaCreateManagedWidget("passwdTime", dialogWidgetClass, textbox,
144                             XtNfromVert, lock_timeout_text,
145                             XtNright, XtChainRight,
146                             XtNfromHoriz, fade_text,
147                             NULL);
148
149   buttonbox=
150     XtVaCreateManagedWidget("buttonbox", boxWidgetClass, preferences_form,
151                             XtNfromVert, rlabel,
152                             XtNfromHoriz, textbox,
153                             XtNright, XtChainRight,
154                             XtNorientation, XtorientVertical,
155                             NULL);
156   verbose_toggle =
157     XtVaCreateManagedWidget("verbose", toggleWidgetClass, buttonbox,
158                             NULL);
159   install_cmap_toggle =
160     XtVaCreateManagedWidget("cmap", toggleWidgetClass, buttonbox,
161                             NULL);
162   fade_toggle =
163     XtVaCreateManagedWidget("fade", toggleWidgetClass, buttonbox,
164                             NULL);
165   unfade_toggle =
166     XtVaCreateManagedWidget("unfade", toggleWidgetClass, buttonbox,
167                             NULL);
168   lock_toggle = 
169     XtVaCreateManagedWidget("lock", toggleWidgetClass, buttonbox,
170                             NULL);
171
172
173   prefs_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
174                                      NULL);
175   prefs_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
176                                        NULL);
177 }
178
179 void
180 create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
181 {
182   Widget subform, box, viewport, label2;
183   int depth = visual_depth(XtScreen(parent), visual);
184
185   demo_dialog = 
186     XtVaCreatePopupShell("demo_dialog", transientShellWidgetClass, parent,
187                          XtNvisual, visual,
188                          XtNcolormap, colormap,
189                          XtNdepth, depth,
190                          NULL);
191
192   demo_form =
193     XtVaCreateManagedWidget("demo_form", formWidgetClass, demo_dialog,
194                             XtNvisual, visual,
195                             XtNcolormap, colormap,
196                             XtNdepth, depth,
197                             XtNleft, XtChainLeft,
198                             XtNright, XtChainRight,
199                             XtNtop, XtChainTop,
200                             NULL);
201
202   label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, demo_form,
203                             XtNleft, XtChainLeft,
204                             XtNright, XtChainRight,
205                             XtNtop, XtChainTop,
206                             NULL);
207
208   label2 = XtVaCreateManagedWidget("label2", labelWidgetClass, demo_form,
209                             XtNleft, XtChainLeft,
210                             XtNright, XtChainRight,
211                             XtNfromVert, label1,
212                             NULL);
213
214   subform =
215     XtVaCreateManagedWidget("subform", formWidgetClass, demo_form,
216                             XtNleft, XtChainLeft,
217                             XtNright, XtChainRight,
218                             XtNfromVert, label2,
219                             XtNresizable, True,
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 #if 0
256   restart = XtVaCreateManagedWidget("restart", commandWidgetClass, box, NULL);
257 #endif
258   done = XtVaCreateManagedWidget("done", commandWidgetClass, box, NULL);
259 }