X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2824cdb7f6ac2371fefd3d44eff62bb48ebc0a3..38534f596974042130716a26276e9564b0b72295:/include/wx/mdi.h diff --git a/include/wx/mdi.h b/include/wx/mdi.h index e11290ead9..52cbed7da4 100644 --- a/include/wx/mdi.h +++ b/include/wx/mdi.h @@ -17,6 +17,7 @@ #if wxUSE_MDI #include "wx/frame.h" +#include "wx/menu.h" // forward declarations class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame; @@ -80,15 +81,18 @@ public: #if wxUSE_MENUS // return the pointer to the current window menu or NULL if we don't have // because of wxFRAME_NO_WINDOW_MENU style - wxMenu* GetWindowMenu() const { return m_windowMenu; }; + wxMenu* GetWindowMenu() const { return m_windowMenu; } // use the given menu instead of the default window menu // // menu can be NULL to disable the window menu completely virtual void SetWindowMenu(wxMenu *menu) { - delete m_windowMenu; - m_windowMenu = menu; + if ( menu != m_windowMenu ) + { + delete m_windowMenu; + m_windowMenu = menu; + } } #endif // wxUSE_MENUS @@ -119,6 +123,10 @@ public: virtual wxMDIClientWindow *OnCreateClient(); protected: + // Override to pass menu/toolbar events to the active child first. + virtual bool TryBefore(wxEvent& event); + + // This is wxMDIClientWindow for all the native implementations but not for // the generic MDI version which has its own wxGenericMDIClientWindow and // so we store it as just a base class pointer because we don't need its @@ -172,6 +180,16 @@ public: // level windows too virtual bool IsTopLevel() const { return false; } + // In all ports keyboard navigation must stop at MDI child frame level and + // can't cross its boundary. Indicate this by overriding this function to + // return true. + virtual bool IsTopNavigationDomain() const { return true; } + + // Raising any frame is supposed to show it but wxFrame Raise() + // implementation doesn't work for MDI child frames in most forms so + // forward this to Activate() which serves the same purpose by default. + virtual void Raise() { Activate(); } + protected: wxMDIParentFrame *m_mdiParent; }; @@ -355,6 +373,31 @@ inline wxMDIClientWindow *wxMDIParentFrameBase::OnCreateClient() return new wxMDIClientWindow; } +inline bool wxMDIParentFrameBase::TryBefore(wxEvent& event) +{ + // Menu (and toolbar) events should be sent to the active child frame + // first, if any. + if ( event.GetEventType() == wxEVT_MENU || + event.GetEventType() == wxEVT_UPDATE_UI ) + { + wxMDIChildFrame * const child = GetActiveChild(); + if ( child ) + { + // However avoid sending the event back to the child if it's + // currently being propagated to us from it. + wxWindow* const + from = static_cast(event.GetPropagatedFrom()); + if ( !from || !from->IsDescendant(child) ) + { + if ( child->ProcessWindowEventLocally(event) ) + return true; + } + } + } + + return wxFrame::TryBefore(event); +} + #endif // wxUSE_MDI #endif // _WX_MDI_H_BASE_