- m_needParent = TRUE;
-
- wxSize newSize = size;
-
- PreCreation( parent, id, pos, newSize, style, name );
-
- m_label = label;
- m_widget = gtk_button_new_with_label( label );
-
- if (newSize.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label );
- if (newSize.y == -1) newSize.y = 26;
- SetSize( newSize.x, newSize.y );
-
- gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
- GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
-
- PostCreation();
-
- Show( TRUE );
-
- return TRUE;
-};
-
-void wxButton::SetDefault(void)
+ m_needParent = true;
+ m_acceptsFocus = true;
+
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxButton creation failed") );
+ return false;
+ }
+
+ m_widget = gtk_button_new_with_label("");
+
+ float x_alignment = 0.5;
+ if (HasFlag(wxBU_LEFT))
+ x_alignment = 0.0;
+ else if (HasFlag(wxBU_RIGHT))
+ x_alignment = 1.0;
+
+ float y_alignment = 0.5;
+ if (HasFlag(wxBU_TOP))
+ y_alignment = 0.0;
+ else if (HasFlag(wxBU_BOTTOM))
+ y_alignment = 1.0;
+
+ if (GTK_IS_MISC(BUTTON_CHILD(m_widget)))
+ gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
+ x_alignment, y_alignment);
+
+ SetLabel(label);
+
+ if (style & wxNO_BORDER)
+ gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
+
+ gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked",
+ GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
+
+ gtk_signal_connect_after( GTK_OBJECT(m_widget), "style_set",
+ GTK_SIGNAL_FUNC(gtk_button_style_set_callback), (gpointer*) this );
+
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+
+ return true;
+}
+
+
+wxWindow *wxButton::SetDefault()
+{
+ wxWindow *oldDefault = wxButtonBase::SetDefault();
+
+ GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
+ gtk_widget_grab_default( m_widget );
+
+ // resize for default border
+ gtk_button_style_set_callback( m_widget, NULL, this );
+
+ return oldDefault;
+}
+
+/* static */
+wxSize wxButtonBase::GetDefaultSize()