ui/motif/menu.c

Wed, 02 Apr 2014 20:31:47 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 02 Apr 2014 20:31:47 +0200
changeset 20
2dda1ad6dc7a
parent 18
06be29a56f8b
child 21
012418e7dc90
permissions
-rw-r--r--

added groups for menu items (Cocoa)

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>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "menu.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "button.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "toolkit.h"
18
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
35 #include "stock.h"
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "../common/context.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../ui/window.h"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 UcxList *menus;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 UcxList *current;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 void ui_menu(char *label) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 // free current menu hierarchy
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 ucx_list_free(current);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 // create menu
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 UiMenu *menu = malloc(sizeof(UiMenu));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 menu->item.add_to = (ui_menu_add_f)add_menu_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 menu->label = label;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 menu->items = NULL;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 menu->parent = NULL;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 current = ucx_list_prepend(NULL, menu);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 menus = ucx_list_append(menus, menu);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 void ui_submenu(char *label) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 UiMenu *menu = malloc(sizeof(UiMenu));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 menu->item.add_to = (ui_menu_add_f)add_menu_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 menu->label = label;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 menu->items = NULL;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 menu->parent = NULL;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 // add submenu to current menu
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 UiMenu *cm = current->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 cm->items = ucx_list_append(cm->items, menu);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 // set the submenu to current menu
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 current = ucx_list_prepend(current, menu);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 void ui_submenu_end() {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 if(ucx_list_size(current) < 2) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 current = ucx_list_remove(current, current);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 void ui_menuitem(char *label, ui_callback f, void *userdata) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 if(!current) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 UiMenuItem *item = malloc(sizeof(UiMenuItem));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 item->item.add_to = (ui_menu_add_f)add_menuitem_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 item->label = label;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 item->userdata = userdata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 item->callback = f;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 UiMenu *cm = current->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 cm->items = ucx_list_append(cm->items, item);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97
18
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
98 void ui_menuitem_st(char *stockid, ui_callback f, void *userdata) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
99 if(!current) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
100 return;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
101 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
102
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
103 UiStMenuItem *item = malloc(sizeof(UiStMenuItem));
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
104 item->item.add_to = (ui_menu_add_f)add_menuitem_st_widget;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
105
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
106 item->stockid = stockid;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
107 item->userdata = userdata;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
108 item->callback = f;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
109
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
110 UiMenu *cm = current->data;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
111 cm->items = ucx_list_append(cm->items, item);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
112 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
113
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 void ui_menuseparator() {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 if(!current) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 UiMenuItemI *item = malloc(sizeof(UiMenuItemI));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 item->add_to = (ui_menu_add_f)add_menuseparator_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 UiMenu *cm = current->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 cm->items = ucx_list_append(cm->items, item);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 void ui_checkitem(char *label, ui_callback f, void *userdata) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 if(!current) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 UiCheckItem *item = malloc(sizeof(UiCheckItem));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 item->item.add_to = (ui_menu_add_f)add_checkitem_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 item->label = label;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 item->callback = f;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 item->userdata = userdata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 UiMenu *cm = current->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 cm->items = ucx_list_append(cm->items, item);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 void ui_checkitem_nv(char *label, char *vname) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 if(!current) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 UiCheckItemNV *item = malloc(sizeof(UiCheckItemNV));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 item->item.add_to = (ui_menu_add_f)add_checkitemnv_widget;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 item->varname = vname;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 item->label = label;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 UiMenu *cm = current->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 cm->items = ucx_list_append(cm->items, item);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155
17
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
156 void ui_menuitem_list(UiList *items, ui_callback f, void *userdata) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
157 if(!current) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
158 return;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
159 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
160
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
161 UiMenuItemList *item = malloc(sizeof(UiMenuItemList));
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
162 item->item.add_to = (ui_menu_add_f)add_menuitem_list_widget;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
163 item->callback = f;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
164 item->userdata = userdata;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
165 item->list = items;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
166
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
167 UiMenu *cm = current->data;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
168 cm->items = ucx_list_append(cm->items, item);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
169 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
170
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 // private menu functions
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 void ui_create_menubar(UiObject *obj) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 if(!menus) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 return;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 Widget menubar = XmCreateMenuBar(obj->widget, "main_list", NULL, 0);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 XtManageChild(menubar);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 UcxList *ls = menus;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 int menu_index = 0;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 while(ls) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 UiMenu *menu = ls->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 menu_index += menu->item.add_to(menubar, menu_index, &menu->item, obj);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 ls = ls->next;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 int add_menu_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 UiMenu *menu = (UiMenu*)item;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 Widget menuItem = XtVaCreateManagedWidget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 menu->label,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 xmCascadeButtonWidgetClass,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 NULL);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 Widget m = XmVaCreateSimplePulldownMenu(parent, menu->label, i, NULL, NULL);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 UcxList *ls = menu->items;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 int menu_index = 0;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 while(ls) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 UiMenuItemI *mi = ls->data;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 menu_index += mi->add_to(m, menu_index, mi, obj);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 ls = ls->next;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 return 1;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 int add_menuitem_widget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 Widget parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 int i,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 UiMenuItemI *item,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 UiObject *obj)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 UiMenuItem *mi = (UiMenuItem*)item;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 Arg args[1];
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 XmString label = XmStringCreateLocalized(mi->label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 XtSetArg(args[0], XmNlabelString, label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 Widget mitem = XtCreateManagedWidget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 "menubutton",
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 xmPushButtonWidgetClass,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 args,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 1);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 XmStringFree(label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 if(mi->callback != NULL) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 UiEventData *event = ucx_mempool_malloc(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 obj->ctx->mempool,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 sizeof(UiEventData));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 event->obj = obj;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 event->user_data = mi->userdata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 event->callback = mi->callback;
17
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
239 event->value = 0;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
240 XtAddCallback(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
241 mitem,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
242 XmNactivateCallback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
243 (XtCallbackProc)ui_push_button_callback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 2
diff changeset
244 event);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 return 1;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249
18
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
250 int add_menuitem_st_widget(Widget parent, int i, UiMenuItemI *item, UiObject *obj) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
251 UiStMenuItem *mi = (UiStMenuItem*)item;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
252
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
253 UiStockItem *si = ui_get_stock_item(mi->stockid);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
254 if(!si) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
255 fprintf(stderr, "UI Error: unknown stock id: %s\n", mi->stockid);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
256 return 0;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
257 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
258
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
259 int n = 0;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
260 Arg args[4];
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
261 XmString label = XmStringCreateLocalized(si->label);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
262 XmString at = NULL;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
263
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
264 XtSetArg(args[n], XmNlabelString, label);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
265 n++;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
266 if(si->accelerator) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
267 XtSetArg(args[n], XmNaccelerator, si->accelerator);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
268 n++;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
269 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
270 if(si->accelerator_label) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
271 at = XmStringCreateLocalized(si->accelerator_label);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
272 XtSetArg(args[n], XmNacceleratorText, at);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
273 n++;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
274 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
275
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
276 Widget mitem = XtCreateManagedWidget(
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
277 "menubutton",
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
278 xmPushButtonWidgetClass,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
279 parent,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
280 args,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
281 n);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
282 XmStringFree(label);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
283 if(at) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
284 XmStringFree(at);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
285 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
286
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
287 if(mi->callback != NULL) {
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
288 UiEventData *event = ucx_mempool_malloc(
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
289 obj->ctx->mempool,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
290 sizeof(UiEventData));
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
291 event->obj = obj;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
292 event->user_data = mi->userdata;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
293 event->callback = mi->callback;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
294 event->value = 0;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
295 XtAddCallback(
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
296 mitem,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
297 XmNactivateCallback,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
298 (XtCallbackProc)ui_push_button_callback,
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
299 event);
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
300 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
301
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
302 return 1;
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
303 }
06be29a56f8b added menu accelerators
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
304
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 int add_menuseparator_widget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 Widget parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 int i,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 UiMenuItemI *item,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 UiObject *obj)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 Widget s = XmCreateSeparatorGadget (parent, "menu_separator", NULL, 0);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 XtManageChild(s);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 return 1;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 int add_checkitem_widget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 Widget parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 int i,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 UiMenuItemI *item,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 UiObject *obj)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 UiCheckItem *ci = (UiCheckItem*)item;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 Arg args[3];
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 XmString label = XmStringCreateLocalized(ci->label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 XtSetArg(args[0], XmNlabelString, label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 XtSetArg(args[1], XmNvisibleWhenOff, 1);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 Widget checkbox = XtCreateManagedWidget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 "menutogglebutton",
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 xmToggleButtonWidgetClass,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 args,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 2);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 XmStringFree(label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 if(ci->callback) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 UiEventData *event = ucx_mempool_malloc(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 obj->ctx->mempool,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 sizeof(UiEventData));
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 event->obj = obj;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 event->user_data = ci->userdata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 event->callback = ci->callback;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 XtAddCallback(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 checkbox,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 XmNvalueChangedCallback,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 (XtCallbackProc)ui_toggle_button_callback,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 event);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 return 1;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 int add_checkitemnv_widget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 Widget parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 int i,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 UiMenuItemI *item,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 UiObject *obj)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 UiCheckItemNV *ci = (UiCheckItemNV*)item;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 Arg args[3];
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 XmString label = XmStringCreateLocalized(ci->label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 XtSetArg(args[0], XmNlabelString, label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 XtSetArg(args[1], XmNvisibleWhenOff, 1);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 Widget checkbox = XtCreateManagedWidget(
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 "menutogglebutton",
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 xmToggleButtonWidgetClass,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 parent,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 args,
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 2);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 XmStringFree(label);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372
2
eeb50c534497 added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
373 UiVar *var = uic_connect_var(obj->ctx, ci->varname, UI_VAR_INTEGER);
eeb50c534497 added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
374 if(var) {
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 UiInteger *value = var->value;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 value->obj = checkbox;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 value->get = ui_toggle_button_get;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378 value->set = ui_toggle_button_set;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 value = 0;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 } else {
2
eeb50c534497 added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
381 // TODO: error
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 }
17
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
383
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
384 return 1;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
385 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
386
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
387 int add_menuitem_list_widget(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
388 Widget parent,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
389 int i,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
390 UiMenuItemI *item,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
391 UiObject *obj)
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
392 {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
393 UiMenuItemList *il = (UiMenuItemList*)item;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
394 UcxMempool *mp = obj->ctx->mempool;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
395
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
396 UiActiveMenuItemList *ls = ucx_mempool_malloc(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
397 mp,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
398 sizeof(UiActiveMenuItemList));
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
399
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
400 ls->object = obj;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
401 ls->menu = parent;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
402 ls->index = i;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
403 ls->oldcount = 0;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
404 ls->list = il->list;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
405 ls->callback = il->callback;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
406 ls->userdata = il->userdata;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
407
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
408 ls->list->observers = ui_add_observer(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
409 ls->list->observers,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
410 (ui_callback)ui_update_menuitem_list,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
411 ls);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
412
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
413 ui_update_menuitem_list(NULL, ls);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
414
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
415 return 0;
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417
17
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
418 void ui_update_menuitem_list(UiEvent *event, UiActiveMenuItemList *list) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
419 Arg args[4];
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
420
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
421 // remove old items
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
422 if(list->oldcount > 0) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
423 Widget *children;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
424 int nc;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
425
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
426 XtVaGetValues(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
427 list->menu,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
428 XmNchildren,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
429 &children,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
430 XmNnumChildren,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
431 &nc,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
432 NULL);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
433
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
434 for(int i=0;i<list->oldcount;i++) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
435 XtDestroyWidget(children[list->index + i]);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
436 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
437 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
438
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
439 char *str = ui_list_first(list->list);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
440 if(str) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
441 // add separator
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
442 XtSetArg(args[0], XmNpositionIndex, list->index);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
443 Widget s = XmCreateSeparatorGadget (list->menu, "menu_separator", args, 1);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
444 XtManageChild(s);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
445 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
446 int i = 1;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
447 while(str) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
448 XmString label = XmStringCreateLocalized(str);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
449 XtSetArg(args[0], XmNlabelString, label);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
450 XtSetArg(args[1], XmNpositionIndex, list->index + i);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
451
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
452 Widget mitem = XtCreateManagedWidget(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
453 "menubutton",
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
454 xmPushButtonWidgetClass,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
455 list->menu,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
456 args,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
457 2);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
458 XmStringFree(label);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
459
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
460 if(list->callback) {
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
461 // TODO: use mempool
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
462 UiEventData *event = malloc(sizeof(UiEventData));
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
463 event->obj = list->object;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
464 event->user_data = list->userdata;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
465 event->callback = list->callback;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
466 event->value = i - 1;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
467
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
468 XtAddCallback(
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
469 mitem,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
470 XmNactivateCallback,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
471 (XtCallbackProc)ui_push_button_callback,
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
472 event);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
473 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
474
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
475 str = ui_list_next(list->list);
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
476 i++;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
477 }
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
478
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
479 list->oldcount = i;
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
480 }
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 void ui_menu_event_wrapper(Widget widget, XtPointer udata, XtPointer cdata) {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 UiEventData *event = udata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 UiEvent e;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485 e.obj = event->obj;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 e.window = event->obj->window;
2
eeb50c534497 added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
487 e.document = event->obj->document;
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 e.intval = 0;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 event->callback(&e, event->user_data);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 }

mercurial