From c70ad28733bce16ad4a0c8a7515a2ddda88a86ef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Jul 2010 10:43:39 +0000 Subject: [PATCH] Don't use tree style to draw focus in DrawItemSelectionRect() in wxGTK. Using gtk_paint_focus() with a tree widget style did a clearly wrong thing with Clearlooks theme: instead of drawing a focus rectangle it drew a background with a shadow overflowing the specified rectangle. This resulted in junk being left when the selection was changing in wx{List,Tree}Ctrl. Just use the widgets own style instead as this seems to work just fine. After this change the code for focus drawing in DrawItemSelectionRect() became identical to the code of DrawFocusRect() so just call the latter from the former instead of duplicating its code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64878 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/renderer.cpp | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/src/gtk/renderer.cpp b/src/gtk/renderer.cpp index 9889c5e4da..8fff4abf1d 100644 --- a/src/gtk/renderer.cpp +++ b/src/gtk/renderer.cpp @@ -530,27 +530,21 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win, const wxRect& rect, int flags ) { - GtkWidget *tree = wxGTKPrivate::GetTreeWidget(); - GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc); wxASSERT_MSG( gdk_window, wxT("cannot use wxRendererNative on wxDC of this type") ); - int x_diff = 0; - if (win->GetLayoutDirection() == wxLayout_RightToLeft) - x_diff = rect.width; - - GtkStateType state = GTK_STATE_NORMAL; - if (flags & wxCONTROL_SELECTED) { + int x_diff = 0; + if (win->GetLayoutDirection() == wxLayout_RightToLeft) + x_diff = rect.width; + // the wxCONTROL_FOCUSED state is deduced // directly from the m_wxwindow by GTK+ - state = GTK_STATE_SELECTED; - - gtk_paint_flat_box( tree->style, // win->m_widget->style, + gtk_paint_flat_box(wxGTKPrivate::GetTreeWidget()->style, gdk_window, - state, + GTK_STATE_SELECTED, GTK_SHADOW_NONE, NULL, win->m_wxwindow, @@ -560,32 +554,9 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win, rect.width, rect.height ); } - else // !wxCONTROL_SELECTED - { - state = GTK_STATE_NORMAL; - } if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED)) - { - if (flags & wxCONTROL_SELECTED) - state = GTK_STATE_SELECTED; - - gtk_paint_focus( tree->style, - gdk_window, - state, - NULL, - win->m_wxwindow, - // Detail "treeview" causes warning with GTK+ 2.12 Clearlooks theme: - // "... no property named `row-ending-details'" - // Using "treeview-middle" would fix the warning, but the right - // edge of the focus rect is not getting erased properly either. - // Better to not specify this detail unless the drawing is fixed. - "", - dc.LogicalToDeviceX(rect.x), - dc.LogicalToDeviceY(rect.y), - rect.width, - rect.height ); - } + DrawFocusRect(win, dc, rect, flags); } void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)