+ if ( GetCount() > 0 )
+ {
+ ::SetFocus((*m_radioButtons)[m_selectedButton == wxNOT_FOUND
+ ? 0
+ : m_selectedButton]);
+ }
+}
+
+// Enable a specific button
+bool wxRadioBox::Enable(int item, bool enable)
+{
+ wxCHECK_MSG( IsValid(item), false,
+ wxT("invalid item in wxRadioBox::Enable()") );
+
+ BOOL ret = ::EnableWindow((*m_radioButtons)[item], enable);
+
+ return (ret == 0) == enable;
+}
+
+// Show a specific button
+bool wxRadioBox::Show(int item, bool show)
+{
+ wxCHECK_MSG( IsValid(item), false,
+ wxT("invalid item in wxRadioBox::Show()") );
+
+ BOOL ret = ::ShowWindow((*m_radioButtons)[item], show ? SW_SHOW : SW_HIDE);
+
+ return (ret != 0) == show;
+}
+
+WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons)
+
+// ----------------------------------------------------------------------------
+// size calculations
+// ----------------------------------------------------------------------------
+
+wxSize wxRadioBox::GetMaxButtonSize() const
+{
+ // calculate the max button size
+ int widthMax = 0,
+ heightMax = 0;
+ const int count = GetCount();
+ for ( int i = 0 ; i < count; i++ )
+ {
+ int width, height;
+ if ( m_radioWidth[i] < 0 )
+ {
+ GetTextExtent(wxGetWindowText((*m_radioButtons)[i]), &width, &height);
+
+ // adjust the size to take into account the radio box itself
+ // FIXME this is totally bogus!
+ width += RADIO_SIZE;
+ height *= 3;
+ height /= 2;
+ }
+ else
+ {
+ width = m_radioWidth[i];
+ height = m_radioHeight[i];
+ }
+
+ if ( widthMax < width )
+ widthMax = width;
+ if ( heightMax < height )
+ heightMax = height;
+ }
+
+ return wxSize(widthMax, heightMax);
+}
+
+wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
+{
+ // the radiobox should be big enough for its buttons
+ int cx1, cy1;
+ wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
+
+ int extraHeight = cy1;
+
+ int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight;
+ int width = GetNumHor() * (sizeBtn.x + cx1) + cx1;
+
+ // Add extra space under the label, if it exists.
+ if (!wxControl::GetLabel().empty())
+ height += cy1/2;
+
+ // and also wide enough for its label
+ int widthLabel;
+ GetTextExtent(GetTitle(), &widthLabel, NULL);
+ widthLabel += RADIO_SIZE; // FIXME this is bogus too
+ if ( widthLabel > width )
+ width = widthLabel;
+
+ return wxSize(width, height);
+}
+
+wxSize wxRadioBox::DoGetBestSize() const
+{
+ return GetTotalButtonSize(GetMaxButtonSize());