diff --git a/include/wx/menu.h b/include/wx/menu.h index 1a5ef27737..8914432b71 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -27,6 +27,7 @@ // included wx/menu.h #include "wx/menuitem.h" +class WXDLLIMPEXP_FWD_CORE wxFrame; class WXDLLIMPEXP_FWD_CORE wxMenu; class WXDLLIMPEXP_FWD_CORE wxMenuBarBase; class WXDLLIMPEXP_FWD_CORE wxMenuBar; @@ -261,6 +262,11 @@ public: void SetInvokingWindow(wxWindow *win); wxWindow *GetInvokingWindow() const; + // the window associated with this menu: this is the invoking window for + // popup menus or the top level window to which the menu bar is attached + // for menus which are part of a menu bar + wxWindow *GetWindow() const; + // style long GetStyle() const { return m_style; } diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h index 852bb646a6..f19beacbf7 100644 --- a/include/wx/msw/menu.h +++ b/include/wx/msw/menu.h @@ -67,10 +67,7 @@ public: bool MSWCommand(WXUINT param, WXWORD id); - // semi-private accessors - // get the window which contains this menu - wxWindow *GetWindow() const; - // get the menu handle + // get the native menu handle WXHMENU GetHMenu() const { return m_hMenu; } #if wxUSE_ACCEL diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 76f17e9481..74d5fd843d 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -540,6 +540,11 @@ wxWindow *wxMenuBase::GetInvokingWindow() const return menu->m_invokingWindow; } +wxWindow *wxMenuBase::GetWindow() const +{ + return GetMenuBar() ? GetMenuBar()->GetFrame() : GetInvokingWindow(); +} + // ---------------------------------------------------------------------------- // wxMenu functions forwarded to wxMenuItem // ---------------------------------------------------------------------------- diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 7c62184ce2..9df0797d69 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -978,15 +978,6 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_) return true; } -// --------------------------------------------------------------------------- -// other -// --------------------------------------------------------------------------- - -wxWindow *wxMenu::GetWindow() const -{ - return GetMenuBar() ? GetMenuBar()->GetFrame() : GetInvokingWindow(); -} - // --------------------------------------------------------------------------- // Menu Bar // ---------------------------------------------------------------------------