Remove "isPopup" parameter from DoSendMenuOpenCloseEvent() in wxMSW.
This parameter is redundant, we can find out whether a menu is a popup one or not from the menu itself, assuming that we always have a valid wxMenu pointer for popup menus events, which really should be the case (we may not have one for the events from system menus). This allows to handle popup menu events case in the base class version of MSWFindMenuFromHMENU() which will allow to reuse it from places other than DoSendMenuOpenCloseEvent() without code duplication now. There should be no changes to the behaviour, this is just a simplification. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1c6bb3f5b8
commit
d7653d9c0c
@ -108,7 +108,7 @@ public:
|
||||
virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; }
|
||||
|
||||
virtual bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu);
|
||||
virtual bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup);
|
||||
virtual bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu);
|
||||
|
||||
// Look up the menu in the menu bar.
|
||||
virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu);
|
||||
|
@ -542,7 +542,7 @@ public:
|
||||
bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu);
|
||||
|
||||
// Command part of HandleMenuPopup() and HandleExitMenuLoop().
|
||||
virtual bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup);
|
||||
virtual bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu);
|
||||
|
||||
// Find the menu corresponding to the given handle.
|
||||
virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu);
|
||||
|
@ -491,10 +491,10 @@ bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
|
||||
return wxWindow::HandleMenuSelect(nItem, flags, hMenu);
|
||||
}
|
||||
|
||||
bool wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup)
|
||||
bool wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu)
|
||||
{
|
||||
// Update the menu depth when dealing with the top level menus.
|
||||
if ( !popup )
|
||||
if ( !menu || menu->IsAttached() )
|
||||
{
|
||||
if ( evtType == wxEVT_MENU_OPEN )
|
||||
{
|
||||
@ -512,12 +512,18 @@ bool wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool p
|
||||
}
|
||||
}
|
||||
|
||||
return wxWindow::DoSendMenuOpenCloseEvent(evtType, menu, popup);
|
||||
return wxWindow::DoSendMenuOpenCloseEvent(evtType, menu);
|
||||
}
|
||||
|
||||
wxMenu* wxFrame::MSWFindMenuFromHMENU(WXHMENU hMenu)
|
||||
{
|
||||
return GetMenuBar() ? GetMenuBar()->MSWGetMenu(hMenu) : NULL;
|
||||
if ( wxMenuBar* mbar = GetMenuBar() )
|
||||
{
|
||||
if ( wxMenu* menu = mbar->MSWGetMenu(hMenu) )
|
||||
return menu;
|
||||
}
|
||||
|
||||
return wxFrameBase::MSWFindMenuFromHMENU(hMenu);
|
||||
}
|
||||
#endif // wxUSE_MENUS && !defined(__WXUNIVERSAL__)
|
||||
|
||||
|
@ -2288,9 +2288,9 @@ wxWindowMSW::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
|
||||
}
|
||||
|
||||
bool
|
||||
wxWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup)
|
||||
wxWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu)
|
||||
{
|
||||
wxMenuEvent event(evtType, popup ? wxID_ANY : 0, menu);
|
||||
wxMenuEvent event(evtType, menu && !menu->IsAttached() ? wxID_ANY : 0, menu);
|
||||
event.SetEventObject(menu);
|
||||
|
||||
return HandleWindowEvent(event);
|
||||
@ -2298,25 +2298,16 @@ wxWindowMSW::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool po
|
||||
|
||||
bool wxWindowMSW::HandleMenuPopup(wxEventType evtType, WXHMENU hMenu)
|
||||
{
|
||||
bool isPopup = false;
|
||||
wxMenu* menu = NULL;
|
||||
if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetHMenu() == hMenu )
|
||||
{
|
||||
menu = wxCurrentPopupMenu;
|
||||
isPopup = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = MSWFindMenuFromHMENU(hMenu);
|
||||
}
|
||||
wxMenu* const menu = MSWFindMenuFromHMENU(hMenu);
|
||||
|
||||
|
||||
return DoSendMenuOpenCloseEvent(evtType, menu, isPopup);
|
||||
return DoSendMenuOpenCloseEvent(evtType, menu);
|
||||
}
|
||||
|
||||
wxMenu* wxWindowMSW::MSWFindMenuFromHMENU(WXHMENU WXUNUSED(hMenu))
|
||||
wxMenu* wxWindowMSW::MSWFindMenuFromHMENU(WXHMENU hMenu)
|
||||
{
|
||||
// We don't have any menus at this level.
|
||||
if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetHMenu() == hMenu )
|
||||
return wxCurrentPopupMenu;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user