Fix regression with spurious generic wxListCtrl columns resizing

Don't set default width every time the column is updated, as it happens
e.g. when it's clicked by the user, but only when it is created, by
moving the code added in 96d36383bd (Use sensible default column width
in generic wxListCtrl too, 2021-08-17) from SetItem() to the ctor of
wxListHeaderData.

Closes #19256.
This commit is contained in:
Vadim Zeitlin
2021-09-07 19:44:02 +02:00
parent bba9aa7122
commit d89af4e311

View File

@@ -298,6 +298,11 @@ wxListHeaderData::wxListHeaderData( const wxListItem &item )
Init(); Init();
SetItem( item ); SetItem( item );
// Always give some initial width to the new columns (it's still possible
// to set the width to 0 explicitly, however).
if ( !(m_mask & wxLIST_MASK_WIDTH) )
SetWidth(wxLIST_DEFAULT_COL_WIDTH);
} }
void wxListHeaderData::SetItem( const wxListItem &item ) void wxListHeaderData::SetItem( const wxListItem &item )
@@ -313,9 +318,8 @@ void wxListHeaderData::SetItem( const wxListItem &item )
if ( m_mask & wxLIST_MASK_FORMAT ) if ( m_mask & wxLIST_MASK_FORMAT )
m_format = item.m_format; m_format = item.m_format;
// Always give some initial width to the new columns (it's still possible if ( m_mask & wxLIST_MASK_WIDTH )
// to set the width to 0 explicitly, however). SetWidth(item.m_width);
SetWidth(m_mask & wxLIST_MASK_WIDTH ? item.m_width : wxLIST_DEFAULT_COL_WIDTH);
if ( m_mask & wxLIST_MASK_STATE ) if ( m_mask & wxLIST_MASK_STATE )
SetState(item.m_state); SetState(item.m_state);