+ // common initialization
+ 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
+ wxUnusedVar(val);
+#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
+
+ // We need an extra one to keep track of the 'dummy' item we
+ // create to end the radio group, so it will be destroyed and
+ // it's id will be released. But we want it separate from the
+ // other buttons since the wxSubwindows will operate on it as
+ // well and we just want to ignore it until destroying it.
+ // For instance, we don't want the bounding box of the radio
+ // buttons to include the dummy button
+ m_radioButtons = new wxSubwindows(n);
+
+ m_radioWidth = new int[n];
+ m_radioHeight = new int[n];
+
+ for ( int i = 0; i < n; i++ )
+ {
+ m_radioWidth[i] =
+ m_radioHeight[i] = wxDefaultCoord;
+ long styleBtn = BS_AUTORADIOBUTTON | WS_TABSTOP | WS_CHILD | WS_VISIBLE;
+ if ( i == 0 )
+ styleBtn |= WS_GROUP;
+
+ wxWindowIDRef subid = NewControlId();
+
+ HWND hwndBtn = ::CreateWindow(wxT("BUTTON"),
+ choices[i].wx_str(),
+ styleBtn,
+ 0, 0, 0, 0, // will be set in SetSize()
+ GetHwndOf(parent),
+ (HMENU)wxUIntToPtr(subid.GetValue()),
+ wxGetInstance(),
+ NULL);
+
+ if ( !hwndBtn )
+ {
+ wxLogLastError(wxT("CreateWindow(radio btn)"));
+
+ return false;
+ }
+
+ // Keep track of the subwindow
+ m_radioButtons->Set(i, hwndBtn, subid);
+
+ SubclassRadioButton((WXHWND)hwndBtn);
+
+ // Also, make it a subcontrol of this control
+ m_subControls.Add(subid);
+ }
+
+ // Create a dummy radio control to end the group.
+ m_dummyId = NewControlId();
+
+ m_dummyHwnd = (WXHWND)::CreateWindow(wxT("BUTTON"),
+ wxEmptyString,
+ WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
+ 0, 0, 0, 0, GetHwndOf(parent),
+ (HMENU)wxUIntToPtr(m_dummyId.GetValue()),
+ wxGetInstance(), NULL);
+
+
+ m_radioButtons->SetFont(GetFont());
+
+#ifdef __WXWINCE__
+ // Set the z-order correctly
+ SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+#endif
+
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
+ 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.
+ 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;