2013-03-15 13:11:33 +00:00
|
|
|
@implementation CocoaItem : NSMenuItem
|
|
|
|
|
2013-03-21 12:59:01 +00:00
|
|
|
-(id) initWith:(phoenix::Item&)itemReference {
|
2013-03-15 13:11:33 +00:00
|
|
|
if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) {
|
|
|
|
item = &itemReference;
|
|
|
|
|
|
|
|
[self setTarget:self];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) activate {
|
|
|
|
if(item->onActivate) item->onActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace phoenix {
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void pItem::setImage(const image& image) {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
unsigned size = 15; //there is no API to retrieve the optimal size
|
|
|
|
[cocoaAction setImage:NSMakeImage(image, size, size)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void pItem::setText(const string& text) {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaAction setTitle:[NSString stringWithUTF8String:text]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pItem::constructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
cocoaAction = cocoaItem = [[CocoaItem alloc] initWith:item];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pItem::destructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaAction release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|