From 7a5a5718592cb0873374e6ebc66d12a153d5acea Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 3 May 2004 23:08:55 +0000 Subject: [PATCH] Initial/Best size fixes for wxRadioBox, wxSlider and wxStaticText on wxMSW git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/radiobox.h | 3 +++ src/msw/radiobox.cpp | 4 +++- src/msw/slider95.cpp | 11 +++++------ src/msw/stattext.cpp | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 698bde3d7a..49c1cf0771 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -128,6 +128,9 @@ public: { SetBackgroundColour(bg); } protected: + // we can't compute our best size before the items are added to the control + virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { } + // subclass one radio button void SubclassRadioButton(WXHWND hWndBtn); diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 29943e25c8..c42ccbd12c 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -346,9 +346,11 @@ bool wxRadioBox::Create(wxWindow *parent, (HMENU)NewControlId(), wxGetInstance(), NULL); SetSelection(0); - SetSize(pos.x, pos.y, size.x, size.y); + // Now that we have items determine what is the best size and set it. + SetBestSize(size); + return TRUE; } diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 3853c60447..36e29a5da7 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -143,11 +143,6 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; m_tickFreq = 0; - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; - long msStyle = 0; long wstyle = 0; @@ -272,9 +267,13 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, } } - SetSize(x, y, width, height); + SetSize(pos.x, pos.y, size.x, size.y); SetValue(value); + // SetInitialBestSize is not called since we don't call MSWCreateControl + // for this control, so call SetBestSize here instead. + SetBestSize(size); + return TRUE; } diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index ad7ef96d15..12b7403018 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -216,6 +216,7 @@ void wxStaticText::SetLabel(const wxString& label) if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) { DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + SetSizeHints(GetSize()); } } @@ -229,6 +230,7 @@ bool wxStaticText::SetFont(const wxFont& font) if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) { DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + SetSizeHints(GetSize()); } return ret;