#pragma hdrstop
#endif
+#ifndef WX_PRECOMP
+ #include "wx/sizer.h"
+#endif
+
#include "wx/vscroll.h"
// ----------------------------------------------------------------------------
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
h += OnGetLineHeight(line);
}
+ // if we still have remaining space below, maybe we can fit everything?
+ if ( h < hWindow )
+ {
+ wxCoord hAll = h;
+ for ( size_t lineFirst = m_lineFirst; lineFirst > 0; lineFirst-- )
+ {
+ hAll += OnGetLineHeight(m_lineFirst - 1);
+ if ( hAll > hWindow )
+ break;
+ }
+
+ if ( hAll < hWindow )
+ {
+ // we don't need scrollbar at all
+ RemoveScrollbar();
+ return;
+ }
+ }
+
m_nVisible = line - m_lineFirst;
int pageSize = m_nVisible;
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)
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, h;
+ 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();