From 2b043c2212b5ee369b0511cdc9764fc9a61092e6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 13 Nov 2007 14:18:44 +0000 Subject: [PATCH] charmap: scroll 1 position on SB_LINEDOWN and 1 page on SB_PAGEDOWN, update window on SB_THUMPTRACK, use ScrollWindowEx on scrolling. svn path=/trunk/; revision=30422 --- reactos/base/applications/charmap/map.c | 56 +++++++++++++++------ reactos/base/applications/charmap/precomp.h | 2 +- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/reactos/base/applications/charmap/map.c b/reactos/base/applications/charmap/map.c index 565d4d5ec67..6b3825d50a2 100644 --- a/reactos/base/applications/charmap/map.c +++ b/reactos/base/applications/charmap/map.c @@ -91,7 +91,7 @@ FillGrid(PMAP infoPtr, for (y = 0; y < YCELLS; y++) for (x = 0; x < XCELLS; x++) { - ch = (WCHAR)((256 * infoPtr->iPage) + (XCELLS * y) + x); + ch = (WCHAR)((XCELLS * (y + infoPtr->iYStart)) + x); TagFontToCell(&infoPtr->Cells[y][x], ch); @@ -348,43 +348,67 @@ OnVScroll(PMAP infoPtr, INT Value, INT Pos) { + INT iYDiff, iOldYStart = infoPtr->iYStart; + switch (Value) { case SB_LINEUP: - infoPtr->iPage -= 1; + infoPtr->iYStart -= 1; break; case SB_LINEDOWN: - infoPtr->iPage += 1; + infoPtr->iYStart += 1; break; case SB_PAGEUP: - infoPtr->iPage -= 16; + infoPtr->iYStart -= YCELLS; break; case SB_PAGEDOWN: - infoPtr->iPage += 16; + infoPtr->iYStart += YCELLS; break; - case SB_THUMBPOSITION: - infoPtr->iPage = Pos; + case SB_THUMBTRACK: + infoPtr->iYStart = Pos; break; default: break; } - infoPtr->iPage = max(0, - min(infoPtr->iPage, 255)); + infoPtr->iYStart = max(0, + min(infoPtr->iYStart, 255*16)); - SetScrollPos(infoPtr->hMapWnd, - SB_VERT, - infoPtr->iPage, - TRUE); + iYDiff = iOldYStart - infoPtr->iYStart; + if (iYDiff) + { + SetScrollPos(infoPtr->hMapWnd, + SB_VERT, + infoPtr->iYStart, + TRUE); - InvalidateRect(infoPtr->hMapWnd, - NULL, - TRUE); + if (abs(iYDiff) < YCELLS) + { + RECT rect; + GetClientRect(infoPtr->hMapWnd, &rect); + rect.top += 2; + rect.bottom -= 2; + ScrollWindowEx(infoPtr->hMapWnd, + 0, + iYDiff * infoPtr->CellSize.cy, + &rect, + &rect, + NULL, + NULL, + SW_INVALIDATE); + } + else + { + InvalidateRect(infoPtr->hMapWnd, + NULL, + TRUE); + } + } } diff --git a/reactos/base/applications/charmap/precomp.h b/reactos/base/applications/charmap/precomp.h index 2f9713c3cb9..040886cefd7 100644 --- a/reactos/base/applications/charmap/precomp.h +++ b/reactos/base/applications/charmap/precomp.h @@ -36,7 +36,7 @@ typedef struct _MAP PCELL pActiveCell; HFONT hFont; LOGFONTW CurrentFont; - INT iPage; + INT iYStart; } MAP, *PMAP; typedef struct {