]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/radiobox.cpp
compilation fixes
[wxWidgets.git] / src / gtk1 / radiobox.cpp
index 7d2f23a120020221ac48568c0258482aa00bed0f..1871c04a4acc12da0c49924fe5dd4ff9075bbeba 100644 (file)
@@ -113,8 +113,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
         gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
            GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
 
-        gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), 
-                         GTK_WIDGET(m_radio), 
+        gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow),
+                         GTK_WIDGET(m_radio),
                          m_x+10, m_y+10+(i*24), 10, 10 );
     }
 
@@ -163,6 +163,14 @@ wxSize wxRadioBox::LayoutItems()
     int x = 7;
     int y = 15;
 
+    if ( m_majorDim == 0 )
+    {
+        // avoid dividing by 0 below
+        wxFAIL_MSG( _T("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 );
@@ -254,7 +262,7 @@ bool wxRadioBox::Show( bool show )
 
     if ((m_windowStyle & wxNO_BORDER) != 0)
         gtk_widget_hide( m_widget );
-    
+
     wxNode *node = m_boxes.First();
     while (node)
     {
@@ -320,7 +328,11 @@ void wxRadioBox::SetSelection( int n )
 
     GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
 
+    DisableEvents();
+    
     gtk_toggle_button_set_state( button, 1 );
+    
+    EnableEvents();
 }
 
 int wxRadioBox::GetSelection(void) const
@@ -486,6 +498,30 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
     wxFAIL_MSG(_T("wxRadioBox::SetNumberOfRowsOrCols not implemented."));
 }
 
+void wxRadioBox::DisableEvents()
+{
+    wxNode *node = m_boxes.First();
+    while (node)
+    {
+        gtk_signal_disconnect_by_func( GTK_OBJECT(node->Data()),
+           GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
+
+       node = node->Next();
+    }
+}
+
+void wxRadioBox::EnableEvents()
+{
+    wxNode *node = m_boxes.First();
+    while (node)
+    {
+        gtk_signal_connect( GTK_OBJECT(node->Data()), "clicked",
+           GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
+
+       node = node->Next();
+    }
+}
+
 void wxRadioBox::ApplyWidgetStyle()
 {
     SetWidgetStyle();