3 static const TCHAR szMapWndClass
[] = TEXT("FontMapWnd");
4 static const TCHAR szLrgCellWndClass
[] = TEXT("LrgCellWnd");
7 TagFontToCell(PCELL pCell
,
19 for (y
= 0; y
< YCELLS
; y
++)
20 for (x
= 0; x
< XCELLS
; x
++)
22 infoPtr
->Cells
[y
][x
].CellExt
.left
= x
* infoPtr
->CellSize
.cx
+ 1;
23 infoPtr
->Cells
[y
][x
].CellExt
.top
= y
* infoPtr
->CellSize
.cy
+ 1;
24 infoPtr
->Cells
[y
][x
].CellExt
.right
= (x
+ 1) * infoPtr
->CellSize
.cx
+ 2;
25 infoPtr
->Cells
[y
][x
].CellExt
.bottom
= (y
+ 1) * infoPtr
->CellSize
.cy
+ 2;
27 CopyRect(&infoPtr
->Cells
[y
][x
].CellInt
,
28 &infoPtr
->Cells
[y
][x
].CellExt
);
30 InflateRect(&infoPtr
->Cells
[y
][x
].CellInt
,
37 DrawActiveCell(PMAP infoPtr
,
41 infoPtr
->pActiveCell
->CellInt
.left
,
42 infoPtr
->pActiveCell
->CellInt
.top
,
43 infoPtr
->pActiveCell
->CellInt
.right
,
44 infoPtr
->pActiveCell
->CellInt
.bottom
);
50 DrawGrid(PMAP infoPtr
,
55 for (y
= 0; y
< YCELLS
; y
++)
56 for (x
= 0; x
< XCELLS
; x
++)
59 infoPtr
->Cells
[y
][x
].CellExt
.left
,
60 infoPtr
->Cells
[y
][x
].CellExt
.top
,
61 infoPtr
->Cells
[y
][x
].CellExt
.right
,
62 infoPtr
->Cells
[y
][x
].CellExt
.bottom
);
65 if (infoPtr
->pActiveCell
)
66 DrawActiveCell(infoPtr
,
72 FillGrid(PMAP infoPtr
,
80 hOldFont
= SelectObject(hdc
,
83 for (y
= 0; y
< YCELLS
; y
++)
84 for (x
= 0; x
< XCELLS
; x
++)
86 ch
= (TCHAR
)((256 * infoPtr
->iPage
) + (XCELLS
* y
) + x
);
88 TagFontToCell(&infoPtr
->Cells
[y
][x
], ch
);
93 &infoPtr
->Cells
[y
][x
].CellInt
,
94 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
103 CreateLargeCell(PMAP infoPtr
)
108 &infoPtr
->pActiveCell
->CellExt
);
110 MapWindowPoints(infoPtr
->hMapWnd
,
119 infoPtr
->hLrgWnd
= CreateWindowEx(0,
122 WS_CHILDWINDOW
| WS_VISIBLE
,
125 rLarge
.right
- rLarge
.left
,
126 rLarge
.bottom
- rLarge
.top
,
131 if (!infoPtr
->hLrgWnd
)
139 MoveLargeCell(PMAP infoPtr
)
144 &infoPtr
->pActiveCell
->CellExt
);
146 MapWindowPoints(infoPtr
->hMapWnd
,
155 MoveWindow(infoPtr
->hLrgWnd
,
158 rLarge
.right
- rLarge
.left
,
159 rLarge
.bottom
- rLarge
.top
,
162 InvalidateRect(infoPtr
->hLrgWnd
,
169 SetFont(PMAP infoPtr
,
175 DeleteObject(infoPtr
->hFont
);
177 ZeroMemory(&infoPtr
->CurrentFont
,
180 hdc
= GetDC(infoPtr
->hMapWnd
);
181 infoPtr
->CurrentFont
.lfHeight
= GetDeviceCaps(hdc
,
183 ReleaseDC(infoPtr
->hMapWnd
, hdc
);
185 infoPtr
->CurrentFont
.lfCharSet
= DEFAULT_CHARSET
;
186 lstrcpy(infoPtr
->CurrentFont
.lfFaceName
,
189 infoPtr
->hFont
= CreateFontIndirect(&infoPtr
->CurrentFont
);
191 InvalidateRect(infoPtr
->hMapWnd
,
198 OnClick(PMAP infoPtr
,
208 for (x
= 0; x
< XCELLS
; x
++)
209 for (y
= 0; y
< YCELLS
; y
++)
211 if (PtInRect(&infoPtr
->Cells
[y
][x
].CellInt
,
214 /* if the cell is not already active */
215 if (!infoPtr
->Cells
[y
][x
].bActive
)
217 /* set previous active cell to inactive */
218 if (infoPtr
->pActiveCell
)
220 /* invalidate normal cells, required when
221 * moving a small active cell via keyboard */
222 if (!infoPtr
->pActiveCell
->bLarge
)
224 InvalidateRect(infoPtr
->hMapWnd
,
225 &infoPtr
->pActiveCell
->CellInt
,
229 infoPtr
->pActiveCell
->bActive
= FALSE
;
230 infoPtr
->pActiveCell
->bLarge
= FALSE
;
233 /* set new cell to active */
234 infoPtr
->pActiveCell
= &infoPtr
->Cells
[y
][x
];
235 infoPtr
->pActiveCell
->bActive
= TRUE
;
236 infoPtr
->pActiveCell
->bLarge
= TRUE
;
237 if (infoPtr
->hLrgWnd
)
238 MoveLargeCell(infoPtr
);
240 CreateLargeCell(infoPtr
);
244 /* flick between large and small */
245 if (infoPtr
->pActiveCell
->bLarge
)
247 DestroyWindow(infoPtr
->hLrgWnd
);
248 infoPtr
->hLrgWnd
= NULL
;
252 CreateLargeCell(infoPtr
);
255 infoPtr
->pActiveCell
->bLarge
= (infoPtr
->pActiveCell
->bLarge
) ? FALSE
: TRUE
;
265 OnCreate(PMAP infoPtr
,
272 infoPtr
= HeapAlloc(GetProcessHeap(),
278 SetWindowLongPtr(hwnd
,
281 if (GetLastError() == 0)
286 infoPtr
->hMapWnd
= hwnd
;
287 infoPtr
->hParent
= hParent
;
289 GetClientRect(hwnd
, &rc
);
290 infoPtr
->ClientSize
.cx
= rc
.right
;
291 infoPtr
->ClientSize
.cy
= rc
.bottom
;
292 infoPtr
->CellSize
.cx
= infoPtr
->ClientSize
.cx
/ XCELLS
;
293 infoPtr
->CellSize
.cy
= infoPtr
->ClientSize
.cy
/ YCELLS
;
295 infoPtr
->pActiveCell
= NULL
;
299 SetScrollRange(hwnd
, SB_VERT
, 0, 255, FALSE
);
300 SetScrollPos(hwnd
, SB_VERT
, 0, TRUE
);
311 OnVScroll(PMAP infoPtr
,
326 infoPtr
->iPage
-= 16;
330 infoPtr
->iPage
+= 16;
333 case SB_THUMBPOSITION
:
334 infoPtr
->iPage
= Pos
;
341 infoPtr
->iPage
= max(0,
345 SetScrollPos(infoPtr
->hMapWnd
,
350 InvalidateRect(infoPtr
->hMapWnd
,
357 OnPaint(PMAP infoPtr
,
366 if (!GetUpdateRect(infoPtr
->hMapWnd
,
376 hdc
= BeginPaint(infoPtr
->hMapWnd
,
392 EndPaint(infoPtr
->hMapWnd
,
399 MapWndProc(HWND hwnd
,
407 infoPtr
= (PMAP
)GetWindowLongPtr(hwnd
,
414 if (!OnCreate(infoPtr
,
416 ((LPCREATESTRUCTW
)lParam
)->hwndParent
))
444 LPTSTR lpFontName
= (LPTSTR
)lParam
;
449 HeapFree(GetProcessHeap(),
465 DeleteObject(infoPtr
->hFont
);
466 HeapFree(GetProcessHeap(),
469 SetWindowLongPtr(hwnd
,
477 Ret
= DefWindowProc(hwnd
,
489 RegisterMapClasses(HINSTANCE hInstance
)
493 //wc.style = CS_DBLCLKS;
494 wc
.lpfnWndProc
= MapWndProc
;
495 wc
.cbWndExtra
= sizeof(PMAP
);
496 wc
.hInstance
= hInstance
;
497 wc
.hCursor
= LoadCursor(NULL
,
499 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
500 wc
.lpszClassName
= szMapWndClass
;
502 if (RegisterClass(&wc
))
504 wc
.lpfnWndProc
= LrgCellWndProc
;
506 wc
.lpszClassName
= szLrgCellWndClass
;
508 return RegisterClass(&wc
) != 0;
515 UnregisterMapClasses(HINSTANCE hInstance
)
517 UnregisterClass(szMapWndClass
,
520 UnregisterClass(szLrgCellWndClass
,