]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/checkbox.cpp
Tweaks needed to be able to build wxPython with wxGTK.
[wxWidgets.git] / src / gtk / checkbox.cpp
index b33fd486e6f73eb78fd75af68fa90049cb637e78..6e94fdfcebd52e6a18b54560fa4c2f7add0f2352 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        checkbox.cpp
 // Purpose:
 // Author:      Robert Roebling
-// Id:          $id$
+// Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -27,6 +27,13 @@ extern bool   g_blockEventsOnDrag;
 static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb )
 {
   if (!cb->HasVMT()) return;
+  
+  if (cb->m_blockFirstEvent)
+  {
+    cb->m_blockFirstEvent = FALSE;
+    return;
+  } 
+  
   if (g_blockEventsOnDrag) return;
   
   wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
@@ -57,6 +64,8 @@ bool wxCheckBox::Create(  wxWindow *parent, wxWindowID id, const wxString &label
 
   m_widget = gtk_check_button_new_with_label( m_label );
  
+  m_blockFirstEvent = FALSE;
+  
   wxSize newSize = size;
   if (newSize.x == -1) newSize.x = 25+gdk_string_measure( m_widget->style->font, label );
   if (newSize.y == -1) newSize.y = 26;
@@ -65,6 +74,10 @@ bool wxCheckBox::Create(  wxWindow *parent, wxWindowID id, const wxString &label
   gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", 
     GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this );
     
+  m_parent->AddChild( this );
+
+  (m_parent->m_insertCallback)( m_parent, this );
+  
   PostCreation();
   
   gtk_widget_realize( GTK_BUTTON( m_widget )->child );
@@ -72,6 +85,7 @@ bool wxCheckBox::Create(  wxWindow *parent, wxWindowID id, const wxString &label
   SetLabel( label );
 
   SetBackgroundColour( parent->GetBackgroundColour() );
+  SetForegroundColour( parent->GetForegroundColour() );
 
   Show( TRUE );
     
@@ -81,11 +95,10 @@ bool wxCheckBox::Create(  wxWindow *parent, wxWindowID id, const wxString &label
 void wxCheckBox::SetValue( bool state )
 {
   wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
+    
+  m_blockFirstEvent = TRUE;
 
-  if (state)
-    gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_ACTIVE );
-  else
-    gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_NORMAL );
+  gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), state );
 }
 
 bool wxCheckBox::GetValue() const
@@ -113,29 +126,11 @@ void wxCheckBox::Enable( bool enable )
   gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
 }
 
-void wxCheckBox::SetFont( const wxFont &font )
+void wxCheckBox::ApplyWidgetStyle()
 {
-  wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
-
-  wxControl::SetFont( font );
-  
-  gtk_widget_set_style( GTK_BUTTON(m_widget)->child, 
-    gtk_style_ref(
-      gtk_widget_get_style( m_widget ) ) );
+  SetWidgetStyle();
+  gtk_widget_set_style( m_widget, m_widgetStyle );
+  gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
 }
 
-void wxCheckBox::SetBackgroundColour( const wxColour &colour )
-{
-  return;
-
-  wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
-
-  wxControl::SetBackgroundColour( colour );
-  
-  if (!m_backgroundColour.Ok()) return;
-  
-  gtk_widget_set_style( GTK_BUTTON(m_widget)->child, 
-    gtk_style_ref(
-      gtk_widget_get_style( m_widget ) ) );
-}