Sun, 15 Dec 2024 22:53:51 +0100
add menu toggle/radio button (Motif)
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" |
76
3782827378ab
added context menus (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
37 | #include "container.h" |
0 | 38 | #include "../common/context.h" |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
39 | #include "../common/menu.h" |
0 | 40 | #include "../ui/window.h" |
41 | ||
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
42 | #include <cx/linked_list.h> |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
43 | #include <cx/array_list.h> |
0 | 44 | |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
45 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
46 | static ui_menu_add_f createMenuItem[] = { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
47 | /* UI_MENU */ add_menu_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
48 | /* UI_MENU_ITEM */ add_menuitem_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
49 | /* UI_MENU_CHECK_ITEM */ add_checkitem_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
50 | /* UI_MENU_RADIO_ITEM */ add_radioitem_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
51 | /* UI_MENU_ITEM_LIST */ add_menuitem_list_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
52 | /* UI_MENU_CHECKITEM_LIST */ add_menuitem_list_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
53 | /* UI_MENU_RADIOITEM_LIST */ add_menuitem_list_widget, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
54 | /* UI_MENU_SEPARATOR */ add_menuseparator_widget |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
55 | }; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
56 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
57 | void ui_create_menubar(UiObject *obj, Widget window) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
58 | UiMenu *menus_begin = uic_get_menu_list(); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
59 | if(!menus_begin) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
60 | return; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
61 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
62 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
63 | Widget menubar = XmCreateMenuBar(window, "menubar", NULL, 0); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
64 | XtManageChild(menubar); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
65 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
66 | UiMenu *ls = menus_begin; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
67 | while(ls) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
68 | UiMenu *menu = ls; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
69 | add_menu_widget(menubar, 0, &menu->item, obj); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
70 | ls = (UiMenu*)ls->item.next; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
71 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
72 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
73 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
74 | void ui_add_menu_items(Widget parent, int i, UiMenu *menu, UiObject *obj) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
75 | UiMenuItemI *it = menu->items_begin; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
76 | int index = 0; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
77 | while(it) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
78 | createMenuItem[it->type](parent, index, it, obj); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
79 | it = it->next; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
80 | index++; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
81 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
82 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
83 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
84 | void add_menu_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
85 | UiMenu *menu = (UiMenu*)item; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
86 | Arg args[4]; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
87 | int n = 0; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
88 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
89 | XmString s = NULL; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
90 | if(menu->label) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
91 | s = XmStringCreateLocalized((char*)menu->label); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
92 | XtSetArg(args[n], XmNlabelString, s); n++; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
93 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
94 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
95 | Widget submenu = XmVaCreateSimplePulldownMenu(parent, "menu_pulldown", i, NULL, NULL); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
96 | XtSetArg(args[n], XmNsubMenuId, submenu); n++; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
97 | Widget menuItem = XtCreateManagedWidget( |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
98 | "menuitem", |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
99 | xmCascadeButtonWidgetClass, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
100 | parent, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
101 | args, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
102 | n); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
103 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
104 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
105 | if(s) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
106 | XmStringFree(s); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
107 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
108 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
109 | ui_add_menu_items(submenu, i, menu, obj); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
110 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
111 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
112 | void add_menuitem_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
113 | UiMenuItem *it = (UiMenuItem*)item; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
114 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
115 | XmString s = NULL; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
116 | Arg args[4]; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
117 | int n = 0; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
118 | if(it->label) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
119 | s = XmStringCreateLocalized((char*)it->label); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
120 | XtSetArg(args[n], XmNlabelString, s); n++; |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
121 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
122 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
123 | Widget mitem = XtCreateManagedWidget( |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
124 | "menubutton", |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
125 | xmPushButtonWidgetClass, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
126 | parent, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
127 | args, |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
128 | n); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
129 | if(s) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
130 | XmStringFree(s); |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
131 | } |
417
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
132 | |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
133 | if(it->callback) { |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
134 | UiEventData *eventdata = malloc(sizeof(UiEventData)); |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
135 | eventdata->callback = it->callback; |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
136 | eventdata->userdata = it->userdata; |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
137 | eventdata->obj = obj; |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
138 | eventdata->value = 0; |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
139 | XtAddCallback( |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
140 | mitem, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
141 | XmNactivateCallback, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
142 | (XtCallbackProc)ui_push_button_callback, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
143 | eventdata); |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
144 | XtAddCallback( |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
145 | mitem, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
146 | XmNdestroyCallback, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
147 | (XtCallbackProc)ui_destroy_eventdata, |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
148 | eventdata); |
f0fee61a70be
implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
149 | } |
419
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
150 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
151 | ui_set_widget_groups(obj->ctx, mitem, it->groups); |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
152 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
153 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
154 | void add_menuseparator_widget(Widget p, int i, UiMenuItemI *item, UiObject *obj) { |
418
a57268d20ed9
add menu separator (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
417
diff
changeset
|
155 | Widget s = XmCreateSeparatorGadget (p, "menuseparator", NULL, 0); |
a57268d20ed9
add menu separator (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
417
diff
changeset
|
156 | XtManageChild(s); |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
157 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
158 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
159 | void add_checkitem_widget(Widget p, int i, UiMenuItemI *item, UiObject *obj) { |
419
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
160 | UiMenuCheckItem *it = (UiMenuCheckItem*)item; |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
161 | |
419
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
162 | Arg args[4]; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
163 | int n = 0; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
164 | XmString s = NULL; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
165 | if(it->label) { |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
166 | s = XmStringCreateLocalized(it->label); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
167 | XtSetArg(args[n], XmNlabelString, s); n++; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
168 | } |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
169 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
170 | //XtSetArg(args[n], XmNvisibleWhenOff, 0); n++; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
171 | Widget checkbox = XtCreateManagedWidget( |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
172 | "menutogglebutton", |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
173 | xmToggleButtonWidgetClass, |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
174 | p, |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
175 | args, |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
176 | n); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
177 | if(s) { |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
178 | XmStringFree(s); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
179 | } |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
180 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
181 | ui_bind_togglebutton(obj, checkbox, it->varname, NULL, it->callback, it->userdata, 0); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
182 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
183 | ui_set_widget_groups(obj->ctx, checkbox, it->groups); |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
184 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
185 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
186 | void add_radioitem_widget(Widget p, int index, UiMenuItemI *item, UiObject *obj) { |
419
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
187 | UiMenuRadioItem *it = (UiMenuRadioItem*)item; |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
188 | |
419
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
189 | Arg args[4]; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
190 | int n = 0; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
191 | XmString s = NULL; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
192 | if(it->label) { |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
193 | s = XmStringCreateLocalized(it->label); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
194 | XtSetArg(args[n], XmNlabelString, s); n++; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
195 | } |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
196 | XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY_ROUND); n++; |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
197 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
198 | Widget button = XmCreateToggleButton(p, "menuradiobutton", args, n); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
199 | XtManageChild(button); |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
200 | |
7d15cad351fc
add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
418
diff
changeset
|
201 | ui_bind_radiobutton(obj, button, NULL, it->varname, it->callback, it->userdata, 0); |
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
202 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
203 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
204 | void add_checkitemnv_widget(Widget p, int i, UiMenuItemI *item, UiObject *obj) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
205 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
206 | } |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
207 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
208 | void add_menuitem_list_widget(Widget p, int i, UiMenuItemI *item, UiObject *obj) { |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
209 | |
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
210 | } |