From 0ea4366163cb7ff02e3cdc7a8c0513a8036a9f80 Mon Sep 17 00:00:00 2001 From: wangqr Date: Sun, 25 Aug 2019 21:34:58 -0400 Subject: [PATCH] Fix the width of expander in wxDataViewCtrl In 8f386265dc0db1b96d435c83cd1aaca5c2e9cdaa, the width of a tree expander is changed to the native value on the platform. But some calculations still use guessed value (m_lineHeight) as the width. This fixes the value, by retrieving the width using the same method as in OnPaint(). Closes https://github.com/wxWidgets/wxWidgets/pull/1508 Closes #18473. --- src/generic/datavgen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 0a2d50c8c2..dcb6792ca5 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2153,8 +2153,7 @@ wxBitmap wxDataViewMainWindow::CreateItemBitmap( unsigned int row, int &indent ) { wxDataViewTreeNode *node = GetTreeNodeByRow(row); indent = GetOwner()->GetIndent() * node->GetIndentLevel(); - indent = indent + m_lineHeight; - // try to use the m_lineHeight as the expander space + indent += wxRendererNative::Get().GetExpanderSize(this).GetWidth(); } width -= indent; @@ -3879,7 +3878,7 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, { wxDataViewTreeNode* node = GetTreeNodeByRow(row); indent = GetOwner()->GetIndent() * node->GetIndentLevel(); - indent = indent + m_lineHeight; // use m_lineHeight as the width of the expander + indent += wxRendererNative::Get().GetExpanderSize(this).GetWidth(); } wxRect itemRect( xpos + indent, @@ -4708,6 +4707,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) int indent = node->GetIndentLevel(); itemOffset = GetOwner()->GetIndent()*indent; + const int expWidth = wxRendererNative::Get().GetExpanderSize(this).GetWidth(); if ( node->HasChildren() ) { @@ -4715,7 +4715,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // visual expander so the user can hit that little thing reliably wxRect rect(xpos + itemOffset, GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2, - m_lineHeight, m_lineHeight); + expWidth, m_lineHeight); if( rect.Contains(x, y) ) { @@ -4737,7 +4737,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // 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; + itemOffset += expWidth; } if (!hoverOverExpander) {