X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63916e4494c0f0d382f9ed3337d1fcec900028d1..24aab8e81a8627802e4111d9c99a50ece8d0026e:/src/generic/vscroll.cpp diff --git a/src/generic/vscroll.cpp b/src/generic/vscroll.cpp index 3fc8a940d5..a7d388a9bf 100644 --- a/src/generic/vscroll.cpp +++ b/src/generic/vscroll.cpp @@ -24,6 +24,10 @@ #pragma hdrstop #endif +#ifndef WX_PRECOMP + #include "wx/sizer.h" +#endif + #include "wx/vscroll.h" // ---------------------------------------------------------------------------- @@ -156,6 +160,13 @@ size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full) return lineFirst; } +void wxVScrolledWindow::RemoveScrollbar() +{ + m_lineFirst = 0; + m_nVisible = m_lineMax; + SetScrollbar(wxVERTICAL, 0, 0, 0); +} + void wxVScrolledWindow::UpdateScrollbar() { // see how many lines can we fit on screen @@ -185,8 +196,8 @@ void wxVScrolledWindow::UpdateScrollbar() if ( hAll < hWindow ) { // we don't need scrollbar at all - m_lineFirst = 0; - SetScrollbar(wxVERTICAL, 0, 0, 0); + RemoveScrollbar(); + return; } } @@ -218,8 +229,15 @@ void wxVScrolledWindow::SetLineCount(size_t count) m_heightTotal = EstimateTotalHeight(); // recalculate the scrollbars parameters - m_lineFirst = 1; // make sure it is != 0 - ScrollToLine(0); + if ( count ) + { + m_lineFirst = 1; // make sure it is != 0 + ScrollToLine(0); + } + else // no items + { + RemoveScrollbar(); + } } void wxVScrolledWindow::RefreshLine(size_t line) @@ -282,6 +300,27 @@ void wxVScrolledWindow::RefreshAll() Refresh(); } +bool wxVScrolledWindow::Layout() +{ + if ( GetSizer() ) + { + // adjust the sizer dimensions/position taking into account the + // virtual size and scrolled position of the window. + + int w = 0, h = 0; + GetVirtualSize(&w, &h); + + // x is always 0 so no variable needed + int y = -GetLinesHeight(0, GetFirstVisibleLine()); + + GetSizer()->SetDimension(0, y, w, h); + return true; + } + + // fall back to default for LayoutConstraints + return wxPanel::Layout(); +} + int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const { const size_t lineMax = GetVisibleEnd();