From 4eeae960a3c54f0007f5cc87af56af615154cfe6 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 22 Dec 2021 08:51:52 -0800 Subject: [PATCH] Avoid drawing selection rectangle when not selected The draw used wxTRANSPARENT_BRUSH in that case, so it was a no-op, but better to not do it at all --- src/msw/renderer.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index 260a8cfd81..96b6d0e689 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -363,26 +363,18 @@ void wxRendererMSWBase::DrawItemSelectionRect(wxWindow *win, return; } - wxBrush brush; if ( flags & wxCONTROL_SELECTED ) { - if ( flags & wxCONTROL_FOCUSED ) + wxColour color(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + if ((flags & wxCONTROL_FOCUSED) == 0) { - brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + color = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); } - else // !focused - { - brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - } - } - else // !selected - { - brush = *wxTRANSPARENT_BRUSH; - } - wxDCBrushChanger setBrush(dc, brush); - wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN); - dc.DrawRectangle( rect ); + wxDCBrushChanger setBrush(dc, wxBrush(color)); + wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN); + dc.DrawRectangle(rect); + } if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT)) DrawFocusRect( win, dc, rect, flags );