X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..4e15d1caa03346c126015019c1fdf093033ef40b:/src/univ/menu.cpp diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index eaf34b8f9e..957fb39972 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -281,10 +281,6 @@ private: // wxWin macros // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) -IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow) -IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) - BEGIN_EVENT_TABLE(wxPopupMenuWindow, wxPopupTransientWindow) EVT_KEY_DOWN(wxPopupMenuWindow::OnKeyDown) @@ -606,7 +602,7 @@ void wxPopupMenuWindow::DoDraw(wxControlRenderer *renderer) bmp = item->GetDisabledBitmap(); } - if ( !bmp.Ok() ) + if ( !bmp.IsOk() ) { // strangely enough, for unchecked item we use the // "checked" bitmap because this is the default one - this @@ -1096,11 +1092,7 @@ const wxMenuGeometryInfo& wxMenu::GetGeometryInfo() const void wxMenu::InvalidateGeometryInfo() { - if ( m_geometry ) - { - delete m_geometry; - m_geometry = NULL; - } + wxDELETE(m_geometry); } // ---------------------------------------------------------------------------- @@ -1114,13 +1106,6 @@ void wxMenu::OnItemAdded(wxMenuItem *item) #if wxUSE_ACCEL AddAccelFor(item); #endif // wxUSE_ACCEL - - // the submenus of a popup menu should have the same invoking window as it - // has - if ( m_invokingWindow && item->IsSubMenu() ) - { - item->GetSubMenu()->SetInvokingWindow(m_invokingWindow); - } } void wxMenu::EndRadioGroup() @@ -1222,6 +1207,10 @@ void wxMenu::Attach(wxMenuBarBase *menubar) void wxMenu::Detach() { + // After the menu is detached from the menu bar, it shouldn't send its + // events to it. + SetNextHandler(NULL); + wxMenuBase::Detach(); } @@ -1231,45 +1220,7 @@ void wxMenu::Detach() wxWindow *wxMenu::GetRootWindow() const { - if ( GetMenuBar() ) - { - // simple case - a normal menu attached to the menubar - return GetMenuBar(); - } - - // we're a popup menu but the trouble is that only the top level popup menu - // has a pointer to the invoking window, so we must walk up the menu chain - // if needed - wxWindow *win = GetInvokingWindow(); - if ( win ) - { - // we already have it - return win; - } - - wxMenu *menu = GetParent(); - while ( menu ) - { - // We are a submenu of a menu of a menubar - if (menu->GetMenuBar()) - return menu->GetMenuBar(); - - win = menu->GetInvokingWindow(); - if ( win ) - break; - - menu = menu->GetParent(); - } - - // we're probably going to crash in the caller anyhow, but try to detect - // this error as soon as possible - wxASSERT_MSG( win, wxT("menu without any associated window?") ); - - // also remember it in this menu so that we don't have to search for it the - // next time - wxConstCast(this, wxMenu)->m_invokingWindow = win; - - return win; + return GetMenuBar() ? GetMenuBar() : GetInvokingWindow(); } wxRenderer *wxMenu::GetRenderer() const @@ -1338,12 +1289,10 @@ void wxMenu::OnDismiss(bool dismissParent) } else // popup menu { - wxCHECK_RET( m_invokingWindow, wxT("what kind of menu is this?") ); - - m_invokingWindow->DismissPopupMenu(); + wxWindow * const win = GetInvokingWindow(); + wxCHECK_RET( win, wxT("what kind of menu is this?") ); - // Why reset it here? We need it for sending the event to... - // SetInvokingWindow(NULL); + win->DismissPopupMenu(); } } } @@ -2420,8 +2369,6 @@ void wxMenuBar::PopupCurrentMenu(bool selectFirst) // item, not to the right of it wxRect rectItem = GetItemRect(m_current); - m_menuShown->SetInvokingWindow(m_frameLast); - m_menuShown->Popup(ClientToScreen(rectItem.GetPosition()), wxSize(0, rectItem.GetHeight()), selectFirst); @@ -2546,10 +2493,6 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) Update(); #endif // 0 - menu->SetInvokingWindow(this); - - // wxLogDebug( "Name of invoking window %s", menu->GetInvokingWindow()->GetName().c_str() ); - menu->Popup(ClientToScreen(wxPoint(x, y)), wxSize(0,0)); // this is not very useful if the menu was popped up because of the mouse @@ -2566,14 +2509,11 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) ms_evtLoopPopup = new wxEventLoop; ms_evtLoopPopup->Run(); - delete ms_evtLoopPopup; - ms_evtLoopPopup = NULL; + wxDELETE(ms_evtLoopPopup); // remove the handler PopEventHandler(true /* delete it */); - menu->SetInvokingWindow(NULL); - #ifdef __WXMSW__ SetCursor(cursorOld); #endif // __WXMSW__