Merge branch 'listctrl-autosize-checkboxes'
Fix autosizing column with checkboxes in generic wxListCtrl. See https://github.com/wxWidgets/wxWidgets/pull/1721
This commit is contained in:
@@ -3279,8 +3279,6 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
|
|
||||||
wxListHeaderData *column = node->GetData();
|
wxListHeaderData *column = node->GetData();
|
||||||
|
|
||||||
size_t count = GetItemCount();
|
|
||||||
|
|
||||||
if ( width == wxLIST_AUTOSIZE_USEHEADER || width == wxLIST_AUTOSIZE )
|
if ( width == wxLIST_AUTOSIZE_USEHEADER || width == wxLIST_AUTOSIZE )
|
||||||
{
|
{
|
||||||
wxListCtrlMaxWidthCalculator calculator(this, col);
|
wxListCtrlMaxWidthCalculator calculator(this, col);
|
||||||
@@ -3297,7 +3295,8 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
size_t first_visible, last_visible;
|
size_t first_visible, last_visible;
|
||||||
GetVisibleLinesRange(&first_visible, &last_visible);
|
GetVisibleLinesRange(&first_visible, &last_visible);
|
||||||
|
|
||||||
calculator.ComputeBestColumnWidth(count, first_visible, last_visible);
|
calculator.ComputeBestColumnWidth(GetItemCount(),
|
||||||
|
first_visible, last_visible);
|
||||||
pWidthInfo->nMaxWidth = calculator.GetMaxWidth();
|
pWidthInfo->nMaxWidth = calculator.GetMaxWidth();
|
||||||
pWidthInfo->bNeedsUpdate = false;
|
pWidthInfo->bNeedsUpdate = false;
|
||||||
}
|
}
|
||||||
@@ -3306,17 +3305,26 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
|||||||
calculator.UpdateWithWidth(pWidthInfo->nMaxWidth);
|
calculator.UpdateWithWidth(pWidthInfo->nMaxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand the last column to fit the client size
|
width = calculator.GetMaxWidth() + AUTOSIZE_COL_MARGIN;
|
||||||
// only for AUTOSIZE_USEHEADER to mimic MSW behaviour
|
|
||||||
int margin = 0;
|
if ( col == 0 && HasCheckBoxes() )
|
||||||
if ( (width == wxLIST_AUTOSIZE_USEHEADER) && (col == GetColumnCount() - 1) )
|
|
||||||
{
|
{
|
||||||
margin = GetClientSize().GetX();
|
// also account for the space needed by the checkbox
|
||||||
for ( int i = 0; i < col && margin > 0; ++i )
|
width += wxRendererNative::Get().GetCheckBoxSize(this).x
|
||||||
margin -= m_columns.Item(i)->GetData()->GetWidth();
|
+ 2*MARGIN_AROUND_CHECKBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = wxMax(margin, calculator.GetMaxWidth() + AUTOSIZE_COL_MARGIN);
|
// expand the last column to fit the client size
|
||||||
|
// only for AUTOSIZE_USEHEADER to mimic MSW behaviour
|
||||||
|
if ( (width == wxLIST_AUTOSIZE_USEHEADER) && (col == GetColumnCount() - 1) )
|
||||||
|
{
|
||||||
|
int margin = GetClientSize().GetX();
|
||||||
|
for ( int i = 0; i < col && margin > 0; ++i )
|
||||||
|
margin -= m_columns.Item(i)->GetData()->GetWidth();
|
||||||
|
|
||||||
|
if ( margin > width )
|
||||||
|
width = margin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
column->SetWidth( width );
|
column->SetWidth( width );
|
||||||
|
Reference in New Issue
Block a user