// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#include <ctype.h>
+
#ifdef __BORLANDC__
#pragma hdrstop
#endif
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);
}
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);
}
// 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() )
if ( rc != wxNOT_FOUND )
return rc;
}
- else if ( !item->IsSeparator() )
+
+ // we execute this code for submenus as well to alllow finding them by
+ // name just like the ordinary items
+ if ( !item->IsSeparator() )
{
if ( item->GetLabel() == label )
return item->GetId();
{
if ( pos == m_menus.GetCount() )
{
- return Append(menu, title);
+ return wxMenuBarBase::Append(menu, title);
}
else
{
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
// ---------------------------------------------------------------------------