supporting Window Menu as Carbon did
This commit is contained in:
@@ -109,6 +109,7 @@ public:
|
|||||||
static long s_macPreferencesMenuItemId ;
|
static long s_macPreferencesMenuItemId ;
|
||||||
static long s_macExitMenuItemId ;
|
static long s_macExitMenuItemId ;
|
||||||
static wxString s_macHelpMenuTitleName ;
|
static wxString s_macHelpMenuTitleName ;
|
||||||
|
static wxString s_macWindowMenuTitleName ;
|
||||||
|
|
||||||
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
|
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
|
||||||
|
|
||||||
|
@@ -68,6 +68,7 @@ long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
|||||||
long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
|
long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
|
||||||
long wxApp::s_macExitMenuItemId = wxID_EXIT ;
|
long wxApp::s_macExitMenuItemId = wxID_EXIT ;
|
||||||
wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
|
wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
|
||||||
|
wxString wxApp::s_macWindowMenuTitleName = wxT("&Window") ;
|
||||||
|
|
||||||
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
|
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
|
||||||
|
|
||||||
|
@@ -193,11 +193,10 @@ public :
|
|||||||
[m_osxMenu removeItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem()];
|
[m_osxMenu removeItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem()];
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void MakeRoot() wxOVERRIDE
|
virtual void MacSetupAppleMenu()
|
||||||
{
|
{
|
||||||
wxMenu* peer = GetWXPeer();
|
wxMenu* peer = GetWXPeer();
|
||||||
|
|
||||||
[NSApp setMainMenu:m_osxMenu];
|
|
||||||
[NSApp setAppleMenu:[[m_osxMenu itemAtIndex:0] submenu]];
|
[NSApp setAppleMenu:[[m_osxMenu itemAtIndex:0] submenu]];
|
||||||
|
|
||||||
wxMenuItem *services = peer->FindItem(wxID_OSX_SERVICES);
|
wxMenuItem *services = peer->FindItem(wxID_OSX_SERVICES);
|
||||||
@@ -208,6 +207,11 @@ public :
|
|||||||
else
|
else
|
||||||
[NSApp setServicesMenu:nil];
|
[NSApp setServicesMenu:nil];
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void MacSetupHelpMenu()
|
||||||
|
{
|
||||||
|
wxMenu* peer = GetWXPeer();
|
||||||
|
|
||||||
NSMenu* helpMenu = nil;
|
NSMenu* helpMenu = nil;
|
||||||
int helpid = peer->FindItem(wxApp::s_macHelpMenuTitleName);
|
int helpid = peer->FindItem(wxApp::s_macHelpMenuTitleName);
|
||||||
@@ -226,6 +230,79 @@ public :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) )
|
virtual void Enable( bool WXUNUSED(enable) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user