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>
18 #include "gtxwindows.h"
19 #include "gtxobjects.h"
20 #include "gtxtextobj.h"
21 #include "gtxlightobj.h"
22 #include "gtxkeymap.h"
26 struct gtx_frame
*frameA
, *frameB
;
28 struct onode
*objectA
, *objectB
;
29 struct onode
*lightA
, *lightB
;
32 ChangeMenuCmd(void *param1
, void *param2
)
34 struct gwin
* awin
= (struct gwin
*) param1
;
35 afs_int32 arock
= (intptr_t)param2
;
45 gtxframe_ClearMenus(tf
);
46 } else if (arock
== 2) {
47 code
= gtxframe_DeleteMenu(tf
, "NewLabel");
49 gtxframe_DisplayString(tf
, "Can't delete menu!");
50 } else if (arock
== 3) {
51 code
= gtxframe_ClearMenus(tf
);
52 gtxframe_AddMenu(frameA
, "FrameB", "b");
53 gtxframe_AddMenu(frameA
, "NewLabel", "c");
59 ChangeListCmd(void *param1
, void *param2
)
61 struct gwin
*awin
= (struct gwin
*) param1
;
62 afs_int32 arock
= (intptr_t)param2
;
72 gtxframe_ClearList(tf
);
73 } else if (arock
== 2) {
74 code
= gtxframe_RemoveFromList(tf
, lightA
);
76 gtxframe_DisplayString(tf
, "Can't delete light!");
77 } else if (arock
== 3) {
78 code
= gtxframe_ClearList(tf
);
79 gtxframe_AddToList(frameA
, objectA
);
80 gtxframe_AddToList(frameA
, lightA
);
86 NoCallCmd(void *param
, void *unused
)
88 struct gwin
*awin
= (struct gwin
*)param
;
90 gtxframe_DisplayString(awin
->w_frame
,
91 "Function should be mapped on '$d', not 'd'");
96 ChangeCmd(void *param
, void *unused
)
98 struct gwin
*awin
= (struct gwin
*) param
;
103 gtxframe_AskForString(awin
->w_frame
, "New object string: ", "TestNew",
104 tbuffer
, sizeof(tbuffer
));
106 /* have new value, write it to object A */
107 gator_text_Write(objectA
, tbuffer
, 0, 0, 0);
113 StupidCmd(void *param
, void *unused
)
115 struct gwin
*awin
= (struct gwin
*)param
;
117 gtxframe_DisplayString(awin
->w_frame
,
118 "You're already showing that frame!");
123 SwitchToACmd(void *param
, void *unused
)
125 struct gwin
*awin
= (struct gwin
*)param
;
126 gtxframe_SetFrame(awin
, frameA
);
131 SwitchToBCmd(void *param
, void *unused
)
133 struct gwin
*awin
= (struct gwin
*)param
;
134 gtxframe_SetFrame(awin
, frameB
);
138 #include "AFS_component_version_number.c"
141 main(int argc
, char **argv
)
144 struct gator_textobj_params textcrparams
;
145 struct gator_light_crparams lightcrparams
;
146 struct keymap_map
*tmap
;
148 win
= gtx_Init(0, -1);
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
, "Text1-A");
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;
167 gator_objects_create((struct onode_createparams
*)(&textcrparams
));
168 gator_text_Write(objectA
, "This is object A", 0, 0, 0);
170 /* create a couple of objects, a and b, and have the "a" and "b" keys
171 * switch the display from one to the other */
172 textcrparams
.onode_params
.cr_type
= GATOR_OBJ_TEXT
;
173 strcpy(textcrparams
.onode_params
.cr_name
, "Text2-B");
174 textcrparams
.onode_params
.cr_x
= 30;
175 textcrparams
.onode_params
.cr_y
= 10;
176 textcrparams
.onode_params
.cr_width
= 35;
177 textcrparams
.onode_params
.cr_height
= 7;
178 textcrparams
.onode_params
.cr_window
= win
; /* ???? */
179 textcrparams
.onode_params
.cr_home_obj
= NULL
;
180 textcrparams
.onode_params
.cr_prev_obj
= NULL
;
181 textcrparams
.onode_params
.cr_parent_obj
= NULL
;
182 textcrparams
.onode_params
.cr_helpstring
= "Help string for text";
183 textcrparams
.maxEntries
= 7;
184 textcrparams
.maxCharsPerEntry
= 35;
187 gator_objects_create((struct onode_createparams
*)(&textcrparams
));
188 gator_text_Write(objectB
, "This is object B", 0, 0, 0);
190 lightcrparams
.onode_params
.cr_type
= GATOR_OBJ_LIGHT
;
191 lightcrparams
.onode_params
.cr_x
= 10;
192 lightcrparams
.onode_params
.cr_y
= 10;
193 lightcrparams
.onode_params
.cr_width
= 10;
194 lightcrparams
.onode_params
.cr_height
= 10;
195 lightcrparams
.onode_params
.cr_window
= win
; /* ???? */
196 lightcrparams
.onode_params
.cr_home_obj
= NULL
;
197 lightcrparams
.onode_params
.cr_prev_obj
= NULL
;
198 lightcrparams
.onode_params
.cr_parent_obj
= NULL
;
199 lightcrparams
.onode_params
.cr_helpstring
= "Help string for text";
200 strcpy(lightcrparams
.label
, "Light-1");
201 lightcrparams
.label_x
= 0;
202 lightcrparams
.label_y
= 0;
203 lightcrparams
.flashfreq
= 100;
204 lightcrparams
.appearance
= GATOR_LIGHTMASK_INVVIDEO
;
206 gator_objects_create((struct onode_createparams
*)(&lightcrparams
));
208 /* create basic frames */
209 frameA
= gtxframe_Create();
210 frameB
= gtxframe_Create();
212 /* setup A's frame */
213 gtxframe_ClearList(frameA
);
214 gtxframe_AddToList(frameA
, objectA
);
215 gtxframe_AddToList(frameA
, lightA
);
216 keymap_BindToString(frameA
->keymap
, "b", SwitchToBCmd
, NULL
, NULL
);
217 keymap_BindToString(frameA
->keymap
, "a", StupidCmd
, NULL
, NULL
);
218 keymap_BindToString(frameA
->keymap
, "c", ChangeCmd
, NULL
, NULL
);
219 keymap_BindToString(frameA
->keymap
, "\033a", ChangeMenuCmd
, "ChangeMenu",
221 keymap_BindToString(frameA
->keymap
, "\033b", ChangeMenuCmd
, "ChangeMenu",
223 keymap_BindToString(frameA
->keymap
, "\033c", ChangeMenuCmd
, "ChangeMenu",
225 keymap_BindToString(frameA
->keymap
, "\0331", ChangeListCmd
, "ChangeList",
227 keymap_BindToString(frameA
->keymap
, "\0332", ChangeListCmd
, "ChangeList",
229 keymap_BindToString(frameA
->keymap
, "\0333", ChangeListCmd
, "ChangeList",
231 gtxframe_AddMenu(frameA
, "FrameB", "b");
232 gtxframe_AddMenu(frameA
, "NewLabel", "c");
234 /* setup B's frame */
235 gtxframe_ClearList(frameB
);
236 gtxframe_AddToList(frameB
, objectB
);
237 keymap_BindToString(frameB
->keymap
, "a", SwitchToACmd
, NULL
, NULL
);
238 keymap_BindToString(frameB
->keymap
, "b", StupidCmd
, NULL
, NULL
);
239 keymap_BindToString(frameB
->keymap
, "d", NoCallCmd
, NULL
, NULL
);
240 keymap_BindToString(frameB
->keymap
, "d", (int (*)())0, NULL
, NULL
);
241 keymap_BindToString(frameB
->keymap
, "\033d", NoCallCmd
, NULL
, NULL
);
242 gtxframe_AddMenu(frameB
, "FrameA", "a");
244 /* finally setup the first window */
245 gtxframe_AddToList(frameA
, objectA
);
246 gtxframe_SetFrame(win
, frameA
);
248 /* play with maps for a while */
249 tmap
= (struct keymap_map
*)keymap_Create();
250 keymap_BindToString(tmap
, "d", NoCallCmd
, "test", (char *)1);
251 keymap_BindToString(tmap
, "cd", NoCallCmd
, "bozo", NULL
);
254 gtx_InputServer(win
);