From: Francesco Montorsi Date: Sun, 28 Mar 2010 22:23:38 +0000 (+0000) Subject: no real changes: just a small optimization on wxStaticText::DoSetLabel() to avoid... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7517dcb56e4153e11abc99f464d70ddeb25e3af0 no real changes: just a small optimization on wxStaticText::DoSetLabel() to avoid altering m_labelOrig there (it's already modified by SetLabel(), no need to change it twice) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/control.h b/include/wx/control.h index 31ceeef421..79d6d833fd 100644 --- a/include/wx/control.h +++ b/include/wx/control.h @@ -170,7 +170,8 @@ protected: wxEllipsizeMode mode, int maxWidth, int replacementWidth, int marginWidth); - // this field contains the label in wx format, i.e. with '&' mnemonics + // this field contains the label in wx format, i.e. with '&' mnemonics, + // as it was passed to the last SetLabel() call wxString m_labelOrig; wxDECLARE_NO_COPY_CLASS(wxControlBase); diff --git a/include/wx/stattext.h b/include/wx/stattext.h index f9e202ac1b..f3aa8fc9d3 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -99,13 +99,14 @@ protected: // functions required for wxST_ELLIPSIZE_* support // These functions are platform-specific and must be overridden in ports // which do not natively support ellipsization and they must be implemented - // in a way so that the m_label member of wxControl is not touched: + // in a way so that the m_labelOrig member of wxControl is not touched: // returns the real label currently displayed inside the control. virtual wxString DoGetLabel() const { return wxEmptyString; } // sets the real label currently displayed inside the control, - // _without_ invalidating the size. The text passed is always markup-free. + // _without_ invalidating the size. The text passed is always markup-free + // but may contain the mnemonic characters. virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } private: diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index ebbd47c37c..7e3d81d770 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -132,7 +132,7 @@ void wxStaticText::SetLabel( const wxString& str ) // adjust the label size to the new label unless disabled if ( !HasFlag(wxST_NO_AUTORESIZE) && - !IsEllipsized() ) // if ellipsize is ON, then we don't want to get resized! + !IsEllipsized() ) // if ellipsization is ON, then we don't want to get resized! SetSize( GetBestSize() ); } @@ -175,8 +175,8 @@ bool wxStaticText::SetFont( const wxFont &font ) } void wxStaticText::DoSetSize(int x, int y, - int width, int height, - int sizeFlags ) + int width, int height, + int sizeFlags ) { wxStaticTextBase::DoSetSize(x, y, width, height, sizeFlags); @@ -230,7 +230,11 @@ wxString wxStaticText::DoGetLabel() const void wxStaticText::DoSetLabel(const wxString& str) { - GTKSetLabelForLabel(GTK_LABEL(m_widget), str); + // this function looks like GTKSetLabelForLabel() but here we just want to modify + // the GTK control without altering any internal wxStaticText variable + + const wxString labelGTK = GTKConvertMnemonics(str); + gtk_label_set_text_with_mnemonic(GTK_LABEL(m_widget), wxGTK_CONV(labelGTK)); } // static