From b53e9e2006eb96aad4d5d3367a6574a07ad7a3de Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Jun 2019 23:40:18 +0200 Subject: [PATCH] Rename wxStaticText::Do[SG]etLabel() to WX[SG]etVisibleLabel() The names of these methods were confusing because they implied that they were the actual implementations of the public [SG]etLabel(), while this wasn't at all the case. Give them then ames describing what they really do and also update the comments to hopefully be more clear. No real changes. --- include/wx/generic/stattextg.h | 4 ++-- include/wx/gtk/stattext.h | 4 ++-- include/wx/motif/stattext.h | 4 ++-- include/wx/msw/stattext.h | 4 ++-- include/wx/osx/stattext.h | 4 ++-- include/wx/stattext.h | 28 +++++++++++++++++----------- include/wx/univ/stattext.h | 4 ++-- src/common/stattextcmn.cpp | 4 ++-- src/generic/stattextg.cpp | 4 ++-- src/gtk/stattext.cpp | 4 ++-- src/motif/stattext.cpp | 6 +++--- src/msw/stattext.cpp | 16 +++++++++------- src/osx/stattext_osx.cpp | 8 ++++---- src/univ/stattext.cpp | 6 +++--- 14 files changed, 54 insertions(+), 46 deletions(-) diff --git a/include/wx/generic/stattextg.h b/include/wx/generic/stattextg.h index 2a85d99c17..84210423d4 100644 --- a/include/wx/generic/stattextg.h +++ b/include/wx/generic/stattextg.h @@ -54,8 +54,8 @@ public: protected: virtual wxSize DoGetBestClientSize() const wxOVERRIDE; - virtual wxString DoGetLabel() const wxOVERRIDE { return m_label; } - virtual void DoSetLabel(const wxString& label) wxOVERRIDE; + virtual wxString WXGetVisibleLabel() const wxOVERRIDE { return m_label; } + virtual void WXSetVisibleLabel(const wxString& label) wxOVERRIDE; void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE; diff --git a/include/wx/gtk/stattext.h b/include/wx/gtk/stattext.h index b94f399a50..37f2939c47 100644 --- a/include/wx/gtk/stattext.h +++ b/include/wx/gtk/stattext.h @@ -49,8 +49,8 @@ protected: virtual wxSize DoGetBestSize() const wxOVERRIDE; - virtual wxString DoGetLabel() const wxOVERRIDE; - virtual void DoSetLabel(const wxString& str) wxOVERRIDE; + virtual wxString WXGetVisibleLabel() const wxOVERRIDE; + virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE; #if wxUSE_MARKUP virtual bool DoSetLabelMarkup(const wxString& markup) wxOVERRIDE; #endif // wxUSE_MARKUP diff --git a/include/wx/motif/stattext.h b/include/wx/motif/stattext.h index e92780cd02..2e6ce08699 100644 --- a/include/wx/motif/stattext.h +++ b/include/wx/motif/stattext.h @@ -51,8 +51,8 @@ public: virtual WXWidget GetLabelWidget() const { return m_labelWidget; } - virtual void DoSetLabel(const wxString& str); - virtual wxString DoGetLabel() const; + virtual void WXSetVisibleLabel(const wxString& str); + virtual wxString WXGetVisibleLabel() const; virtual wxSize DoGetBestSize() const; protected: diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index e52248fc84..9c9f0fb227 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -47,8 +47,8 @@ protected: int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE; - virtual wxString DoGetLabel() const wxOVERRIDE; - virtual void DoSetLabel(const wxString& str) wxOVERRIDE; + virtual wxString WXGetVisibleLabel() const wxOVERRIDE; + virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE; wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText); }; diff --git a/include/wx/osx/stattext.h b/include/wx/osx/stattext.h index 45249da560..87136c1861 100644 --- a/include/wx/osx/stattext.h +++ b/include/wx/osx/stattext.h @@ -41,8 +41,8 @@ public: protected : - virtual wxString DoGetLabel() const wxOVERRIDE; - virtual void DoSetLabel(const wxString& str) wxOVERRIDE; + virtual wxString WXGetVisibleLabel() const wxOVERRIDE; + virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE; virtual wxSize DoGetBestSize() const wxOVERRIDE; diff --git a/include/wx/stattext.h b/include/wx/stattext.h index 237f93620e..369ab6dc87 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -63,21 +63,27 @@ protected: // functions required for wxST_ELLIPSIZE_* support // style. Shouldn't be called if we don't have any. wxString Ellipsize(const wxString& label) const; - // to be called when updating the size of the static text: - // updates the label redoing ellipsization calculations + + // Note that even though ports with native support for ellipsization + // (currently only wxGTK) don't need this stuff, we still need to define it + // as it's used by wxGenericStaticText. + + // Must be called when the size or font changes to redo the ellipsization + // for the new size. Calls WXSetVisibleLabel() to actually update the + // display. void UpdateLabel(); - // 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_labelOrig member of wxControl is not touched: + // These functions are platform-specific and must be implemented in the + // platform-specific code. They must not use or update m_labelOrig. - // returns the real label currently displayed inside the control. - virtual wxString DoGetLabel() const { return wxEmptyString; } + // Returns the label currently displayed inside the control, with mnemonics + // if any. + virtual wxString WXGetVisibleLabel() const = 0; - // sets the real label currently displayed inside the control, - // _without_ invalidating the size. The text passed is always markup-free - // but may contain the mnemonic characters. - virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } + // Sets the real label currently displayed inside the control, _without_ + // invalidating the size. The text passed is always markup-free but may + // contain the mnemonic characters. + virtual void WXSetVisibleLabel(const wxString& str) = 0; // Update the current size to match the best size unless wxST_NO_AUTORESIZE // style is explicitly used. diff --git a/include/wx/univ/stattext.h b/include/wx/univ/stattext.h index 891ad7cf60..54a0284c58 100644 --- a/include/wx/univ/stattext.h +++ b/include/wx/univ/stattext.h @@ -58,8 +58,8 @@ protected: // draw the control virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE; - virtual void DoSetLabel(const wxString& str) wxOVERRIDE; - virtual wxString DoGetLabel() const wxOVERRIDE; + virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE; + virtual wxString WXGetVisibleLabel() const wxOVERRIDE; wxDECLARE_DYNAMIC_CLASS(wxStaticText); }; diff --git a/src/common/stattextcmn.cpp b/src/common/stattextcmn.cpp index d3e01244d3..553c607647 100644 --- a/src/common/stattextcmn.cpp +++ b/src/common/stattextcmn.cpp @@ -240,9 +240,9 @@ void wxStaticTextBase::UpdateLabel() // In fact, we must be careful not to touch the original label passed to // SetLabel() otherwise GetLabel() will behave in a strange way to the user // (e.g. returning a "Ver...ing" instead of "Very long string") ! - if (newlabel == DoGetLabel()) + if (newlabel == WXGetVisibleLabel()) return; - DoSetLabel(newlabel); + WXSetVisibleLabel(newlabel); } wxString wxStaticTextBase::GetEllipsizedLabel() const diff --git a/src/generic/stattextg.cpp b/src/generic/stattextg.cpp index fe2f13759c..ce32239065 100644 --- a/src/generic/stattextg.cpp +++ b/src/generic/stattextg.cpp @@ -100,7 +100,7 @@ wxSize wxGenericStaticText::DoGetBestClientSize() const void wxGenericStaticText::SetLabel(const wxString& label) { wxControl::SetLabel(label); - DoSetLabel(GetEllipsizedLabel()); + WXSetVisibleLabel(GetEllipsizedLabel()); AutoResizeIfNecessary(); @@ -115,7 +115,7 @@ void wxGenericStaticText::SetLabel(const wxString& label) Refresh(); } -void wxGenericStaticText::DoSetLabel(const wxString& label) +void wxGenericStaticText::WXSetVisibleLabel(const wxString& label) { m_mnemonic = FindAccelIndex(label, &m_label); } diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 36d87b502c..067cf1294e 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -272,13 +272,13 @@ void wxStaticText::GTKWidgetDoSetMnemonic(GtkWidget* w) // These functions should be used only when GTK+ < 2.6 by wxStaticTextBase::UpdateLabel() -wxString wxStaticText::DoGetLabel() const +wxString wxStaticText::WXGetVisibleLabel() const { GtkLabel *label = GTK_LABEL(m_widget); return wxGTK_CONV_BACK( gtk_label_get_text( label ) ); } -void wxStaticText::DoSetLabel(const wxString& str) +void wxStaticText::WXSetVisibleLabel(const wxString& str) { GTKSetLabelForLabel(GTK_LABEL(m_widget), str); } diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 44822abbfe..2fdea861ff 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -77,12 +77,12 @@ void wxStaticText::SetLabel(const wxString& label) m_labelOrig = label; // save original label // Motif does not support ellipsized labels natively - DoSetLabel(GetEllipsizedLabel()); + WXSetVisibleLabel(GetEllipsizedLabel()); } // for wxST_ELLIPSIZE_* support: -wxString wxStaticText::DoGetLabel() const +wxString wxStaticText::WXGetVisibleLabel() const { XmString label = NULL; XtVaGetValues((Widget)m_labelWidget, XmNlabelString, &label, NULL); @@ -90,7 +90,7 @@ wxString wxStaticText::DoGetLabel() const return wxXmStringToString(label); } -void wxStaticText::DoSetLabel(const wxString& str) +void wxStaticText::WXSetVisibleLabel(const wxString& str) { // build our own cleaned label wxXmString label_str(RemoveMnemonics(str)); diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index f5a29f380e..fd171211a8 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -179,10 +179,10 @@ void wxStaticText::SetLabel(const wxString& label) #ifdef SS_ENDELLIPSIS if ( updateStyle.IsOn(SS_ENDELLIPSIS) ) - DoSetLabel(GetLabel()); + WXSetVisibleLabel(GetLabel()); else #endif // SS_ENDELLIPSIS - DoSetLabel(GetEllipsizedLabel()); + WXSetVisibleLabel(GetEllipsizedLabel()); AutoResizeIfNecessary(); } @@ -197,16 +197,18 @@ bool wxStaticText::SetFont(const wxFont& font) return true; } -// for wxST_ELLIPSIZE_* support: +// These functions are used by wxST_ELLIPSIZE_* supporting code in +// wxStaticTextBase which requires us to implement them, but actually the base +// wxWindow methods already do exactly what we need under this platform. -wxString wxStaticText::DoGetLabel() const +wxString wxStaticText::WXGetVisibleLabel() const { - return wxGetWindowText(GetHwnd()); + return wxWindow::GetLabel(); } -void wxStaticText::DoSetLabel(const wxString& str) +void wxStaticText::WXSetVisibleLabel(const wxString& str) { - SetWindowText(GetHwnd(), str.c_str()); + wxWindow::SetLabel(str); } diff --git a/src/osx/stattext_osx.cpp b/src/osx/stattext_osx.cpp index 53e0e0ced9..cea4cf5c19 100644 --- a/src/osx/stattext_osx.cpp +++ b/src/osx/stattext_osx.cpp @@ -71,11 +71,11 @@ void wxStaticText::SetLabel(const wxString& label) ) { // leave ellipsization to the OS - DoSetLabel(GetLabel()); + WXSetVisibleLabel(GetLabel()); } else // not supported natively { - DoSetLabel(GetEllipsizedLabel()); + WXSetVisibleLabel(GetEllipsizedLabel()); } AutoResizeIfNecessary(); @@ -98,7 +98,7 @@ bool wxStaticText::SetFont(const wxFont& font) return ret; } -void wxStaticText::DoSetLabel(const wxString& label) +void wxStaticText::WXSetVisibleLabel(const wxString& label) { m_label = RemoveMnemonics(label); GetPeer()->SetLabel(m_label , GetFont().GetEncoding() ); @@ -118,7 +118,7 @@ bool wxStaticText::DoSetLabelMarkup(const wxString& markup) #endif // wxUSE_MARKUP && wxOSX_USE_COCOA -wxString wxStaticText::DoGetLabel() const +wxString wxStaticText::WXGetVisibleLabel() const { return m_label; } diff --git a/src/univ/stattext.cpp b/src/univ/stattext.cpp index a79338873c..7d25958ad9 100644 --- a/src/univ/stattext.cpp +++ b/src/univ/stattext.cpp @@ -77,15 +77,15 @@ void wxStaticText::SetLabel(const wxString& str) m_labelOrig = str; // draw as real label the abbreviated version of it - DoSetLabel(GetEllipsizedLabel()); + WXSetVisibleLabel(GetEllipsizedLabel()); } -void wxStaticText::DoSetLabel(const wxString& str) +void wxStaticText::WXSetVisibleLabel(const wxString& str) { UnivDoSetLabel(str); } -wxString wxStaticText::DoGetLabel() const +wxString wxStaticText::WXGetVisibleLabel() const { return wxControl::GetLabel(); }