From d9c4ffa89374b337ff6416ef5d9e742c026f11e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 2 Feb 2012 14:26:06 +0000 Subject: [PATCH] Fix initial wxRadioBox buttons positions in wxMSW. We only updated the button positions when the radio box was moved or resized after being created but didn't do it initially, so a radio box created with fixed position and size didn't lay out its buttons correctly. Do lay them out immediately after creating the radio box to fix this. Closes #13912. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/radiobox.h | 3 +++ src/msw/radiobox.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 2edf86df4f..5e3c362e51 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -149,6 +149,9 @@ protected: // get the total size occupied by the radio box buttons wxSize GetTotalButtonSize(const wxSize& sizeBtn) const; + // Adjust all the buttons to the new window size. + void PositionAllButtons(int x, int y, int width, int height); + virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index de869045c1..c33b564474 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -252,6 +252,10 @@ bool wxRadioBox::Create(wxWindow *parent, // Now that we have items determine what is the best size and set it. SetInitialSize(size); + // And update all the buttons positions to match it. + const wxSize actualSize = GetSize(); + PositionAllButtons(pos.x, pos.y, actualSize.x, actualSize.y); + return true; } @@ -625,6 +629,12 @@ void wxRadioBox::DoMoveWindow(int x, int y, int width, int height) { wxStaticBox::DoMoveWindow(x, y, width, height); + PositionAllButtons(x, y, width, height); +} + +void +wxRadioBox::PositionAllButtons(int x, int y, int width, int WXUNUSED(height)) +{ wxSize maxSize = GetMaxButtonSize(); int maxWidth = maxSize.x, maxHeight = maxSize.y; -- 2.45.2