- }
-
- wxSize newSize = size;
- if (newSize.x == -1) newSize.x = maxLen+10;
- if (newSize.y == -1) newSize.y = height;
- SetSize( newSize.x, newSize.y );
-
- PostCreation();
-
- SetLabel( title );
-
- SetBackgroundColour( parent->GetBackgroundColour() );
-
- Show( TRUE );
-
- return TRUE;
-}
-
-wxRadioBox::~wxRadioBox(void)
-{
- wxNode *node = m_boxes.First();
- while (node)
- {
- GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_widget_destroy( button );
- node = node->Next();
- }
-}
-
-void wxRadioBox::OnSize( wxSizeEvent &event )
-{
- wxControl::OnSize( event );
-
- int x = m_x+5;
- int y = m_y+15;
-
- wxNode *node = m_boxes.First();
- while (node)
- {
- GtkWidget *button = GTK_WIDGET( node->Data() );
-
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, x, y );
- y += 20;
-
- int w = m_width-10;
- if (w < 15) w = 15;
- gtk_widget_set_usize( button, w, 20 );
-
- 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;
+ wxList::compatibility_iterator node = m_boxes.Item( j*num_of_rows );
+ for (int i1 = 0; i1< num_of_rows; i1++)
+ {
+ GtkWidget *button = GTK_WIDGET( node->GetData() );
+
+ 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->GetNext();
+ if (!node) break;
+ }
+
+ // we don't know the max_len before
+
+ node = m_boxes.Item( j*num_of_rows );
+ for (int i2 = 0; i2< num_of_rows; i2++)
+ {
+ GtkWidget *button = GTK_WIDGET( node->GetData() );
+
+ gtk_pizza_resize( GTK_PIZZA(m_parent->m_wxwindow), button, max_len, 20 );
+
+ node = node->GetNext();
+ 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;
+
+ wxList::compatibility_iterator node = m_boxes.GetFirst();
+ while (node)
+ {
+ GtkWidget *button = GTK_WIDGET( node->GetData() );
+
+ 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->GetNext();
+ }
+
+ node = m_boxes.GetFirst();
+ while (node)
+ {
+ GtkWidget *button = GTK_WIDGET( node->GetData() );
+
+ gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
+ x += max;
+
+ node = node->GetNext();
+ }
+ res.x = x+4;
+ res.y = 40;
+ }
+
+ return res;