Fixed checking with multiple-selection enabled, added left offset.

This commit is contained in:
Maarten Bent
2016-02-06 18:54:08 +01:00
parent 9301692b68
commit dedda75b3a

View File

@@ -103,7 +103,7 @@ static const int IMAGE_MARGIN_IN_REPORT_MODE = 5;
static const int HEADER_IMAGE_MARGIN_IN_REPORT_MODE = 2; static const int HEADER_IMAGE_MARGIN_IN_REPORT_MODE = 2;
// space after a checkbox // 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); wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(m_owner);
int yOffset = (rect.height - cbSize.GetHeight()) / 2; int yOffset = (rect.height - cbSize.GetHeight()) / 2;
wxRect rr(x, rect.y + yOffset, cbSize.GetWidth(), cbSize.GetHeight()); wxRect rr(x, rect.y + yOffset, cbSize.GetWidth(), cbSize.GetHeight());
rr.x += MARGIN_AROUND_CHECKBOX;
int flags = 0; int flags = 0;
if (m_checked) if (m_checked)
flags |= wxCONTROL_CHECKED; flags |= wxCONTROL_CHECKED;
wxRendererNative::Get().DrawCheckBox(m_owner, *dc, rr, flags); 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; size_t col = 0;
@@ -2576,14 +2577,12 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
bool cmdModifierDown = event.CmdDown(); bool cmdModifierDown = event.CmdDown();
if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) ) if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) )
{
if ( IsSingleSel() || !IsHighlighted(current) )
{ {
if (IsClickInsideCheckbox(current, x, y)) if (IsClickInsideCheckbox(current, x, y))
{ {
CheckItem(current, !IsItemChecked(current)); CheckItem(current, !IsItemChecked(current));
} }
else else if (IsSingleSel() || !IsHighlighted(current))
{ {
HighlightAll(false); HighlightAll(false);
@@ -2591,7 +2590,6 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
ReverseHighlight(m_current); ReverseHighlight(m_current);
} }
}
else // multi sel & current is highlighted & no mod keys else // multi sel & current is highlighted & no mod keys
{ {
m_lineSelectSingleOnUp = current; m_lineSelectSingleOnUp = current;
@@ -3743,7 +3741,7 @@ bool wxListMainWindow::IsClickInsideCheckbox(long item, int x, int y)
wxRect lineRect = GetLineRect(item); wxRect lineRect = GetLineRect(item);
wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(this); wxSize cbSize = wxRendererNative::Get().GetCheckBoxSize(this);
int yOffset = (lineRect.height - cbSize.GetHeight()) / 2; 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))); return (rr.Contains(wxPoint(x, y)));
} }