]> git.saurik.com Git - wxWidgets.git/commitdiff
moved wxMenuBar::FindMenu(title) from MSW to common code
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Feb 2000 09:53:55 +0000 (09:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 22 Feb 2000 09:53:55 +0000 (09:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/menu.h
include/wx/msw/menu.h
src/common/menucmn.cpp
src/msw/menu.cpp

index e3521afa2cec1df6038fd89cfdbf2499adb701c2..cf5e6b3f93ff395a533101182a1707da308349b3 100644 (file)
@@ -297,6 +297,9 @@ public:
     // if menu is !NULL, it will be filled with wxMenu this item belongs to
     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
     // -----------
 
index 741b88aa6eac021a2c7e02c4c07c2412cc4a8579..30815349c39f4662da17d0fc036909545d58e457 100644 (file)
@@ -153,7 +153,6 @@ public:
 
     // implementation from now on
     WXHMENU Create();
-    int  FindMenu(const wxString& title);
     void Detach();
 
         // returns TRUE if we're attached to a frame
index ff228f99dc6494a98c715f68e29ae20e95021bd5..5fa6e0723b7bf89301b6373901975379f69c4ce3 100644 (file)
@@ -544,6 +544,26 @@ wxMenu *wxMenuBarBase::Remove(size_t pos)
     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
 // ---------------------------------------------------------------------------
index 0894f1f6cf9db8670b6118520dc034de1934d1de..a91bb5dd2f46fbd8e036311d9fa20ffb0a8ad534 100644 (file)
@@ -632,22 +632,6 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
     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
 // ---------------------------------------------------------------------------