| 109 } |
110 } |
| 110 |
111 |
| 111 @end |
112 @end |
| 112 |
113 |
| 113 NSToolbarItem* ui_nstoolbaritem_create_item(UiObject *obj, UiToolbarItem *item, NSString *identifier) { |
114 NSToolbarItem* ui_nstoolbaritem_create_item(UiObject *obj, UiToolbarItem *item, NSString *identifier) { |
| 114 NSToolbarItem *tbItem = [[NSToolbarItem alloc] initWithItemIdentifier: identifier]; |
115 NSToolbarItem *button = [[NSToolbarItem alloc] initWithItemIdentifier: identifier]; |
| 115 |
116 button.bordered = YES; |
| 116 NSButton *button = [[NSButton alloc] init]; |
|
| 117 tbItem.view = button; |
|
| 118 |
117 |
| 119 if(item->args.label) { |
118 if(item->args.label) { |
| 120 NSString *label = [[NSString alloc] initWithUTF8String:item->args.label]; |
119 NSString *label = [[NSString alloc] initWithUTF8String:item->args.label]; |
| 121 [tbItem setLabel:label]; |
120 button.paletteLabel = label; |
| 122 if(!item->args.icon) { |
121 button.label = label; |
| 123 button.title = label; |
|
| 124 } |
|
| 125 } |
122 } |
| 126 if(item->args.icon) { |
123 if(item->args.icon) { |
| 127 button.image = [NSImage imageNamed: [[NSString alloc] initWithUTF8String:item->args.icon]]; |
124 //button.image = [NSImage imageNamed: [[NSString alloc] initWithUTF8String:item->args.icon]]; |
| |
125 button.image = ui_cocoa_named_icon(item->args.icon); |
| 128 } |
126 } |
| 129 |
127 |
| 130 if(item->args.onclick) { |
128 if(item->args.onclick) { |
| 131 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata]; |
129 EventData *event = [[EventData alloc] init:item->args.onclick userdata:item->args.onclickdata]; |
| 132 event.obj = obj; |
130 event.obj = obj; |
| 133 button.target = event; |
131 button.target = event; |
| 134 button.action = @selector(handleEvent:); |
132 button.action = @selector(handleEvent:); |
| 135 objc_setAssociatedObject(button, "eventdata", event, OBJC_ASSOCIATION_RETAIN); |
133 objc_setAssociatedObject(button, "eventdata", event, OBJC_ASSOCIATION_RETAIN); |
| 136 } |
134 } |
| 137 return tbItem; |
135 return button; |
| 138 } |
136 } |
| 139 |
137 |
| 140 NSToolbarItem* ui_nstoolbaritem_create_toggle(UiObject *obj, UiToolbarToggleItem *item, NSString *identifier) { |
138 NSToolbarItem* ui_nstoolbaritem_create_toggle(UiObject *obj, UiToolbarToggleItem *item, NSString *identifier) { |
| 141 NSToolbarItem *tbItem = [[NSToolbarItem alloc] initWithItemIdentifier: identifier]; |
139 NSToolbarItem *tbItem = [[NSToolbarItem alloc] initWithItemIdentifier: identifier]; |
| 142 if(item->args.label) { |
140 if(item->args.label) { |