]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/button.cpp
set mask when converting pixbuf to pixmap
[wxWidgets.git] / src / gtk / button.cpp
index e3a010662fea6e5093544a71b8e79eceae6cc0f7..629420edf76f49c82113f3c6ae9b139db3d94ea0 100644 (file)
@@ -127,11 +127,12 @@ bool wxButton::Create(  wxWindow *parent, wxWindowID id, const wxString &label,
     else if (HasFlag(wxBU_BOTTOM))
         y_alignment = 1.0;
 
-#ifdef __WXGTK20__
+#if GTK_CHECK_VERSION(2,4,0)
     gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment);
 #else
-    gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
-                            x_alignment, y_alignment);
+    if (GTK_IS_MISC(BUTTON_CHILD(m_widget)))
+        gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
+                                x_alignment, y_alignment);
 #endif
 
     if (!label.empty())
@@ -156,9 +157,19 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, wxStockItemID stock,
                       const wxValidator& validator, const wxString& name)
 {
 #ifdef __WXGTK20__
-    m_widget = gtk_button_new_from_stock(wxStockItemToGTK(stock));
-    return Create(parent, id, wxEmptyString,
-                  pos, wxDefaultSize, style, validator, name);
+    const char *gtkstock = wxStockItemToGTK(stock);
+    if (gtkstock)
+    {
+        m_widget = gtk_button_new_from_stock(gtkstock);
+        return Create(parent, id, wxEmptyString,
+                      pos, wxDefaultSize, style, validator, name);
+    }
+    else
+    {
+        // not supported by this GTK+ version
+        return Create(parent, id, wxGetStockItemLabel(stock),
+                      pos, wxDefaultSize, style, validator, name);
+    }
 #else
     return CreateStock(parent, id, stock, descriptiveLabel,
                        pos, style, validator, name);