From 7118e711dcf3bdb543d5e20cac2c45d50c691979 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Apr 2010 15:07:39 +0000 Subject: [PATCH] Move wxMSW wxMenu::GetWindow() down to wxMenuBase. GetInvokingWindow() can only be used for the popup menus which have the invoking window, so add a new function which can be used to get the window associated with any kind of menu in all ports -- it already existed in wxMSW but is needed elsewhere too. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/menu.h | 6 ++++++ include/wx/msw/menu.h | 5 +---- src/common/menucmn.cpp | 5 +++++ src/msw/menu.cpp | 9 --------- 4 files changed, 12 insertions(+), 13 deletions(-) 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 // --------------------------------------------------------------------------- -- 2.45.2