From d4a3bf9b852d7aec9a02d174c9783a6fd894a5f7 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 4 Dec 2007 02:09:17 +0000 Subject: [PATCH] fixed first and last line calculations --- trackview.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/trackview.cpp b/trackview.cpp index 17e8fdb..ec5a79b 100644 --- a/trackview.cpp +++ b/trackview.cpp @@ -62,15 +62,17 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks) { TCHAR temp[256]; - int firstLine = 0; // scrollPosY + max((rcTracks.top - topMarginHeight) / fontHeight, 0); - int lastLine = lines; // scrollPosY + min(((rcTracks.bottom - topMarginHeight) + (fontHeight - 1)) / fontHeight, lines - 1); + int firstLine = editLine - windowLines / 2 - 1; + int lastLine = editLine + windowLines / 2 + 1; + + /* clamp first & last line */ + firstLine = min(max(firstLine, 0), lines - 1); + lastLine = min(max(lastLine, 0), lines - 1); // int editLine = firstLine + (lastLine - firstLine) / 2; HBRUSH editBrush = CreateSolidBrush(RGB(255, 255, 0)); // HBRUSH editBrush = CreateSolidBrush(RGB(255, 255, 0)); - lastLine = min(lastLine, lines) - 1; - RECT topLeftCorner; topLeftCorner.top = 0; topLeftCorner.bottom = topMarginHeight; @@ -102,7 +104,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks) else if ((line % 4) == 0) SetTextColor(hdc, RGB(64, 64, 64)); else SetTextColor(hdc, RGB(128, 128, 128)); - _sntprintf_s(temp, 256, _T("%04Xh"), line); + _sntprintf_s(temp, 256, _T("%0*Xh"), 5, line); TextOut(hdc, leftMargin.left, leftMargin.top, temp, int(_tcslen(temp))