old-hiro/cocoa/menu-bar.cpp
2016-05-15 12:45:15 +02:00

40 lines
753 B
C++

#if defined(Hiro_MenuBar)
namespace hiro {
auto pMenuBar::construct() -> void {
}
auto pMenuBar::destruct() -> void {
}
auto pMenuBar::append(sMenu menu) -> void {
@autoreleasepool {
if(auto parent = _parent()) {
if(auto pMenu = menu->self()) {
[[parent->cocoaWindow menuBar] addItem:pMenu->cocoaAction];
}
}
}
}
auto pMenuBar::remove(sMenu menu) -> void {
@autoreleasepool {
if(auto parent = _parent()) {
if(auto pMenu = menu->self()) {
[[parent->cocoaWindow menuBar] removeItem:pMenu->cocoaAction];
}
}
}
}
auto pMenuBar::_parent() -> maybe<pWindow&> {
if(auto parent = self().parentWindow()) {
if(auto self = parent->self()) return *self;
}
return nothing;
}
}
#endif