moved wxMenuBar::FindMenu(title) from MSW to common code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -297,6 +297,9 @@ public:
|
|||||||
// if menu is !NULL, it will be filled with wxMenu this item belongs to
|
// if menu is !NULL, it will be filled with wxMenu this item belongs to
|
||||||
virtual wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const = 0;
|
virtual wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const = 0;
|
||||||
|
|
||||||
|
// find menu by its caption, return wxNOT_FOUND on failure
|
||||||
|
int FindMenu(const wxString& title);
|
||||||
|
|
||||||
// item access
|
// item access
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
|
@@ -153,7 +153,6 @@ public:
|
|||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
WXHMENU Create();
|
WXHMENU Create();
|
||||||
int FindMenu(const wxString& title);
|
|
||||||
void Detach();
|
void Detach();
|
||||||
|
|
||||||
// returns TRUE if we're attached to a frame
|
// returns TRUE if we're attached to a frame
|
||||||
|
@@ -544,6 +544,26 @@ wxMenu *wxMenuBarBase::Remove(size_t pos)
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxMenuBarBase::FindMenu(const wxString& title)
|
||||||
|
{
|
||||||
|
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
|
// wxMenuBar functions forwarded to wxMenuItem
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@@ -632,22 +632,6 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
|
|||||||
return m_titles[pos];
|
return m_titles[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxMenuBar::FindMenu(const wxString& title)
|
|
||||||
{
|
|
||||||
wxString menuTitle = wxStripMenuCodes(title);
|
|
||||||
|
|
||||||
size_t count = GetMenuCount();
|
|
||||||
for ( size_t i = 0; i < count; i++ )
|
|
||||||
{
|
|
||||||
wxString title = wxStripMenuCodes(m_titles[i]);
|
|
||||||
if ( menuTitle == title )
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxNOT_FOUND;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// wxMenuBar construction
|
// wxMenuBar construction
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user