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.
This commit is contained in:
Vadim Zeitlin
2019-06-12 23:40:18 +02:00
parent e3a62efd43
commit b53e9e2006
14 changed files with 54 additions and 46 deletions

View File

@@ -54,8 +54,8 @@ public:
protected: protected:
virtual wxSize DoGetBestClientSize() const wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
virtual wxString DoGetLabel() const wxOVERRIDE { return m_label; } virtual wxString WXGetVisibleLabel() const wxOVERRIDE { return m_label; }
virtual void DoSetLabel(const wxString& label) wxOVERRIDE; virtual void WXSetVisibleLabel(const wxString& label) wxOVERRIDE;
void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE; void DoSetSize(int x, int y, int width, int height, int sizeFlags) wxOVERRIDE;

View File

@@ -49,8 +49,8 @@ protected:
virtual wxSize DoGetBestSize() const wxOVERRIDE; virtual wxSize DoGetBestSize() const wxOVERRIDE;
virtual wxString DoGetLabel() const wxOVERRIDE; virtual wxString WXGetVisibleLabel() const wxOVERRIDE;
virtual void DoSetLabel(const wxString& str) wxOVERRIDE; virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE;
#if wxUSE_MARKUP #if wxUSE_MARKUP
virtual bool DoSetLabelMarkup(const wxString& markup) wxOVERRIDE; virtual bool DoSetLabelMarkup(const wxString& markup) wxOVERRIDE;
#endif // wxUSE_MARKUP #endif // wxUSE_MARKUP

View File

@@ -51,8 +51,8 @@ public:
virtual WXWidget GetLabelWidget() const virtual WXWidget GetLabelWidget() const
{ return m_labelWidget; } { return m_labelWidget; }
virtual void DoSetLabel(const wxString& str); virtual void WXSetVisibleLabel(const wxString& str);
virtual wxString DoGetLabel() const; virtual wxString WXGetVisibleLabel() const;
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
protected: protected:

View File

@@ -47,8 +47,8 @@ protected:
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
virtual wxSize DoGetBestClientSize() const wxOVERRIDE; virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
virtual wxString DoGetLabel() const wxOVERRIDE; virtual wxString WXGetVisibleLabel() const wxOVERRIDE;
virtual void DoSetLabel(const wxString& str) wxOVERRIDE; virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText); wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText);
}; };

View File

@@ -41,8 +41,8 @@ public:
protected : protected :
virtual wxString DoGetLabel() const wxOVERRIDE; virtual wxString WXGetVisibleLabel() const wxOVERRIDE;
virtual void DoSetLabel(const wxString& str) wxOVERRIDE; virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE;
virtual wxSize DoGetBestSize() const wxOVERRIDE; virtual wxSize DoGetBestSize() const wxOVERRIDE;

View File

@@ -63,21 +63,27 @@ protected: // functions required for wxST_ELLIPSIZE_* support
// style. Shouldn't be called if we don't have any. // style. Shouldn't be called if we don't have any.
wxString Ellipsize(const wxString& label) const; 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(); void UpdateLabel();
// These functions are platform-specific and must be overridden in ports // These functions are platform-specific and must be implemented in the
// which do not natively support ellipsization and they must be implemented // platform-specific code. They must not use or update m_labelOrig.
// in a way so that the m_labelOrig member of wxControl is not touched:
// returns the real label currently displayed inside the control. // Returns the label currently displayed inside the control, with mnemonics
virtual wxString DoGetLabel() const { return wxEmptyString; } // if any.
virtual wxString WXGetVisibleLabel() const = 0;
// sets the real label currently displayed inside the control, // Sets the real label currently displayed inside the control, _without_
// _without_ invalidating the size. The text passed is always markup-free // invalidating the size. The text passed is always markup-free but may
// but may contain the mnemonic characters. // contain the mnemonic characters.
virtual void DoSetLabel(const wxString& WXUNUSED(str)) { } virtual void WXSetVisibleLabel(const wxString& str) = 0;
// Update the current size to match the best size unless wxST_NO_AUTORESIZE // Update the current size to match the best size unless wxST_NO_AUTORESIZE
// style is explicitly used. // style is explicitly used.

View File

@@ -58,8 +58,8 @@ protected:
// draw the control // draw the control
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE; virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
virtual void DoSetLabel(const wxString& str) wxOVERRIDE; virtual void WXSetVisibleLabel(const wxString& str) wxOVERRIDE;
virtual wxString DoGetLabel() const wxOVERRIDE; virtual wxString WXGetVisibleLabel() const wxOVERRIDE;
wxDECLARE_DYNAMIC_CLASS(wxStaticText); wxDECLARE_DYNAMIC_CLASS(wxStaticText);
}; };

View File

@@ -240,9 +240,9 @@ void wxStaticTextBase::UpdateLabel()
// In fact, we must be careful not to touch the original label passed to // 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 // SetLabel() otherwise GetLabel() will behave in a strange way to the user
// (e.g. returning a "Ver...ing" instead of "Very long string") ! // (e.g. returning a "Ver...ing" instead of "Very long string") !
if (newlabel == DoGetLabel()) if (newlabel == WXGetVisibleLabel())
return; return;
DoSetLabel(newlabel); WXSetVisibleLabel(newlabel);
} }
wxString wxStaticTextBase::GetEllipsizedLabel() const wxString wxStaticTextBase::GetEllipsizedLabel() const

View File

@@ -100,7 +100,7 @@ wxSize wxGenericStaticText::DoGetBestClientSize() const
void wxGenericStaticText::SetLabel(const wxString& label) void wxGenericStaticText::SetLabel(const wxString& label)
{ {
wxControl::SetLabel(label); wxControl::SetLabel(label);
DoSetLabel(GetEllipsizedLabel()); WXSetVisibleLabel(GetEllipsizedLabel());
AutoResizeIfNecessary(); AutoResizeIfNecessary();
@@ -115,7 +115,7 @@ void wxGenericStaticText::SetLabel(const wxString& label)
Refresh(); Refresh();
} }
void wxGenericStaticText::DoSetLabel(const wxString& label) void wxGenericStaticText::WXSetVisibleLabel(const wxString& label)
{ {
m_mnemonic = FindAccelIndex(label, &m_label); m_mnemonic = FindAccelIndex(label, &m_label);
} }

View File

@@ -272,13 +272,13 @@ void wxStaticText::GTKWidgetDoSetMnemonic(GtkWidget* w)
// These functions should be used only when GTK+ < 2.6 by wxStaticTextBase::UpdateLabel() // 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); GtkLabel *label = GTK_LABEL(m_widget);
return wxGTK_CONV_BACK( gtk_label_get_text( label ) ); 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); GTKSetLabelForLabel(GTK_LABEL(m_widget), str);
} }

View File

@@ -77,12 +77,12 @@ void wxStaticText::SetLabel(const wxString& label)
m_labelOrig = label; // save original label m_labelOrig = label; // save original label
// Motif does not support ellipsized labels natively // Motif does not support ellipsized labels natively
DoSetLabel(GetEllipsizedLabel()); WXSetVisibleLabel(GetEllipsizedLabel());
} }
// for wxST_ELLIPSIZE_* support: // for wxST_ELLIPSIZE_* support:
wxString wxStaticText::DoGetLabel() const wxString wxStaticText::WXGetVisibleLabel() const
{ {
XmString label = NULL; XmString label = NULL;
XtVaGetValues((Widget)m_labelWidget, XmNlabelString, &label, NULL); XtVaGetValues((Widget)m_labelWidget, XmNlabelString, &label, NULL);
@@ -90,7 +90,7 @@ wxString wxStaticText::DoGetLabel() const
return wxXmStringToString(label); return wxXmStringToString(label);
} }
void wxStaticText::DoSetLabel(const wxString& str) void wxStaticText::WXSetVisibleLabel(const wxString& str)
{ {
// build our own cleaned label // build our own cleaned label
wxXmString label_str(RemoveMnemonics(str)); wxXmString label_str(RemoveMnemonics(str));

View File

@@ -179,10 +179,10 @@ void wxStaticText::SetLabel(const wxString& label)
#ifdef SS_ENDELLIPSIS #ifdef SS_ENDELLIPSIS
if ( updateStyle.IsOn(SS_ENDELLIPSIS) ) if ( updateStyle.IsOn(SS_ENDELLIPSIS) )
DoSetLabel(GetLabel()); WXSetVisibleLabel(GetLabel());
else else
#endif // SS_ENDELLIPSIS #endif // SS_ENDELLIPSIS
DoSetLabel(GetEllipsizedLabel()); WXSetVisibleLabel(GetEllipsizedLabel());
AutoResizeIfNecessary(); AutoResizeIfNecessary();
} }
@@ -197,16 +197,18 @@ bool wxStaticText::SetFont(const wxFont& font)
return true; 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);
} }

View File

@@ -71,11 +71,11 @@ void wxStaticText::SetLabel(const wxString& label)
) )
{ {
// leave ellipsization to the OS // leave ellipsization to the OS
DoSetLabel(GetLabel()); WXSetVisibleLabel(GetLabel());
} }
else // not supported natively else // not supported natively
{ {
DoSetLabel(GetEllipsizedLabel()); WXSetVisibleLabel(GetEllipsizedLabel());
} }
AutoResizeIfNecessary(); AutoResizeIfNecessary();
@@ -98,7 +98,7 @@ bool wxStaticText::SetFont(const wxFont& font)
return ret; return ret;
} }
void wxStaticText::DoSetLabel(const wxString& label) void wxStaticText::WXSetVisibleLabel(const wxString& label)
{ {
m_label = RemoveMnemonics(label); m_label = RemoveMnemonics(label);
GetPeer()->SetLabel(m_label , GetFont().GetEncoding() ); GetPeer()->SetLabel(m_label , GetFont().GetEncoding() );
@@ -118,7 +118,7 @@ bool wxStaticText::DoSetLabelMarkup(const wxString& markup)
#endif // wxUSE_MARKUP && wxOSX_USE_COCOA #endif // wxUSE_MARKUP && wxOSX_USE_COCOA
wxString wxStaticText::DoGetLabel() const wxString wxStaticText::WXGetVisibleLabel() const
{ {
return m_label; return m_label;
} }

View File

@@ -77,15 +77,15 @@ void wxStaticText::SetLabel(const wxString& str)
m_labelOrig = str; m_labelOrig = str;
// draw as real label the abbreviated version of it // 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); UnivDoSetLabel(str);
} }
wxString wxStaticText::DoGetLabel() const wxString wxStaticText::WXGetVisibleLabel() const
{ {
return wxControl::GetLabel(); return wxControl::GetLabel();
} }