]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/control.cpp
Disable wxUSE_ENH_METAFILE for wxGTK builds.
[wxWidgets.git] / src / gtk / control.cpp
index ff33e9af473f1d14dfd561c06b8d72f3e90f85cf..705da6fa502eba15a9843910cada8371965b582a 100644 (file)
@@ -105,7 +105,6 @@ void wxControl::PostCreation(const wxSize& size)
     gtk_widget_ensure_style(m_widget);
 #endif
 
-    GTKApplyWidgetStyle();
     SetInitialSize(size);
 }
 
@@ -234,6 +233,14 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
                                              int state)
 {
     wxVisualAttributes attr;
+
+    GtkWidget* tlw = NULL;
+    if (gtk_widget_get_parent(widget) == NULL)
+    {
+        tlw = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+        gtk_container_add(GTK_CONTAINER(tlw), widget);
+    }
+
 #ifdef __WXGTK3__
     GtkStateFlags stateFlag = GTK_STATE_FLAG_NORMAL;
     if (state)
@@ -258,29 +265,30 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
     if (!style)
         style = gtk_widget_get_default_style();
 
-    if (!style)
+    if (style)
     {
-        return wxWindow::GetClassDefaultAttributes(wxWINDOW_VARIANT_NORMAL);
-    }
-
-    // get the style's colours
-    attr.colFg = wxColour(style->fg[state]);
-    if (useBase)
-        attr.colBg = wxColour(style->base[state]);
-    else
-        attr.colBg = wxColour(style->bg[state]);
+        // get the style's colours
+        attr.colFg = wxColour(style->fg[state]);
+        if (useBase)
+            attr.colBg = wxColour(style->base[state]);
+        else
+            attr.colBg = wxColour(style->bg[state]);
 
-    // get the style's font
-    if ( !style->font_desc )
-        style = gtk_widget_get_default_style();
-    if ( style && style->font_desc )
-    {
-        wxNativeFontInfo info;
-        info.description = style->font_desc;
-        attr.font = wxFont(info);
-        info.description = NULL;
+        // get the style's font
+        if (!style->font_desc)
+            style = gtk_widget_get_default_style();
+        if (style && style->font_desc)
+        {
+            wxNativeFontInfo info;
+            info.description = style->font_desc;
+            attr.font = wxFont(info);
+            info.description = NULL;
+        }
     }
+    else
+        attr = wxWindow::GetClassDefaultAttributes(wxWINDOW_VARIANT_NORMAL);
 #endif
+
     if (!attr.font.IsOk())
     {
         GtkSettings *settings = gtk_settings_get_default();
@@ -296,56 +304,9 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
         g_free (font_name);
     }
 
-    return attr;
-}
-
-
-//static
-wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t widget_new,
-                                             bool useBase,
-                                             int state)
-{
-    wxVisualAttributes attr;
-    // NB: we need toplevel window so that GTK+ can find the right style
-    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    GtkWidget* widget = widget_new();
-    gtk_container_add(GTK_CONTAINER(wnd), widget);
-    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(wnd);
-    return attr;
-}
-
-//static
-wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t widget_new,
-                                             bool useBase,
-                                             int state)
-{
-    wxVisualAttributes attr;
-    // NB: we need toplevel window so that GTK+ can find the right style
-    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    GtkWidget* widget = widget_new("");
-    gtk_container_add(GTK_CONTAINER(wnd), widget);
-    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(wnd);
-    return attr;
-}
+    if (tlw)
+        gtk_widget_destroy(tlw);
 
-
-//static
-wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t widget_new,
-                                             bool useBase,
-                                             int state)
-{
-    wxVisualAttributes attr;
-    // NB: we need toplevel window so that GTK+ can find the right style
-    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    GtkWidget* widget = widget_new(NULL);
-    gtk_container_add(GTK_CONTAINER(wnd), widget);
-    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(wnd);
     return attr;
 }
 
@@ -355,16 +316,7 @@ wxSize wxControl::GTKGetPreferredSize(GtkWidget* widget) const
 {
     GtkRequisition req;
 #ifdef __WXGTK3__
-    if (gtk_widget_get_request_mode(widget) != GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
-    {
-        gtk_widget_get_preferred_height(widget, NULL, &req.height);
-        gtk_widget_get_preferred_width_for_height(widget, req.height, NULL, &req.width);
-    }
-    else
-    {
-        gtk_widget_get_preferred_width(widget, NULL, &req.width);
-        gtk_widget_get_preferred_height_for_width(widget, req.width, NULL, &req.height);
-    }
+    gtk_widget_get_preferred_size(widget, NULL, &req);
 #else
     GTK_WIDGET_GET_CLASS(widget)->size_request(widget, &req);
 #endif