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