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