Fold best size and ellipsis handling in AutoResizeIfNecessary()
Refactor wxStaticText code to use AutoResizeIfNecessary() for all the updates done after the label extent changes (whether it's due to the change of the label itself or the font used for rendering it). There should be no changes in behaviour after this commit except for a small bug fix in wxGenericStaticText when setting label with markup: this didn't invalidate the best size before, but does now.
This commit is contained in:
@@ -138,14 +138,9 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid static text") );
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
(this->*setter)(GTK_LABEL(m_widget), label);
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if ( !HasFlag(wxST_NO_AUTORESIZE) &&
|
||||
!IsEllipsized() ) // if ellipsization is ON, then we don't want to get resized!
|
||||
SetSize( GetBestSize() );
|
||||
AutoResizeIfNecessary();
|
||||
}
|
||||
|
||||
void wxStaticText::SetLabel(const wxString& label)
|
||||
@@ -222,11 +217,8 @@ bool wxStaticText::SetFont( const wxFont &font )
|
||||
gtk_label_set_use_underline(GTK_LABEL(m_widget), !isUnderlined);
|
||||
}
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
}
|
||||
AutoResizeIfNecessary();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user