X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62e9285abaaf4f5d1261434b20b390a4c0486585..2d55af1dfa7fd1cc2df13a6593fd51591cfcfcb1:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index b80eeaf622..2f24a4a993 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -95,7 +95,7 @@ void wxDataViewColumn::Init(int width, wxAlignment align, int flags) m_sort = false; m_sortAscending = true; } - + void wxDataViewColumn::UpdateDisplay() { if (m_owner) @@ -471,6 +471,7 @@ public: void ScrollWindow( int dx, int dy, const wxRect *rect = NULL ); void ScrollTo( int rows, int column ); + unsigned GetCurrentRow() const { return m_currentRow; } bool HasCurrentRow() { return m_currentRow != (unsigned int)-1; } void ChangeCurrentRow( unsigned int row ); @@ -3814,7 +3815,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) else if ( align & wxALIGN_BOTTOM ) rectItem.y += cell_rect.height - size.y; // else: wxALIGN_TOP is the default - } + } } wxPoint pos( event.GetPosition() ); @@ -4145,7 +4146,7 @@ int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const if (column==col) return i; } - + return wxNOT_FOUND; #else // This returns the position in pixels which is not what we want. @@ -4174,6 +4175,24 @@ wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const : 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(row) != oldCurrent ) + { + m_clientArea->ChangeCurrentRow(row); + m_clientArea->RefreshRow(oldCurrent); + m_clientArea->RefreshRow(row); + } +} + // Selection code with wxDataViewItem as parameters wxDataViewItem wxDataViewCtrl::GetSelection() const { @@ -4229,9 +4248,9 @@ void wxDataViewCtrl::Select( const wxDataViewItem & item ) // 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 ); }