Tue, 22 Jul 2014 19:15:44 +0200
improved motif tabs
0 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
31 | #include <stdarg.h> |
0 | 32 | |
33 | #include "menu.h" | |
34 | #include "button.h" | |
35 | #include "toolkit.h" | |
18
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
36 | #include "stock.h" |
0 | 37 | #include "../common/context.h" |
38 | #include "../ui/window.h" | |
39 | ||
40 | UcxList *menus; | |
41 | UcxList *current; | |
42 | ||
43 | void ui_menu(char *label) { | |
44 | // free current menu hierarchy | |
45 | ucx_list_free(current); | |
46 | ||
47 | // create menu | |
48 | UiMenu *menu = malloc(sizeof(UiMenu)); | |
49 | menu->item.add_to = (ui_menu_add_f)add_menu_widget; | |
50 | ||
51 | menu->label = label; | |
52 | menu->items = NULL; | |
53 | menu->parent = NULL; | |
54 | ||
55 | current = ucx_list_prepend(NULL, menu); | |
56 | menus = ucx_list_append(menus, menu); | |
57 | ||
58 | } | |
59 | ||
60 | void ui_submenu(char *label) { | |
61 | UiMenu *menu = malloc(sizeof(UiMenu)); | |
62 | menu->item.add_to = (ui_menu_add_f)add_menu_widget; | |
63 | ||
64 | menu->label = label; | |
65 | menu->items = NULL; | |
66 | menu->parent = NULL; | |
67 | ||
68 | // add submenu to current menu | |
69 | UiMenu *cm = current->data; | |
70 | cm->items = ucx_list_append(cm->items, menu); | |
71 | ||
72 | // set the submenu to current menu | |
73 | current = ucx_list_prepend(current, menu); | |
74 | } | |
75 | ||
76 | void ui_submenu_end() { | |
77 | if(ucx_list_size(current) < 2) { | |
78 | return; | |
79 | } | |
80 | current = ucx_list_remove(current, current); | |
81 | } | |
82 | ||
83 | void ui_menuitem(char *label, ui_callback f, void *userdata) { | |
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
84 | ui_menuitem_gr(label, f, userdata, -1); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
85 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
86 | |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
87 | void ui_menuitem_st(char *stockid, ui_callback f, void *userdata) { |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
88 | ui_menuitem_stgr(stockid, f, userdata, -1); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
89 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
90 | |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
91 | void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...) { |
0 | 92 | if(!current) { |
93 | return; | |
94 | } | |
95 | ||
96 | UiMenuItem *item = malloc(sizeof(UiMenuItem)); | |
97 | item->item.add_to = (ui_menu_add_f)add_menuitem_widget; | |
98 | ||
99 | item->label = label; | |
100 | item->userdata = userdata; | |
101 | item->callback = f; | |
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
102 | item->groups = NULL; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
103 | |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
104 | // add groups |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
105 | va_list ap; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
106 | va_start(ap, userdata); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
107 | int group; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
108 | while((group = va_arg(ap, int)) != -1) { |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
109 | item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
110 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
111 | va_end(ap); |
0 | 112 | |
113 | UiMenu *cm = current->data; | |
114 | cm->items = ucx_list_append(cm->items, item); | |
115 | } | |
116 | ||
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
117 | void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...) { |
18
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
118 | if(!current) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
119 | return; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
120 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
121 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
122 | UiStMenuItem *item = malloc(sizeof(UiStMenuItem)); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
123 | item->item.add_to = (ui_menu_add_f)add_menuitem_st_widget; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
124 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
125 | item->stockid = stockid; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
126 | item->userdata = userdata; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
127 | item->callback = f; |
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
128 | item->groups = NULL; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
129 | |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
130 | // add groups |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
131 | va_list ap; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
132 | va_start(ap, userdata); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
133 | int group; |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
134 | while((group = va_arg(ap, int)) != -1) { |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
135 | item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
136 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
137 | va_end(ap); |
18
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
138 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
139 | UiMenu *cm = current->data; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
140 | cm->items = ucx_list_append(cm->items, item); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
141 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
142 | |
0 | 143 | void ui_menuseparator() { |
144 | if(!current) { | |
145 | return; | |
146 | } | |
147 | ||
148 | UiMenuItemI *item = malloc(sizeof(UiMenuItemI)); | |
149 | item->add_to = (ui_menu_add_f)add_menuseparator_widget; | |
150 | ||
151 | UiMenu *cm = current->data; | |
152 | cm->items = ucx_list_append(cm->items, item); | |
153 | } | |
154 | ||
155 | ||
156 | void ui_checkitem(char *label, ui_callback f, void *userdata) { | |
157 | if(!current) { | |
158 | return; | |
159 | } | |
160 | ||
161 | UiCheckItem *item = malloc(sizeof(UiCheckItem)); | |
162 | item->item.add_to = (ui_menu_add_f)add_checkitem_widget; | |
163 | item->label = label; | |
164 | item->callback = f; | |
165 | item->userdata = userdata; | |
166 | ||
167 | UiMenu *cm = current->data; | |
168 | cm->items = ucx_list_append(cm->items, item); | |
169 | } | |
170 | ||
171 | void ui_checkitem_nv(char *label, char *vname) { | |
172 | if(!current) { | |
173 | return; | |
174 | } | |
175 | ||
176 | UiCheckItemNV *item = malloc(sizeof(UiCheckItemNV)); | |
177 | item->item.add_to = (ui_menu_add_f)add_checkitemnv_widget; | |
178 | item->varname = vname; | |
179 | item->label = label; | |
180 | ||
181 | UiMenu *cm = current->data; | |
182 | cm->items = ucx_list_append(cm->items, item); | |
183 | } | |
184 | ||
17
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
185 | void ui_menuitem_list(UiList *items, ui_callback f, void *userdata) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
186 | if(!current) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
187 | return; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
188 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
189 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
190 | UiMenuItemList *item = malloc(sizeof(UiMenuItemList)); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
191 | item->item.add_to = (ui_menu_add_f)add_menuitem_list_widget; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
192 | item->callback = f; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
193 | item->userdata = userdata; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
194 | item->list = items; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
195 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
196 | UiMenu *cm = current->data; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
197 | cm->items = ucx_list_append(cm->items, item); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
198 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
199 | |
0 | 200 | |
201 | // private menu functions | |
202 | void ui_create_menubar(UiObject *obj) { | |
203 | if(!menus) { | |
204 | return; | |
205 | } | |
206 | ||
207 | Widget menubar = XmCreateMenuBar(obj->widget, "main_list", NULL, 0); | |
208 | XtManageChild(menubar); | |
209 | ||
210 | UcxList *ls = menus; | |
211 | int menu_index = 0; | |
212 | while(ls) { | |
213 | UiMenu *menu = ls->data; | |
214 | menu_index += menu->item.add_to(menubar, menu_index, &menu->item, obj); | |
215 | ||
216 | ls = ls->next; | |
217 | } | |
218 | } | |
219 | ||
220 | int add_menu_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) { | |
221 | UiMenu *menu = (UiMenu*)item; | |
222 | ||
223 | Widget menuItem = XtVaCreateManagedWidget( | |
224 | menu->label, | |
225 | xmCascadeButtonWidgetClass, | |
226 | parent, | |
227 | NULL); | |
228 | Widget m = XmVaCreateSimplePulldownMenu(parent, menu->label, i, NULL, NULL); | |
229 | ||
230 | UcxList *ls = menu->items; | |
231 | int menu_index = 0; | |
232 | while(ls) { | |
233 | UiMenuItemI *mi = ls->data; | |
234 | menu_index += mi->add_to(m, menu_index, mi, obj); | |
235 | ls = ls->next; | |
236 | } | |
237 | ||
238 | return 1; | |
239 | } | |
240 | ||
241 | int add_menuitem_widget( | |
242 | Widget parent, | |
243 | int i, | |
244 | UiMenuItemI *item, | |
245 | UiObject *obj) | |
246 | { | |
247 | UiMenuItem *mi = (UiMenuItem*)item; | |
248 | ||
249 | Arg args[1]; | |
250 | XmString label = XmStringCreateLocalized(mi->label); | |
251 | XtSetArg(args[0], XmNlabelString, label); | |
252 | ||
253 | Widget mitem = XtCreateManagedWidget( | |
254 | "menubutton", | |
255 | xmPushButtonWidgetClass, | |
256 | parent, | |
257 | args, | |
258 | 1); | |
259 | XmStringFree(label); | |
260 | ||
261 | if(mi->callback != NULL) { | |
262 | UiEventData *event = ucx_mempool_malloc( | |
263 | obj->ctx->mempool, | |
264 | sizeof(UiEventData)); | |
265 | event->obj = obj; | |
266 | event->user_data = mi->userdata; | |
267 | event->callback = mi->callback; | |
17
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
268 | event->value = 0; |
3 | 269 | XtAddCallback( |
270 | mitem, | |
271 | XmNactivateCallback, | |
272 | (XtCallbackProc)ui_push_button_callback, | |
273 | event); | |
0 | 274 | } |
275 | ||
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
276 | if(mi->groups) { |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
277 | uic_add_group_widget(obj->ctx, mitem, mi->groups); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
278 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
279 | |
0 | 280 | return 1; |
281 | } | |
282 | ||
18
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
283 | int add_menuitem_st_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
284 | UiStMenuItem *mi = (UiStMenuItem*)item; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
285 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
286 | UiStockItem *si = ui_get_stock_item(mi->stockid); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
287 | if(!si) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
288 | fprintf(stderr, "UI Error: unknown stock id: %s\n", mi->stockid); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
289 | return 0; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
290 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
291 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
292 | int n = 0; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
293 | Arg args[4]; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
294 | XmString label = XmStringCreateLocalized(si->label); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
295 | XmString at = NULL; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
296 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
297 | XtSetArg(args[n], XmNlabelString, label); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
298 | n++; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
299 | if(si->accelerator) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
300 | XtSetArg(args[n], XmNaccelerator, si->accelerator); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
301 | n++; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
302 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
303 | if(si->accelerator_label) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
304 | at = XmStringCreateLocalized(si->accelerator_label); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
305 | XtSetArg(args[n], XmNacceleratorText, at); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
306 | n++; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
307 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
308 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
309 | Widget mitem = XtCreateManagedWidget( |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
310 | "menubutton", |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
311 | xmPushButtonWidgetClass, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
312 | parent, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
313 | args, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
314 | n); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
315 | XmStringFree(label); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
316 | if(at) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
317 | XmStringFree(at); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
318 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
319 | |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
320 | if(mi->callback != NULL) { |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
321 | UiEventData *event = ucx_mempool_malloc( |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
322 | obj->ctx->mempool, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
323 | sizeof(UiEventData)); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
324 | event->obj = obj; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
325 | event->user_data = mi->userdata; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
326 | event->callback = mi->callback; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
327 | event->value = 0; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
328 | XtAddCallback( |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
329 | mitem, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
330 | XmNactivateCallback, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
331 | (XtCallbackProc)ui_push_button_callback, |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
332 | event); |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
333 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
334 | |
21
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
335 | if(mi->groups) { |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
336 | uic_add_group_widget(obj->ctx, mitem, mi->groups); |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
337 | } |
012418e7dc90
added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
338 | |
18
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
339 | return 1; |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
340 | } |
06be29a56f8b
added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
17
diff
changeset
|
341 | |
0 | 342 | int add_menuseparator_widget( |
343 | Widget parent, | |
344 | int i, | |
345 | UiMenuItemI *item, | |
346 | UiObject *obj) | |
347 | { | |
348 | Widget s = XmCreateSeparatorGadget (parent, "menu_separator", NULL, 0); | |
349 | XtManageChild(s); | |
350 | return 1; | |
351 | } | |
352 | ||
353 | int add_checkitem_widget( | |
354 | Widget parent, | |
355 | int i, | |
356 | UiMenuItemI *item, | |
357 | UiObject *obj) | |
358 | { | |
359 | UiCheckItem *ci = (UiCheckItem*)item; | |
360 | ||
361 | Arg args[3]; | |
362 | XmString label = XmStringCreateLocalized(ci->label); | |
363 | XtSetArg(args[0], XmNlabelString, label); | |
364 | XtSetArg(args[1], XmNvisibleWhenOff, 1); | |
365 | Widget checkbox = XtCreateManagedWidget( | |
366 | "menutogglebutton", | |
367 | xmToggleButtonWidgetClass, | |
368 | parent, | |
369 | args, | |
370 | 2); | |
371 | XmStringFree(label); | |
372 | ||
373 | if(ci->callback) { | |
374 | UiEventData *event = ucx_mempool_malloc( | |
375 | obj->ctx->mempool, | |
376 | sizeof(UiEventData)); | |
377 | event->obj = obj; | |
378 | event->user_data = ci->userdata; | |
379 | event->callback = ci->callback; | |
380 | XtAddCallback( | |
381 | checkbox, | |
382 | XmNvalueChangedCallback, | |
383 | (XtCallbackProc)ui_toggle_button_callback, | |
384 | event); | |
385 | } | |
386 | ||
387 | return 1; | |
388 | } | |
389 | ||
390 | int add_checkitemnv_widget( | |
391 | Widget parent, | |
392 | int i, | |
393 | UiMenuItemI *item, | |
394 | UiObject *obj) | |
395 | { | |
396 | UiCheckItemNV *ci = (UiCheckItemNV*)item; | |
397 | ||
398 | Arg args[3]; | |
399 | XmString label = XmStringCreateLocalized(ci->label); | |
400 | XtSetArg(args[0], XmNlabelString, label); | |
401 | XtSetArg(args[1], XmNvisibleWhenOff, 1); | |
402 | Widget checkbox = XtCreateManagedWidget( | |
403 | "menutogglebutton", | |
404 | xmToggleButtonWidgetClass, | |
405 | parent, | |
406 | args, | |
407 | 2); | |
408 | XmStringFree(label); | |
409 | ||
2
eeb50c534497
added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
410 | UiVar *var = uic_connect_var(obj->ctx, ci->varname, UI_VAR_INTEGER); |
eeb50c534497
added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
411 | if(var) { |
0 | 412 | UiInteger *value = var->value; |
413 | value->obj = checkbox; | |
414 | value->get = ui_toggle_button_get; | |
415 | value->set = ui_toggle_button_set; | |
416 | value = 0; | |
417 | } else { | |
2
eeb50c534497
added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
418 | // TODO: error |
0 | 419 | } |
17
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
420 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
421 | return 1; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
422 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
423 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
424 | int add_menuitem_list_widget( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
425 | Widget parent, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
426 | int i, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
427 | UiMenuItemI *item, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
428 | UiObject *obj) |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
429 | { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
430 | UiMenuItemList *il = (UiMenuItemList*)item; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
431 | UcxMempool *mp = obj->ctx->mempool; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
432 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
433 | UiActiveMenuItemList *ls = ucx_mempool_malloc( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
434 | mp, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
435 | sizeof(UiActiveMenuItemList)); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
436 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
437 | ls->object = obj; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
438 | ls->menu = parent; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
439 | ls->index = i; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
440 | ls->oldcount = 0; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
441 | ls->list = il->list; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
442 | ls->callback = il->callback; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
443 | ls->userdata = il->userdata; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
444 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
445 | ls->list->observers = ui_add_observer( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
446 | ls->list->observers, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
447 | (ui_callback)ui_update_menuitem_list, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
448 | ls); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
449 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
450 | ui_update_menuitem_list(NULL, ls); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
451 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
452 | return 0; |
0 | 453 | } |
454 | ||
17
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
455 | void ui_update_menuitem_list(UiEvent *event, UiActiveMenuItemList *list) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
456 | Arg args[4]; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
457 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
458 | // remove old items |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
459 | if(list->oldcount > 0) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
460 | Widget *children; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
461 | int nc; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
462 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
463 | XtVaGetValues( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
464 | list->menu, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
465 | XmNchildren, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
466 | &children, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
467 | XmNnumChildren, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
468 | &nc, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
469 | NULL); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
470 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
471 | for(int i=0;i<list->oldcount;i++) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
472 | XtDestroyWidget(children[list->index + i]); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
473 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
474 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
475 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
476 | char *str = ui_list_first(list->list); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
477 | if(str) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
478 | // add separator |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
479 | XtSetArg(args[0], XmNpositionIndex, list->index); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
480 | Widget s = XmCreateSeparatorGadget (list->menu, "menu_separator", args, 1); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
481 | XtManageChild(s); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
482 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
483 | int i = 1; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
484 | while(str) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
485 | XmString label = XmStringCreateLocalized(str); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
486 | XtSetArg(args[0], XmNlabelString, label); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
487 | XtSetArg(args[1], XmNpositionIndex, list->index + i); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
488 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
489 | Widget mitem = XtCreateManagedWidget( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
490 | "menubutton", |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
491 | xmPushButtonWidgetClass, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
492 | list->menu, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
493 | args, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
494 | 2); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
495 | XmStringFree(label); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
496 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
497 | if(list->callback) { |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
498 | // TODO: use mempool |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
499 | UiEventData *event = malloc(sizeof(UiEventData)); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
500 | event->obj = list->object; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
501 | event->user_data = list->userdata; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
502 | event->callback = list->callback; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
503 | event->value = i - 1; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
504 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
505 | XtAddCallback( |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
506 | mitem, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
507 | XmNactivateCallback, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
508 | (XtCallbackProc)ui_push_button_callback, |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
509 | event); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
510 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
511 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
512 | str = ui_list_next(list->list); |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
513 | i++; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
514 | } |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
515 | |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
516 | list->oldcount = i; |
db95c0104937
added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
517 | } |
0 | 518 | |
519 | void ui_menu_event_wrapper(Widget widget, XtPointer udata, XtPointer cdata) { | |
520 | UiEventData *event = udata; | |
521 | UiEvent e; | |
522 | e.obj = event->obj; | |
523 | e.window = event->obj->window; | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
524 | e.document = event->obj->ctx->document; |
0 | 525 | e.intval = 0; |
526 | event->callback(&e, event->user_data); | |
527 | } |