]>
Commit | Line | Data |
---|---|---|
703082ea | 1 | /* $Header$ |
2 | */ | |
3 | ||
4 | #include <stdio.h> | |
5 | #include <errno.h> | |
6 | #include <X11/Intrinsic.h> | |
7 | #include <X11/Xaw/Box.h> | |
8 | #include <X11/Xaw/Command.h> | |
9 | #include <X11/Xaw/Form.h> | |
10 | #include <X11/Xaw/AsciiText.h> | |
11 | #include <X11/Shell.h> | |
12 | #include <X11/StringDefs.h> | |
13 | #include <X11/cursorfont.h> | |
14 | #include <X11/Xutil.h> | |
15 | #include <X11/Xlib.h> | |
16 | ||
17 | ||
18 | int quit(), help(), again(), go(); | |
19 | void advance_focus(), retreat_focus(); | |
20 | char fname[128], mname[128], lname[128], iname[128], uname[128], pname[128]; | |
21 | Widget TopWidget; | |
22 | ||
23 | XtActionsRec field_actions[] = { | |
24 | {"AdvanceFocus", advance_focus}, | |
25 | {"RetreatFocus", retreat_focus}, | |
26 | }; | |
27 | ||
28 | #define NFIELDS 5 | |
29 | struct field { | |
30 | char *s; | |
31 | Widget w; | |
32 | } fields[NFIELDS] = { | |
33 | { fname }, { mname }, { lname }, { iname }, { uname } | |
34 | }; | |
35 | int active_field = 0; | |
36 | ||
37 | ||
38 | main(argc, argv) | |
39 | int argc; | |
40 | char **argv; | |
41 | { | |
42 | Widget table, w, box; | |
43 | Arg args[10]; | |
44 | Cardinal arg_cnt; | |
45 | Cursor cursor; | |
46 | ||
47 | setenv("XAPPLRESDIR", "/mit/moiradev/src/clients/xregister/"); | |
48 | TopWidget = XtInitialize("Register", "Register", NULL, 0, | |
49 | (unsigned int *)&argc, argv); | |
50 | ||
51 | XtGetApplicationResources(TopWidget, NULL, NULL, 0, NULL); | |
52 | box = XtCreateManagedWidget("box", formWidgetClass, TopWidget, args, 0); | |
53 | XtCreateManagedWidget("title", labelWidgetClass, box, args, 0); | |
54 | XtCreateManagedWidget("logo", labelWidgetClass, box, args, 0); | |
55 | XtCreateManagedWidget("info", asciiTextWidgetClass, box, args, 0); | |
56 | XtCreateManagedWidget("fnamel", labelWidgetClass, box, args, 0); | |
57 | XtCreateManagedWidget("mnamel", labelWidgetClass, box, args, 0); | |
58 | XtCreateManagedWidget("lnamel", labelWidgetClass, box, args, 0); | |
59 | XtCreateManagedWidget("idl", labelWidgetClass, box, args, 0); | |
60 | XtCreateManagedWidget("loginl", labelWidgetClass, box, args, 0); | |
61 | ||
62 | XtAddActions(field_actions, 2); | |
63 | fname[0] = 0; | |
64 | XtSetArg(args[0], XtNstring, fname); | |
65 | fields[0].w = XtCreateManagedWidget("fnameb", asciiTextWidgetClass, | |
66 | box, args, 1); | |
67 | mname[0] = 0; | |
68 | XtSetArg(args[0], XtNstring, mname); | |
69 | fields[1].w = XtCreateManagedWidget("mnameb", asciiTextWidgetClass, | |
70 | box, args, 1); | |
71 | lname[0] = 0; | |
72 | XtSetArg(args[0], XtNstring, lname); | |
73 | fields[2].w = XtCreateManagedWidget("lnameb", asciiTextWidgetClass, | |
74 | box, args, 1); | |
75 | iname[0] = 0; | |
76 | XtSetArg(args[0], XtNstring, iname); | |
77 | fields[3].w = XtCreateManagedWidget("idb", asciiTextWidgetClass, | |
78 | box, args, 1); | |
79 | uname[0] = 0; | |
80 | XtSetArg(args[0], XtNstring, uname); | |
81 | fields[4].w = XtCreateManagedWidget("loginb", asciiTextWidgetClass, | |
82 | box, args, 1); | |
83 | ||
84 | w = XtCreateManagedWidget("go", commandWidgetClass, box, args, 0); | |
85 | XtAddCallback(w, XtNcallback, go, NULL); | |
86 | w = XtCreateManagedWidget("again", commandWidgetClass, box, args, 0); | |
87 | XtAddCallback(w, XtNcallback, again, NULL); | |
88 | w = XtCreateManagedWidget("quit", commandWidgetClass, box, args, 0); | |
89 | XtAddCallback(w, XtNcallback, quit, NULL); | |
90 | ||
91 | XtRealizeWidget(TopWidget); | |
92 | XtMainLoop(); | |
93 | } | |
94 | ||
95 | ||
96 | quit() | |
97 | { | |
98 | exit(0); | |
99 | } | |
100 | ||
101 | remove_popup(ignored, w, ignored1) | |
102 | Widget ignored; | |
103 | caddr_t w; | |
104 | caddr_t ignored1; | |
105 | { | |
106 | XtPopdown((Widget) w); | |
107 | } | |
108 | ||
109 | help(button) | |
110 | Widget button; | |
111 | { | |
112 | static Widget top; | |
113 | Widget box, last; | |
114 | Cardinal num_args; | |
115 | Arg args[12]; | |
116 | Position x, y; | |
117 | static int inited = 0; | |
118 | ||
119 | if (!inited++) { | |
120 | XtTranslateCoords(TopWidget, (Position) 0, (Position) 120, &x, &y); | |
121 | num_args = 0; | |
122 | XtSetArg(args[num_args], XtNx, x); num_args++; | |
123 | XtSetArg(args[num_args], XtNy, y); num_args++; | |
124 | top = XtCreatePopupShell("helpshell", transientShellWidgetClass, | |
125 | TopWidget, args, num_args); | |
126 | ||
127 | box = XtCreateManagedWidget("box", boxWidgetClass, top, NULL, 0); | |
128 | last = XtCreateManagedWidget("helptext", asciiTextWidgetClass, | |
129 | box, args, 0); | |
130 | last = XtCreateManagedWidget("helpcmd", commandWidgetClass, | |
131 | box, NULL, 0); | |
132 | XtAddCallback(last, XtNcallback, remove_popup, top); | |
133 | } | |
134 | XtPopup(top, XtGrabNone); | |
135 | } | |
136 | ||
137 | again() | |
138 | { | |
139 | fname[0] = mname[0] = lname[0] = iname[0] = uname[0] = pname[0] = 0; | |
140 | activate_field(0); | |
141 | } | |
142 | ||
143 | activate_field(f) | |
144 | int f; | |
145 | { | |
146 | Arg args[10]; | |
147 | int i; | |
148 | ||
149 | XtSetArg(args[0], XtNborderWidth, 0); | |
150 | XtSetArg(args[1], XtNdisplayCaret, False); | |
151 | for (i = 0; i < NFIELDS; i++) { | |
152 | XtSetValues(fields[i].w, args, 2); | |
153 | } | |
154 | XtSetArg(args[0], XtNborderWidth, 2); | |
155 | XtSetArg(args[1], XtNdisplayCaret, True); | |
156 | XtSetValues(fields[f].w, args, 2); | |
157 | } | |
158 | ||
159 | void advance_focus() | |
160 | { | |
161 | if (active_field++ >= NFIELDS) | |
162 | active_field = 0; | |
163 | activate_field(active_field); | |
164 | ||
165 | } | |
166 | ||
167 | void retreat_focus() | |
168 | { | |
169 | if (active_field-- < 0) | |
170 | active_field = NFIELDS; | |
171 | activate_field(active_field); | |
172 | ||
173 | } | |
174 | ||
175 | go() | |
176 | { | |
177 | } |