From 0c90ea40c3f18e6ec0e2e404a85d165203bfc269 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 3 Oct 2019 02:04:36 +0200 Subject: [PATCH] Don't auto-resize wxDataViewCtrl columns below their initial size It's unexpected that decreasing the width of the control makes the last column diminish in size until nothing (at least if it's minimum size was not set), instead of showing horizontal scrollbar, so prevent this from happening by considering the initial column width as being "manually set", which prevents the code from making the column narrower than it automatically. This seems to make sense and is consistent with the handling of initial size, which becomes "best", and hence "minimal", size of the control, for wxWindow. Closes #18343. --- include/wx/generic/dataview.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index b6fc60857e..a2031d8b5f 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -138,13 +138,18 @@ public: if ( width == m_width ) return false; + // Normally we don't update it here as this method is called by + // UpdateColumnSizes() which resizes the column automatically, and not + // "manually", but if it's the first time the width is being set for a + // column created with the default width, do set m_manuallySetWidth in + // order to prevent the column from becoming narrower than its initial + // size when the control is resized, as this is unexpected. + if ( m_width == -1 ) + m_manuallySetWidth = width; + m_width = width; UpdateWidth(); - // We must not update m_manuallySetWidth here as this method is called by - // UpdateColumnSizes() which resizes the column automatically, and not - // "manually". - return true; }