ui/cocoa/toolbar.m

changeset 14
e2fd132ab781
parent 7
431dde3c5fbe
child 23
decc6bf584aa
equal deleted inserted replaced
13:2dbc56c2323b 14:e2fd132ab781
29 #import <stdio.h> 29 #import <stdio.h>
30 #import <stdlib.h> 30 #import <stdlib.h>
31 #import <string.h> 31 #import <string.h>
32 32
33 #import "toolbar.h" 33 #import "toolbar.h"
34 #import "stock.h"
34 35
35 36
36 static UiToolbarDelegate* toolbar_delegate; 37 static UiToolbarDelegate* toolbar_delegate;
37 38
38 /* --------------------- UiToolbarStockItem --------------------- */ 39 /* --------------------- UiToolbarStockItem --------------------- */
53 54
54 55
55 - (NSToolbarItem *) createItem:(NSToolbar*)toolbar 56 - (NSToolbarItem *) createItem:(NSToolbar*)toolbar
56 identifier:(NSString*)identifier 57 identifier:(NSString*)identifier
57 { 58 {
58 /*
59 UiStockItem *s = ui_get_stock_item(stockid); 59 UiStockItem *s = ui_get_stock_item(stockid);
60 if(s == nil) { 60 if(s == nil) {
61 printf("cannot find stock item\n"); 61 printf("cannot find stock item\n");
62 return nil; 62 return nil;
63 } 63 }
64 if([s buttonImage] == nil && [s itemImage] == nil) {
65 return nil;
66 }
67 */
68 64
69 NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier: 65 NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:
70 identifier] autorelease]; 66 identifier] autorelease];
71 //[item setLabel:[s label]]; 67 //[item setLabel:[s label]];
72 //[item setPaletteLabel:[s label]]; 68 //[item setPaletteLabel:[s label]];
73 [item setLabel:@"Add"]; 69 [item setLabel:s->label];
74 [item setPaletteLabel:@"Operation"]; 70 [item setPaletteLabel:@"Operation"];
75 71
76 // create button ... 72 // create button ...
77 NSRect frame = NSMakeRect(0, 0, 40, 22); 73 NSRect frame = NSMakeRect(0, 0, 40, 22);
78 //NSSearchField *sf = [[NSSearchField alloc]initWithFrame:frame]; 74 //NSSearchField *sf = [[NSSearchField alloc]initWithFrame:frame];
79 NSButton *button = [[NSButton alloc]initWithFrame:frame]; 75 NSButton *button = [[NSButton alloc]initWithFrame:frame];
80 //[button setImage:[s buttonImage]]; 76 //[button setImage:[s buttonImage]];
81 [button setImage:[NSImage imageNamed: NSImageNameAddTemplate]]; 77 //[button setImage:[NSImage imageNamed: NSImageNameAddTemplate]];
78 if(s->image) {
79 [button setImage:s->image];
80 } else {
81 [button setImage:[NSImage imageNamed: NSImageNameRemoveTemplate]];
82 }
82 [button setBezelStyle: NSTexturedRoundedBezelStyle]; 83 [button setBezelStyle: NSTexturedRoundedBezelStyle];
83 [item setView:button]; 84 [item setView:button];
84 85
85 // event 86 // event
86 EventWrapper *event = [[EventWrapper alloc] 87 EventWrapper *event = [[EventWrapper alloc]

mercurial