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
This commit is contained in:
Paul Cornett 2021-12-22 08:51:52 -08:00
parent 419f899b3d
commit 4eeae960a3

View File

@ -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 );