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>
15 #include "gtxwindows.h"
16 #include "gtxobjects.h"
17 #include "gtxtextobj.h"
18 #include "gtxlightobj.h"
19 #include "gtxkeymap.h"
23 struct gtx_frame
*frameA
, *frameB
;
25 struct onode
*objectA
, *objectB
;
26 struct onode
*lightA
, *lightB
;
29 ChangeMenuCmd(void *param1
, void *param2
)
31 struct gwin
* awin
= (struct gwin
*) param1
;
32 afs_int32 arock
= (intptr_t)param2
;
42 gtxframe_ClearMenus(tf
);
43 } else if (arock
== 2) {
44 code
= gtxframe_DeleteMenu(tf
, "NewLabel");
46 gtxframe_DisplayString(tf
, "Can't delete menu!");
47 } else if (arock
== 3) {
48 gtxframe_ClearMenus(tf
);
49 gtxframe_AddMenu(frameA
, "FrameB", "b");
50 gtxframe_AddMenu(frameA
, "NewLabel", "c");
56 ChangeListCmd(void *param1
, void *param2
)
58 struct gwin
*awin
= (struct gwin
*) param1
;
59 afs_int32 arock
= (intptr_t)param2
;
69 gtxframe_ClearList(tf
);
70 } else if (arock
== 2) {
71 code
= gtxframe_RemoveFromList(tf
, lightA
);
73 gtxframe_DisplayString(tf
, "Can't delete light!");
74 } else if (arock
== 3) {
75 gtxframe_ClearList(tf
);
76 gtxframe_AddToList(frameA
, objectA
);
77 gtxframe_AddToList(frameA
, lightA
);
83 NoCallCmd(void *param
, void *unused
)
85 struct gwin
*awin
= (struct gwin
*)param
;
87 gtxframe_DisplayString(awin
->w_frame
,
88 "Function should be mapped on '$d', not 'd'");
93 ChangeCmd(void *param
, void *unused
)
95 struct gwin
*awin
= (struct gwin
*) param
;
100 gtxframe_AskForString(awin
->w_frame
, "New object string: ", "TestNew",
101 tbuffer
, sizeof(tbuffer
));
103 /* have new value, write it to object A */
104 gator_text_Write(objectA
, tbuffer
, 0, 0, 0);
110 StupidCmd(void *param
, void *unused
)
112 struct gwin
*awin
= (struct gwin
*)param
;
114 gtxframe_DisplayString(awin
->w_frame
,
115 "You're already showing that frame!");
120 SwitchToACmd(void *param
, void *unused
)
122 struct gwin
*awin
= (struct gwin
*)param
;
123 gtxframe_SetFrame(awin
, frameA
);
128 SwitchToBCmd(void *param
, void *unused
)
130 struct gwin
*awin
= (struct gwin
*)param
;
131 gtxframe_SetFrame(awin
, frameB
);
135 #include "AFS_component_version_number.c"
138 main(int argc
, char **argv
)
141 struct gator_textobj_params textcrparams
;
142 struct gator_light_crparams lightcrparams
;
143 struct keymap_map
*tmap
;
145 win
= gtx_Init(0, -1);
147 /* create a couple of objects, a and b, and have the "a" and "b" keys
148 * switch the display from one to the other */
149 textcrparams
.onode_params
.cr_type
= GATOR_OBJ_TEXT
;
150 strcpy(textcrparams
.onode_params
.cr_name
, "Text1-A");
151 textcrparams
.onode_params
.cr_x
= 30;
152 textcrparams
.onode_params
.cr_y
= 10;
153 textcrparams
.onode_params
.cr_width
= 35;
154 textcrparams
.onode_params
.cr_height
= 7;
155 textcrparams
.onode_params
.cr_window
= win
; /* ???? */
156 textcrparams
.onode_params
.cr_home_obj
= NULL
;
157 textcrparams
.onode_params
.cr_prev_obj
= NULL
;
158 textcrparams
.onode_params
.cr_parent_obj
= NULL
;
159 textcrparams
.onode_params
.cr_helpstring
= "Help string for text";
160 textcrparams
.maxEntries
= 7;
161 textcrparams
.maxCharsPerEntry
= 35;
164 gator_objects_create((struct onode_createparams
*)(&textcrparams
));
165 gator_text_Write(objectA
, "This is object A", 0, 0, 0);
167 /* create a couple of objects, a and b, and have the "a" and "b" keys
168 * switch the display from one to the other */
169 textcrparams
.onode_params
.cr_type
= GATOR_OBJ_TEXT
;
170 strcpy(textcrparams
.onode_params
.cr_name
, "Text2-B");
171 textcrparams
.onode_params
.cr_x
= 30;
172 textcrparams
.onode_params
.cr_y
= 10;
173 textcrparams
.onode_params
.cr_width
= 35;
174 textcrparams
.onode_params
.cr_height
= 7;
175 textcrparams
.onode_params
.cr_window
= win
; /* ???? */
176 textcrparams
.onode_params
.cr_home_obj
= NULL
;
177 textcrparams
.onode_params
.cr_prev_obj
= NULL
;
178 textcrparams
.onode_params
.cr_parent_obj
= NULL
;
179 textcrparams
.onode_params
.cr_helpstring
= "Help string for text";
180 textcrparams
.maxEntries
= 7;
181 textcrparams
.maxCharsPerEntry
= 35;
184 gator_objects_create((struct onode_createparams
*)(&textcrparams
));
185 gator_text_Write(objectB
, "This is object B", 0, 0, 0);
187 lightcrparams
.onode_params
.cr_type
= GATOR_OBJ_LIGHT
;
188 lightcrparams
.onode_params
.cr_x
= 10;
189 lightcrparams
.onode_params
.cr_y
= 10;
190 lightcrparams
.onode_params
.cr_width
= 10;
191 lightcrparams
.onode_params
.cr_height
= 10;
192 lightcrparams
.onode_params
.cr_window
= win
; /* ???? */
193 lightcrparams
.onode_params
.cr_home_obj
= NULL
;
194 lightcrparams
.onode_params
.cr_prev_obj
= NULL
;
195 lightcrparams
.onode_params
.cr_parent_obj
= NULL
;
196 lightcrparams
.onode_params
.cr_helpstring
= "Help string for text";
197 strcpy(lightcrparams
.label
, "Light-1");
198 lightcrparams
.label_x
= 0;
199 lightcrparams
.label_y
= 0;
200 lightcrparams
.flashfreq
= 100;
201 lightcrparams
.appearance
= GATOR_LIGHTMASK_INVVIDEO
;
203 gator_objects_create((struct onode_createparams
*)(&lightcrparams
));
205 /* create basic frames */
206 frameA
= gtxframe_Create();
207 frameB
= gtxframe_Create();
209 /* setup A's frame */
210 gtxframe_ClearList(frameA
);
211 gtxframe_AddToList(frameA
, objectA
);
212 gtxframe_AddToList(frameA
, lightA
);
213 keymap_BindToString(frameA
->keymap
, "b", SwitchToBCmd
, NULL
, NULL
);
214 keymap_BindToString(frameA
->keymap
, "a", StupidCmd
, NULL
, NULL
);
215 keymap_BindToString(frameA
->keymap
, "c", ChangeCmd
, NULL
, NULL
);
216 keymap_BindToString(frameA
->keymap
, "\033a", ChangeMenuCmd
, "ChangeMenu",
218 keymap_BindToString(frameA
->keymap
, "\033b", ChangeMenuCmd
, "ChangeMenu",
220 keymap_BindToString(frameA
->keymap
, "\033c", ChangeMenuCmd
, "ChangeMenu",
222 keymap_BindToString(frameA
->keymap
, "\0331", ChangeListCmd
, "ChangeList",
224 keymap_BindToString(frameA
->keymap
, "\0332", ChangeListCmd
, "ChangeList",
226 keymap_BindToString(frameA
->keymap
, "\0333", ChangeListCmd
, "ChangeList",
228 gtxframe_AddMenu(frameA
, "FrameB", "b");
229 gtxframe_AddMenu(frameA
, "NewLabel", "c");
231 /* setup B's frame */
232 gtxframe_ClearList(frameB
);
233 gtxframe_AddToList(frameB
, objectB
);
234 keymap_BindToString(frameB
->keymap
, "a", SwitchToACmd
, NULL
, NULL
);
235 keymap_BindToString(frameB
->keymap
, "b", StupidCmd
, NULL
, NULL
);
236 keymap_BindToString(frameB
->keymap
, "d", NoCallCmd
, NULL
, NULL
);
237 keymap_BindToString(frameB
->keymap
, "d", (int (*)())0, NULL
, NULL
);
238 keymap_BindToString(frameB
->keymap
, "\033d", NoCallCmd
, NULL
, NULL
);
239 gtxframe_AddMenu(frameB
, "FrameA", "a");
241 /* finally setup the first window */
242 gtxframe_AddToList(frameA
, objectA
);
243 gtxframe_SetFrame(win
, frameA
);
245 /* play with maps for a while */
246 tmap
= (struct keymap_map
*)keymap_Create();
247 keymap_BindToString(tmap
, "d", NoCallCmd
, "test", (char *)1);
248 keymap_BindToString(tmap
, "cd", NoCallCmd
, "bozo", NULL
);
251 gtx_InputServer(win
);