Fix the width of expander in wxDataViewCtrl

In 8f386265dc, 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.
This commit is contained in:
wangqr
2019-08-25 21:34:58 -04:00
committed by Vadim Zeitlin
parent 83134174fa
commit 0ea4366163

View File

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