/////////////////////////////////////////////////////////////////////////////
-// Name: src/osx/radiobox.cpp
+// Name: src/osx/radiobox_osx.cpp
// Purpose: wxRadioBox
// Author: Stefan Csomor
// Modified by: JS Lair (99/11/15) first implementation
int n, const wxString choices[],
int majorDim, long style,
const wxValidator& val, const wxString& name )
-{
- m_macIsUserPane = false ;
-
+{
+ DontCreatePeer();
+
if ( !wxControl::Create( parent, id, pos, size, style, val, name ) )
return false;
- int i;
-
- m_noItems = (unsigned int)n;
+ // during construction we must keep this at 0, otherwise GetBestSize fails
+ m_noItems = 0;
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
m_labelOrig = m_label = label;
- m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() );
+ SetPeer(wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() ));
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
wxRadioButton *radBtn = new wxRadioButton(
this,
// m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle );
}
+ // as all radiobuttons have been set-up, set the correct dimensions
+ m_noItems = (unsigned int)n;
+ SetMajorDim( majorDim == 0 ? n : majorDim, style );
+
SetSelection( 0 );
+ InvalidateBestSize();
+ SetInitialSize( size );
MacPostControlCreate( pos, size );
return true;
wxSize bestSizeRadio ;
if ( m_radioButtonCycle )
bestSizeRadio = m_radioButtonCycle->GetBestSize();
-
+
for (unsigned int i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] );
}
// according to HIG (official space - 3 Pixels Diff between Frame and Layout size)
- int space = 3;
+ int space = 3;
if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
space = 2;
-
+
totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space;
totWidth = GetColumnCount() * (maxWidth + charWidth);
current = current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS)
- y_offset += maxHeight + space;
+ y_offset += maxHeight + space;
else
x_offset += maxWidth + charWidth;
}
}
// according to HIG (official space - 3 Pixels Diff between Frame and Layout size)
- int space = 3;
+ int space = 3;
if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
space = 2;
-
+
totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space;
totWidth = GetColumnCount() * (maxWidth + charWidth);
bool retval = wxWindowBase::SetFont( font );
// dont' update the native control, it has its own small font
-
+
// should we iterate over the children ?
return retval;