ui/motif/menu.c

Mon, 06 Jan 2025 22:22:55 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 06 Jan 2025 22:22:55 +0100
changeset 101
7b3a3130be44
parent 100
d2bd73d28ff1
permissions
-rw-r--r--

update ucx, toolkit

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

mercurial