[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.

svn path=/trunk/; revision=51795
This commit is contained in:
Gregor Schneider 2011-05-16 17:46:49 +00:00
parent f151ca5b4e
commit 52539ea5a9

View file

@ -61,53 +61,76 @@ DrawActiveCell(PMAP infoPtr,
static static
VOID VOID
DrawGrid(PMAP infoPtr, DrawGrid(PMAP infoPtr,
HDC hdc) PAINTSTRUCT *ps)
{ {
INT x, y; INT x, y;
RECT rc;
PCELL Cell;
for (y = 0; y < YCELLS; y++) for (y = 0; y < YCELLS; y++)
for (x = 0; x < XCELLS; x++) for (x = 0; x < XCELLS; x++)
{ {
Rectangle(hdc, Cell = &infoPtr->Cells[y][x];
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) if (!IntersectRect(&rc,
DrawActiveCell(infoPtr, &ps->rcPaint,
hdc); &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 static
VOID VOID
FillGrid(PMAP infoPtr, FillGrid(PMAP infoPtr,
HDC hdc) PAINTSTRUCT *ps)
{ {
HFONT hOldFont; HFONT hOldFont;
WCHAR ch; WCHAR ch;
INT x, y; INT x, y;
RECT rc;
PCELL Cell;
hOldFont = SelectObject(hdc, hOldFont = SelectObject(ps->hdc,
infoPtr->hFont); infoPtr->hFont);
for (y = 0; y < YCELLS; y++) for (y = 0; y < YCELLS; y++)
for (x = 0; x < XCELLS; x++) 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); ch = (WCHAR)((XCELLS * (y + infoPtr->iYStart)) + x);
TagFontToCell(&infoPtr->Cells[y][x], ch); TagFontToCell(Cell, ch);
DrawTextW(hdc, DrawTextW(ps->hdc,
&ch, &ch,
1, 1,
&infoPtr->Cells[y][x].CellInt, &Cell->CellInt,
DT_CENTER | DT_VCENTER | DT_SINGLELINE); DT_CENTER | DT_VCENTER | DT_SINGLELINE);
} }
SelectObject(hdc, SelectObject(ps->hdc,
hOldFont); hOldFont);
} }
@ -187,6 +210,10 @@ SetFont(PMAP infoPtr,
{ {
HDC hdc; HDC hdc;
/* Destroy Zoom window, since it was created with older font */
DestroyWindow(infoPtr->hLrgWnd);
infoPtr->hLrgWnd = NULL;
if (infoPtr->hFont) if (infoPtr->hFont)
DeleteObject(infoPtr->hFont); DeleteObject(infoPtr->hFont);
@ -207,6 +234,13 @@ SetFont(PMAP infoPtr,
InvalidateRect(infoPtr->hMapWnd, InvalidateRect(infoPtr->hMapWnd,
NULL, NULL,
TRUE); TRUE);
/* Test if zoom window must be reopened */
if (infoPtr->pActiveCell != NULL &&
infoPtr->pActiveCell->bLarge)
{
CreateLargeCell(infoPtr);
}
} }
@ -391,6 +425,11 @@ OnVScroll(PMAP infoPtr,
iYDiff = iOldYStart - infoPtr->iYStart; iYDiff = iOldYStart - infoPtr->iYStart;
if (iYDiff) if (iYDiff)
{ {
if (infoPtr->hLrgWnd != NULL)
{
ShowWindow(infoPtr->hLrgWnd, SW_HIDE);
}
SetScrollPos(infoPtr->hMapWnd, SetScrollPos(infoPtr->hMapWnd,
SB_VERT, SB_VERT,
infoPtr->iYStart, infoPtr->iYStart,
@ -417,6 +456,11 @@ OnVScroll(PMAP infoPtr,
NULL, NULL,
TRUE); TRUE);
} }
if (infoPtr->hLrgWnd != NULL)
{
ShowWindow(infoPtr->hLrgWnd, SW_SHOW);
}
} }
} }
@ -450,11 +494,9 @@ OnPaint(PMAP infoPtr,
} }
} }
DrawGrid(infoPtr, DrawGrid(infoPtr, &ps);
hdc);
FillGrid(infoPtr, FillGrid(infoPtr, &ps);
hdc);
if (wParam == 0) if (wParam == 0)
{ {