X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5179bc0bca526f0297d8930838ad4112faa967cd..3508c1432884472f0d24f0f98c0dc75ed35df297:/src/generic/datavgen.cpp?ds=sidebyside diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 3f3a3052cd..32691b07ab 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -91,7 +91,7 @@ public: protected: // implement/override wxHeaderCtrl functions by forwarding them to the main // control - virtual wxHeaderColumn& GetColumn(unsigned int idx) + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const { return *(GetOwner()->GetColumn(idx)); } @@ -2423,7 +2423,10 @@ bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const return false; if (!node->HasChildren()) + { + delete node; return false; + } return node->IsOpen(); } @@ -2805,7 +2808,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) { case WXK_RETURN: { - if (m_currentRow > 0) + if (m_currentRow >= 0) { wxWindow *parent = GetParent(); wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, parent->GetId()); @@ -3038,6 +3041,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // select single line SelectAllRows( false ); SelectRow( m_lineSelectSingleOnUp, true ); + SendSelectionChangedEvent( GetItemByRow(m_lineSelectSingleOnUp) ); } //Process the event of user clicking the expander @@ -3523,18 +3527,33 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) { wxDataViewSelection selection(wxDataViewSelectionCmp); + + wxDataViewItem last_parent; + int len = sel.GetCount(); for( int i = 0; i < len; i ++ ) { - int row = m_clientArea->GetRowByItem( sel[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(row) ); } + m_clientArea->SetSelections( selection ); } void wxDataViewCtrl::Select( const wxDataViewItem & item ) { + ExpandAncestors( item ); + int row = m_clientArea->GetRowByItem( item ); if( row >= 0 ) { @@ -3658,6 +3677,10 @@ void wxDataViewCtrl::EnsureVisible( int row, int column ) void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column ) { + ExpandAncestors( item ); + + m_clientArea->RecalculateDisplay(); + int row = m_clientArea->GetRowByItem(item); if( row >= 0 ) {