wxDataViewItem GetPrevItem( wxDataViewCtrl const& aView, wxDataViewItem const& aItem ) { auto prevItem = GetPrevSibling( aView, aItem ); if( !prevItem.IsOk() ) { prevItem = aView.GetModel()->GetParent( aItem ); } else if( aView.IsExpanded( prevItem ) ) { wxDataViewItemArray children; aView.GetModel()->GetChildren( prevItem, children ); prevItem = children[children.size() - 1]; } return prevItem; }
wxDataViewItem GetNextItem( wxDataViewCtrl const& aView, wxDataViewItem const& aItem ) { wxDataViewItem nextItem; if( !aItem.IsOk() ) { // No selection. Select the first. wxDataViewItemArray children; aView.GetModel()->GetChildren( aItem, children ); return children[0]; } if( aView.IsExpanded( aItem ) ) { wxDataViewItemArray children; aView.GetModel()->GetChildren( aItem, children ); nextItem = children[0]; } else { // Walk up levels until we find one that has a next sibling. for( wxDataViewItem walk = aItem; walk.IsOk(); walk = aView.GetModel()->GetParent( walk ) ) { nextItem = GetNextSibling( aView, walk ); if( nextItem.IsOk() ) break; } } return nextItem; }