diff --git a/interface/wx/stattext.h b/interface/wx/stattext.h index 19525e0ae7..230a208d7d 100644 --- a/interface/wx/stattext.h +++ b/interface/wx/stattext.h @@ -99,6 +99,18 @@ public: */ bool IsEllipsized() const; + /** + Change the label shown in the control. + + Notice that since wxWidgets 3.1.1 this function is guaranteed not to do + anything if the label didn't really change, so there is no benefit to + checking if the new label is different from the current one in the + application code. + + @see wxControl::SetLabel() + */ + virtual void SetLabel(const wxString& label); + /** This functions wraps the controls label so that each of its lines becomes at most @a width pixels wide if possible (the lines are broken at words diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index c560dcb4b1..b84ddd9073 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -144,6 +144,9 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label) void wxStaticText::SetLabel(const wxString& label) { + if ( label == m_labelOrig ) + return; + m_labelOrig = label; GTKDoSetLabel(&wxStaticText::GTKSetLabelForLabel, label); diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 9920a4c82d..44822abbfe 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -71,6 +71,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, void wxStaticText::SetLabel(const wxString& label) { + if ( label == m_labelOrig ) + return; + m_labelOrig = label; // save original label // Motif does not support ellipsized labels natively diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 3d0d074023..62dd20512b 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -150,6 +150,10 @@ void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags) void wxStaticText::SetLabel(const wxString& label) { + // If the label doesn't really change, avoid flicker by not doing anything. + if ( label == m_labelOrig ) + return; + #ifdef SS_ENDELLIPSIS long styleReal = ::GetWindowLong(GetHwnd(), GWL_STYLE); if ( HasFlag(wxST_ELLIPSIZE_END) ) diff --git a/src/osx/stattext_osx.cpp b/src/osx/stattext_osx.cpp index 5a291af9f9..4176add134 100644 --- a/src/osx/stattext_osx.cpp +++ b/src/osx/stattext_osx.cpp @@ -58,6 +58,9 @@ bool wxStaticText::Create( wxWindow *parent, void wxStaticText::SetLabel(const wxString& label) { + if ( label == m_labelOrig ) + return; + m_labelOrig = label; // middle/end ellipsization is handled by the OS: diff --git a/src/univ/stattext.cpp b/src/univ/stattext.cpp index a34cf8ad17..08dfe84b4f 100644 --- a/src/univ/stattext.cpp +++ b/src/univ/stattext.cpp @@ -70,6 +70,9 @@ void wxStaticText::DoDraw(wxControlRenderer *renderer) void wxStaticText::SetLabel(const wxString& str) { + if ( label == m_labelOrig ) + return; + // save original label m_labelOrig = str;