]> git.saurik.com Git - wxWidgets.git/commitdiff
add GTK3-specific code for DrawItemSelectionRect(), fixes drawing selected tree contr...
authorPaul Cornett <paulcor@bullseye.com>
Tue, 6 Nov 2012 17:43:34 +0000 (17:43 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Tue, 6 Nov 2012 17:43:34 +0000 (17:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/renderer.cpp

index b65721598ccc31df1fc83cd5b1d4383aab59c622..2254c5ecdf14884e39ad5966697a39748c1560d1 100644 (file)
@@ -650,16 +650,28 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
                                      int flags )
 {
     wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+    if (drawable == NULL)
+        return;
 
-    if (drawable && (flags & wxCONTROL_SELECTED))
+    if (flags & wxCONTROL_SELECTED)
     {
         int x_diff = 0;
         if (win->GetLayoutDirection() == wxLayout_RightToLeft)
             x_diff = rect.width;
 
+        GtkWidget* treeWidget = wxGTKPrivate::GetTreeWidget();
+
+#ifdef __WXGTK3__
+        GtkStyleContext* sc = gtk_widget_get_style_context(treeWidget);
+        gtk_style_context_save(sc);
+        gtk_style_context_set_state(sc, GTK_STATE_FLAG_SELECTED);
+        gtk_style_context_add_class(sc, GTK_STYLE_CLASS_CELL);
+        gtk_render_background(sc, drawable, rect.x - x_diff, rect.y, rect.width, rect.height);
+        gtk_style_context_restore(sc);
+#else
         // the wxCONTROL_FOCUSED state is deduced
         // directly from the m_wxwindow by GTK+
-        gtk_paint_flat_box(gtk_widget_get_style(wxGTKPrivate::GetTreeWidget()),
+        gtk_paint_flat_box(gtk_widget_get_style(treeWidget),
                         drawable,
                         GTK_STATE_SELECTED,
                         GTK_SHADOW_NONE,
@@ -670,6 +682,7 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
                         dc.LogicalToDeviceY(rect.y),
                         rect.width,
                         rect.height );
+#endif
     }
 
     if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))