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.
This commit is contained in:
Vadim Zeitlin
2020-05-01 03:29:32 +02:00
parent 6c5f3f8929
commit d74389f930
2 changed files with 10 additions and 1 deletions

View File

@@ -154,7 +154,7 @@ public:
// user interactively. // user interactively.
void WXOnResize(int width); void WXOnResize(int width);
int WXGetManuallySetWidth() const { return m_manuallySetWidth; } int WXGetManuallySetWidth() const;
private: private:
// common part of all ctors // common part of all ctors

View File

@@ -217,6 +217,15 @@ void wxDataViewColumn::WXOnResize(int width)
m_owner->OnColumnResized(); 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() void wxDataViewColumn::UpdateDisplay()
{ {
if (m_owner) if (m_owner)