X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/835d0d55c1fe46b5a18493e70060b0afd1d75e95..54f11060867c4c97ebbe7954353f5c311262fc4b:/src/gtk/dataview.cpp?ds=sidebyside diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 52b0a5e05d..297f496801 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -2686,7 +2686,16 @@ void wxDataViewColumn::SetSortable( bool sortable ) { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - gtk_tree_view_column_set_clickable( column, sortable ); + if ( sortable ) + { + gtk_tree_view_column_set_sort_column_id( column, GetModelColumn() ); + } + else + { + gtk_tree_view_column_set_sort_column_id( column, -1 ); + gtk_tree_view_column_set_sort_indicator( column, FALSE ); + gtk_tree_view_column_set_clickable( column, FALSE ); + } } bool wxDataViewColumn::IsSortable() const @@ -2695,25 +2704,18 @@ bool wxDataViewColumn::IsSortable() const return gtk_tree_view_column_get_clickable( column ); } -void wxDataViewColumn::SetAsSortKey( bool sort ) +void wxDataViewColumn::SetAsSortKey( bool WXUNUSED(sort) ) { - GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - - if (sort) - { - gtk_tree_view_column_set_sort_column_id( column, GetModelColumn() ); - } - else - { - gtk_tree_view_column_set_sort_column_id( column, -1 ); - gtk_tree_view_column_set_sort_indicator( column, FALSE ); - } + // it might not make sense to have this function in wxHeaderColumn at + // all in fact, changing of the sort order should only be done using the + // associated control API + wxFAIL_MSG( "not implemented" ); } bool wxDataViewColumn::IsSortKey() const { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - return (gtk_tree_view_column_get_sort_column_id( column ) != -1); + return gtk_tree_view_column_get_sort_indicator( column ); } bool wxDataViewColumn::IsResizeable() const @@ -4011,6 +4013,17 @@ void wxDataViewCtrl::Collapse( const wxDataViewItem & item ) gtk_tree_path_free( path ); } +bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const +{ + GtkTreeIter iter; + iter.user_data = item.GetID(); + GtkTreePath *path = m_internal->get_path( &iter ); + bool res = gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path ); + gtk_tree_path_free( path ); + + return res; +} + wxDataViewItem wxDataViewCtrl::GetSelection() const { GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) ); @@ -4100,12 +4113,23 @@ void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) gtk_tree_selection_unselect_all( selection ); + wxDataViewItem last_parent; + size_t i; for (i = 0; i < sel.GetCount(); i++) { + wxDataViewItem item = sel[i]; + wxDataViewItem parent = GetModel()->GetParent( item ); + if (parent) + { + if (parent != last_parent) + ExpandAncestors(item); + } + last_parent = parent; + GtkTreeIter iter; iter.stamp = m_internal->GetGtkModel()->stamp; - iter.user_data = (gpointer) sel[i].GetID(); + iter.user_data = (gpointer) item.GetID(); gtk_tree_selection_select_iter( selection, &iter ); } @@ -4114,6 +4138,8 @@ void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) void wxDataViewCtrl::Select( const wxDataViewItem & item ) { + ExpandAncestors(item); + GtkDisableSelectionEvents(); GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) ); @@ -4176,6 +4202,8 @@ void wxDataViewCtrl::UnselectAll() void wxDataViewCtrl::EnsureVisible(const wxDataViewItem& item, const wxDataViewColumn *WXUNUSED(column)) { + ExpandAncestors(item); + GtkTreeIter iter; iter.user_data = (gpointer) item.GetID(); GtkTreePath *path = m_internal->get_path( &iter );