X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3b9f782ef3949f583e8ac53795d36787f044fc3..09981ba7981297056da49ceb0eb85d3ac9fc5f6f:/src/osx/menu_osx.cpp diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index 281c0121db..4825f18340 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -18,6 +18,8 @@ #include "wx/wxprec.h" +#if wxUSE_MENUS + #include "wx/menu.h" #ifndef WX_PRECOMP @@ -74,7 +76,7 @@ void wxMenu::Init() m_startRadioGroup = -1; m_allowRearrange = true; m_noEventsMode = false; - + m_peer = wxMenuImpl::Create( this, wxStripMenuCodes(m_title) ); @@ -142,7 +144,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) pSubMenu->DoRearrange(); } else - { + { if ( pItem->GetId() == idMenuTitle ) pItem->GetMenu()->Enable( idMenuTitle, false ); } @@ -163,7 +165,7 @@ void wxMenu::EndRadioGroup() wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) { - wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") ); + wxCHECK_MSG( item, NULL, wxT("NULL item in wxMenu::DoAppend") ); bool check = false; @@ -195,7 +197,7 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) } else { - wxFAIL_MSG( _T("where is the radio group start item?") ); + wxFAIL_MSG( wxT("where is the radio group start item?") ); } } } @@ -291,7 +293,7 @@ void wxMenu::DoRearrange() { if ( !AllowRearrange() ) return; - + wxMenuItem* previousItem = NULL ; size_t pos ; wxMenuItemList::compatibility_iterator node; @@ -329,7 +331,7 @@ void wxMenu::DoRearrange() { // next (i.e. second as we must be first) item is // the separator to hide - wxASSERT_MSG( pos == 0, _T("should be the menu start") ); + wxASSERT_MSG( pos == 0, wxT("should be the menu start") ); sepToHide = next; } else if ( GetMenuItems().GetCount() == pos + 1 && @@ -503,18 +505,17 @@ void wxMenuBar::Init() m_menuBarFrame = NULL; m_invokingWindow = NULL; m_rootMenu = new wxMenu(); - wxMenu* applemenu = new wxMenu(); - applemenu->SetAllowRearrange(false); - applemenu->Append( wxApp::s_macAboutMenuItemId, "About..." ); - applemenu->AppendSeparator(); - applemenu->Append( wxApp::s_macPreferencesMenuItemId, "Preferences..." ); - applemenu->AppendSeparator(); - -#if ! wxOSX_USE_CARBON - applemenu->Append( wxApp::s_macExitMenuItemId, "Quit\tCtrl+Q" ); + m_appleMenu = new wxMenu(); + m_appleMenu->SetAllowRearrange(false); + m_appleMenu->Append( wxApp::s_macAboutMenuItemId, "About..." ); + m_appleMenu->AppendSeparator(); +#if !wxOSX_USE_CARBON + m_appleMenu->Append( wxApp::s_macPreferencesMenuItemId, "Preferences..." ); + m_appleMenu->AppendSeparator(); + m_appleMenu->Append( wxApp::s_macExitMenuItemId, "Quit\tCtrl+Q" ); #endif - m_rootMenu->AppendSubMenu(applemenu, "\x14") ; + m_rootMenu->AppendSubMenu(m_appleMenu, "\x14") ; } wxMenuBar::wxMenuBar() @@ -563,8 +564,9 @@ void wxMenuBar::MacInstallMenuBar() { if ( s_macInstalledMenuBar == this ) return ; - + m_rootMenu->GetPeer()->MakeRoot(); + // DisableMenuCommand( NULL , kHICommandPreferences ) ; #if 0 MenuBarHandle menubar = NULL ; @@ -763,7 +765,7 @@ void wxMenuBar::MacInstallMenuBar() void wxMenuBar::EnableTop(size_t pos, bool enable) { wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") ); - + m_rootMenu->FindItemByPosition( pos )->Enable(enable); Refresh(); @@ -845,7 +847,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) return false; m_titles.Insert(title, pos); - + m_rootMenu->Insert( pos+firstMenuPos, wxMenuItem::New( m_rootMenu, wxID_ANY, title, "", wxITEM_NORMAL, menu ) ); if (m_invokingWindow) @@ -922,6 +924,8 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) void wxMenuBar::UnsetInvokingWindow() { m_invokingWindow = NULL; + wxMenubarUnsetInvokingWindow(m_appleMenu); + wxMenu *menu; wxMenuList::compatibility_iterator node = m_menus.GetFirst(); @@ -937,6 +941,8 @@ void wxMenuBar::UnsetInvokingWindow() void wxMenuBar::SetInvokingWindow(wxFrame *frame) { m_invokingWindow = frame; + wxMenubarSetInvokingWindow(m_appleMenu, frame); + wxMenu *menu; wxMenuList::compatibility_iterator node = m_menus.GetFirst(); @@ -991,3 +997,5 @@ wxMenuItem *wxMenuBar::FindItem(int id, wxMenu **itemMenu) const return item; } + +#endif