X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..4e15d1caa03346c126015019c1fdf093033ef40b:/src/gtk/button.cpp diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 28379ea998..6e496d75bb 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -18,7 +18,10 @@ #include "wx/stockitem.h" +#include #include "wx/gtk/private.h" +#include "wx/gtk/private/gtk2-compat.h" +#include "wx/gtk/private/list.h" // ---------------------------------------------------------------------------- // GTK callbacks @@ -173,7 +176,12 @@ wxSize wxButtonBase::GetDefaultSize() gtk_container_add(GTK_CONTAINER(box), btn); gtk_container_add(GTK_CONTAINER(wnd), box); GtkRequisition req; +#ifdef __WXGTK3__ + gtk_widget_get_preferred_height(btn, NULL, &req.height); + gtk_widget_get_preferred_width_for_height(btn, req.height, NULL, &req.width); +#else gtk_widget_size_request(btn, &req); +#endif gint minwidth, minheight; gtk_widget_style_get(box, @@ -252,13 +260,12 @@ GtkLabel *wxButton::GTKGetLabel() const { GtkWidget* box = gtk_bin_get_child(GTK_BIN(child)); GtkLabel* label = NULL; - GList* list = gtk_container_get_children(GTK_CONTAINER(box)); + wxGtkList list(gtk_container_get_children(GTK_CONTAINER(box))); for (GList* item = list; item; item = item->next) { if (GTK_IS_LABEL(item->data)) label = GTK_LABEL(item->data); } - g_list_free(list); return label; } @@ -269,9 +276,9 @@ GtkLabel *wxButton::GTKGetLabel() const void wxButton::DoApplyWidgetStyle(GtkRcStyle *style) { - gtk_widget_modify_style(m_widget, style); + GTKApplyStyle(m_widget, style); GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget)); - gtk_widget_modify_style(child, style); + GTKApplyStyle(child, style); // for buttons with images, the path to the label is (at least in 2.12) // GtkButton -> GtkAlignment -> GtkHBox -> GtkLabel @@ -280,12 +287,11 @@ void wxButton::DoApplyWidgetStyle(GtkRcStyle *style) GtkWidget* box = gtk_bin_get_child(GTK_BIN(child)); if ( GTK_IS_BOX(box) ) { - GList* list = gtk_container_get_children(GTK_CONTAINER(box)); + wxGtkList list(gtk_container_get_children(GTK_CONTAINER(box))); for (GList* item = list; item; item = item->next) { - gtk_widget_modify_style(GTK_WIDGET(item->data), style); + GTKApplyStyle(GTK_WIDGET(item->data), style); } - g_list_free(list); } } } @@ -296,7 +302,7 @@ wxSize wxButton::DoGetBestSize() const // extra border around it, but we don't want to take it into account in // our size calculations (otherwise the result is visually ugly), so // always return the size of non default button from here - const bool isDefault = gtk_widget_has_default(m_widget); + const bool isDefault = gtk_widget_has_default(m_widget) != 0; if ( isDefault ) { // temporarily unset default flag