]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/menu.cpp
Fix file paths in wxFileSystemWatcherEvent under OS X.
[wxWidgets.git] / src / msw / menu.cpp
index afb0df14e95fdb445dfa8e5e84e75fa6b161f69f..4769e1b00b9a57002c063b4cc14b4746a786821c 100644 (file)
@@ -885,6 +885,30 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
     return true;
 }
 
+// get the menu with given handle (recursively)
+wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu)
+{
+    // check self
+    if ( GetHMenu() == hMenu )
+        return this;
+
+    // recursively query submenus
+    for ( size_t n = 0 ; n < GetMenuItemCount(); ++n )
+    {
+        wxMenuItem* item = FindItemByPosition(n);
+        wxMenu* submenu = item->GetSubMenu();
+        if ( submenu )
+        {
+            submenu = submenu->MSWGetMenu(hMenu);
+            if (submenu)
+                return submenu;
+        }
+    }
+
+    // unknown hMenu
+    return NULL;
+}
+
 // ---------------------------------------------------------------------------
 // Menu Bar
 // ---------------------------------------------------------------------------
@@ -1467,4 +1491,22 @@ void wxMenuBar::Detach()
     wxMenuBarBase::Detach();
 }
 
+// get the menu with given handle (recursively)
+wxMenu* wxMenuBar::MSWGetMenu(WXHMENU hMenu)
+{
+    wxCHECK_MSG( GetHMenu() != hMenu, NULL,
+                 wxT("wxMenuBar::MSWGetMenu(): menu handle is wxMenuBar, not wxMenu") );
+
+    // query all menus
+    for ( size_t n = 0 ; n < GetMenuCount(); ++n )
+    {
+        wxMenu* menu = GetMenu(n)->MSWGetMenu(hMenu);
+        if ( menu )
+            return menu;
+    }
+
+    // unknown hMenu
+    return NULL;
+}
+
 #endif // wxUSE_MENUS