Add optional columns autosizing to wxDataViewCtrl.

Only implemented in the generic and GTK+ versions at the moment, OS X
support will be added later.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65948 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-10-30 15:57:41 +00:00
parent 9aebcb5e44
commit d0154e3a5a
6 changed files with 131 additions and 26 deletions

View File

@@ -3205,23 +3205,20 @@ int wxDataViewColumn::GetWidth() const
void wxDataViewColumn::SetWidth( int width )
{
if (width < 0)
if ( width == wxCOL_WIDTH_AUTOSIZE )
{
#if 1
gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_FIXED );
// TODO find a better calculation
gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column), wxDVC_DEFAULT_WIDTH );
#else
// this is unpractical for large numbers of items and disables
// user resizing, which is totally unexpected
// NB: this disables user resizing
gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_AUTOSIZE );
#endif
}
else
{
gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_FIXED );
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 );
}
}