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:
Vadim Zeitlin
2014-12-05 22:17:43 +00:00
parent 1c6bb3f5b8
commit d7653d9c0c
4 changed files with 20 additions and 23 deletions

View File

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