| 102 return ui_nstoolbaritem_create_item(_obj, (UiToolbarItem*)item, itemIdentifier); |
103 return ui_nstoolbaritem_create_item(_obj, (UiToolbarItem*)item, itemIdentifier); |
| 103 } |
104 } |
| 104 case UI_TOOLBAR_TOGGLEITEM: { |
105 case UI_TOOLBAR_TOGGLEITEM: { |
| 105 return ui_nstoolbaritem_create_toggle(_obj, (UiToolbarToggleItem*)item, itemIdentifier); |
106 return ui_nstoolbaritem_create_toggle(_obj, (UiToolbarToggleItem*)item, itemIdentifier); |
| 106 } |
107 } |
| |
108 case UI_TOOLBAR_MENU: { |
| |
109 return ui_nstoolbaritem_create_menu(_obj, (UiToolbarMenuItem*)item, itemIdentifier); |
| |
110 } |
| 107 } |
111 } |
| 108 |
112 |
| 109 return nil; |
113 return nil; |
| 110 } |
114 } |
| 111 |
115 |
| 149 NSString *label = [[NSString alloc] initWithUTF8String:item->args.label]; |
153 NSString *label = [[NSString alloc] initWithUTF8String:item->args.label]; |
| 150 button.paletteLabel = label; |
154 button.paletteLabel = label; |
| 151 button.label = label; |
155 button.label = label; |
| 152 } |
156 } |
| 153 if(item->args.icon) { |
157 if(item->args.icon) { |
| 154 //button.image = [NSImage imageNamed: [[NSString alloc] initWithUTF8String:item->args.icon]]; |
|
| 155 button.image = ui_cocoa_named_icon(item->args.icon); |
158 button.image = ui_cocoa_named_icon(item->args.icon); |
| 156 } |
159 } |
| 157 |
160 |
| 158 if(item->args.onclick) { |
161 if(item->args.onclick) { |
| 159 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata]; |
162 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata]; |
| 217 void ui_toolbar_seg_toggleitem_set(UiInteger *i, int64_t value) { |
220 void ui_toolbar_seg_toggleitem_set(UiInteger *i, int64_t value) { |
| 218 NSSegmentedControl *seg = (__bridge NSSegmentedControl*)i->obj; |
221 NSSegmentedControl *seg = (__bridge NSSegmentedControl*)i->obj; |
| 219 i->value = value; |
222 i->value = value; |
| 220 [seg setSelected:value != 0 forSegment:0]; |
223 [seg setSelected:value != 0 forSegment:0]; |
| 221 } |
224 } |
| |
225 |
| |
226 NSToolbarItem* ui_nstoolbaritem_create_menu(UiObject *obj, UiToolbarMenuItem *item, NSString *identifier) { |
| |
227 NSMenuToolbarItem *button = [[NSMenuToolbarItem alloc] initWithItemIdentifier: identifier]; |
| |
228 button.bordered = YES; |
| |
229 |
| |
230 if(item->args.label) { |
| |
231 NSString *label = [[NSString alloc] initWithUTF8String:item->args.label]; |
| |
232 button.paletteLabel = label; |
| |
233 button.label = label; |
| |
234 } |
| |
235 if(item->args.icon) { |
| |
236 button.image = ui_cocoa_named_icon(item->args.icon); |
| |
237 } |
| |
238 |
| |
239 NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; |
| |
240 ui_add_menu_items(menu, 0, &item->menu); |
| |
241 |
| |
242 button.menu = menu; |
| |
243 |
| |
244 return button; |
| |
245 } |