From 3cc638ed7f1c7f114a6683714567d90f0ba9ded2 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 6 Nov 2012 17:43:34 +0000 Subject: [PATCH] add GTK3-specific code for DrawItemSelectionRect(), fixes drawing selected tree control item git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/renderer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gtk/renderer.cpp b/src/gtk/renderer.cpp index b65721598c..2254c5ecdf 100644 --- a/src/gtk/renderer.cpp +++ b/src/gtk/renderer.cpp @@ -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)) -- 2.49.0