Fix computation of the item offset in generic wxDataViewCtrl code.
We need to account for the expander even for the items that don't have children when computing their offset as their parent still does have it, contributing to the total offset. This corrects the fixes of r68836 to also work for the leaf items. Also rename expanderOffset variable to more clear itemOffset. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68960 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3524,23 +3524,22 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
// button) and also determine the offset of the real cell start, skipping
|
// button) and also determine the offset of the real cell start, skipping
|
||||||
// the indentation and the expander itself.
|
// the indentation and the expander itself.
|
||||||
bool hoverOverExpander = false;
|
bool hoverOverExpander = false;
|
||||||
int expanderOffset = 0;
|
int itemOffset = 0;
|
||||||
if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
|
if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
|
||||||
{
|
{
|
||||||
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
|
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
|
||||||
if( node!=NULL && node->HasChildren() )
|
|
||||||
{
|
|
||||||
int indent = node->GetIndentLevel();
|
|
||||||
indent = GetOwner()->GetIndent()*indent;
|
|
||||||
|
|
||||||
|
int indent = node->GetIndentLevel();
|
||||||
|
itemOffset = GetOwner()->GetIndent()*indent;
|
||||||
|
|
||||||
|
if ( node->HasChildren() )
|
||||||
|
{
|
||||||
// we make the rectangle we are looking in a bit bigger than the actual
|
// we make the rectangle we are looking in a bit bigger than the actual
|
||||||
// visual expander so the user can hit that little thing reliably
|
// visual expander so the user can hit that little thing reliably
|
||||||
wxRect rect( xpos + indent,
|
wxRect rect(itemOffset,
|
||||||
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
|
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
|
||||||
m_lineHeight, m_lineHeight);
|
m_lineHeight, m_lineHeight);
|
||||||
|
|
||||||
expanderOffset = indent + m_lineHeight;
|
|
||||||
|
|
||||||
if( rect.Contains(x, y) )
|
if( rect.Contains(x, y) )
|
||||||
{
|
{
|
||||||
// So the mouse is over the expander
|
// So the mouse is over the expander
|
||||||
@@ -3558,6 +3557,10 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
m_underMouse = node;
|
m_underMouse = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Account for the expander as well, even if this item doesn't have it,
|
||||||
|
// its parent does so it still counts for the offset.
|
||||||
|
itemOffset += m_lineHeight;
|
||||||
}
|
}
|
||||||
if (!hoverOverExpander)
|
if (!hoverOverExpander)
|
||||||
{
|
{
|
||||||
@@ -3832,9 +3835,9 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
// notify cell about click
|
// notify cell about click
|
||||||
cell->PrepareForItem(model, item, col->GetModelColumn());
|
cell->PrepareForItem(model, item, col->GetModelColumn());
|
||||||
|
|
||||||
wxRect cell_rect( xpos + expanderOffset,
|
wxRect cell_rect( xpos + itemOffset,
|
||||||
GetLineStart( current ),
|
GetLineStart( current ),
|
||||||
col->GetWidth() - expanderOffset,
|
col->GetWidth() - itemOffset,
|
||||||
GetLineHeight( current ) );
|
GetLineHeight( current ) );
|
||||||
|
|
||||||
// Report position relative to the cell's custom area, i.e.
|
// Report position relative to the cell's custom area, i.e.
|
||||||
|
Reference in New Issue
Block a user