]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/radiobut.cpp
support for standard command IDs
[wxWidgets.git] / src / gtk / radiobut.cpp
index e79978e8b7979b865bde961b6aff74064d1d4077..9d0f498faef74cdd913088b11d0c577a505a92de 100644 (file)
@@ -7,11 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "radiobut.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -40,6 +35,7 @@ extern wxWindowGTK   *g_delayedFocus;
 // "clicked"
 //-----------------------------------------------------------------------------
 
+extern "C" {
 static 
 void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb )
 {
@@ -58,6 +54,7 @@ void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *r
     event.SetEventObject( rb );
     rb->GetEventHandler()->ProcessEvent( event );
 }
+}
 
 //-----------------------------------------------------------------------------
 // wxRadioButton
@@ -86,12 +83,8 @@ bool wxRadioButton::Create( wxWindow *parent,
         return FALSE;
     }
 
-    if (HasFlag(wxRB_GROUP))
-    {
-        // start a new group
-        m_radioButtonGroup = (GSList*) NULL;
-    }
-    else
+    GSList* radioButtonGroup = NULL;
+    if (!HasFlag(wxRB_GROUP))
     {
         // search backward for last group start
         wxRadioButton *chief = (wxRadioButton*) NULL;
@@ -110,16 +103,11 @@ bool wxRadioButton::Create( wxWindow *parent,
         if (chief)
         {
             // we are part of the group started by chief
-            m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) );
-        }
-        else
-        {
-            // start a new group
-            m_radioButtonGroup = (GSList*) NULL;
+            radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) );
         }
     }
 
-    m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, wxGTK_CONV( label ) );
+    m_widget = gtk_radio_button_new_with_label( radioButtonGroup, wxGTK_CONV( label ) );
       
     SetLabel(label);
 
@@ -128,23 +116,7 @@ bool wxRadioButton::Create( wxWindow *parent,
        
     m_parent->DoAddChild( this );
   
-    PostCreation();
-
-    SetFont( parent->GetFont() );
-
-    wxSize size_best( DoGetBestSize() );
-    wxSize new_size( size );
-    if (new_size.x == -1)
-        new_size.x = size_best.x;
-    if (new_size.y == -1)
-        new_size.y = size_best.y;
-    if ((new_size.x != size.x) || (new_size.y != size.y))
-        SetSize( new_size.x, new_size.y );
-        
-    SetBackgroundColour( parent->GetBackgroundColour() );
-    SetForegroundColour( parent->GetForegroundColour() );
-  
-    Show( TRUE );
+    PostCreation(size);
 
     return TRUE;
 }
@@ -203,11 +175,10 @@ bool wxRadioButton::Enable( bool enable )
     return TRUE;
 }
 
-void wxRadioButton::ApplyWidgetStyle()
+void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
@@ -249,4 +220,19 @@ wxSize wxRadioButton::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxRadioButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    wxVisualAttributes attr;
+    // NB: we need toplevel window so that GTK+ can find the right style
+    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
+    gtk_container_add(GTK_CONTAINER(wnd), widget);
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(wnd);
+    return attr;
+}
+
+
 #endif