From 3294b9a63a30f385b7c061acda069dc4e5820599 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Jan 2018 16:47:11 +0100 Subject: [PATCH] Don't invalidate best size for controls with wxST_NO_AUTORESIZE This results in non-intuitive behaviour, as the controls with this style still get resized after changing their label, so don't do it. See https://groups.google.com/d/msg/wx-dev/58xFP4FIxXc/hm5WO0xNBwAJ --- src/common/stattextcmn.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/common/stattextcmn.cpp b/src/common/stattextcmn.cpp index a83d937246..811aceb190 100644 --- a/src/common/stattextcmn.cpp +++ b/src/common/stattextcmn.cpp @@ -205,16 +205,21 @@ void wxStaticTextBase::Wrap(int width) void wxStaticTextBase::AutoResizeIfNecessary() { - // This method is only called if either the label or the font changed, i.e. - // if the label extent changed, so the best size is not the same neither - // any more. - InvalidateBestSize(); - // This flag is specifically used to prevent the control from resizing even // when its label changes. if ( HasFlag(wxST_NO_AUTORESIZE) ) return; + // This method is only called if either the label or the font changed, i.e. + // if the label extent changed, so the best size is not the same neither + // any more. + // + // Note that we don't invalidate it when wxST_NO_AUTORESIZE is on because + // this would result in the control being effectively resized during the + // next Layout() and this style is used expressly to prevent this from + // happening. + InvalidateBestSize(); + SetSize(GetBestSize()); }