]> git.saurik.com Git - wxWidgets.git/commitdiff
added virtual wxFrame::FindItemInMenuBar(): overriding it in wxMDIParentFrame allows...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 May 2007 17:03:38 +0000 (17:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 May 2007 17:03:38 +0000 (17:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/frame.h
include/wx/msw/mdi.h
src/common/framecmn.cpp
src/msw/mdi.cpp

index c9bf79c946f33ddf2a3cb879bcc6bfaeb7832f29..2d3a8988c9717750fe97e252141b5ffb232d168e 100644 (file)
@@ -81,6 +81,11 @@ public:
 #if wxUSE_MENUS
     virtual void SetMenuBar(wxMenuBar *menubar);
     virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
+
+    // find the item by id in the frame menu bar: this is an internal function
+    // and exists mainly in order to be overridden in the MDI parent frame
+    // which also looks at its active child menu bar
+    virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
 #endif // wxUSE_MENUS
 
     // process menu command: returns true if processed
@@ -212,8 +217,8 @@ protected:
     virtual void PositionStatusBar() { }
 
     // show the help string for the given menu item using DoGiveHelp() if the
-    // given item does have a help string, return false if there is no help for
-    // such item
+    // given item does have a help string (as determined by FindInMenuBar()),
+    // return false if there is no help for such item
     bool ShowMenuHelp(int helpid);
 
     wxStatusBar *m_frameStatusBar;
index cd0b21b28d24c6eb6c8604a8ea58f68c51aeaac7..3b9c41387e4bf40874982892a0a856636969a917 100644 (file)
@@ -92,6 +92,9 @@ public:
     virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
     virtual bool MSWTranslateMessage(WXMSG* msg);
 
+    // override wxFrameBase function to also look in the active child menu bar
+    virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
+
 protected:
 #if wxUSE_MENUS_NATIVE
     virtual void InternalSetMenuBar();
index 0c964bb6f4dd3431c69113e2c73a14c3bc1429a4..e93d1010e12b31a5be69debf8c061ad67e021e64 100644 (file)
@@ -356,15 +356,12 @@ bool wxFrameBase::ShowMenuHelp(int menuId)
     wxString helpString;
     if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ )
     {
-        wxMenuBar *menuBar = GetMenuBar();
-        if ( menuBar )
-        {
-            // it's ok if we don't find the item because it might belong
-            // to the popup menu
-            wxMenuItem *item = menuBar->FindItem(menuId);
-            if ( item )
-                helpString = item->GetHelp();
-        }
+        const wxMenuItem * const item = FindItemInMenuBar(menuId);
+        if ( item )
+            helpString = item->GetHelp();
+
+        // notice that it's ok if we don't find the item because it might
+        // belong to the popup menu, so don't assert here
     }
 
     DoGiveHelp(helpString, true);
@@ -560,4 +557,11 @@ void wxFrameBase::SetMenuBar(wxMenuBar *menubar)
     this->AttachMenuBar(menubar);
 }
 
+const wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const
+{
+    const wxMenuBar * const menuBar = GetMenuBar();
+
+    return menuBar ? menuBar->FindItem(menuId) : NULL;
+}
+
 #endif // wxUSE_MENUS
index 231ab43b1f9fde5e0a9563a2b9d31cb997080e3d..881f48fce921531f534f36fe1226ac2bf52aae05 100644 (file)
@@ -315,6 +315,17 @@ void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
     }
 }
 
+const wxMenuItem *wxMDIParentFrame::FindItemInMenuBar(int menuId) const
+{
+    const wxMenuItem *item = wxFrame::FindItemInMenuBar(menuId);
+    if ( !item && m_currentChild )
+    {
+        item = m_currentChild->FindItemInMenuBar(menuId);
+    }
+
+    return item;
+}
+
 void wxMDIParentFrame::UpdateClientSize()
 {
     if ( GetClientWindow() )
@@ -475,24 +486,6 @@ WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message,
             rc = true;
             break;
 
-        case WM_MENUSELECT:
-            {
-                WXWORD item, flags;
-                WXHMENU hmenu;
-                UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
-
-                if ( m_parentFrameActive )
-                {
-                    processed = HandleMenuSelect(item, flags, hmenu);
-                }
-                else if (m_currentChild)
-                {
-                    processed = m_currentChild->
-                        HandleMenuSelect(item, flags, hmenu);
-                }
-            }
-            break;
-
         case WM_SIZE:
             // though we don't (usually) resize the MDI client to exactly fit the
             // client area we need to pass this one to DefFrameProc to allow the children to show