Author: gschneider Date: Mon May 16 17:46:49 2011 New Revision: 51795
URL: http://svn.reactos.org/svn/reactos?rev=51795&view=rev Log: [charmap] Carlo Bramini (carlo dot bramix at libero dot it): - Fix font zoom when scrolling and changing fonts - Optimize font zoom drawing See issue #3500 for more details.
Modified: trunk/reactos/base/applications/charmap/map.c
Modified: trunk/reactos/base/applications/charmap/map.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/m... ============================================================================== --- trunk/reactos/base/applications/charmap/map.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/charmap/map.c [iso-8859-1] Mon May 16 17:46:49 2011 @@ -61,53 +61,76 @@ static VOID DrawGrid(PMAP infoPtr, - HDC hdc) + PAINTSTRUCT *ps) { INT x, y; + RECT rc; + PCELL Cell;
for (y = 0; y < YCELLS; y++) for (x = 0; x < XCELLS; x++) { - Rectangle(hdc, - infoPtr->Cells[y][x].CellExt.left, - infoPtr->Cells[y][x].CellExt.top, - infoPtr->Cells[y][x].CellExt.right, - infoPtr->Cells[y][x].CellExt.bottom); - } - - if (infoPtr->pActiveCell) - DrawActiveCell(infoPtr, - hdc); + Cell = &infoPtr->Cells[y][x]; + + if (!IntersectRect(&rc, + &ps->rcPaint, + &Cell->CellExt)) + { + continue; + } + + Rectangle(ps->hdc, + Cell->CellExt.left, + Cell->CellExt.top, + Cell->CellExt.right, + Cell->CellExt.bottom); + + if (infoPtr->pActiveCell == Cell) + { + DrawActiveCell(infoPtr, ps->hdc); + } + } }
static VOID FillGrid(PMAP infoPtr, - HDC hdc) + PAINTSTRUCT *ps) { HFONT hOldFont; WCHAR ch; INT x, y; - - hOldFont = SelectObject(hdc, + RECT rc; + PCELL Cell; + + hOldFont = SelectObject(ps->hdc, infoPtr->hFont);
for (y = 0; y < YCELLS; y++) for (x = 0; x < XCELLS; x++) { + Cell = &infoPtr->Cells[y][x]; + + if (!IntersectRect(&rc, + &ps->rcPaint, + &Cell->CellExt)) + { + continue; + } + ch = (WCHAR)((XCELLS * (y + infoPtr->iYStart)) + x);
- TagFontToCell(&infoPtr->Cells[y][x], ch); - - DrawTextW(hdc, + TagFontToCell(Cell, ch); + + DrawTextW(ps->hdc, &ch, 1, - &infoPtr->Cells[y][x].CellInt, + &Cell->CellInt, DT_CENTER | DT_VCENTER | DT_SINGLELINE); }
- SelectObject(hdc, + SelectObject(ps->hdc, hOldFont); }
@@ -187,6 +210,10 @@ { HDC hdc;
+ /* Destroy Zoom window, since it was created with older font */ + DestroyWindow(infoPtr->hLrgWnd); + infoPtr->hLrgWnd = NULL; + if (infoPtr->hFont) DeleteObject(infoPtr->hFont);
@@ -207,6 +234,13 @@ InvalidateRect(infoPtr->hMapWnd, NULL, TRUE); + + /* Test if zoom window must be reopened */ + if (infoPtr->pActiveCell != NULL && + infoPtr->pActiveCell->bLarge) + { + CreateLargeCell(infoPtr); + } }
@@ -391,6 +425,11 @@ iYDiff = iOldYStart - infoPtr->iYStart; if (iYDiff) { + if (infoPtr->hLrgWnd != NULL) + { + ShowWindow(infoPtr->hLrgWnd, SW_HIDE); + } + SetScrollPos(infoPtr->hMapWnd, SB_VERT, infoPtr->iYStart, @@ -417,6 +456,11 @@ NULL, TRUE); } + + if (infoPtr->hLrgWnd != NULL) + { + ShowWindow(infoPtr->hLrgWnd, SW_SHOW); + } } }
@@ -450,11 +494,9 @@ } }
- DrawGrid(infoPtr, - hdc); - - FillGrid(infoPtr, - hdc); + DrawGrid(infoPtr, &ps); + + FillGrid(infoPtr, &ps);
if (wParam == 0) {