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
This commit is contained in:
Paul Cornett
2012-11-06 17:43:34 +00:00
parent 5d2ebe49df
commit 3cc638ed7f

View File

@@ -650,16 +650,28 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
int flags ) int flags )
{ {
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc); wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (drawable == NULL)
return;
if (drawable && (flags & wxCONTROL_SELECTED)) if (flags & wxCONTROL_SELECTED)
{ {
int x_diff = 0; int x_diff = 0;
if (win->GetLayoutDirection() == wxLayout_RightToLeft) if (win->GetLayoutDirection() == wxLayout_RightToLeft)
x_diff = rect.width; 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 // the wxCONTROL_FOCUSED state is deduced
// directly from the m_wxwindow by GTK+ // 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, drawable,
GTK_STATE_SELECTED, GTK_STATE_SELECTED,
GTK_SHADOW_NONE, GTK_SHADOW_NONE,
@@ -670,6 +682,7 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
dc.LogicalToDeviceY(rect.y), dc.LogicalToDeviceY(rect.y),
rect.width, rect.width,
rect.height ); rect.height );
#endif
} }
if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED)) if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))