From e5507c27a11b103bea4579700e3ba70a111a42f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Feb 2016 20:36:03 +0100 Subject: [PATCH] Stop using GTK_TREE_VIEW_COLUMN_AUTOSIZE in wxDataViewCtrl Using this column type made the control even slower for a big number of items and also prevented the user from resizing the column which was unexpected. See #16680. --- src/gtk/dataview.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 19d9dfaeae..7b73d1a9ba 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -3309,19 +3309,15 @@ int wxDataViewColumn::GetWidth() const void wxDataViewColumn::SetWidth( int width ) { - if ( width == wxCOL_WIDTH_AUTOSIZE ) + // Notice that we don't have anything to do for wxCOL_WIDTH_DEFAULT and + // wxCOL_WIDTH_AUTOSIZE as the native control tries to use the appropriate + // width by default anyhow, don't use GTK_TREE_VIEW_COLUMN_AUTOSIZE to + // force it because, as mentioned in GTK+ documentation, it's completely + // inappropriate for controls with a lot of items (because it's O(N)) and + // it would also prevent the user from resizing the column manually which + // we want to allow for resizeable columns. + if ( width >= 0 ) { - // NB: this disables user resizing - gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_AUTOSIZE ); - } - else - { - if ( width == wxCOL_WIDTH_DEFAULT ) - { - // TODO find a better calculation - width = wxDVC_DEFAULT_WIDTH; - } - gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_FIXED ); gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column), width ); }