ui/cocoa/menu.m

Thu, 10 Dec 2020 13:43:25 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 10 Dec 2020 13:43:25 +0100
changeset 2
ea89bbb0c4c8
parent 0
804d8803eade
permissions
-rw-r--r--

toolkit update

0
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
804d8803eade add existing toolkit source
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
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #import <stdio.h>
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #import <stdlib.h>
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #import <string.h>
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #import <stdarg.h>
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #import "menu.h"
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #import "window.h"
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #import "stock.h"
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 @implementation UiMenuDelegate
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 - (UiMenuDelegate*) init {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 items = NULL;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 itemlists = NULL;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 return self;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 - (void) menuNeedsUpdate:(NSMenu *) menu {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 NSWindow *activeWindow = [NSApp keyWindow];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 [(UiCocoaWindow*)activeWindow updateMenu: menu];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 - (void) addItem:(NSMenuItem*) item var: (char*)name {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 UiStateItem *i = malloc(sizeof(UiStateItem));
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 i->item = item;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 i->var = name;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 items = ucx_list_append(items, i);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 - (void) addList:(UiList*) list menu:(NSMenu*)menu index: (int)i callback: (ui_callback)f data:(void*) data {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 UiMenuItemList *itemList = malloc(sizeof(UiMenuItemList));
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 itemList->list = list;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 itemList->menu = menu;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 itemList->first = NULL;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 itemList->index = i;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 itemList->oldcount = 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 itemList->callback = f;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 itemList->data = data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 itemlists = ucx_list_append(itemlists, itemList);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 - (UcxList*) items {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 return items;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 - (UcxList*) lists {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 return itemlists;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 @end
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 @implementation UiGroupMenuItem
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 - (id)initWithTitle:(NSString*)title action:(SEL)action keyEquivalent:(NSString*)s {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 [super initWithTitle:title action:action keyEquivalent:s];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 groups = [[NSMutableArray alloc]initWithCapacity: 8];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 return self;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 - (void) addGroup:(int)group {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 NSNumber *groupNumber = [NSNumber numberWithInteger:group];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 [groups addObject:groupNumber];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 - (void) checkGroups:(int*)g count:(int)n {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 int c = [groups count];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 char *check = calloc(1, c);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 for(int i=0;i<n;i++) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 for(int k=0;k<c;k++) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 NSNumber *groupNumber = [groups objectAtIndex:k];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 if([groupNumber intValue] == g[i]) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 check[k] = 1;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 break;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 for(int j=0;j<c;j++) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 if(check[j] == 0) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 [self setEnabled:NO];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 return;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 [self setEnabled:YES];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 @end
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 //static NSMenu *currentMenu = NULL;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 static UcxList *current;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 static int currentItemIndex = 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 static UiMenuDelegate *delegate;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 void ui_menu_init() {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 delegate = [[UiMenuDelegate alloc]init];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 UiMenuDelegate* ui_menu_delegate() {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 return delegate;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 void ui_menu(char *title) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 NSString *str = [[NSString alloc] initWithUTF8String:title];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 NSMenu *menu = [[NSMenu alloc] initWithTitle: str];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 NSMenuItem *menuItem = [[NSApp mainMenu] addItemWithTitle:str
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 action:nil keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 [menu setDelegate: delegate];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 [menu setAutoenablesItems:NO];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 [[NSApp mainMenu] setSubmenu:menu forItem:menuItem];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 //currentMenu = menu;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 currentItemIndex = 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 current = ucx_list_prepend(NULL, menu);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 void ui_submenu(char *title) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 NSString *str = [[NSString alloc] initWithUTF8String:title];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 NSMenu *menu = [[NSMenu alloc] initWithTitle: str];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 NSMenuItem *menuItem = [currentMenu addItemWithTitle:str
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 action:nil keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 [menu setDelegate: delegate];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 [menu setAutoenablesItems:NO];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 [currentMenu setSubmenu:menu forItem:menuItem];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 //currentMenu = menu;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 currentItemIndex = 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 current = ucx_list_prepend(current, menu);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 void ui_submenu_end() {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 if(ucx_list_size(current) < 2) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 return;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 current = ucx_list_remove(current, current);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 void ui_menuitem(char *label, ui_callback f, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 ui_menuitem_gr(label, f, data, -1);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 void ui_menuitem_st(char *stockid, ui_callback f, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 ui_menuitem_stgr(stockid, f, data, -1);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 // create menu item
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 EventWrapper *event = [[EventWrapper alloc]initWithData:userdata callback:f];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 NSString *title = [[NSString alloc] initWithUTF8String:label];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 UiGroupMenuItem *item = [[UiGroupMenuItem alloc]initWithTitle:title action:@selector(handleEvent:) keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 [item setTarget:event];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 // add groups
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 va_list ap;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 va_start(ap, userdata);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 int group;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 while((group = va_arg(ap, int)) != -1) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 [item addGroup: group];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 va_end(ap);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 [currentMenu addItem:item];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 currentItemIndex++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 // create menu item
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 EventWrapper *event = [[EventWrapper alloc]initWithData:userdata callback:f];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 UiStockItem *si = ui_get_stock_item(stockid);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 UiGroupMenuItem *item = [[UiGroupMenuItem alloc]initWithTitle:si->label
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 action:@selector(handleEvent:)
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 keyEquivalent:si->keyEquivalent];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 [item setTarget:event];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 // add groups
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 va_list ap;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 va_start(ap, userdata);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 int group;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 while((group = va_arg(ap, int)) != -1) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 [item addGroup: group];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 va_end(ap);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 [currentMenu addItem:item];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 currentItemIndex++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 void ui_checkitem(char *label, ui_callback f, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 EventWrapper *event = [[EventWrapper alloc]initWithData:data callback:f];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 NSString *str = [[NSString alloc] initWithUTF8String:label];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 NSMenuItem *item = [currentMenu addItemWithTitle:str
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 action:@selector(handleStateEvent:) keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 [item setTarget:event];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 [delegate addItem: item var:NULL];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 currentItemIndex++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 void ui_checkitem_nv(char *label, char *vname) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 EventWrapper *event = [[EventWrapper alloc]initWithData:NULL callback:NULL];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 NSString *str = [[NSString alloc] initWithUTF8String:label];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 NSMenuItem *item = [currentMenu addItemWithTitle:str
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 action:@selector(handleStateEvent:) keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 [item setTarget:event];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 [delegate addItem: item var:vname];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 currentItemIndex++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 void ui_menuseparator() {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 [currentMenu addItem: [NSMenuItem separatorItem]];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 currentItemIndex++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 void ui_menuitem_list (UiList *items, ui_callback f, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 NSMenu *currentMenu = current->data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 [delegate addList:items menu:currentMenu index:currentItemIndex callback:f data:data];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 int ui_menuitem_get(UiInteger *i) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 UiMenuItem *item = i->obj;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 i->value = [item->item state];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 return i->value;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 void ui_menuitem_set(UiInteger *i, int value) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 UiMenuItem *item = i->obj;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 [item->item setState: value];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 i->value = value;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 item->state = value;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 int ui_update_item(UiCocoaWindow *window, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 UiMenuItem *item = data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 [item->item setState: item->state];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 return 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 int ui_update_item_list(UiCocoaWindow *window, void *data) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 UiMenuItemList *itemList = data;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 UiList *list = itemList->list;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 for(int r=0;r<itemList->oldcount;r++) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 [itemList->menu removeItemAtIndex:itemList->index];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 char *str = ui_list_first(list);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 int i = itemList->index;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 [itemList->menu insertItem: [NSMenuItem separatorItem] atIndex: i];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 i++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 while(str) {
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 EventWrapper *event = [[EventWrapper alloc]initWithData:itemList->data callback:itemList->callback];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 [event setIntval: i - itemList->index - 1];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 NSString *title = [[NSString alloc] initWithUTF8String:str];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 NSMenuItem *item = [[NSMenuItem alloc]initWithTitle:title action:@selector(handleEvent:) keyEquivalent:@""];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 [item setTarget:event];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 [itemList->menu insertItem:item atIndex:i];
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 str = ui_list_next(list);
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 i++;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 }
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 itemList->oldcount = i - itemList->index;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 return 0;
804d8803eade add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 }

mercurial