X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7edcafa467269b15e0e967e9fe9ee08c6696b8a7..3242feb1c09fd28c5a41ed1ee76e37d56213f19b:/src/univ/menu.cpp diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index c87393282d..2f30a0a6d8 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -123,6 +123,8 @@ class wxPopupMenuWindow : public wxPopupTransientWindow { public: wxPopupMenuWindow(wxWindow *parent, wxMenu *menu); + + ~wxPopupMenuWindow(); // override the base class version to select the first item initially virtual void Popup(wxWindow *focus = NULL); @@ -255,6 +257,8 @@ public: } else { + // return FALSE; + return wxEvtHandler::ProcessEvent(event); } } @@ -308,6 +312,10 @@ wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu) SetCursor(wxCURSOR_ARROW); } +wxPopupMenuWindow::~wxPopupMenuWindow() +{ +} + // ---------------------------------------------------------------------------- // wxPopupMenuWindow current item/node handling // ---------------------------------------------------------------------------- @@ -662,7 +670,7 @@ bool wxPopupMenuWindow::ProcessLeftDown(wxMouseEvent& event) wxPopupMenuWindow *win = menu->m_popupMenu; wxCHECK_MSG( win, FALSE, _T("parent menu not shown?") ); - + pos = ClientToScreen(pos); if ( win->GetMenuItemFromPoint(win->ScreenToClient(pos)) ) { @@ -1154,6 +1162,10 @@ wxWindow *wxMenu::GetRootWindow() const 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; @@ -1164,7 +1176,7 @@ wxWindow *wxMenu::GetRootWindow() const // we're probably going to crash in the caller anyhow, but try to detect // this error as soon as possible wxASSERT_MSG( win, _T("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; @@ -1241,7 +1253,9 @@ void wxMenu::OnDismiss(bool dismissParent) wxCHECK_RET( m_invokingWindow, _T("what kind of menu is this?") ); m_invokingWindow->DismissPopupMenu(); - SetInvokingWindow(NULL); + + // Why reset it here? We need it for sending the event to... + // SetInvokingWindow(NULL); } } } @@ -1259,7 +1273,7 @@ void wxMenu::Popup(const wxPoint& pos, const wxSize& size, bool selectFirst) { m_popupMenu->SelectFirst(); } - + // the geometry might have changed since the last time we were shown, so // always resize m_popupMenu->SetClientSize(GetGeometryInfo().GetSize()); @@ -1311,7 +1325,7 @@ bool wxMenu::ClickItem(wxMenuItem *item) // not applicabled isChecked = -1; } - + return SendEvent(item->GetId(), isChecked); } @@ -1383,20 +1397,10 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu, int id, const wxString& text, const wxString& help, - bool isCheckable, + wxItemKind kind, wxMenu *subMenu) + : wxMenuItemBase(parentMenu, id, text, help, kind, subMenu) { - m_id = id; - m_parentMenu = parentMenu; - m_subMenu = subMenu; - - m_text = text; - m_help = help; - - m_isCheckable = isCheckable; - m_isEnabled = TRUE; - m_isChecked = FALSE; - m_posY = m_height = -1; @@ -1416,10 +1420,10 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, int id, const wxString& name, const wxString& help, - bool isCheckable, + wxItemKind kind, wxMenu *subMenu) { - return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu); + return new wxMenuItem(parentMenu, id, name, help, kind, subMenu); } /* static */ @@ -1460,7 +1464,7 @@ void wxMenuItem::SetText(const wxString& text) void wxMenuItem::SetCheckable(bool checkable) { - if ( checkable != m_isCheckable ) + if ( checkable != IsCheckable() ) { wxMenuItemBase::SetCheckable(checkable); @@ -1510,6 +1514,8 @@ void wxMenuBar::Init() m_menuShown = NULL; m_shouldShowMenu = FALSE; + + // m_windowStyle |= wxNO_FULL_REPAINT_ON_RESIZE; } void wxMenuBar::Attach(wxFrame *frame) @@ -1837,7 +1843,7 @@ int wxMenuBar::GetMenuFromPoint(const wxPoint& pos) const void wxMenuBar::SelectMenu(size_t pos) { SetFocus(); - wxLogDebug("Capturing mouse from wxMenuBar::SelectMenu"); + wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::SelectMenu")); CaptureMouse(); DoSelectMenu(pos); @@ -1926,7 +1932,7 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event) } else // on item { - wxLogDebug("Capturing mouse from wxMenuBar::OnLeftDown"); + wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::OnLeftDown")); CaptureMouse(); // show it as selected @@ -2289,7 +2295,7 @@ void wxMenuBar::OnDismiss() { if ( GetCapture() ) { - wxLogDebug("Releasing mouse from wxMenuBar::OnDismiss"); + wxLogTrace(_T("mousecapture"), _T("Releasing mouse from wxMenuBar::OnDismiss")); GetCapture()->ReleaseMouse(); } @@ -2345,6 +2351,9 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) #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 @@ -2379,7 +2388,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) void wxWindow::DismissPopupMenu() { wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") ); - + ms_evtLoopPopup->Exit(); }