// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "vscroll.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
wxRect rect;
rect.width = GetClientSize().x;
rect.height = OnGetLineHeight(line);
- for ( size_t n = GetFirstVisibleLine(); n < line; n++ )
+ for ( size_t n = GetVisibleBegin(); n < line; n++ )
{
rect.y += OnGetLineHeight(n);
}
// clump the range to just the visible lines -- it is useless to refresh
// the other ones
- if ( from < GetFirstVisibleLine() )
- from = GetFirstVisibleLine();
+ if ( from < GetVisibleBegin() )
+ from = GetVisibleBegin();
- if ( to > GetLastVisibleLine() )
- to = GetLastVisibleLine();
+ if ( to >= GetVisibleEnd() )
+ to = GetVisibleEnd();
+ else
+ to++;
// calculate the rect occupied by these lines on screen
wxRect rect;
rect.width = GetClientSize().x;
- for ( size_t nBefore = GetFirstVisibleLine(); nBefore < from; nBefore++ )
+ for ( size_t nBefore = GetVisibleBegin(); nBefore < from; nBefore++ )
{
rect.y += OnGetLineHeight(nBefore);
}
- for ( size_t nBetween = from; nBetween <= to; nBetween++ )
+ for ( size_t nBetween = from; nBetween < to; nBetween++ )
{
rect.height += OnGetLineHeight(nBetween);
}
int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const
{
- const size_t lineMax = GetLastVisibleLine();
- for ( size_t line = GetFirstVisibleLine(); line <= lineMax; line++ )
+ const size_t lineMax = GetVisibleEnd();
+ for ( size_t line = GetVisibleBegin(); line < lineMax; line++ )
{
y -= OnGetLineHeight(line);
if ( y < 0 )
// remember the currently shown lines for the refresh code below
- size_t lineFirstOld = GetFirstVisibleLine(),
- lineLastOld = GetLastVisibleLine();
+ size_t lineFirstOld = GetVisibleBegin(),
+ lineLastOld = GetVisibleEnd();
m_lineFirst = line;
// finally refresh the display -- but only redraw as few lines as possible
// to avoid flicker
- if ( GetFirstVisibleLine() > lineLastOld ||
- GetLastVisibleLine() < lineFirstOld )
+ if ( GetVisibleBegin() >= lineLastOld ||
+ GetVisibleEnd() <= lineFirstOld )
{
// the simplest case: we don't have any old lines left, just redraw
// everything
}
else // overlap between the lines we showed before and should show now
{
- ScrollWindow(0, GetLinesHeight(GetFirstVisibleLine(), lineFirstOld));
+ ScrollWindow(0, GetLinesHeight(GetVisibleBegin(), lineFirstOld));
}
return true;
int line;
if ( pages > 0 )
{
- line = GetLastVisibleLine();
+ line = GetVisibleEnd();
+ if ( line )
+ line--;
pages--;
}
else // pages < 0
{
- line = FindFirstFromBottom(GetFirstVisibleLine());
+ line = FindFirstFromBottom(GetVisibleBegin());
pages++;
}
}
else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN )
{
- lineFirstNew = GetLastVisibleLine();
+ lineFirstNew = GetVisibleEnd();
+ if ( lineFirstNew )
+ lineFirstNew--;
}
else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE )
{