X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..06e56e62b9ab3a4ee66d7013c978128e5021f4e2:/src/osx/menuitem_osx.cpp diff --git a/src/osx/menuitem_osx.cpp b/src/osx/menuitem_osx.cpp index a680ad71fc..93ef505286 100644 --- a/src/osx/menuitem_osx.cpp +++ b/src/osx/menuitem_osx.cpp @@ -4,13 +4,15 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: menuitem.cpp 54129 2008-06-11 19:30:52Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" +#if wxUSE_MENUS + #include "wx/menuitem.h" #include "wx/stockitem.h" @@ -27,8 +29,6 @@ wxMenuItemImpl::~wxMenuItemImpl() { } -IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) - wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id, const wxString& t, @@ -41,21 +41,23 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, // In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines // therefore these item must not be translated - if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") ) - m_text = wxT("Quit\tCtrl+Q") ; + if (pParentMenu != NULL && !pParentMenu->GetNoEventsMode()) + if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") ) + m_text = wxT("Quit\tCtrl+Q") ; m_radioGroup.start = -1; m_isRadioGroupStart = false; - - wxString text = wxStripMenuCodes(m_text); + + wxString text = wxStripMenuCodes(m_text, (pParentMenu != NULL && pParentMenu->GetNoEventsMode()) ? wxStrip_Accel : wxStrip_All); if (text.IsEmpty() && !IsSeparator()) { wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); } - + wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; - m_peer = wxMenuItemImpl::Create( this, pParentMenu, id, text, entry, strHelp, kind, pSubMenu ); + // use accessors for ID and Kind because they might have been changed in the base constructor + m_peer = wxMenuItemImpl::Create( this, pParentMenu, GetId(), text, entry, strHelp, GetKind(), pSubMenu ); delete entry; } @@ -80,7 +82,7 @@ void wxMenuItem::Enable(bool bDoEnable) // eg. BeginAppModalStateForWindow() will disable menus and ignore this change // which in turn causes m_isEnabled to become out of sync with real menuitem state #if wxOSX_USE_CARBON - && !(m_parentMenu && !IsMenuItemEnabled(MAC_WXHMENU(m_parentMenu->GetHMenu()), 0)) + && !(m_parentMenu && !IsMenuItemEnabled(MAC_WXHMENU(m_parentMenu->GetHMenu()), 0)) #endif ) // always update builtin menuitems @@ -120,7 +122,7 @@ void wxMenuItem::Check(bool bDoCheck) const wxMenuItemList& items = m_parentMenu->GetMenuItems(); int pos = items.IndexOf(this); wxCHECK_RET( pos != wxNOT_FOUND, - _T("menuitem not found in the menu items list?") ); + wxT("menuitem not found in the menu items list?") ); // get the radio group range int start, end; @@ -173,10 +175,10 @@ void wxMenuItem::UpdateItemBitmap() { if ( !m_parentMenu ) return; - - if ( m_bitmap.Ok() ) + + if ( m_bitmap.IsOk() ) { - m_peer->SetBitmap( m_bitmap ); + GetPeer()->SetBitmap( m_bitmap ); } } @@ -187,13 +189,13 @@ void wxMenuItem::UpdateItemStatus() if ( IsSeparator() ) return ; - + if ( IsCheckable() && IsChecked() ) - m_peer->Check( true ); + GetPeer()->Check( true ); else - m_peer->Check( false ); - - m_peer->Enable( IsEnabled() ); + GetPeer()->Check( false ); + + GetPeer()->Enable( IsEnabled() ); } void wxMenuItem::UpdateItemText() @@ -201,15 +203,15 @@ void wxMenuItem::UpdateItemText() if ( !m_parentMenu ) return ; - wxString text = wxStripMenuCodes(m_text); + wxString text = wxStripMenuCodes(m_text, m_parentMenu != NULL && m_parentMenu->GetNoEventsMode() ? wxStrip_Accel : wxStrip_All); if (text.IsEmpty() && !IsSeparator()) { wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); } - + wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; - m_peer->SetLabel( text, entry ); + GetPeer()->SetLabel( text, entry ); delete entry ; } @@ -250,3 +252,5 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, { return new wxMenuItem(parentMenu, id, name, help, kind, subMenu); } + +#endif