| 1 |
@implementation CocoaItem : NSMenuItem |
| 2 |
|
| 3 |
-(id) initWith:(phoenix::Item&)itemReference { |
| 4 |
if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) { |
| 5 |
item = &itemReference; |
| 6 |
|
| 7 |
[self setTarget:self]; |
| 8 |
} |
| 9 |
return self; |
| 10 |
} |
| 11 |
|
| 12 |
-(void) activate { |
| 13 |
if(item->onActivate) item->onActivate(); |
| 14 |
} |
| 15 |
|
| 16 |
@end |
| 17 |
|
| 18 |
namespace phoenix { |
| 19 |
|
| 20 |
void pItem::setImage(const image& image) { |
| 21 |
@autoreleasepool { |
| 22 |
unsigned size = 15; //there is no API to retrieve the optimal size |
| 23 |
[cocoaAction setImage:NSMakeImage(image, size, size)]; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
void pItem::setText(string text) { |
| 28 |
@autoreleasepool { |
| 29 |
[cocoaAction setTitle:[NSString stringWithUTF8String:text]]; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void pItem::constructor() { |
| 34 |
@autoreleasepool { |
| 35 |
cocoaAction = cocoaItem = [[CocoaItem alloc] initWith:item]; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
void pItem::destructor() { |
| 40 |
@autoreleasepool { |
| 41 |
[cocoaAction release]; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
} |