Implemented checking checkboxes.
This commit is contained in:
@@ -850,6 +850,7 @@ private:
|
||||
// Compute the minimal width needed to fully display the column header.
|
||||
int ComputeMinHeaderWidth(const wxListHeaderData* header) const;
|
||||
|
||||
bool IsClickInsideCheckbox(long item, int x, int y);
|
||||
|
||||
// the height of one line using the current font
|
||||
wxCoord m_lineHeight;
|
||||
|
@@ -2578,6 +2578,12 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||
if ( IsSingleSel() || !(cmdModifierDown || event.ShiftDown()) )
|
||||
{
|
||||
if ( IsSingleSel() || !IsHighlighted(current) )
|
||||
{
|
||||
if (IsClickInsideCheckbox(current, x, y))
|
||||
{
|
||||
CheckItem(current, !IsItemChecked(current));
|
||||
}
|
||||
else
|
||||
{
|
||||
HighlightAll(false);
|
||||
|
||||
@@ -2585,6 +2591,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||
|
||||
ReverseHighlight(m_current);
|
||||
}
|
||||
}
|
||||
else // multi sel & current is highlighted & no mod keys
|
||||
{
|
||||
m_lineSelectSingleOnUp = current;
|
||||
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user