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:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user