X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/32db328c7a66ab2c479e1b9dc567b74e0f23257e..6342bd1ab36c1957684c00d408d09fba65d33db6:/src/common/menucmn.cpp diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 74818ae0a9..fd1cc38a1e 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -24,6 +24,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -210,7 +212,7 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item) bool wxMenuBase::Delete(wxMenuItem *item) { - wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Delete") ); + wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Delete") ); return DoDelete(item); } @@ -230,7 +232,7 @@ bool wxMenuBase::DoDelete(wxMenuItem *item) bool wxMenuBase::Destroy(wxMenuItem *item) { - wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Destroy") ); + wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Destroy") ); return DoDestroy(item); } @@ -252,7 +254,7 @@ bool wxMenuBase::DoDestroy(wxMenuItem *item) // Finds the item id matching the given string, -1 if not found. int wxMenuBase::FindItem(const wxString& text) const { - wxString label = wxMenuItem(NULL, wxID_SEPARATOR, text).GetLabel(); + wxString label = wxMenuItem::GetLabelFromText(text); for ( wxMenuItemList::Node *node = m_items.GetFirst(); node; node = node->GetNext() ) @@ -499,7 +501,7 @@ bool wxMenuBarBase::Insert(size_t pos, wxMenu *menu, { if ( pos == m_menus.GetCount() ) { - return Append(menu, title); + return wxMenuBarBase::Append(menu, title); } else { @@ -542,6 +544,26 @@ wxMenu *wxMenuBarBase::Remove(size_t pos) return menu; } +int wxMenuBarBase::FindMenu(const wxString& title) const +{ + wxString label = wxMenuItem::GetLabelFromText(title); + + size_t count = GetMenuCount(); + for ( size_t i = 0; i < count; i++ ) + { + wxString title2 = GetLabelTop(i); + if ( (title2 == title) || + (wxMenuItem::GetLabelFromText(title2) == label) ) + { + // found + return (int)i; + } + } + + return wxNOT_FOUND; + +} + // --------------------------------------------------------------------------- // wxMenuBar functions forwarded to wxMenuItem // ---------------------------------------------------------------------------