*
*/
-#include <precomp.h>
+#include "precomp.h"
#include <stdlib.h>
static const WCHAR szMapWndClass[] = L"FontMapWnd";
static const WCHAR szLrgCellWndClass[] = L"LrgCellWnd";
-static
-VOID
-TagFontToCell(PCELL pCell,
- WCHAR ch)
-{
- pCell->ch = ch;
-}
+#define MAX_ROWS (0xFFFF / XCELLS) + 1 - YCELLS
static
INT x, y;
RECT rc;
PCELL Cell;
+ INT i, added;
hOldFont = SelectObject(ps->hdc,
infoPtr->hFont);
+ i = XCELLS * infoPtr->iYStart;
+
+ added = 0;
+
for (y = 0; y < YCELLS; y++)
for (x = 0; x < XCELLS; x++)
{
+ ch = (WCHAR)infoPtr->ValidGlyphs[i];
+
Cell = &infoPtr->Cells[y][x];
- if (!IntersectRect(&rc,
- &ps->rcPaint,
- &Cell->CellExt))
+ if (IntersectRect(&rc,
+ &ps->rcPaint,
+ &Cell->CellExt))
{
- continue;
- }
+ Cell->ch = ch;
- ch = (WCHAR)((XCELLS * (y + infoPtr->iYStart)) + x);
+ DrawTextW(ps->hdc,
+ &ch,
+ 1,
+ &Cell->CellInt,
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE);
- TagFontToCell(Cell, ch);
+ added++;
+ }
- DrawTextW(ps->hdc,
- &ch,
- 1,
- &Cell->CellInt,
- DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+ i++;
+ ch = (WCHAR)i;
}
-
SelectObject(ps->hdc,
hOldFont);
}
LPWSTR lpFontName)
{
HDC hdc;
+ WCHAR ch[MAX_GLYPHS];
+ WORD out[MAX_GLYPHS];
+ DWORD i, j;
/* Destroy Zoom window, since it was created with older font */
DestroyWindow(infoPtr->hLrgWnd);
sizeof(LOGFONTW));
hdc = GetDC(infoPtr->hMapWnd);
- infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc,
- LOGPIXELSY) / 5;
- ReleaseDC(infoPtr->hMapWnd, hdc);
+ infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 5;
infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET;
- wcscpy(infoPtr->CurrentFont.lfFaceName,
- lpFontName);
+ wcsncpy(infoPtr->CurrentFont.lfFaceName,
+ lpFontName,
+ sizeof(infoPtr->CurrentFont.lfFaceName) / sizeof(infoPtr->CurrentFont.lfFaceName[0]));
infoPtr->hFont = CreateFontIndirectW(&infoPtr->CurrentFont);
NULL,
TRUE);
- /* Test if zoom window must be reopened */
- if (infoPtr->pActiveCell != NULL &&
- infoPtr->pActiveCell->bLarge)
+ infoPtr->pActiveCell = &infoPtr->Cells[0][0];
+
+ // Get all the valid glyphs in this font
+
+ SelectObject(hdc, infoPtr->hFont);
+
+ for (i = 0; i < MAX_GLYPHS; i++)
+ ch[i] = (WCHAR)i;
+
+ if (GetGlyphIndicesW(hdc,
+ ch,
+ MAX_GLYPHS,
+ out,
+ GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR)
{
- CreateLargeCell(infoPtr);
+ j = 0;
+ for (i = 0; i < MAX_GLYPHS; i++)
+ {
+ if (out[i] != 0xffff)
+ {
+ infoPtr->ValidGlyphs[j] = ch[i];
+ j++;
+ }
+ }
+ infoPtr->NumValidGlyphs = j;
}
+
+ ReleaseDC(infoPtr->hMapWnd, hdc);
+
+ infoPtr->NumRows = infoPtr->NumValidGlyphs / XCELLS;
+ if (infoPtr->NumValidGlyphs % XCELLS)
+ infoPtr->NumRows += 1;
+ infoPtr->NumRows = (infoPtr->NumRows > YCELLS) ? infoPtr->NumRows - YCELLS : 0;
+
+ SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, infoPtr->NumRows, FALSE);
+ SetScrollPos(infoPtr->hMapWnd, SB_VERT, 0, TRUE);
+ infoPtr->iYStart = 0;
}
static
BOOL
-OnCreate(PMAP infoPtr,
- HWND hwnd,
- HWND hParent)
+MapOnCreate(PMAP infoPtr,
+ HWND hwnd,
+ HWND hParent)
{
RECT rc;
BOOL Ret = FALSE;
SetGrid(infoPtr);
- SetScrollRange(hwnd, SB_VERT, 0, 255, FALSE);
- SetScrollPos(hwnd, SB_VERT, 0, TRUE);
+ SetScrollPos(infoPtr->hParent, SB_VERT, 0, TRUE);
Ret = TRUE;
}
break;
}
- infoPtr->iYStart = max(0,
- min(infoPtr->iYStart, 255*16));
+ infoPtr->iYStart = max(0, infoPtr->iYStart);
+ infoPtr->iYStart = min(infoPtr->iYStart, infoPtr->NumRows);
iYDiff = iOldYStart - infoPtr->iYStart;
if (iYDiff)
{
return;
}
- hdc = (HDC)wParam;
+ ps.hdc = (HDC)wParam;
}
else
{
{
case WM_CREATE:
{
- if (!OnCreate(infoPtr,
- hwnd,
- ((LPCREATESTRUCTW)lParam)->hwndParent))
+ if (!MapOnCreate(infoPtr,
+ hwnd,
+ ((LPCREATESTRUCTW)lParam)->hwndParent))
{
return (LRESULT)-1;
}