X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0bca03736369e836cce9297509505c5972e775dd..5942996c94a82dcbedf7b1041b08acd8d1d97449:/src/gtk1/menu.cpp diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index f19e78a481..fa3f149dd0 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -11,6 +11,7 @@ #include "wx/wxprec.h" #include "wx/menu.h" +#include "wx/stockitem.h" #ifndef WX_PRECOMP #include "wx/intl.h" @@ -765,8 +766,16 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) return label; } -void wxMenuItem::SetText( const wxString& str ) +void wxMenuItem::SetText( const wxString& string ) { + wxString str = string; + if ( str.empty() && !IsSeparator() ) + { + wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); + str = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR | + wxSTOCK_WITH_MNEMONIC); + } + // Some optimization to avoid flicker wxString oldLabel = m_text; oldLabel = wxStripMenuCodes(oldLabel); @@ -857,8 +866,6 @@ void wxMenuItem::DoSetText( const wxString& str ) pc++; m_hotKey = pc; } - - // wxPrintf( wxT("DoSetText(): str %s m_text %s hotkey %s\n"), str.c_str(), m_text.c_str(), m_hotKey.c_str() ); } #if wxUSE_ACCEL @@ -871,11 +878,12 @@ wxAcceleratorEntry *wxMenuItem::GetAccel() const return (wxAcceleratorEntry *)NULL; } - // as wxGetAccelFromString() looks for TAB, insert a dummy one here + // accelerator parsing code looks for them after a TAB, so insert a dummy + // one here wxString label; label << wxT('\t') << GetHotKey(); - return wxGetAccelFromString(label); + return wxAcceleratorEntry::Create(label); } #endif // wxUSE_ACCEL @@ -1415,7 +1423,7 @@ static wxString GetGtkHotKey( const wxMenuItem& item ) hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1); break; */ - // if there are any other keys wxGetAccelFromString() may + // if there are any other keys wxAcceleratorEntry::Create() may // return, we should process them here default: