+ wxSize newSize = size;
+ if (newSize.x == -1) newSize.x = ls.x;
+ if (newSize.y == -1) newSize.y = ls.y;
+ SetSize( newSize.x, newSize.y );
+
+ SetBackgroundColour( parent->GetBackgroundColour() );
+ SetForegroundColour( parent->GetForegroundColour() );
+
+ Show( TRUE );
+
+ return TRUE;
+}
+
+wxRadioBox::~wxRadioBox()
+{
+ wxNode *node = m_boxes.First();
+ while (node)
+ {
+ GtkWidget *button = GTK_WIDGET( node->Data() );
+ gtk_widget_destroy( button );
+ node = node->Next();
+ }
+}
+
+void wxRadioBox::DoSetSize( int x, int y, int width, int height, int sizeFlags )
+{
+ wxWindow::DoSetSize( x, y, width, height, sizeFlags );
+
+ LayoutItems();
+}
+
+wxSize wxRadioBox::LayoutItems()
+{
+ int x = 7;
+ int y = 15;
+
+ if ( m_majorDim == 0 )
+ {
+ // avoid dividing by 0 below
+ wxFAIL_MSG( wxT("dimension of radiobox should not be 0!") );
+
+ m_majorDim = 1;
+ }
+
+ int num_per_major = (m_boxes.GetCount() - 1) / m_majorDim +1;
+
+ wxSize res( 0, 0 );
+
+ int num_of_cols = 0;
+ int num_of_rows = 0;
+ if (HasFlag(wxRA_SPECIFY_COLS))
+ {
+ num_of_cols = m_majorDim;
+ num_of_rows = num_per_major;
+ }
+ else
+ {
+ num_of_cols = num_per_major;
+ num_of_rows = m_majorDim;
+ }
+
+ if ( HasFlag(wxRA_SPECIFY_COLS) ||
+ (HasFlag(wxRA_SPECIFY_ROWS) && (num_of_cols > 1)) )
+ {
+ for (int j = 0; j < num_of_cols; j++)
+ {
+ y = 15;
+
+ int max_len = 0;
+ wxNode *node = m_boxes.Nth( j*num_of_rows );
+ for (int i1 = 0; i1< num_of_rows; i1++)
+ {
+ GtkWidget *button = GTK_WIDGET( node->Data() );
+
+ GtkRequisition req;
+ req.width = 2;
+ req.height = 2;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request )
+ (button, &req );
+
+ if (req.width > max_len) max_len = req.width;
+
+ gtk_pizza_move( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y );
+ y += req.height;
+
+ node = node->Next();
+ if (!node) break;
+ }
+
+ // we don't know the max_len before
+
+ node = m_boxes.Nth( j*num_of_rows );
+ for (int i2 = 0; i2< num_of_rows; i2++)
+ {
+ GtkWidget *button = GTK_WIDGET( node->Data() );
+
+ gtk_pizza_resize( GTK_PIZZA(m_parent->m_wxwindow), button, max_len, 20 );
+
+ node = node->Next();
+ if (!node) break;
+ }
+
+ if (y > res.y) res.y = y;
+
+ x += max_len + 2;
+ }
+
+ res.x = x+4;
+ res.y += 4;
+ }
+ else
+ {
+ int max = 0;
+
+ wxNode *node = m_boxes.First();
+ while (node)
+ {
+ GtkWidget *button = GTK_WIDGET( node->Data() );
+
+ GtkRequisition req;
+ req.width = 2;
+ req.height = 2;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request )
+ (button, &req );
+
+ if (req.width > max) max = req.width;
+
+ node = node->Next();
+ }
+
+ node = m_boxes.First();
+ while (node)
+ {
+ GtkWidget *button = GTK_WIDGET( node->Data() );
+
+ gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
+ x += max;
+
+ node = node->Next();
+ }
+ res.x = x+4;
+ res.y = 40;
+ }
+
+ return res;