2015-12-30 06:41:46 +00:00
|
|
|
#if defined(Hiro_Menu)
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
@implementation CocoaMenu : NSMenuItem
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
-(id) initWith:(hiro::mMenu&)menuReference {
|
2013-03-15 13:11:33 +00:00
|
|
|
if(self = [super initWithTitle:@"" action:nil keyEquivalent:@""]) {
|
|
|
|
menu = &menuReference;
|
|
|
|
|
|
|
|
cocoaMenu = [[NSMenu alloc] initWithTitle:@""];
|
|
|
|
[self setSubmenu:cocoaMenu];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSMenu*) cocoaMenu {
|
|
|
|
return cocoaMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
namespace hiro {
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::construct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
cocoaAction = cocoaMenu = [[CocoaMenu alloc] initWith:self()];
|
|
|
|
pAction::construct();
|
|
|
|
|
|
|
|
setImage(state().image);
|
|
|
|
setText(state().text);
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::destruct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
[[cocoaAction cocoaMenu] release];
|
|
|
|
[cocoaAction release];
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::append(sAction action) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
// [[cocoaAction cocoaMenu] addItem:action.p.cocoaAction];
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::remove(sAction action) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
// [[cocoaAction cocoaMenu] removeItem:action.p.cocoaAction];
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::setImage(const Image& image) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
uint size = 15; //there is no API to retrieve the optimal size
|
|
|
|
// [cocoaAction setImage:NSMakeImage(image, size, size)];
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pMenu::setText(const string& text) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
2015-12-30 06:41:46 +00:00
|
|
|
[[cocoaAction cocoaMenu] setTitle:[NSString stringWithUTF8String:text]];
|
|
|
|
[cocoaAction setTitle:[NSString stringWithUTF8String:text]];
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-12-30 06:41:46 +00:00
|
|
|
|
|
|
|
#endif
|