+// ----------------------------------------------------------------------------
+// size calculations
+// ----------------------------------------------------------------------------
+
+wxSize wxRadioBox::GetMaxButtonSize() const
+{
+ // calculate the max button size
+ int widthMax = 0,
+ heightMax = 0;
+ for ( int i = 0 ; i < m_noItems; 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;
+
+#if defined(CTL3D) && !CTL3D
+ // Requires a bigger group box in plain Windows
+ extraHeight *= 3;
+ extraHeight /= 2;
+#endif
+
+ int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight;
+ int width = GetNumHor() * (sizeBtn.x + cx1) + cx1;
+
+ // 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());
+}
+