void SetSortColumn( int column ) { m_sort_column = column; }
int GetSortColumn() { return m_sort_column; }
+ void SetDataViewSortColumn( wxDataViewColumn *column ) { m_dataview_sort_column = column; }
+ wxDataViewColumn *GetDataViewSortColumn() { return m_dataview_sort_column; }
+
bool IsSorted() { return (m_sort_column >= 0); }
GtkWxTreeModel *m_gtk_model;
wxDataViewCtrl *m_owner;
GtkSortType m_sort_order;
+ wxDataViewColumn *m_dataview_sort_column;
int m_sort_column;
};
return TRUE;
}
+wxDataViewColumn *gs_lastLeftClickHeader = NULL;
+
void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable *sortable,
gint sort_column_id,
GtkSortType order)
GtkWxTreeModel *tree_model = (GtkWxTreeModel *) sortable;
g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable) );
- if ((sort_column_id == (gint) tree_model->internal->GetSortColumn()) &&
- (order == tree_model->internal->GetSortOrder()))
- return;
-
- tree_model->internal->SetSortColumn( sort_column_id );
+ tree_model->internal->SetDataViewSortColumn( gs_lastLeftClickHeader );
- tree_model->internal->SetSortOrder( order );
+ if ((sort_column_id != (gint) tree_model->internal->GetSortColumn()) ||
+ (order != tree_model->internal->GetSortOrder()))
+ {
+ tree_model->internal->SetSortColumn( sort_column_id );
+ tree_model->internal->SetSortOrder( order );
- gtk_tree_sortable_sort_column_changed (sortable);
+ gtk_tree_sortable_sort_column_changed (sortable);
- tree_model->internal->GetDataViewModel()->Resort();
+ tree_model->internal->GetDataViewModel()->Resort();
+ }
- wxDataViewCtrl *dv = tree_model->internal->GetOwner();
- wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, dv->GetId() );
- // TODO event.SetDataViewColumn( column );
- event.SetModel( dv->GetModel() );
- dv->GetEventHandler()->ProcessEvent( event );
+ if (gs_lastLeftClickHeader)
+ {
+ wxDataViewCtrl *dv = tree_model->internal->GetOwner();
+ wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, dv->GetId() );
+ event.SetDataViewColumn( gs_lastLeftClickHeader );
+ event.SetModel( dv->GetModel() );
+ dv->GetEventHandler()->ProcessEvent( event );
+ }
+
+ gs_lastLeftClickHeader = NULL;
}
void wxgtk_tree_model_set_sort_func (GtkTreeSortable *sortable,
if (gdk_event->button == 1)
{
+ gs_lastLeftClickHeader = column;
+
wxDataViewCtrl *dv = column->GetOwner();
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, dv->GetId() );
event.SetDataViewColumn( column );
m_root = NULL;
m_sort_order = GTK_SORT_ASCENDING;
m_sort_column = -1;
+ m_dataview_sort_column = NULL;
InitTree();
}
wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const
{
- return NULL;
+ return m_internal->GetDataViewSortColumn();
}
void wxDataViewCtrl::Expand( const wxDataViewItem & item )