+bool wxButton::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString &label,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxButton creation failed") );
+ return false;
+ }
+
+ // create either a standard button with text label (which may still contain
+ // an image under GTK+ 2.6+) or a bitmap-only button if we don't have any
+ // label
+ const bool
+ useLabel = !(style & wxBU_NOTEXT) && (!label.empty() || wxIsStockID(id));
+ if ( useLabel )
+ {
+ m_widget = gtk_button_new_with_mnemonic("");
+ }
+ else // no label, suppose we will have a bitmap
+ {
+ m_widget = gtk_button_new();
+
+ GtkWidget *image = gtk_image_new();
+ gtk_widget_show(image);
+ gtk_container_add(GTK_CONTAINER(m_widget), image);
+ }
+
+ g_object_ref(m_widget);
+
+ 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;
+
+ gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment);
+
+ if ( useLabel )
+ SetLabel(label);
+
+ if (style & wxNO_BORDER)
+ gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
+
+ g_signal_connect_after (m_widget, "clicked",
+ G_CALLBACK (wxgtk_button_clicked_callback),
+ this);
+
+ g_signal_connect_after (m_widget, "style_set",
+ G_CALLBACK (wxgtk_button_style_set_callback),
+ this);
+
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+
+ return true;
+}