X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2bfe6731edfca732418012b03438db85b4aa0dd..3508c1432884472f0d24f0f98c0dc75ed35df297:/src/gtk/dataview.cpp?ds=sidebyside diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index ab13937530..297f496801 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -2515,15 +2515,13 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column), } -IMPLEMENT_CLASS(wxDataViewColumn, wxDataViewColumnBase) - #include WX_DEFINE_LIST(wxDataViewColumnList) wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell, unsigned int model_column, int width, - wxAlignment align, int flags ) : - wxDataViewColumnBase( title, cell, model_column, width, align, flags ) + wxAlignment align, int flags ) + : wxDataViewColumnBase( cell, model_column ) { Init( align, flags, width ); @@ -2532,8 +2530,8 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *c wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, unsigned int model_column, int width, - wxAlignment align, int flags ) : - wxDataViewColumnBase( bitmap, cell, model_column, width, align, flags ) + wxAlignment align, int flags ) + : wxDataViewColumnBase( bitmap, cell, model_column ) { Init( align, flags, width ); @@ -2688,8 +2686,16 @@ void wxDataViewColumn::SetSortable( bool sortable ) { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); - gtk_tree_view_column_set_clickable( GTK_TREE_VIEW_COLUMN(m_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 @@ -2698,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 @@ -4014,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) ); @@ -4103,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 ); } @@ -4117,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) ); @@ -4179,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 );