Auto size last visible column in generic wxDataViewCtrl

Resize the last visible column and not just the last column, which might
be hidden, to fill up all the available space.

See #18295.
This commit is contained in:
Vadim Zeitlin 2019-10-19 22:02:20 +02:00
parent c6d2f6d9fe
commit 6af316b537

View File

@ -5070,8 +5070,35 @@ void wxDataViewMainWindow::UpdateColumnSizes()
int fullWinWidth = GetSize().x;
wxDataViewColumn *lastCol = owner->GetColumn(colsCount - 1);
int colswidth = GetEndOfLastCol();
// Find the last shown column: we shouldn't bother to resize the columns
// that are hidden anyhow.
int lastColIndex = -1;
wxDataViewColumn *lastCol wxDUMMY_INITIALIZE(NULL);
for ( int colIndex = colsCount - 1; colIndex >= 0; --colIndex )
{
lastCol = owner->GetColumnAt(colIndex);
if ( !lastCol->IsHidden() )
{
lastColIndex = colIndex;
break;
}
}
if ( lastColIndex == -1 )
{
// All columns are hidden.
return;
}
int colswidth = 0;
for ( int colIndex = 0; colIndex < lastColIndex; ++colIndex )
{
const wxDataViewColumn *c = owner->GetColumnAt(colIndex);
if ( !c->IsHidden() )
colswidth += c->GetWidth();
}
int lastColX = colswidth - lastCol->GetWidth();
if ( lastColX < fullWinWidth )
{