From 841c14c37c878dff35a552626c77c7d7a44ff558 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Dec 2018 18:50:18 +0100 Subject: [PATCH] Fix expanding last wxDataViewCtrl column in the generic version The code added in 4156e1a5c94283cb037132518dfb80dbc1403e12 didn't quite work correctly because it used the old size of the window, before it was resized, and not the new size. This was almost unnoticeable when drag-resizing the window, but very noticeable when maximizing the containing TLW, as could be seen on the 3rd page of the dataview sample, for example, where the last column kept its size instead of expanding. See #13904, #18295. --- src/generic/datavgen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index f94700b072..c5aad72db8 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -5172,9 +5172,6 @@ wxSize wxDataViewCtrl::GetSizeAvailableForScrollTarget(const wxSize& size) void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) ) { - if ( m_clientArea && GetColumnCount() ) - m_clientArea->UpdateColumnSizes(); - // We need to override OnSize so that our scrolled // window a) does call Layout() to use sizers for // positioning the controls but b) does not query @@ -5186,6 +5183,11 @@ void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) ) AdjustScrollbars(); + // Update the last column size to take all the available space. Note that + // this must be done after calling Layout() to update m_clientArea size. + if ( m_clientArea && GetColumnCount() ) + m_clientArea->UpdateColumnSizes(); + // We must redraw the headers if their height changed. Normally this // shouldn't happen as the control shouldn't let itself be resized beneath // its minimal height but avoid the display artefacts that appear if it