X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9add93670bb4a38e4007b8422b34b29b6194eecb..b765da9f5090ef076302eb0d12cfc11b61296430:/src/common/menucmn.cpp diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 4cca372c62..8ab7f2b95f 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 26.10.99 // RCS-ID: $Id$ -// Copyright: (c) wxWindows team +// Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -72,6 +72,10 @@ wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu, m_isChecked = FALSE; m_id = id; m_kind = kind; + if (m_id == wxID_ANY) + m_id = wxNewId(); + if (m_id == wxID_SEPARATOR) + m_kind = wxITEM_SEPARATOR; } wxMenuItemBase::~wxMenuItemBase() @@ -94,6 +98,8 @@ static inline bool CompareAccelString(const wxString& str, const wxChar *accel) // specified wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) { + // wxPrintf( wxT("label %s\n"), label.c_str() ); + // check for accelerators: they are given after '\t' int posTab = label.Find(wxT('\t')); if ( posTab != wxNOT_FOUND ) { @@ -272,6 +278,8 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) #endif // wxUSE_ACCEL +bool wxMenuBase::ms_locked = true; + // ---------------------------------------------------------------------------- // wxMenu ctor and dtor // ---------------------------------------------------------------------------- @@ -302,11 +310,6 @@ void wxMenuBase::AddSubMenu(wxMenu *submenu) { wxCHECK_RET( submenu, _T("can't add a NULL submenu") ); - if ( m_menuBar ) - { - submenu->Attach(m_menuBar); - } - submenu->SetParent((wxMenu *)this); } @@ -533,6 +536,15 @@ wxMenuItem* wxMenuBase::FindItemByPosition(size_t position) const // window will be used. void wxMenuBase::UpdateUI(wxEvtHandler* source) { + if (GetInvokingWindow()) + { + // Don't update menus if the parent + // frame is about to get deleted + wxWindow *tlw = wxGetTopLevelParent( GetInvokingWindow() ); + if (tlw && wxPendingDelete.Member(tlw)) + return; + } + if ( !source && GetInvokingWindow() ) source = GetInvokingWindow()->GetEventHandler(); if ( !source ) @@ -612,6 +624,13 @@ bool wxMenuBase::SendEvent(int id, int checked) // wxMenu attaching/detaching to/from menu bar // ---------------------------------------------------------------------------- +wxMenuBar* wxMenuBase::GetMenuBar() const +{ + if(GetParent()) + return GetParent()->GetMenuBar(); + return m_menuBar; +} + void wxMenuBase::Attach(wxMenuBarBase *menubar) { // use Detach() instead!