From 388703a5734f2832c664b4e2d94a4dcfedfd1958 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 17 Dec 2006 02:13:04 +0000 Subject: [PATCH] forcefully get rid of the scrollbars in CalcWindowSizes() if we don't need them any more git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43993 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6ac0795e12..22939d4afc 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4623,6 +4623,33 @@ void wxGrid::CalcWindowSizes() int cw, ch; GetClientSize( &cw, &ch ); + // this block of code tries to work around the following problem: the grid + // could have been just resized to have enough space to show the full grid + // window contents without the scrollbars, but its client size could be + // not big enough because the grid has the scrollbars right now and so the + // scrollbars would remain even though we don't need them any more + // + // to prevent this from happening, check if we have enough space for + // everything without the scrollbars and explicitly disable them then + wxSize size = GetSize() - GetWindowBorderSize(); + if ( size != wxSize(cw, ch) ) + { + // check if we have enough space for grid window after accounting for + // the fixed size elements + size.x -= m_rowLabelWidth; + size.y -= m_colLabelHeight; + + const wxSize vsize = m_gridWin->GetVirtualSize(); + + if ( size.x >= vsize.x && size.y >= vsize.y ) + { + // yes, we do, so remove the scrollbars and use the new client size + // (which should be the same as full window size - borders now) + SetScrollbars(0, 0, 0, 0); + GetClientSize(&cw, &ch); + } + } + if ( m_cornerLabelWin && m_cornerLabelWin->IsShown() ) m_cornerLabelWin->SetSize( 0, 0, m_rowLabelWidth, m_colLabelHeight ); -- 2.45.2