supporting Window Menu as Carbon did
This commit is contained in:
@@ -109,6 +109,7 @@ public:
|
||||
static long s_macPreferencesMenuItemId ;
|
||||
static long s_macExitMenuItemId ;
|
||||
static wxString s_macHelpMenuTitleName ;
|
||||
static wxString s_macWindowMenuTitleName ;
|
||||
|
||||
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
|
||||
|
||||
|
@@ -68,6 +68,7 @@ long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
||||
long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
|
||||
long wxApp::s_macExitMenuItemId = wxID_EXIT ;
|
||||
wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
|
||||
wxString wxApp::s_macWindowMenuTitleName = wxT("&Window") ;
|
||||
|
||||
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
|
||||
|
||||
|
@@ -192,14 +192,13 @@ public :
|
||||
{
|
||||
[m_osxMenu removeItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem()];
|
||||
}
|
||||
|
||||
virtual void MakeRoot() wxOVERRIDE
|
||||
|
||||
virtual void MacSetupAppleMenu()
|
||||
{
|
||||
wxMenu* peer = GetWXPeer();
|
||||
|
||||
[NSApp setMainMenu:m_osxMenu];
|
||||
[NSApp setAppleMenu:[[m_osxMenu itemAtIndex:0] submenu]];
|
||||
|
||||
|
||||
wxMenuItem *services = peer->FindItem(wxID_OSX_SERVICES);
|
||||
if ( services )
|
||||
[NSApp setServicesMenu:services->GetSubMenu()->GetHMenu()];
|
||||
@@ -208,6 +207,11 @@ public :
|
||||
else
|
||||
[NSApp setServicesMenu:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void MacSetupHelpMenu()
|
||||
{
|
||||
wxMenu* peer = GetWXPeer();
|
||||
|
||||
NSMenu* helpMenu = nil;
|
||||
int helpid = peer->FindItem(wxApp::s_macHelpMenuTitleName);
|
||||
@@ -225,6 +229,79 @@ public :
|
||||
[NSApp setHelpMenu:helpMenu];
|
||||
|
||||
}
|
||||
|
||||
virtual NSMenu* MacCreateOrFindWindowMenu()
|
||||
{
|
||||
wxMenu* peer = GetWXPeer();
|
||||
|
||||
NSMenu* windowMenu = nil;
|
||||
int windowmenuid = peer->FindItem(wxApp::s_macWindowMenuTitleName);
|
||||
if ( windowmenuid == wxNOT_FOUND )
|
||||
windowmenuid = peer->FindItem(_("&Window"));
|
||||
|
||||
if ( windowmenuid != wxNOT_FOUND )
|
||||
{
|
||||
wxMenuItem* windowMenuItem = peer->FindItem(windowmenuid);
|
||||
|
||||
if ( windowMenuItem->IsSubMenu() )
|
||||
windowMenu = windowMenuItem->GetSubMenu()->GetHMenu();
|
||||
}
|
||||
|
||||
if ( windowMenu == nil )
|
||||
{
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
NSMenuItem* windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[windowMenuItem setSubmenu:windowMenu];
|
||||
[windowMenu release];
|
||||
[m_osxMenu addItem:windowMenuItem];
|
||||
}
|
||||
return windowMenu;
|
||||
}
|
||||
|
||||
virtual void MacSetupWindowMenu()
|
||||
{
|
||||
if ( GetWXPeer()->GetMenuBar()->GetAutoWindowMenu() )
|
||||
{
|
||||
NSMenu* windowMenu = MacCreateOrFindWindowMenu();
|
||||
NSMenuItem* item = nil;
|
||||
bool menuWasEmpty = [windowMenu numberOfItems] == 0;
|
||||
if ( !menuWasEmpty )
|
||||
item = [windowMenu itemAtIndex:0];
|
||||
|
||||
if ( item == nil || [item action] != @selector(performMiniaturize:) )
|
||||
{
|
||||
item = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||
[windowMenu insertItem:item atIndex:0];
|
||||
[item setEnabled:YES];
|
||||
[item release];
|
||||
|
||||
item = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
||||
[windowMenu insertItem:item atIndex:1];
|
||||
[item release];
|
||||
|
||||
[windowMenu insertItem:[NSMenuItem separatorItem] atIndex:2];
|
||||
|
||||
item = [[NSMenuItem alloc] initWithTitle:@"Bring All to Front" action:@selector(arrangeInFront:) keyEquivalent:@""];
|
||||
[windowMenu insertItem:item atIndex:3];
|
||||
[item release];
|
||||
|
||||
if ( !menuWasEmpty )
|
||||
[windowMenu insertItem:[NSMenuItem separatorItem] atIndex:4];
|
||||
}
|
||||
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
}
|
||||
}
|
||||
|
||||
virtual void MakeRoot() wxOVERRIDE
|
||||
{
|
||||
[NSApp setMainMenu:m_osxMenu];
|
||||
|
||||
MacSetupAppleMenu();
|
||||
MacSetupHelpMenu();
|
||||
MacSetupWindowMenu();
|
||||
|
||||
}
|
||||
|
||||
virtual void Enable( bool WXUNUSED(enable) )
|
||||
{
|
||||
|
Reference in New Issue
Block a user