Always invalidate wxStaticText best size after changing its label.

wxST_NO_AUTORESIZE style only affects whether the control is actually resized
when its text changes, but its best size should always change, so that if the
window containing it is explicitly relaid out the size does change.

Moreover, in wxMSW and wxOSX the best size was never invalidated at all when
the label was ellipsized, so it was never updated for them, preventing, for
example, comparing the best size with the current one to check if the text is
effectively ellipsized (and so needs to be shown in a tooltip, for example).

Fix this by calling InvalidateBestSize() unconditionally, this should make
these ports behave in the same was as wxGTK already did.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2015-01-09 03:29:58 +00:00
parent ee5ab1fffa
commit 5c9d7e139d
4 changed files with 7 additions and 4 deletions

View File

@@ -50,7 +50,6 @@ bool wxStaticText::Create( wxWindow *parent,
// Normally this is done in SetLabel() below but we avoid doing it when
// this style is used, so we need to explicitly do it in the ctor in
// this case or otherwise the control would retain its initial tiny size.
InvalidateBestSize();
SetInitialSize(size);
}
@@ -76,10 +75,11 @@ void wxStaticText::SetLabel(const wxString& label)
DoSetLabel(GetEllipsizedLabel());
}
InvalidateBestSize();
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
!IsEllipsized() ) // don't resize if we adjust to current size
{
InvalidateBestSize();
SetSize( GetBestSize() );
}