From d74389f9303ef0052a1541476ad026a4d7b3c572 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 May 2020 03:29:32 +0200 Subject: [PATCH] Fix WXGetManuallySetWidth() for columns using wxCOL_WIDTH_DEFAULT Columns without any explicitly specified width still shouldn't be shrunk down to 0 size by UpdateColumnSizes(), so handle them as if they were created using wxDVC_DEFAULT_WIDTH instead -- which is what their actual width is/would be. This is a better fix than the one in 0c90ea40c3 (Don't auto-resize wxDataViewCtrl columns below their initial size, 2019-10-03) and that commit can be reverted now, as will be done soon. See #18343. --- include/wx/generic/dataview.h | 2 +- src/generic/datavgen.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index 4c932cfd1c..247a30d253 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -154,7 +154,7 @@ public: // user interactively. void WXOnResize(int width); - int WXGetManuallySetWidth() const { return m_manuallySetWidth; } + int WXGetManuallySetWidth() const; private: // common part of all ctors diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index bce892416b..0e8689765d 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -217,6 +217,15 @@ void wxDataViewColumn::WXOnResize(int width) m_owner->OnColumnResized(); } +int wxDataViewColumn::WXGetManuallySetWidth() const +{ + // Note that we need to return valid value even if no width was initially + // specified, as otherwise the last column created without any explicit + // width could be reduced to nothing by UpdateColumnSizes() when the + // control is shrunk. + return DoGetEffectiveWidth(m_manuallySetWidth); +} + void wxDataViewColumn::UpdateDisplay() { if (m_owner)