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 <afsconfig.h>
11 #include <afs/param.h>
24 #include "gtxwindows.h"
25 #include "gtxobjects.h"
26 #include "gtxtextobj.h"
27 #include "gtxlightobj.h"
30 struct gtx_frame *frameA, *frameB;
32 struct onode *objectA, *objectB;
33 struct onode *lightA, *lightB;
35 static int ChangeMenuCmd(awin, arock)
37 register struct gwin *awin; {
38 register struct gtx_frame *tf;
39 register afs_int32 code;
45 gtxframe_ClearMenus(tf);
47 else if (arock == 2) {
48 code = gtxframe_DeleteMenu(tf, "NewLabel");
49 if (code) gtxframe_DisplayString(tf, "Can't delete menu!");
51 else if (arock == 3) {
52 code = gtxframe_ClearMenus(tf);
53 gtxframe_AddMenu(frameA, "FrameB", "b");
54 gtxframe_AddMenu(frameA, "NewLabel", "c");
59 static int ChangeListCmd(awin, arock)
61 register struct gwin *awin; {
62 register struct gtx_frame *tf;
63 register afs_int32 code;
69 gtxframe_ClearList(tf);
71 else if (arock == 2) {
72 code = gtxframe_RemoveFromList(tf, lightA);
73 if (code) gtxframe_DisplayString(tf, "Can't delete light!");
75 else if (arock == 3) {
76 code = gtxframe_ClearList(tf);
77 gtxframe_AddToList(frameA, objectA);
78 gtxframe_AddToList(frameA, lightA);
83 static int NoCallCmd(awin)
85 gtxframe_DisplayString(awin->w_frame, "Function should be mapped on '$d', not 'd'");
89 static int ChangeCmd(awin)
92 register afs_int32 code;
94 code = gtxframe_AskForString(awin->w_frame, "New object string: ", "TestNew",
95 tbuffer, sizeof(tbuffer));
97 /* have new value, write it to object A */
98 gator_text_Write(objectA, tbuffer, 0, 0, 0);
103 static int StupidCmd(awin)
105 gtxframe_DisplayString(awin->w_frame, "You're already showing that frame!");
109 static int SwitchToACmd(awin)
111 gtxframe_SetFrame(awin, frameA);
115 static int SwitchToBCmd(awin)
117 gtxframe_SetFrame(awin, frameB);
121 #include "AFS_component_version_number.c"
125 struct gator_textobj_params textcrparams;
126 struct gator_light_crparams lightcrparams;
127 register struct keymap_map *tmap;
129 win = gtx_Init(0, -1);
131 /* create a couple of objects, a and b, and have the "a" and "b" keys
132 switch the display from one to the other */
133 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT;
134 strcpy(textcrparams.onode_params.cr_name, "Text1-A");
135 textcrparams.onode_params.cr_x = 30;
136 textcrparams.onode_params.cr_y = 10;
137 textcrparams.onode_params.cr_width = 35;
138 textcrparams.onode_params.cr_height = 7;
139 textcrparams.onode_params.cr_window = win; /* ???? */
140 textcrparams.onode_params.cr_home_obj = NULL;
141 textcrparams.onode_params.cr_prev_obj = NULL;
142 textcrparams.onode_params.cr_parent_obj = NULL;
143 textcrparams.onode_params.cr_helpstring = "Help string for text";
144 textcrparams.maxEntries = 7;
145 textcrparams.maxCharsPerEntry = 35;
147 objectA = gator_objects_create((struct onode_createparams *)(&textcrparams));
148 gator_text_Write(objectA, "This is object A", 0, 0, 0);
150 /* create a couple of objects, a and b, and have the "a" and "b" keys
151 switch the display from one to the other */
152 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT;
153 strcpy(textcrparams.onode_params.cr_name, "Text2-B");
154 textcrparams.onode_params.cr_x = 30;
155 textcrparams.onode_params.cr_y = 10;
156 textcrparams.onode_params.cr_width = 35;
157 textcrparams.onode_params.cr_height = 7;
158 textcrparams.onode_params.cr_window = win; /* ???? */
159 textcrparams.onode_params.cr_home_obj = NULL;
160 textcrparams.onode_params.cr_prev_obj = NULL;
161 textcrparams.onode_params.cr_parent_obj = NULL;
162 textcrparams.onode_params.cr_helpstring = "Help string for text";
163 textcrparams.maxEntries = 7;
164 textcrparams.maxCharsPerEntry = 35;
166 objectB = gator_objects_create((struct onode_createparams *)(&textcrparams));
167 gator_text_Write(objectB, "This is object B", 0, 0, 0);
169 lightcrparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
170 lightcrparams.onode_params.cr_x = 10;
171 lightcrparams.onode_params.cr_y = 10;
172 lightcrparams.onode_params.cr_width = 10;
173 lightcrparams.onode_params.cr_height = 10;
174 lightcrparams.onode_params.cr_window = win; /* ???? */
175 lightcrparams.onode_params.cr_home_obj = NULL;
176 lightcrparams.onode_params.cr_prev_obj = NULL;
177 lightcrparams.onode_params.cr_parent_obj = NULL;
178 lightcrparams.onode_params.cr_helpstring = "Help string for text";
179 strcpy(lightcrparams.label, "Light-1");
180 lightcrparams.label_x = 0;
181 lightcrparams.label_y = 0;
182 lightcrparams.flashfreq = 100;
183 lightcrparams.appearance = GATOR_LIGHTMASK_INVVIDEO;
184 lightA = gator_objects_create((struct onode_createparams *)(&lightcrparams));
186 /* create basic frames */
187 frameA = gtxframe_Create();
188 frameB = gtxframe_Create();
190 /* setup A's frame */
191 gtxframe_ClearList(frameA);
192 gtxframe_AddToList(frameA, objectA);
193 gtxframe_AddToList(frameA, lightA);
194 keymap_BindToString(frameA->keymap, "b", SwitchToBCmd, NULL, NULL);
195 keymap_BindToString(frameA->keymap, "a", StupidCmd, NULL, NULL);
196 keymap_BindToString(frameA->keymap, "c", ChangeCmd, NULL, NULL);
197 keymap_BindToString(frameA->keymap, "\033a", ChangeMenuCmd, "ChangeMenu", (char *) 1);
198 keymap_BindToString(frameA->keymap, "\033b", ChangeMenuCmd, "ChangeMenu", (char *) 2);
199 keymap_BindToString(frameA->keymap, "\033c", ChangeMenuCmd, "ChangeMenu", (char *) 3);
200 keymap_BindToString(frameA->keymap, "\0331", ChangeListCmd, "ChangeList", (char *) 1);
201 keymap_BindToString(frameA->keymap, "\0332", ChangeListCmd, "ChangeList", (char *) 2);
202 keymap_BindToString(frameA->keymap, "\0333", ChangeListCmd, "ChangeList", (char *) 3);
203 gtxframe_AddMenu(frameA, "FrameB", "b");
204 gtxframe_AddMenu(frameA, "NewLabel", "c");
206 /* setup B's frame */
207 gtxframe_ClearList(frameB);
208 gtxframe_AddToList(frameB, objectB);
209 keymap_BindToString(frameB->keymap, "a", SwitchToACmd, NULL, NULL);
210 keymap_BindToString(frameB->keymap, "b", StupidCmd, NULL, NULL);
211 keymap_BindToString(frameB->keymap, "d", NoCallCmd, NULL, NULL);
212 keymap_BindToString(frameB->keymap, "d", (int (*)()) 0, NULL, NULL);
213 keymap_BindToString(frameB->keymap, "\033d", NoCallCmd, NULL, NULL);
214 gtxframe_AddMenu(frameB, "FrameA", "a");
216 /* finally setup the first window */
217 gtxframe_AddToList(frameA, objectA);
218 gtxframe_SetFrame(win, frameA);
220 /* play with maps for a while */
221 tmap = (struct keymap_map *) keymap_Create();
222 keymap_BindToString(tmap, "d", NoCallCmd, "test", (char *) 1);
223 keymap_BindToString(tmap, "cd", NoCallCmd, "bozo", NULL);
226 gtx_InputServer(win);