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
This commit is contained in:
Vadim Zeitlin 2010-04-24 15:07:39 +00:00
parent 3ded4b22fe
commit 7118e711dc
4 changed files with 12 additions and 13 deletions

View File

@ -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; }

View File

@ -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

View File

@ -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
// ----------------------------------------------------------------------------

View File

@ -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
// ---------------------------------------------------------------------------