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
This commit is contained in:
Vadim Zeitlin 2011-08-22 12:13:39 +00:00
parent 665ec08c05
commit 902334c8fa

View File

@ -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