refactor WM_COMMAND messages handling in MDI frames to avoid duplicating code unnecessarily and generally streamline it; added possibility to use custom menu commands in the "Window" menu and specifying accelerators for them now works too (show this in the sample); finally added standard ids for the MDI window menu commands

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-27 16:47:41 +00:00
parent 67fdb6f9af
commit 1483e5db8d
9 changed files with 216 additions and 201 deletions

View File

@@ -107,6 +107,9 @@ public:
// get the currently active menu: this is the same as the frame menu for
// normal frames but is overridden by wxMDIParentFrame
virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; }
// find the item in our menu bar: this is again a hook for MDI frames
virtual wxMenuItem *MSWFindMenuBarItem(WXWORD id);
#endif // wxUSE_MENUS
protected:

View File

@@ -15,6 +15,8 @@
#include "wx/frame.h"
class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable;
// ---------------------------------------------------------------------------
// wxMDIParentFrame
// ---------------------------------------------------------------------------
@@ -22,7 +24,7 @@
class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
{
public:
wxMDIParentFrame();
wxMDIParentFrame() { }
wxMDIParentFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
@@ -103,6 +105,7 @@ public:
#if wxUSE_MENUS
// override wxFrameBase function to also look in the active child menu bar
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
virtual wxMenuItem *MSWFindMenuBarItem(WXWORD id);
#endif // wxUSE_MENUS
protected:
@@ -115,12 +118,13 @@ protected:
// set the size of the MDI client window to match the frame size
void UpdateClientSize();
// true if MDI Frame is intercepting commands, not child
bool m_parentFrameActive;
private:
#if wxUSE_MENUS
// "Window" menu commands event handlers
void OnMDICommand(wxCommandEvent& event);
void OnMDIChild(wxCommandEvent& event);
// add/remove window menu if we have it (i.e. m_windowMenu != NULL)
void AddWindowMenu();
void RemoveWindowMenu();
@@ -128,6 +132,10 @@ private:
// update the window menu (if we have it) to enable or disable the commands
// which only make sense when we have more than one child
void UpdateWindowMenu(bool enable);
#if wxUSE_ACCEL
wxAcceleratorTable *m_accelWindowMenu;
#endif // wxUSE_ACCEL
#endif // wxUSE_MENUS
// return the number of child frames we currently have (maybe 0)
@@ -187,7 +195,6 @@ public:
// Handlers
bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
bool HandleWindowPosChanging(void *lpPos);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
bool HandleGetMinMaxInfo(void *mmInfo);
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);