From dedda75b3a82ebd7dfe2683e08a63af8de9db0a0 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 6 Feb 2016 18:54:08 +0100 Subject: [PATCH] Fixed checking with multiple-selection enabled, added left offset. --- src/generic/listctrl.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a5818503fa..61eaf730ee 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -103,7 +103,7 @@ static const int IMAGE_MARGIN_IN_REPORT_MODE = 5; static const int HEADER_IMAGE_MARGIN_IN_REPORT_MODE = 2; // space after a checkbox -static const int MARGIN_AFTER_CHECKBOX = 5; +static const int MARGIN_AROUND_CHECKBOX = 5; // ---------------------------------------------------------------------------- @@ -801,13 +801,14 @@ void wxListLineData::DrawInReportMode( wxDC *dc, wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(m_owner); int yOffset = (rect.height - cbSize.GetHeight()) / 2; wxRect rr(x, rect.y + yOffset, cbSize.GetWidth(), cbSize.GetHeight()); + rr.x += MARGIN_AROUND_CHECKBOX; int flags = 0; if (m_checked) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(m_owner, *dc, rr, flags); - x += cbSize.GetWidth() + MARGIN_AFTER_CHECKBOX; + x += cbSize.GetWidth() + (2 * MARGIN_AROUND_CHECKBOX); } size_t col = 0; @@ -2577,20 +2578,17 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) bool cmdModifierDown = event.CmdDown(); if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) ) { - if ( IsSingleSel() || !IsHighlighted(current) ) + if (IsClickInsideCheckbox(current, x, y)) { - if (IsClickInsideCheckbox(current, x, y)) - { - CheckItem(current, !IsItemChecked(current)); - } - else - { - HighlightAll(false); + CheckItem(current, !IsItemChecked(current)); + } + else if (IsSingleSel() || !IsHighlighted(current)) + { + HighlightAll(false); - ChangeCurrent(current); + ChangeCurrent(current); - ReverseHighlight(m_current); - } + ReverseHighlight(m_current); } else // multi sel & current is highlighted & no mod keys { @@ -3743,7 +3741,7 @@ bool wxListMainWindow::IsClickInsideCheckbox(long item, int x, int y) wxRect lineRect = GetLineRect(item); wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(this); int yOffset = (lineRect.height - cbSize.GetHeight()) / 2; - wxRect rr(0, lineRect.y + yOffset, cbSize.GetWidth(), cbSize.GetHeight()); + wxRect rr(MARGIN_AROUND_CHECKBOX, lineRect.y + yOffset, cbSize.GetWidth(), cbSize.GetHeight()); return (rr.Contains(wxPoint(x, y))); }