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);
|
wxDataViewTreeNode *node = GetTreeNodeByRow(row);
|
||||||
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
|
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
|
||||||
indent = indent + m_lineHeight;
|
indent += wxRendererNative::Get().GetExpanderSize(this).GetWidth();
|
||||||
// try to use the m_lineHeight as the expander space
|
|
||||||
}
|
}
|
||||||
width -= indent;
|
width -= indent;
|
||||||
|
|
||||||
@@ -3879,7 +3878,7 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item,
|
|||||||
{
|
{
|
||||||
wxDataViewTreeNode* node = GetTreeNodeByRow(row);
|
wxDataViewTreeNode* node = GetTreeNodeByRow(row);
|
||||||
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
|
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,
|
wxRect itemRect( xpos + indent,
|
||||||
@@ -4708,6 +4707,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
|
|
||||||
int indent = node->GetIndentLevel();
|
int indent = node->GetIndentLevel();
|
||||||
itemOffset = GetOwner()->GetIndent()*indent;
|
itemOffset = GetOwner()->GetIndent()*indent;
|
||||||
|
const int expWidth = wxRendererNative::Get().GetExpanderSize(this).GetWidth();
|
||||||
|
|
||||||
if ( node->HasChildren() )
|
if ( node->HasChildren() )
|
||||||
{
|
{
|
||||||
@@ -4715,7 +4715,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
// 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 + itemOffset,
|
wxRect rect(xpos + itemOffset,
|
||||||
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
|
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
|
||||||
m_lineHeight, m_lineHeight);
|
expWidth, m_lineHeight);
|
||||||
|
|
||||||
if( rect.Contains(x, y) )
|
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,
|
// Account for the expander as well, even if this item doesn't have it,
|
||||||
// its parent does so it still counts for the offset.
|
// its parent does so it still counts for the offset.
|
||||||
itemOffset += m_lineHeight;
|
itemOffset += expWidth;
|
||||||
}
|
}
|
||||||
if (!hoverOverExpander)
|
if (!hoverOverExpander)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user