X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14f355c2b5c71fc7c3d680aea366582d2ac60f7b..c5fc899bf29ca7d9c4e2a070e28228b430a68dd3:/src/common/menucmn.cpp diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 1938ce4ca8..b272d1483d 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -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 ) { @@ -131,7 +137,7 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) current.clear(); } else { - current += wxTolower(label[n]); + current += (wxChar) wxTolower(label[n]); } } @@ -166,6 +172,8 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) keyCode = WXK_DELETE; else if ( current == wxT("DELETE") ) keyCode = WXK_DELETE; + else if ( current == wxT("BACK") ) + keyCode = WXK_BACK; else if ( current == wxT("INS") ) keyCode = WXK_INSERT; else if ( current == wxT("INSERT") ) @@ -270,6 +278,8 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) #endif // wxUSE_ACCEL +bool wxMenuBase::ms_locked = true; + // ---------------------------------------------------------------------------- // wxMenu ctor and dtor // ---------------------------------------------------------------------------- @@ -288,7 +298,7 @@ void wxMenuBase::Init(long style) wxMenuBase::~wxMenuBase() { WX_CLEAR_LIST(wxMenuItemList, m_items); - + // Actually, in GTK, the submenus have to get deleted first. } @@ -300,17 +310,12 @@ 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); } -bool wxMenuBase::DoAppend(wxMenuItem *item) +wxMenuItem* wxMenuBase::DoAppend(wxMenuItem *item) { - wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") ); + wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Append()") ); m_items.Append(item); item->SetMenu((wxMenu*)this); @@ -319,12 +324,12 @@ bool wxMenuBase::DoAppend(wxMenuItem *item) AddSubMenu(item->GetSubMenu()); } - return TRUE; + return item; } -bool wxMenuBase::Insert(size_t pos, wxMenuItem *item) +wxMenuItem* wxMenuBase::Insert(size_t pos, wxMenuItem *item) { - wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert") ); + wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert") ); if ( pos == GetMenuItemCount() ) { @@ -339,9 +344,9 @@ bool wxMenuBase::Insert(size_t pos, wxMenuItem *item) } } -bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) +wxMenuItem* wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) { - wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert()") ); + wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert()") ); wxMenuItemList::compatibility_iterator node = m_items.Item(pos); wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") ); @@ -353,7 +358,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) AddSubMenu(item->GetSubMenu()); } - return TRUE; + return item; } wxMenuItem *wxMenuBase::Remove(wxMenuItem *item) @@ -531,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 ) @@ -610,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!