Implement autosizing of columns in generic wxListCtrl

Autosize the column to fit its contents or its label width if there are
no items when its divider is double clicked.

This is consistent with wxMSW behaviour and is generally convenient.

Closes https://github.com/wxWidgets/wxWidgets/pull/1573
This commit is contained in:
oneeyeman1
2019-10-01 08:05:23 -05:00
committed by Vadim Zeitlin
parent 0e0ea2ad84
commit f46a5423ae

View File

@@ -1359,6 +1359,15 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
event.GetPosition());
}
}
else if ( event.LeftDClick() && hit_border )
{
// Autosize the column when the divider is clicked: if there are
// any items, fit the columns to its contents, otherwise just fit
// it to its label width.
parent->SetColumnWidth(m_column,
parent->IsEmpty() ? wxLIST_AUTOSIZE_USEHEADER
: wxLIST_AUTOSIZE);
}
else if (event.Moving())
{
bool setCursor;