X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/58751a8685259e02cb71d193654e2afa1112fda1..de2ce07c7a13f9b0800c8f9e68adadebdc9aa89c:/src/mac/menu.cpp diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index bffd5b416d..e4e0879b02 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -74,7 +74,7 @@ void wxMenu::Init() if ( !m_hMenu ) { - wxLogLastError("UMANewMenu failed"); + wxLogLastError(wxT("UMANewMenu failed")); } // if we have a title, insert it in the beginning of the menu @@ -145,10 +145,14 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) } else { + // MacOS counts menu items from 1 and inserts after, therefore having the + // same effect as wx 0 based and inserting before, we must correct pos + // after however for updates to be correct UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") , pos); + pos += 1 ; } - SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos+1 , pItem->GetId() ) ; + SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; pItem->UpdateItemText() ; pItem->UpdateItemBitmap() ; pItem->UpdateItemStatus() ; @@ -173,9 +177,9 @@ void wxMenu::EndRadioGroup() m_startRadioGroup = -1; } -bool wxMenu::DoAppend(wxMenuItem *item) +wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) { - wxCHECK_MSG( item, FALSE, _T("NULL item in wxMenu::DoAppend") ); + wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") ); bool check = FALSE; @@ -218,7 +222,7 @@ bool wxMenu::DoAppend(wxMenuItem *item) if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) ) { - return FALSE; + return NULL; } if ( check ) @@ -227,12 +231,15 @@ bool wxMenu::DoAppend(wxMenuItem *item) item->Check(TRUE); } - return TRUE; + return item; } -bool wxMenu::DoInsert(size_t pos, wxMenuItem *item) +wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { - return wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos); + if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos)) + return item; + else + return NULL; } wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) @@ -272,15 +279,6 @@ bool wxMenu::ProcessCommand(wxCommandEvent & event) { bool processed = FALSE; -#if WXWIN_COMPATIBILITY - // Try a callback - if (m_callback) - { - (void)(*(m_callback))(*this, event); - processed = TRUE; - } -#endif WXWIN_COMPATIBILITY - // Try the menu's event handler if ( !processed && GetEventHandler()) { @@ -445,6 +443,7 @@ auto-merge for MDI in case this will be necessary */ wxMenuBar* wxMenuBar::s_macInstalledMenuBar = NULL ; +wxMenuBar* wxMenuBar::s_macCommonMenuBar = NULL ; void wxMenuBar::Init() { @@ -481,6 +480,8 @@ wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::~wxMenuBar() { + if (s_macCommonMenuBar == this) + s_macCommonMenuBar = NULL; if (s_macInstalledMenuBar == this) { ::ClearMenuBar(); @@ -743,12 +744,10 @@ wxMenu *wxMenuBar::Remove(size_t pos) ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; } - menu->Detach(); - Refresh(); } - m_titles.Remove(pos); + m_titles.RemoveAt(pos); return menu; }