Fixes #10556: wxDataViewCtrl keyboard navigation broken in r59379, some internal renaming
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -495,9 +495,10 @@ public:
|
|||||||
void HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column );
|
void HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column );
|
||||||
wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn* column );
|
wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn* column );
|
||||||
|
|
||||||
void Expand( unsigned int row ) { OnExpanding( row ); }
|
void Expand( unsigned int row );
|
||||||
void Collapse( unsigned int row ) { OnCollapsing( row ); }
|
void Collapse( unsigned int row );
|
||||||
bool IsExpanded( unsigned int row ) const;
|
bool IsExpanded( unsigned int row ) const;
|
||||||
|
bool HasChildren( unsigned int row ) const;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
bool EnableDragSource( const wxDataFormat &format );
|
bool EnableDragSource( const wxDataFormat &format );
|
||||||
@@ -518,8 +519,6 @@ private:
|
|||||||
int RecalculateCount();
|
int RecalculateCount();
|
||||||
|
|
||||||
wxDataViewEvent SendExpanderEvent( wxEventType type, const wxDataViewItem & item );
|
wxDataViewEvent SendExpanderEvent( wxEventType type, const wxDataViewItem & item );
|
||||||
void OnExpanding( unsigned int row );
|
|
||||||
void OnCollapsing( unsigned int row );
|
|
||||||
|
|
||||||
wxDataViewTreeNode * FindNode( const wxDataViewItem & item );
|
wxDataViewTreeNode * FindNode( const wxDataViewItem & item );
|
||||||
|
|
||||||
@@ -2908,18 +2907,40 @@ bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
|
|||||||
return node->IsOpen();
|
return node->IsOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxDataViewMainWindow::HasChildren( unsigned int row ) const
|
||||||
|
{
|
||||||
|
if (IsVirtualList())
|
||||||
|
return false;
|
||||||
|
|
||||||
void wxDataViewMainWindow::OnExpanding( unsigned int row )
|
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
|
||||||
|
if (!node)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!node->HasChildren())
|
||||||
|
{
|
||||||
|
delete node;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDataViewMainWindow::Expand( unsigned int row )
|
||||||
{
|
{
|
||||||
if (IsVirtualList())
|
if (IsVirtualList())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
|
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
|
||||||
if( node != NULL )
|
if (!node)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!node->HasChildren())
|
||||||
{
|
{
|
||||||
if( node->HasChildren())
|
delete node;
|
||||||
{
|
return;
|
||||||
if( !node->IsOpen())
|
}
|
||||||
|
|
||||||
|
if (!node->IsOpen())
|
||||||
{
|
{
|
||||||
wxDataViewEvent e =
|
wxDataViewEvent e =
|
||||||
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, node->GetItem());
|
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, node->GetItem());
|
||||||
@@ -2958,23 +2979,9 @@ void wxDataViewMainWindow::OnExpanding( unsigned int row )
|
|||||||
// Send the expanded event
|
// Send the expanded event
|
||||||
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,node->GetItem());
|
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED,node->GetItem());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
// Why should we select the next row here???
|
|
||||||
SelectRow( row, false );
|
|
||||||
SelectRow( row + 1, true );
|
|
||||||
ChangeCurrentRow( row + 1 );
|
|
||||||
SendSelectionChangedEvent( GetItemByRow(row+1));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
delete node;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewMainWindow::OnCollapsing(unsigned int row)
|
void wxDataViewMainWindow::Collapse(unsigned int row)
|
||||||
{
|
{
|
||||||
if (IsVirtualList())
|
if (IsVirtualList())
|
||||||
return;
|
return;
|
||||||
@@ -2983,13 +2990,13 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
|
|||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !node->HasChildren())
|
if (!node->HasChildren())
|
||||||
{
|
{
|
||||||
delete node;
|
delete node;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( node->HasChildren() && node->IsOpen() )
|
if (node->IsOpen())
|
||||||
{
|
{
|
||||||
wxDataViewEvent e =
|
wxDataViewEvent e =
|
||||||
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,node->GetItem());
|
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,node->GetItem());
|
||||||
@@ -3026,7 +3033,7 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
|
|||||||
{
|
{
|
||||||
// if there were no selected items below our node we still need to "fix" the
|
// if there were no selected items below our node we still need to "fix" the
|
||||||
// selection list to adjust for the changing of the row indices.
|
// selection list to adjust for the changing of the row indices.
|
||||||
// We actually do the opposite of what we are doing in OnExpanding().
|
// We actually do the opposite of what we are doing in Expand().
|
||||||
for(unsigned i=0; i<m_selection.size(); ++i)
|
for(unsigned i=0; i<m_selection.size(); ++i)
|
||||||
{
|
{
|
||||||
const unsigned testRow = m_selection[i];
|
const unsigned testRow = m_selection[i];
|
||||||
@@ -3048,21 +3055,6 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
|
|||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
|
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
node = node->GetParent();
|
|
||||||
if( node != NULL )
|
|
||||||
{
|
|
||||||
int parent = GetRowByItem( node->GetItem() );
|
|
||||||
if( parent >= 0 )
|
|
||||||
{
|
|
||||||
SelectRow( row, false);
|
|
||||||
SelectRow(parent , true );
|
|
||||||
ChangeCurrentRow( parent );
|
|
||||||
SendSelectionChangedEvent( node->GetItem() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item )
|
wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item )
|
||||||
@@ -3389,16 +3381,57 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
break;
|
break;
|
||||||
// Add the process for tree expanding/collapsing
|
// Add the process for tree expanding/collapsing
|
||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
OnCollapsing(m_currentRow);
|
{
|
||||||
|
if (IsVirtualList())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow);
|
||||||
|
if (!node)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (node->HasChildren())
|
||||||
|
{
|
||||||
|
Collapse(m_currentRow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxDataViewTreeNode *parent_node = node->GetParent();
|
||||||
|
delete node;
|
||||||
|
if (parent_node)
|
||||||
|
{
|
||||||
|
int parent = GetRowByItem( parent_node->GetItem() );
|
||||||
|
if ( parent >= 0 )
|
||||||
|
{
|
||||||
|
unsigned int row = m_currentRow;
|
||||||
|
SelectRow( row, false);
|
||||||
|
SelectRow( parent, true );
|
||||||
|
ChangeCurrentRow( parent );
|
||||||
|
SendSelectionChangedEvent( parent_node->GetItem() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case WXK_RIGHT:
|
case WXK_RIGHT:
|
||||||
OnExpanding( m_currentRow);
|
{
|
||||||
|
if (!IsExpanded( m_currentRow ))
|
||||||
|
Expand( m_currentRow );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned int row = m_currentRow;
|
||||||
|
SelectRow( row, false );
|
||||||
|
SelectRow( row + 1, true );
|
||||||
|
ChangeCurrentRow( row + 1 );
|
||||||
|
SendSelectionChangedEvent( GetItemByRow(row+1) );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WXK_END:
|
case WXK_END:
|
||||||
|
{
|
||||||
if (!IsEmpty())
|
if (!IsEmpty())
|
||||||
OnArrowChar( GetRowCount() - 1, event );
|
OnArrowChar( GetRowCount() - 1, event );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WXK_HOME:
|
case WXK_HOME:
|
||||||
if (!IsEmpty())
|
if (!IsEmpty())
|
||||||
OnArrowChar( 0, event );
|
OnArrowChar( 0, event );
|
||||||
@@ -3693,9 +3726,9 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
// valid and have children.
|
// valid and have children.
|
||||||
// So we don't need any extra checks.
|
// So we don't need any extra checks.
|
||||||
if( node->IsOpen() )
|
if( node->IsOpen() )
|
||||||
OnCollapsing(current);
|
Collapse(current);
|
||||||
else
|
else
|
||||||
OnExpanding(current);
|
Expand(current);
|
||||||
}
|
}
|
||||||
else if ((event.LeftDown() || simulateClick) && !hoverOverExpander)
|
else if ((event.LeftDown() || simulateClick) && !hoverOverExpander)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user