2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
11 #include <afsconfig.h>
15 #include "gtxwindows.h"
16 #include "gtxobjects.h"
17 #include "gtxtextobj.h"
18 #include "gtxlightobj.h"
21 struct gtx_frame *frameA, *frameB;
23 struct onode *objectA, *objectB;
24 struct onode *lightA, *lightB;
26 static int ChangeMenuCmd(awin, arock)
28 register struct gwin *awin; {
29 register struct gtx_frame *tf;
30 register afs_int32 code;
36 gtxframe_ClearMenus(tf);
38 else if (arock == 2) {
39 code = gtxframe_DeleteMenu(tf, "NewLabel");
40 if (code) gtxframe_DisplayString(tf, "Can't delete menu!");
42 else if (arock == 3) {
43 code = gtxframe_ClearMenus(tf);
44 gtxframe_AddMenu(frameA, "FrameB", "b");
45 gtxframe_AddMenu(frameA, "NewLabel", "c");
50 static int ChangeListCmd(awin, arock)
52 register struct gwin *awin; {
53 register struct gtx_frame *tf;
54 register afs_int32 code;
60 gtxframe_ClearList(tf);
62 else if (arock == 2) {
63 code = gtxframe_RemoveFromList(tf, lightA);
64 if (code) gtxframe_DisplayString(tf, "Can't delete light!");
66 else if (arock == 3) {
67 code = gtxframe_ClearList(tf);
68 gtxframe_AddToList(frameA, objectA);
69 gtxframe_AddToList(frameA, lightA);
74 static int NoCallCmd(awin)
76 gtxframe_DisplayString(awin->w_frame, "Function should be mapped on '$d', not 'd'");
80 static int ChangeCmd(awin)
83 register afs_int32 code;
85 code = gtxframe_AskForString(awin->w_frame, "New object string: ", "TestNew",
86 tbuffer, sizeof(tbuffer));
88 /* have new value, write it to object A */
89 gator_text_Write(objectA, tbuffer, 0, 0, 0);
94 static int StupidCmd(awin)
96 gtxframe_DisplayString(awin->w_frame, "You're already showing that frame!");
100 static int SwitchToACmd(awin)
102 gtxframe_SetFrame(awin, frameA);
106 static int SwitchToBCmd(awin)
108 gtxframe_SetFrame(awin, frameB);
112 #include "AFS_component_version_number.c"
116 struct gator_textobj_params textcrparams;
117 struct gator_light_crparams lightcrparams;
118 register struct keymap_map *tmap;
120 win = gtx_Init(0, -1);
122 /* create a couple of objects, a and b, and have the "a" and "b" keys
123 switch the display from one to the other */
124 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT;
125 strcpy(textcrparams.onode_params.cr_name, "Text1-A");
126 textcrparams.onode_params.cr_x = 30;
127 textcrparams.onode_params.cr_y = 10;
128 textcrparams.onode_params.cr_width = 35;
129 textcrparams.onode_params.cr_height = 7;
130 textcrparams.onode_params.cr_window = win; /* ???? */
131 textcrparams.onode_params.cr_home_obj = (struct onode *)0;
132 textcrparams.onode_params.cr_prev_obj = (struct onode *)0;
133 textcrparams.onode_params.cr_parent_obj = (struct onode *)0;
134 textcrparams.onode_params.cr_helpstring = "Help string for text";
135 textcrparams.maxEntries = 7;
136 textcrparams.maxCharsPerEntry = 35;
138 objectA = gator_objects_create((struct onode_createparams *)(&textcrparams));
139 gator_text_Write(objectA, "This is object A", 0, 0, 0);
141 /* create a couple of objects, a and b, and have the "a" and "b" keys
142 switch the display from one to the other */
143 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT;
144 strcpy(textcrparams.onode_params.cr_name, "Text2-B");
145 textcrparams.onode_params.cr_x = 30;
146 textcrparams.onode_params.cr_y = 10;
147 textcrparams.onode_params.cr_width = 35;
148 textcrparams.onode_params.cr_height = 7;
149 textcrparams.onode_params.cr_window = win; /* ???? */
150 textcrparams.onode_params.cr_home_obj = (struct onode *)0;
151 textcrparams.onode_params.cr_prev_obj = (struct onode *)0;
152 textcrparams.onode_params.cr_parent_obj = (struct onode *)0;
153 textcrparams.onode_params.cr_helpstring = "Help string for text";
154 textcrparams.maxEntries = 7;
155 textcrparams.maxCharsPerEntry = 35;
157 objectB = gator_objects_create((struct onode_createparams *)(&textcrparams));
158 gator_text_Write(objectB, "This is object B", 0, 0, 0);
160 lightcrparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
161 lightcrparams.onode_params.cr_x = 10;
162 lightcrparams.onode_params.cr_y = 10;
163 lightcrparams.onode_params.cr_width = 10;
164 lightcrparams.onode_params.cr_height = 10;
165 lightcrparams.onode_params.cr_window = win; /* ???? */
166 lightcrparams.onode_params.cr_home_obj = (struct onode *)0;
167 lightcrparams.onode_params.cr_prev_obj = (struct onode *)0;
168 lightcrparams.onode_params.cr_parent_obj = (struct onode *)0;
169 lightcrparams.onode_params.cr_helpstring = "Help string for text";
170 strcpy(lightcrparams.label, "Light-1");
171 lightcrparams.label_x = 0;
172 lightcrparams.label_y = 0;
173 lightcrparams.flashfreq = 100;
174 lightcrparams.appearance = GATOR_LIGHTMASK_INVVIDEO;
175 lightA = gator_objects_create((struct onode_createparams *)(&lightcrparams));
177 /* create basic frames */
178 frameA = gtxframe_Create();
179 frameB = gtxframe_Create();
181 /* setup A's frame */
182 gtxframe_ClearList(frameA);
183 gtxframe_AddToList(frameA, objectA);
184 gtxframe_AddToList(frameA, lightA);
185 keymap_BindToString(frameA->keymap, "b", SwitchToBCmd, (char *) 0, (char *) 0);
186 keymap_BindToString(frameA->keymap, "a", StupidCmd, (char *) 0, (char *) 0);
187 keymap_BindToString(frameA->keymap, "c", ChangeCmd, (char *) 0, (char *) 0);
188 keymap_BindToString(frameA->keymap, "\033a", ChangeMenuCmd, "ChangeMenu", (char *) 1);
189 keymap_BindToString(frameA->keymap, "\033b", ChangeMenuCmd, "ChangeMenu", (char *) 2);
190 keymap_BindToString(frameA->keymap, "\033c", ChangeMenuCmd, "ChangeMenu", (char *) 3);
191 keymap_BindToString(frameA->keymap, "\0331", ChangeListCmd, "ChangeList", (char *) 1);
192 keymap_BindToString(frameA->keymap, "\0332", ChangeListCmd, "ChangeList", (char *) 2);
193 keymap_BindToString(frameA->keymap, "\0333", ChangeListCmd, "ChangeList", (char *) 3);
194 gtxframe_AddMenu(frameA, "FrameB", "b");
195 gtxframe_AddMenu(frameA, "NewLabel", "c");
197 /* setup B's frame */
198 gtxframe_ClearList(frameB);
199 gtxframe_AddToList(frameB, objectB);
200 keymap_BindToString(frameB->keymap, "a", SwitchToACmd, (char *) 0, (char *) 0);
201 keymap_BindToString(frameB->keymap, "b", StupidCmd, (char *) 0, (char *) 0);
202 keymap_BindToString(frameB->keymap, "d", NoCallCmd, (char *) 0, (char *) 0);
203 keymap_BindToString(frameB->keymap, "d", (int (*)()) 0, (char *) 0, (char *) 0);
204 keymap_BindToString(frameB->keymap, "\033d", NoCallCmd, (char *) 0, (char *) 0);
205 gtxframe_AddMenu(frameB, "FrameA", "a");
207 /* finally setup the first window */
208 gtxframe_AddToList(frameA, objectA);
209 gtxframe_SetFrame(win, frameA);
211 /* play with maps for a while */
212 tmap = (struct keymap_map *) keymap_Create();
213 keymap_BindToString(tmap, "d", NoCallCmd, "test", (char *) 1);
214 keymap_BindToString(tmap, "cd", NoCallCmd, "bozo", (char *) 0);
217 gtx_InputServer(win);