Remove wxTreeListCtrl special first column resizing logic
Trying to give all the remaining space after allocating enough to the other columns to the first one doesn't work well with wxDataViewCtrl, which tries to do the same thing, but with the last column, so we actually get some strange mix of behaviours, with both the first and last columns changing size after the control itself is resized. Stop fighting with wxDataViewCtrl and just let it to its own thing. Closes #17476.
This commit is contained in:
parent
008e8fcb21
commit
c6de521959
@ -361,7 +361,7 @@ public:
|
||||
@param width
|
||||
The width of the column in pixels or the special
|
||||
wxCOL_WIDTH_AUTOSIZE value indicating that the column should adjust
|
||||
to its contents. Notice that the first column is special and will
|
||||
to its contents. Notice that the last column is special and will
|
||||
be always resized to fill all the space not taken by the other
|
||||
columns, i.e. the width specified here is ignored for it.
|
||||
@param align
|
||||
@ -405,7 +405,7 @@ public:
|
||||
Set column width to either the given value in pixels or to the value
|
||||
large enough to fit all of the items if width is wxCOL_WIDTH_AUTOSIZE.
|
||||
|
||||
Notice that setting the width of the first column is ignored as this
|
||||
Notice that setting the width of the last column is ignored as this
|
||||
column is always resized to fill the space left by the other columns.
|
||||
*/
|
||||
void SetColumnWidth(unsigned col, int width);
|
||||
|
@ -1455,28 +1455,6 @@ void wxTreeListCtrl::OnSize(wxSizeEvent& event)
|
||||
view->Refresh();
|
||||
view->Update();
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
|
||||
// Resize the first column to take the remaining available space.
|
||||
const unsigned numColumns = GetColumnCount();
|
||||
if ( !numColumns )
|
||||
return;
|
||||
|
||||
// There is a bug in generic wxDataViewCtrl: if the column width sums
|
||||
// up to the total size, horizontal scrollbar (unnecessarily) appears,
|
||||
// so subtract a bit to ensure this doesn't happen.
|
||||
int remainingWidth = rect.width - 5;
|
||||
for ( unsigned n = 1; n < GetColumnCount(); n++ )
|
||||
{
|
||||
remainingWidth -= GetColumnWidth(n);
|
||||
if ( remainingWidth <= 0 )
|
||||
{
|
||||
// There is not enough space, as we're not going to give the
|
||||
// first column negative width anyhow, just don't do anything.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetColumnWidth(0, remainingWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user