summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
665ec08)
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
- // 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;
bool hoverOverExpander = false;
+ int expanderOffset = 0;
if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
{
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
{
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
wxRect rect( xpos + indent,
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
m_lineHeight, m_lineHeight);
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
if( rect.Contains(x, y) )
{
// So the mouse is over the expander
// notify cell about click
cell->PrepareForItem(model, item, col->GetModelColumn());
// 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
// Report position relative to the cell's custom area, i.e.
// no the entire space as given by the control but the one