Implemented checking checkboxes.

This commit is contained in:
Maarten Bent
2016-02-06 17:20:40 +01:00
parent 3b89a3c7c5
commit 7dd65abaf7
2 changed files with 24 additions and 3 deletions

View File

@@ -2579,11 +2579,18 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
if ( IsSingleSel() || !IsHighlighted(current) )
{
HighlightAll( false );
if (IsClickInsideCheckbox(current, x, y))
{
CheckItem(current, !IsItemChecked(current));
}
else
{
HighlightAll(false);
ChangeCurrent(current);
ChangeCurrent(current);
ReverseHighlight(m_current);
ReverseHighlight(m_current);
}
}
else // multi sel & current is highlighted & no mod keys
{
@@ -3739,6 +3746,19 @@ bool wxListMainWindow::IsItemChecked(long item) const
return line->IsChecked();
}
bool wxListMainWindow::IsClickInsideCheckbox(long item, int x, int y)
{
if (HasCheckboxes()) {
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());
return (rr.Contains(wxPoint(x, y)));
}
return false;
}
// ----------------------------------------------------------------------------
// geometry calculation
// ----------------------------------------------------------------------------