ui/motif/menu.c

Sun, 22 Dec 2024 11:49:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 22 Dec 2024 11:49:59 +0100
branch
newapi
changeset 420
28a5920bebe0
parent 419
7d15cad351fc
permissions
-rw-r--r--

implement menu itemlist (Motif)

0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "menu.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "button.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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"
420
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
40 #include "../common/types.h"
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include "../ui/window.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
176
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 169
diff changeset
43 #include <cx/linked_list.h>
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 169
diff changeset
44 #include <cx/array_list.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
46
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
47 static ui_menu_add_f createMenuItem[] = {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
48 /* UI_MENU */ add_menu_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
49 /* UI_MENU_ITEM */ add_menuitem_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
50 /* UI_MENU_CHECK_ITEM */ add_checkitem_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
51 /* UI_MENU_RADIO_ITEM */ add_radioitem_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
52 /* UI_MENU_ITEM_LIST */ add_menuitem_list_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
53 /* UI_MENU_CHECKITEM_LIST */ add_menuitem_list_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
54 /* UI_MENU_RADIOITEM_LIST */ add_menuitem_list_widget,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
55 /* UI_MENU_SEPARATOR */ add_menuseparator_widget
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
58 void ui_create_menubar(UiObject *obj, Widget window) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
59 UiMenu *menus_begin = uic_get_menu_list();
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
60 if(!menus_begin) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
61 return;
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
64 Widget menubar = XmCreateMenuBar(window, "menubar", NULL, 0);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
65 XtManageChild(menubar);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
66
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
67 UiMenu *ls = menus_begin;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
68 while(ls) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
69 UiMenu *menu = ls;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
70 add_menu_widget(menubar, 0, &menu->item, obj);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
71 ls = (UiMenu*)ls->item.next;
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
75 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
76 UiMenuItemI *it = menu->items_begin;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
77 int index = 0;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
78 while(it) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
79 createMenuItem[it->type](parent, index, it, obj);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
80 it = it->next;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
81 index++;
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
85 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
86 UiMenu *menu = (UiMenu*)item;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
87 Arg args[4];
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
88 int n = 0;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
89
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
90 XmString s = NULL;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
91 if(menu->label) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
92 s = XmStringCreateLocalized((char*)menu->label);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
93 XtSetArg(args[n], XmNlabelString, s); n++;
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
96 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
97 XtSetArg(args[n], XmNsubMenuId, submenu); n++;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
98 Widget menuItem = XtCreateManagedWidget(
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
99 "menuitem",
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
100 xmCascadeButtonWidgetClass,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
101 parent,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
102 args,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
103 n);
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
106 if(s) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
107 XmStringFree(s);
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
110 ui_add_menu_items(submenu, i, menu, obj);
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
113 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
114 UiMenuItem *it = (UiMenuItem*)item;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
115
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
116 XmString s = NULL;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
117 Arg args[4];
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
118 int n = 0;
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
119 if(it->label) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
120 s = XmStringCreateLocalized((char*)it->label);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
121 XtSetArg(args[n], XmNlabelString, s); n++;
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
124 Widget mitem = XtCreateManagedWidget(
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
125 "menubutton",
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
126 xmPushButtonWidgetClass,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
127 parent,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
128 args,
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
129 n);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
130 if(s) {
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
131 XmStringFree(s);
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
132 }
417
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
133
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
134 if(it->callback) {
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
135 UiEventData *eventdata = malloc(sizeof(UiEventData));
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
136 eventdata->callback = it->callback;
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
137 eventdata->userdata = it->userdata;
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
138 eventdata->obj = obj;
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
139 eventdata->value = 0;
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
140 XtAddCallback(
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
141 mitem,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
142 XmNactivateCallback,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
143 (XtCallbackProc)ui_push_button_callback,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
144 eventdata);
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
145 XtAddCallback(
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
146 mitem,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
147 XmNdestroyCallback,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
148 (XtCallbackProc)ui_destroy_eventdata,
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
149 eventdata);
f0fee61a70be implement menu item callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 416
diff changeset
150 }
419
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
151
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
152 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
153 }
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
154
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
155 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
156 Widget s = XmCreateSeparatorGadget (p, "menuseparator", NULL, 0);
a57268d20ed9 add menu separator (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 417
diff changeset
157 XtManageChild(s);
416
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
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
160 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
161 UiMenuCheckItem *it = (UiMenuCheckItem*)item;
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
162
419
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
163 Arg args[4];
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
164 int n = 0;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
165 XmString s = NULL;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
166 if(it->label) {
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
167 s = XmStringCreateLocalized(it->label);
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
168 XtSetArg(args[n], XmNlabelString, s); n++;
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
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
171 //XtSetArg(args[n], XmNvisibleWhenOff, 0); n++;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
172 Widget checkbox = XtCreateManagedWidget(
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
173 "menutogglebutton",
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
174 xmToggleButtonWidgetClass,
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
175 p,
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
176 args,
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
177 n);
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
178 if(s) {
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
179 XmStringFree(s);
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
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
182 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
183
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
184 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
185 }
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
186
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
187 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
188 UiMenuRadioItem *it = (UiMenuRadioItem*)item;
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
189
419
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
190 Arg args[4];
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
191 int n = 0;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
192 XmString s = NULL;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
193 if(it->label) {
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
194 s = XmStringCreateLocalized(it->label);
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
195 XtSetArg(args[n], XmNlabelString, s); n++;
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
196 }
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
197 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
198
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
199 Widget button = XmCreateToggleButton(p, "menuradiobutton", args, n);
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
200 XtManageChild(button);
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
201
7d15cad351fc add menu toggle/radio button (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 418
diff changeset
202 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
203 }
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
204
420
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
205 void add_menuitem_list_widget(Widget p, int i, UiMenuItemI *item, UiObject *obj) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
206 UiMenuItemList *il = (UiMenuItemList*)item;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
207 const CxAllocator *a = obj->ctx->allocator;
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
208
420
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
209 UiActiveMenuItemList *ls = cxMalloc(
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
210 a,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
211 sizeof(UiActiveMenuItemList));
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
212 ls->object = obj;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
213 ls->menu = p;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
214 ls->index = i;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
215 ls->oldcount = 0;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
216 ls->getvalue = il->getvalue;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
217 ls->callback = il->callback;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
218 ls->userdata = il->userdata;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
219 ls->addseparator = TRUE;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
220
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
221 ls->var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST); //uic_widget_var(obj->ctx, obj->ctx, NULL, il->varname, UI_VAR_LIST);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
222 UiList *list = ls->var->value;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
223
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
224 UiObserver *observer = ui_observer_new((ui_callback)ui_update_menuitem_list, ls);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
225 list->observers = ui_obsvlist_add(list->observers, observer);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
226 uic_list_register_observer_destructor(obj->ctx, list, observer);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
227
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
228 ui_update_menuitem_list(NULL, ls);
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
229 }
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
230
420
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
231 void ui_update_menuitem_list(UiEvent *event, UiActiveMenuItemList *list) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
232 XmString s = NULL;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
233 Arg args[4];
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
234 int n;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
235
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
236 UiList *ls;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
237 if(list->var && list->var->value) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
238 ls = list->var->value;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
239 } else {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
240 return;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
241 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
242
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
243 if(list->oldcount > 0) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
244 Widget *children;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
245 int nc;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
246
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
247 XtVaGetValues(
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
248 list->menu,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
249 XmNchildren,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
250 &children,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
251 XmNnumChildren,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
252 &nc,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
253 NULL);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
254
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
255 for(int i=0;i<list->oldcount;i++) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
256 XtDestroyWidget(children[list->index + i]);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
257 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
258 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
259
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
260 void* elm = ui_list_first(ls);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
261 int i = 0;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
262 if(elm && list->addseparator) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
263 Widget s = XmCreateSeparatorGadget(list->menu, "menuseparator", NULL, 0);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
264 XtManageChild(s);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
265 i++;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
266 }
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
267
420
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
268 ui_getvaluefunc getvalue = list->getvalue;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
269 while(elm) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
270 n = 0;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
271 char *label = (char*) (getvalue ? getvalue(elm, 0) : elm);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
272 if(label) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
273 s = XmStringCreateLocalized(label);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
274 XtSetArg(args[n], XmNlabelString, s); n++;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
275 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
276
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
277 Widget mitem = XtCreateManagedWidget(
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
278 "menubutton",
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
279 xmPushButtonWidgetClass,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
280 list->menu,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
281 args,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
282 n);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
283 if(s) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
284 XmStringFree(s);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
285 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
286
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
287 if(list->callback) {
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
288 UiEventData *eventdata = malloc(sizeof(UiEventData));
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
289 eventdata->callback = list->callback;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
290 eventdata->userdata = list->userdata;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
291 eventdata->obj = list->object;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
292 eventdata->value = 0;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
293 XtAddCallback(
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
294 mitem,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
295 XmNactivateCallback,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
296 (XtCallbackProc)ui_push_button_callback,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
297 eventdata);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
298 XtAddCallback(
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
299 mitem,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
300 XmNdestroyCallback,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
301 (XtCallbackProc)ui_destroy_eventdata,
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
302 eventdata);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
303 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
304
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
305 elm = ui_list_next(ls);
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
306 i++;
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
307 }
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
308
28a5920bebe0 implement menu itemlist (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 419
diff changeset
309 list->oldcount = i;
416
89ad8467c39f implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents: 406
diff changeset
310 }

mercurial