X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/52ca4ec419e41f800bc8e7a7c4f78f6079c603a6..d8812c6e0e780fb2dae99bc352c5061f58793e14:/src/msw/radiobox.cpp?ds=sidebyside diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 53c5efce54..26519adcbb 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -129,7 +129,7 @@ void wxRadioBox::Init() { m_selectedButton = wxNOT_FOUND; m_radioButtons = NULL; - m_dummyButton = NULL; + m_dummyHwnd = NULL; m_radioWidth = NULL; m_radioHeight = NULL; } @@ -150,6 +150,11 @@ bool wxRadioBox::Create(wxWindow *parent, if ( !wxStaticBox::Create(parent, id, title, pos, size, style, name) ) return false; + // the code elsewhere in this file supposes that either wxRA_SPECIFY_COLS + // or wxRA_SPECIFY_ROWS is set, ensure that this is indeed the case + if ( !(style & (wxRA_SPECIFY_ROWS | wxRA_SPECIFY_COLS)) ) + style |= wxRA_SPECIFY_COLS; + #if wxUSE_VALIDATORS SetValidator(val); #else @@ -164,8 +169,6 @@ bool wxRadioBox::Create(wxWindow *parent, // For instance, we don't want the bounding box of the radio // buttons to include the dummy button m_radioButtons = new wxSubwindows(n); - m_dummyButton = new wxSubwindows(1); - m_radioWidth = new int[n]; m_radioHeight = new int[n]; @@ -185,7 +188,7 @@ bool wxRadioBox::Create(wxWindow *parent, styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), - (HMENU)subid.GetValue(), + (HMENU)wxUIntToPtr(subid.GetValue()), wxGetInstance(), NULL); @@ -206,19 +209,15 @@ bool wxRadioBox::Create(wxWindow *parent, } // Create a dummy radio control to end the group. - wxWindowIDRef subid = NewControlId(); + m_dummyId = NewControlId(); - HWND dummy = ::CreateWindow(_T("BUTTON"), + m_dummyHwnd = (WXHWND)::CreateWindow(_T("BUTTON"), wxEmptyString, WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD, 0, 0, 0, 0, GetHwndOf(parent), - (HMENU)subid.GetValue(), wxGetInstance(), NULL); + (HMENU)wxUIntToPtr(m_dummyId.GetValue()), + wxGetInstance(), NULL); - // Keep track of the subwindow so it will be destroyed when the radio - // box is and it's id will be freed. - // Also, do we need to consider this dummy item a subcontrol and add it - // to m_subControls - m_dummyButton->Set(0, dummy, subid); m_radioButtons->SetFont(GetFont()); @@ -258,7 +257,8 @@ wxRadioBox::~wxRadioBox() m_isBeingDeleted = true; delete m_radioButtons; - delete m_dummyButton; + if ( m_dummyHwnd ) + DestroyWindow((HWND)m_dummyHwnd); delete[] m_radioWidth; delete[] m_radioHeight; } @@ -467,6 +467,25 @@ void wxRadioBox::DoSetItemToolTip(unsigned int item, wxToolTip *tooltip) #endif // wxUSE_TOOLTIPS +bool wxRadioBox::Reparent(wxWindowBase *newParent) +{ + if ( !wxStaticBox::Reparent(newParent) ) + { + return false; + } + + HWND hwndParent = GetHwndOf(GetParent()); + for ( size_t item = 0; item < m_radioButtons->GetCount(); item++ ) + { + ::SetParent((*m_radioButtons)[item], hwndParent); + } +#ifdef __WXWINCE__ + // put static box under the buttons in the Z-order + SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); +#endif + return true; +} + WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons) // ----------------------------------------------------------------------------