+}
+
+wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const
+{
+ return m_sortingColumnIdx == wxNOT_FOUND ? NULL
+ : GetColumn(m_sortingColumnIdx);
+}
+
+wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const
+{
+ return GetItemByRow(m_clientArea->GetCurrentRow());
+}
+
+void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
+{
+ const int row = m_clientArea->GetRowByItem(item);
+
+ const unsigned oldCurrent = m_clientArea->GetCurrentRow();
+ if ( static_cast<unsigned>(row) != oldCurrent )
+ {
+ m_clientArea->ChangeCurrentRow(row);
+ m_clientArea->RefreshRow(oldCurrent);
+ m_clientArea->RefreshRow(row);
+ }
+}
+
+// Selection code with wxDataViewItem as parameters
+wxDataViewItem wxDataViewCtrl::GetSelection() const
+{
+ return m_clientArea->GetSelection();
+}
+
+int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
+{
+ sel.Empty();
+ wxDataViewSelection selection = m_clientArea->GetSelections();
+
+ const size_t len = selection.size();
+ for ( size_t i = 0; i < len; i++ )
+ {
+ wxDataViewItem item = m_clientArea->GetItemByRow(selection[i]);
+ if ( item.IsOk() )
+ {
+ sel.Add(item);
+ }
+ else
+ {
+ wxFAIL_MSG( "invalid item in selection - bad internal state" );
+ }
+ }
+
+ return sel.size();
+}
+
+void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
+{
+ wxDataViewSelection selection(wxDataViewSelectionCmp);
+
+ wxDataViewItem last_parent;
+
+ int len = sel.GetCount();
+ for( int i = 0; i < len; i ++ )
+ {
+ wxDataViewItem item = sel[i];
+ wxDataViewItem parent = GetModel()->GetParent( item );
+ if (parent)
+ {
+ if (parent != last_parent)
+ ExpandAncestors(item);
+ }
+
+ last_parent = parent;
+ int row = m_clientArea->GetRowByItem( item );
+ if( row >= 0 )
+ selection.Add( static_cast<unsigned int>(row) );
+ }
+
+ m_clientArea->SetSelections( selection );
+}
+
+void wxDataViewCtrl::Select( const wxDataViewItem & item )
+{
+ ExpandAncestors( item );
+
+ int row = m_clientArea->GetRowByItem( item );
+ if( row >= 0 )
+ {
+ // Unselect all rows before select another in the single select mode
+ if (m_clientArea->IsSingleSel())
+ m_clientArea->SelectAllRows(false);
+
+ m_clientArea->SelectRow(row, true);
+
+ // Also set focus to the selected item
+ m_clientArea->ChangeCurrentRow( row );
+ }
+}
+
+void wxDataViewCtrl::Unselect( const wxDataViewItem & item )
+{
+ int row = m_clientArea->GetRowByItem( item );
+ if( row >= 0 )
+ m_clientArea->SelectRow(row, false);
+}
+
+bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
+{
+ int row = m_clientArea->GetRowByItem( item );
+ if( row >= 0 )
+ {
+ return m_clientArea->IsRowSelected(row);
+ }
+ return false;
+}
+
+void wxDataViewCtrl::SelectAll()
+{
+ m_clientArea->SelectAllRows(true);
+}
+
+void wxDataViewCtrl::UnselectAll()
+{
+ m_clientArea->SelectAllRows(false);
+}
+
+void wxDataViewCtrl::EnsureVisible( int row, int column )
+{
+ if( row < 0 )
+ row = 0;
+ if( row > (int) m_clientArea->GetRowCount() )
+ row = m_clientArea->GetRowCount();
+
+ int first = m_clientArea->GetFirstVisibleRow();
+ int last = m_clientArea->GetLastVisibleRow();
+ if( row < first )
+ m_clientArea->ScrollTo( row, column );
+ else if( row > last )
+ m_clientArea->ScrollTo( row - last + first, column );
+ else
+ m_clientArea->ScrollTo( first, column );
+}
+
+void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column )
+{
+ ExpandAncestors( item );
+
+ m_clientArea->RecalculateDisplay();
+
+ int row = m_clientArea->GetRowByItem(item);
+ if( row >= 0 )
+ {
+ if( column == NULL )
+ EnsureVisible(row, -1);
+ else
+ EnsureVisible( row, GetColumnIndex(column) );
+ }
+
+}
+
+void wxDataViewCtrl::HitTest( const wxPoint & point, wxDataViewItem & item,
+ wxDataViewColumn* &column ) const
+{
+ m_clientArea->HitTest(point, item, column);
+}
+
+wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item,
+ const wxDataViewColumn* column ) const
+{
+ return m_clientArea->GetItemRect(item, column);
+}
+
+wxDataViewItem wxDataViewCtrl::GetItemByRow( unsigned int row ) const
+{
+ return m_clientArea->GetItemByRow( row );
+}
+
+int wxDataViewCtrl::GetRowByItem( const wxDataViewItem & item ) const
+{
+ return m_clientArea->GetRowByItem( item );
+}
+
+void wxDataViewCtrl::Expand( const wxDataViewItem & item )
+{
+ ExpandAncestors( item );
+
+ int row = m_clientArea->GetRowByItem( item );
+ if (row != -1)
+ m_clientArea->Expand(row);
+}
+
+void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
+{
+ int row = m_clientArea->GetRowByItem( item );
+ if (row != -1)
+ m_clientArea->Collapse(row);
+}
+
+bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
+{
+ int row = m_clientArea->GetRowByItem( item );
+ if (row != -1)
+ return m_clientArea->IsExpanded(row);
+ return false;
+}
+
+void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column )
+{
+ wxDataViewColumn* col = GetColumn( column );
+ if (!col)
+ return;
+
+ wxRect itemRect = GetItemRect(item, col);
+ wxDataViewRenderer* renderer = col->GetRenderer();
+ if (renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE)
+ renderer->StartEditing(item, itemRect);
+}
+
+#endif // !wxUSE_GENERICDATAVIEWCTRL
+
+#endif // wxUSE_DATAVIEWCTRL