From c0e6c0513862fc9a33e5800526058193b7492d8b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 21 Jun 2004 22:58:13 +0000 Subject: [PATCH] reverted m_adjustMinSize change prepatory for a new approach to fix the problem git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27930 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/control.tex | 16 ---------------- include/wx/control.h | 15 +-------------- include/wx/gtk/control.h | 2 -- include/wx/gtk/stattext.h | 3 +-- include/wx/gtk1/control.h | 2 -- include/wx/gtk1/stattext.h | 3 +-- include/wx/mac/carbon/stattext.h | 1 + include/wx/mac/classic/stattext.h | 1 + include/wx/msw/stattext.h | 4 ++++ include/wx/stattext.h | 2 -- src/common/bookctrl.cpp | 4 ---- src/common/ctrlcmn.cpp | 25 ------------------------- src/gtk/bmpbuttn.cpp | 1 - src/gtk/button.cpp | 2 -- src/gtk/checkbox.cpp | 2 -- src/gtk/control.cpp | 11 ----------- src/gtk/radiobox.cpp | 2 -- src/gtk/radiobut.cpp | 2 -- src/gtk/statbox.cpp | 1 - src/gtk/stattext.cpp | 21 +++++++++++++++++++-- src/gtk/tglbtn.cpp | 2 -- src/gtk1/bmpbuttn.cpp | 1 - src/gtk1/button.cpp | 2 -- src/gtk1/checkbox.cpp | 2 -- src/gtk1/control.cpp | 11 ----------- src/gtk1/radiobox.cpp | 2 -- src/gtk1/radiobut.cpp | 2 -- src/gtk1/statbox.cpp | 1 - src/gtk1/stattext.cpp | 21 +++++++++++++++++++-- src/gtk1/tglbtn.cpp | 2 -- src/mac/carbon/stattext.cpp | 22 ++++++++++++++++++++-- src/mac/classic/stattext.cpp | 28 ++++++++++++++++++++++++---- src/msw/stattext.cpp | 28 ++++++++++++++++++++++++++++ 33 files changed, 119 insertions(+), 125 deletions(-) diff --git a/docs/latex/wx/control.tex b/docs/latex/wx/control.tex index 52ecc060f2..75c4e5f975 100644 --- a/docs/latex/wx/control.tex +++ b/docs/latex/wx/control.tex @@ -29,14 +29,6 @@ displays one or more item of data. Simulates the effect of the user issuing a command to the item. See \helpref{wxCommandEvent}{wxcommandevent}. -\membersection{wxControl::GetAdjustMinSizeFlag}\label{wxcontrolgetadjustminsizeflag} - -\func{bool}{GetAdjustMinSizeFlag}{} - -Returns whether the minsize should be adjusted for this control when -SetLabel or SetFont are called. - - \membersection{wxControl::GetLabel}\label{wxcontrolgetlabel} \func{wxString\&}{GetLabel}{\void} @@ -44,14 +36,6 @@ SetLabel or SetFont are called. Returns the control's text. -\membersection{wxControl::SetAdjustMinSizeFlag}\label{wxcontrolsetadjustminsizeflag} - -\func{void}{SetAdjustMinSizeFlag}{\param{bool }{adjust}} - -By default controls will readjust their size and minsize when -SetLabel or SetFont are called. This flag will allow you to -control this behavior. - \membersection{wxControl::SetLabel}\label{wxcontrolsetlabel} \func{void}{SetLabel}{\param{const wxString\& }{label}} diff --git a/include/wx/control.h b/include/wx/control.h index 5fd882ce0c..6552443ecd 100644 --- a/include/wx/control.h +++ b/include/wx/control.h @@ -32,11 +32,10 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr; // wxControl is the base class for all controls // ---------------------------------------------------------------------------- - class WXDLLEXPORT wxControlBase : public wxWindow { public: - wxControlBase() { Init(); } + wxControlBase() { } virtual ~wxControlBase(); @@ -64,16 +63,7 @@ public: // if the button was clicked) virtual void Command(wxCommandEvent &event); - - virtual void SetLabel(const wxString& label); - virtual bool SetFont(const wxFont& font); - virtual bool GetAdjustMinSizeFlag() const { return m_adjustMinSize; } - void SetAdjustMinSizeFlag(bool adjust) { m_adjustMinSize = adjust; } - - protected: - void Init(); - // creates the control (calls wxWindowBase::CreateBase inside) and adds it // to the list of parents children bool CreateControl(wxWindowBase *parent, @@ -98,9 +88,6 @@ protected: SetBestSize(size); } - // should minsize and size be adjusted when font or label change? - bool m_adjustMinSize; - DECLARE_NO_COPY_CLASS(wxControlBase) }; diff --git a/include/wx/gtk/control.h b/include/wx/gtk/control.h index 5d444e9b45..0dd1153df7 100644 --- a/include/wx/gtk/control.h +++ b/include/wx/gtk/control.h @@ -58,7 +58,6 @@ public: protected: virtual wxSize DoGetBestSize() const; void PostCreation(const wxSize& size); - void PostSetLabel(); #ifdef __WXGTK20__ wxString PrepareLabelMnemonics( const wxString &label ) const; @@ -89,7 +88,6 @@ protected: wxString m_label; char m_chAccel; // enabled to avoid breaking binary compatibility later on - bool m_createComplete; private: DECLARE_DYNAMIC_CLASS(wxControl) diff --git a/include/wx/gtk/stattext.h b/include/wx/gtk/stattext.h index dd4d499883..6686c96982 100644 --- a/include/wx/gtk/stattext.h +++ b/include/wx/gtk/stattext.h @@ -57,8 +57,7 @@ public: wxString GetLabel() const; void SetLabel( const wxString &label ); - bool GetAdjustMinSizeFlag() const { return !HasFlag(wxST_NO_AUTORESIZE); } - + bool SetFont( const wxFont &font ); bool SetForegroundColour( const wxColour& colour ); static wxVisualAttributes diff --git a/include/wx/gtk1/control.h b/include/wx/gtk1/control.h index 5d444e9b45..0dd1153df7 100644 --- a/include/wx/gtk1/control.h +++ b/include/wx/gtk1/control.h @@ -58,7 +58,6 @@ public: protected: virtual wxSize DoGetBestSize() const; void PostCreation(const wxSize& size); - void PostSetLabel(); #ifdef __WXGTK20__ wxString PrepareLabelMnemonics( const wxString &label ) const; @@ -89,7 +88,6 @@ protected: wxString m_label; char m_chAccel; // enabled to avoid breaking binary compatibility later on - bool m_createComplete; private: DECLARE_DYNAMIC_CLASS(wxControl) diff --git a/include/wx/gtk1/stattext.h b/include/wx/gtk1/stattext.h index dd4d499883..6686c96982 100644 --- a/include/wx/gtk1/stattext.h +++ b/include/wx/gtk1/stattext.h @@ -57,8 +57,7 @@ public: wxString GetLabel() const; void SetLabel( const wxString &label ); - bool GetAdjustMinSizeFlag() const { return !HasFlag(wxST_NO_AUTORESIZE); } - + bool SetFont( const wxFont &font ); bool SetForegroundColour( const wxColour& colour ); static wxVisualAttributes diff --git a/include/wx/mac/carbon/stattext.h b/include/wx/mac/carbon/stattext.h index 95c32a82b9..c5f41c02c4 100644 --- a/include/wx/mac/carbon/stattext.h +++ b/include/wx/mac/carbon/stattext.h @@ -40,6 +40,7 @@ public: // accessors void SetLabel( const wxString &str ) ; + bool SetFont( const wxFont &font ); protected : diff --git a/include/wx/mac/classic/stattext.h b/include/wx/mac/classic/stattext.h index 15eae66671..17ecf98ad0 100644 --- a/include/wx/mac/classic/stattext.h +++ b/include/wx/mac/classic/stattext.h @@ -41,6 +41,7 @@ class WXDLLEXPORT wxStaticText: public wxStaticTextBase // accessors void SetLabel( const wxString &str ) ; + bool SetFont( const wxFont &font ); // operations virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index c42f65552c..0ceef4c977 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -40,6 +40,10 @@ public: long style = 0, const wxString& name = wxStaticTextNameStr); + // override some methods to resize the window properly + virtual void SetLabel(const wxString& label); + virtual bool SetFont( const wxFont &font ); + protected: // implement/override some base class virtuals virtual wxBorder GetDefaultBorder() const; diff --git a/include/wx/stattext.h b/include/wx/stattext.h index c210383e5c..8590052f74 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -17,8 +17,6 @@ public: virtual void ApplyParentThemeBackground(const wxColour& bg) { SetBackgroundColour(bg); } - bool GetAdjustMinSizeFlag() const { return !HasFlag(wxST_NO_AUTORESIZE); } - private: DECLARE_NO_COPY_CLASS(wxStaticTextBase) }; diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 553ee11ffd..b04136183e 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -46,10 +46,6 @@ void wxBookCtrl::Init() { m_imageList = NULL; m_ownsImageList = false; - // Unlike most controls, we don't want to adjust the min size - // when we set the font, since the page size is not related to - // the font size. - m_adjustMinSize = false; } bool diff --git a/src/common/ctrlcmn.cpp b/src/common/ctrlcmn.cpp index eab0f889f1..242efdca1f 100644 --- a/src/common/ctrlcmn.cpp +++ b/src/common/ctrlcmn.cpp @@ -68,13 +68,6 @@ bool wxControlBase::Create(wxWindow *parent, return ret; } - -void wxControlBase::Init() -{ - m_adjustMinSize = true; -} - - bool wxControlBase::CreateControl(wxWindowBase *parent, wxWindowID id, const wxPoint& pos, @@ -123,24 +116,6 @@ void wxControlBase::InitCommandEvent(wxCommandEvent& event) const } } -void wxControlBase::SetLabel(const wxString& label) -{ - wxWindow::SetLabel(label); - if (GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); -} - - -bool wxControlBase::SetFont(const wxFont& font) -{ - bool ret = wxWindow::SetFont(font); - - if (GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); - - return ret; -} - // ---------------------------------------------------------------------------- // wxStaticBitmap // ---------------------------------------------------------------------------- diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index 8be33e83f7..db11765013 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -184,7 +184,6 @@ void wxBitmapButton::SetLabel( const wxString &label ) wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); wxControl::SetLabel( label ); - PostSetLabel(); } wxString wxBitmapButton::GetLabel() const diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 330b5d0e12..d64273b780 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -175,8 +175,6 @@ void wxButton::SetLabel( const wxString &label ) #else gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } bool wxButton::Enable( bool enable ) diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 33f8a565b7..1c64e26ba1 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -158,8 +158,6 @@ void wxCheckBox::SetLabel( const wxString& label ) #else gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } bool wxCheckBox::Enable( bool enable ) diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index c12735e39b..41f5cc4ea1 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -33,7 +33,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) wxControl::wxControl() { m_needParent = TRUE; - m_createComplete = false; } bool wxControl::Create( wxWindow *parent, @@ -44,7 +43,6 @@ bool wxControl::Create( wxWindow *parent, const wxValidator& validator, const wxString &name ) { - m_createComplete = false; bool ret = wxWindow::Create(parent, id, pos, size, style, name); #if wxUSE_VALIDATORS @@ -70,14 +68,6 @@ void wxControl::SetLabel( const wxString &label ) } } -void wxControl::PostSetLabel() -{ - // make sure the widget has been created, and that PostCreate has already - // been called - if (m_widget && m_createComplete && GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); -} - wxString wxControl::GetLabel() const { return m_label; @@ -113,7 +103,6 @@ void wxControl::PostCreation(const wxSize& size) InheritAttributes(); ApplyWidgetStyle(); SetInitialBestSize(size); - m_createComplete = true; } diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index f0af2b64a5..ea1eee5230 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -540,8 +540,6 @@ void wxRadioBox::SetLabel( const wxString& label ) wxControl::SetLabel( label ); gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) ); - - PostSetLabel(); } void wxRadioBox::SetString( int item, const wxString& label ) diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index 837cd33058..2c3e1c0d10 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -145,8 +145,6 @@ void wxRadioButton::SetLabel( const wxString& label ) #else gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } void wxRadioButton::SetValue( bool val ) diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index 9d489265d8..7c3eb9678e 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -89,7 +89,6 @@ void wxStaticBox::SetLabel( const wxString &label ) gtk_frame_set_label( GTK_FRAME( m_widget ), m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) ); - PostSetLabel(); } // static diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index f3c40c1226..d659e8cc16 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -146,10 +146,27 @@ void wxStaticText::SetLabel( const wxString &label ) #else gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) ); #endif - - PostSetLabel(); + + // adjust the label size to the new label unless disabled + if (!HasFlag(wxST_NO_AUTORESIZE)) + { + SetSize( GetBestSize() ); + SetSizeHints(GetSize()); + } } +bool wxStaticText::SetFont( const wxFont &font ) +{ + bool ret = wxControl::SetFont(font); + + // adjust the label size to the new label unless disabled + if (!HasFlag(wxST_NO_AUTORESIZE)) + { + SetSize( GetBestSize() ); + SetSizeHints(GetSize()); + } + return ret; +} wxSize wxStaticText::DoGetBestSize() const { diff --git a/src/gtk/tglbtn.cpp b/src/gtk/tglbtn.cpp index 7bccf53080..8ac7ec5a3c 100644 --- a/src/gtk/tglbtn.cpp +++ b/src/gtk/tglbtn.cpp @@ -287,8 +287,6 @@ void wxToggleButton::SetLabel(const wxString& label) wxControl::SetLabel(label); gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) ); - - PostSetLabel(); } bool wxToggleButton::Enable(bool enable /*=TRUE*/) diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index 8be33e83f7..db11765013 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -184,7 +184,6 @@ void wxBitmapButton::SetLabel( const wxString &label ) wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); wxControl::SetLabel( label ); - PostSetLabel(); } wxString wxBitmapButton::GetLabel() const diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 330b5d0e12..d64273b780 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -175,8 +175,6 @@ void wxButton::SetLabel( const wxString &label ) #else gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } bool wxButton::Enable( bool enable ) diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 33f8a565b7..1c64e26ba1 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -158,8 +158,6 @@ void wxCheckBox::SetLabel( const wxString& label ) #else gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } bool wxCheckBox::Enable( bool enable ) diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index c12735e39b..41f5cc4ea1 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -33,7 +33,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) wxControl::wxControl() { m_needParent = TRUE; - m_createComplete = false; } bool wxControl::Create( wxWindow *parent, @@ -44,7 +43,6 @@ bool wxControl::Create( wxWindow *parent, const wxValidator& validator, const wxString &name ) { - m_createComplete = false; bool ret = wxWindow::Create(parent, id, pos, size, style, name); #if wxUSE_VALIDATORS @@ -70,14 +68,6 @@ void wxControl::SetLabel( const wxString &label ) } } -void wxControl::PostSetLabel() -{ - // make sure the widget has been created, and that PostCreate has already - // been called - if (m_widget && m_createComplete && GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); -} - wxString wxControl::GetLabel() const { return m_label; @@ -113,7 +103,6 @@ void wxControl::PostCreation(const wxSize& size) InheritAttributes(); ApplyWidgetStyle(); SetInitialBestSize(size); - m_createComplete = true; } diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index f0af2b64a5..ea1eee5230 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -540,8 +540,6 @@ void wxRadioBox::SetLabel( const wxString& label ) wxControl::SetLabel( label ); gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) ); - - PostSetLabel(); } void wxRadioBox::SetString( int item, const wxString& label ) diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index 837cd33058..2c3e1c0d10 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -145,8 +145,6 @@ void wxRadioButton::SetLabel( const wxString& label ) #else gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) ); #endif - - PostSetLabel(); } void wxRadioButton::SetValue( bool val ) diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index 9d489265d8..7c3eb9678e 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -89,7 +89,6 @@ void wxStaticBox::SetLabel( const wxString &label ) gtk_frame_set_label( GTK_FRAME( m_widget ), m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) ); - PostSetLabel(); } // static diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index f3c40c1226..d659e8cc16 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -146,10 +146,27 @@ void wxStaticText::SetLabel( const wxString &label ) #else gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) ); #endif - - PostSetLabel(); + + // adjust the label size to the new label unless disabled + if (!HasFlag(wxST_NO_AUTORESIZE)) + { + SetSize( GetBestSize() ); + SetSizeHints(GetSize()); + } } +bool wxStaticText::SetFont( const wxFont &font ) +{ + bool ret = wxControl::SetFont(font); + + // adjust the label size to the new label unless disabled + if (!HasFlag(wxST_NO_AUTORESIZE)) + { + SetSize( GetBestSize() ); + SetSizeHints(GetSize()); + } + return ret; +} wxSize wxStaticText::DoGetBestSize() const { diff --git a/src/gtk1/tglbtn.cpp b/src/gtk1/tglbtn.cpp index 7bccf53080..8ac7ec5a3c 100644 --- a/src/gtk1/tglbtn.cpp +++ b/src/gtk1/tglbtn.cpp @@ -287,8 +287,6 @@ void wxToggleButton::SetLabel(const wxString& label) wxControl::SetLabel(label); gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) ); - - PostSetLabel(); } bool wxToggleButton::Enable(bool enable /*=TRUE*/) diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 761b0598b5..f4757d19d7 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -92,9 +92,27 @@ void wxStaticText::SetLabel(const wxString& st ) SetControlData( *m_peer, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ), &ref ); - if (GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + SetSize( GetBestSize() ) ; + SetSizeHints(GetSize()); + } Update() ; } +bool wxStaticText::SetFont(const wxFont& font) +{ + bool ret = wxControl::SetFont(font); + + if ( ret ) + { + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + SetSize( GetBestSize() ); + SetSizeHints(GetSize()); + } + } + + return ret; +} diff --git a/src/mac/classic/stattext.cpp b/src/mac/classic/stattext.cpp index 8bc3ee9272..1c0facdbf7 100644 --- a/src/mac/classic/stattext.cpp +++ b/src/mac/classic/stattext.cpp @@ -232,11 +232,31 @@ void wxStaticText::SetLabel(const wxString& st ) { SetTitle( st ) ; m_label = st ; - - if (GetAdjustMinSizeFlag()) - SetBestSize(wxDefaultSize); - + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + // temporary fix until layout measurement and drawing are in synch again + Refresh() ; + SetSize( GetBestSize() ) ; + } Refresh() ; Update() ; } +bool wxStaticText::SetFont(const wxFont& font) +{ + bool ret = wxControl::SetFont(font); + + if ( ret ) + { + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + // temporary fix until layout measurement and drawing are in synch again + Refresh() ; + SetSize( GetBestSize() ); + } + } + + return ret; +} diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 02d4e44b50..12b7403018 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -207,5 +207,33 @@ void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags) Refresh(); } +void wxStaticText::SetLabel(const wxString& label) +{ + wxStaticTextBase::SetLabel(label); + + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + SetSizeHints(GetSize()); + } +} + + +bool wxStaticText::SetFont(const wxFont& font) +{ + bool ret = wxControl::SetFont(font); + + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + SetSizeHints(GetSize()); + } + + return ret; +} #endif // wxUSE_STATTEXT -- 2.45.2