From 902334c8fac2e7fb7b54170315ff027530c4567b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Aug 2011 12:13:39 +0000 Subject: [PATCH] Fix the coordinates in wxDataViewCustomRenderer::LeftClick() in generic wxDVC. The code in generic wxDataViewCtrl implementation didn't take the space taken by tree expander button nor the indentation of child nodes into account, so the coordinates passed to LeftClick() could be completely wrong. Fix this by offsetting them to ensure that click coordinates are always relative to the cell client area. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 650060a5a7..af9e477cb7 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3584,8 +3584,11 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) return; } - // Test whether the mouse is hovered on the tree item button + // Test whether the mouse is hovering over the expander (a.k.a tree "+" + // button) and also determine the offset of the real cell start, skipping + // the indentation and the expander itself. bool hoverOverExpander = false; + int expanderOffset = 0; if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col)) { wxDataViewTreeNode * node = GetTreeNodeByRow(current); @@ -3599,6 +3602,9 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) wxRect rect( xpos + indent, GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2, m_lineHeight, m_lineHeight); + + expanderOffset = indent + m_lineHeight; + if( rect.Contains(x, y) ) { // So the mouse is over the expander @@ -3889,8 +3895,10 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // notify cell about click cell->PrepareForItem(model, item, col->GetModelColumn()); - wxRect cell_rect( xpos, GetLineStart( current ), - col->GetWidth(), GetLineHeight( current ) ); + wxRect cell_rect( xpos + expanderOffset, + GetLineStart( current ), + col->GetWidth() - expanderOffset, + GetLineHeight( current ) ); // Report position relative to the cell's custom area, i.e. // no the entire space as given by the control but the one -- 2.45.2