ReactOS  0.4.12-dev-102-g4b7f1e0
map.c File Reference
#include "precomp.h"
#include <stdlib.h>
Include dependency graph for map.c:

Go to the source code of this file.

Macros

#define MAX_ROWS   (0xFFFF / XCELLS) + 1 - YCELLS
 

Functions

static VOID SetGrid (PMAP infoPtr)
 
static VOID DrawActiveCell (PMAP infoPtr, HDC hdc)
 
static VOID DrawGrid (PMAP infoPtr, PAINTSTRUCT *ps)
 
static VOID FillGrid (PMAP infoPtr, PAINTSTRUCT *ps)
 
static BOOL CreateLargeCell (PMAP infoPtr)
 
static VOID MoveLargeCell (PMAP infoPtr)
 
static VOID SetFont (PMAP infoPtr, LPWSTR lpFontName)
 
static LRESULT NotifyParentOfSelection (PMAP infoPtr, UINT code, WCHAR ch)
 
static VOID OnClick (PMAP infoPtr, WORD ptx, WORD pty)
 
static BOOL MapOnCreate (PMAP infoPtr, HWND hwnd, HWND hParent)
 
static VOID OnVScroll (PMAP infoPtr, INT Value, INT Pos)
 
static VOID OnPaint (PMAP infoPtr, WPARAM wParam)
 
LRESULT CALLBACK MapWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL RegisterMapClasses (HINSTANCE hInstance)
 
VOID UnregisterMapClasses (HINSTANCE hInstance)
 

Variables

static const WCHAR szMapWndClass [] = L"FontMapWnd"
 
static const WCHAR szLrgCellWndClass [] = L"LrgCellWnd"
 

Macro Definition Documentation

◆ MAX_ROWS

#define MAX_ROWS   (0xFFFF / XCELLS) + 1 - YCELLS

Definition at line 17 of file map.c.

Referenced by CheckLevel().

Function Documentation

◆ CreateLargeCell()

static BOOL CreateLargeCell ( PMAP  infoPtr)
static

Definition at line 143 of file map.c.

Referenced by OnClick().

144 {
145  RECT rLarge;
146 
147  CopyRect(&rLarge,
148  &infoPtr->pActiveCell->CellExt);
149 
150  MapWindowPoints(infoPtr->hMapWnd,
151  infoPtr->hParent,
152  (VOID*)&rLarge,
153  2);
154 
155  InflateRect(&rLarge,
156  XLARGE - XCELLS,
157  YLARGE - YCELLS);
158 
159  infoPtr->hLrgWnd = CreateWindowExW(0,
161  NULL,
163  rLarge.left,
164  rLarge.top,
165  rLarge.right - rLarge.left,
166  rLarge.bottom - rLarge.top,
167  infoPtr->hParent,
168  NULL,
169  hInstance,
170  infoPtr);
171  if (!infoPtr->hLrgWnd)
172  return FALSE;
173 
174  return TRUE;
175 }
HWND hParent
Definition: precomp.h:41
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define TRUE
Definition: types.h:120
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define XLARGE
Definition: precomp.h:19
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
HINSTANCE hInstance
Definition: charmap.c:20
PCELL pActiveCell
Definition: precomp.h:46
smooth NULL
Definition: ftsmooth.c:416
RECT CellExt
Definition: precomp.h:31
#define WS_CHILDWINDOW
Definition: pedump.c:639
static const WCHAR szLrgCellWndClass[]
Definition: map.c:15
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HWND hLrgWnd
Definition: precomp.h:42
#define XCELLS
Definition: precomp.h:17
#define YLARGE
Definition: precomp.h:20
HWND hMapWnd
Definition: precomp.h:40
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
LONG bottom
Definition: windef.h:299
#define WS_VISIBLE
Definition: pedump.c:620
#define YCELLS
Definition: precomp.h:18

◆ DrawActiveCell()

static VOID DrawActiveCell ( PMAP  infoPtr,
HDC  hdc 
)
static

Definition at line 45 of file map.c.

Referenced by DrawGrid().

47 {
48  Rectangle(hdc,
49  infoPtr->pActiveCell->CellInt.left,
50  infoPtr->pActiveCell->CellInt.top,
51  infoPtr->pActiveCell->CellInt.right,
52  infoPtr->pActiveCell->CellInt.bottom);
53 
54 }
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
RECT CellInt
Definition: precomp.h:32
PCELL pActiveCell
Definition: precomp.h:46
HDC hdc
Definition: msvc.h:53
LONG bottom
Definition: windef.h:299

◆ DrawGrid()

static VOID DrawGrid ( PMAP  infoPtr,
PAINTSTRUCT ps 
)
static

Definition at line 59 of file map.c.

Referenced by CGridView::GetHwnd(), and OnPaint().

61 {
62  INT x, y;
63  RECT rc;
64  PCELL Cell;
65 
66  for (y = 0; y < YCELLS; y++)
67  for (x = 0; x < XCELLS; x++)
68  {
69  Cell = &infoPtr->Cells[y][x];
70 
71  if (!IntersectRect(&rc,
72  &ps->rcPaint,
73  &Cell->CellExt))
74  {
75  continue;
76  }
77 
78  Rectangle(ps->hdc,
79  Cell->CellExt.left,
80  Cell->CellExt.top,
81  Cell->CellExt.right,
82  Cell->CellExt.bottom);
83 
84  if (infoPtr->pActiveCell == Cell)
85  {
86  DrawActiveCell(infoPtr, ps->hdc);
87  }
88  }
89 }
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
Definition: precomp.h:29
INT INT y
Definition: msvc.h:62
PCELL pActiveCell
Definition: precomp.h:46
RECT CellExt
Definition: precomp.h:31
static VOID DrawActiveCell(PMAP infoPtr, HDC hdc)
Definition: map.c:45
struct zzzz Cell
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define XCELLS
Definition: precomp.h:17
CELL Cells[YCELLS][XCELLS]
Definition: precomp.h:45
INT x
Definition: msvc.h:62
LONG bottom
Definition: windef.h:299
#define YCELLS
Definition: precomp.h:18

◆ FillGrid()

static VOID FillGrid ( PMAP  infoPtr,
PAINTSTRUCT ps 
)
static

Definition at line 94 of file map.c.

Referenced by OnPaint().

96 {
97  HFONT hOldFont;
98  WCHAR ch;
99  INT x, y;
100  RECT rc;
101  PCELL Cell;
102  INT i, added;
103 
104  hOldFont = SelectObject(ps->hdc,
105  infoPtr->hFont);
106 
107  i = XCELLS * infoPtr->iYStart;
108 
109  added = 0;
110 
111  for (y = 0; y < YCELLS; y++)
112  for (x = 0; x < XCELLS; x++)
113  {
114  ch = (WCHAR)infoPtr->ValidGlyphs[i];
115 
116  Cell = &infoPtr->Cells[y][x];
117 
118  if (IntersectRect(&rc,
119  &ps->rcPaint,
120  &Cell->CellExt))
121  {
122  Cell->ch = ch;
123 
124  DrawTextW(ps->hdc,
125  &ch,
126  1,
127  &Cell->CellInt,
129 
130  added++;
131  }
132 
133  i++;
134  ch = (WCHAR)i;
135  }
136  SelectObject(ps->hdc,
137  hOldFont);
138 }
HFONT hFont
Definition: precomp.h:47
__wchar_t WCHAR
Definition: xmlstorage.h:180
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define WCHAR
Definition: msvc.h:43
int32_t INT
Definition: typedefs.h:56
RECT CellInt
Definition: precomp.h:32
Definition: precomp.h:29
INT INT y
Definition: msvc.h:62
GLenum GLclampf GLint i
Definition: glfuncs.h:14
RECT CellExt
Definition: precomp.h:31
#define DT_VCENTER
Definition: winuser.h:543
struct zzzz Cell
if(!(yy_init))
Definition: macro.lex.yy.c:717
USHORT ValidGlyphs[MAX_GLYPHS]
Definition: precomp.h:52
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
WCHAR ch
Definition: precomp.h:35
INT iYStart
Definition: precomp.h:49
#define DT_SINGLELINE
Definition: winuser.h:540
#define XCELLS
Definition: precomp.h:17
CELL Cells[YCELLS][XCELLS]
Definition: precomp.h:45
INT x
Definition: msvc.h:62
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define DT_CENTER
Definition: winuser.h:527
#define YCELLS
Definition: precomp.h:18
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

◆ MapOnCreate()

static BOOL MapOnCreate ( PMAP  infoPtr,
HWND  hwnd,
HWND  hParent 
)
static

Definition at line 379 of file map.c.

Referenced by MapWndProc().

382 {
383  RECT rc;
384  BOOL Ret = FALSE;
385 
386  infoPtr = HeapAlloc(GetProcessHeap(),
387  0,
388  sizeof(MAP));
389  if (infoPtr)
390  {
391  SetLastError(0);
392  SetWindowLongPtrW(hwnd,
393  0,
394  (DWORD_PTR)infoPtr);
395  if (GetLastError() == 0)
396  {
397  ZeroMemory(infoPtr,
398  sizeof(MAP));
399 
400  infoPtr->hMapWnd = hwnd;
401  infoPtr->hParent = hParent;
402 
403  GetClientRect(hwnd, &rc);
404  infoPtr->ClientSize.cx = rc.right;
405  infoPtr->ClientSize.cy = rc.bottom;
406  infoPtr->CellSize.cx = infoPtr->ClientSize.cx / XCELLS;
407  infoPtr->CellSize.cy = infoPtr->ClientSize.cy / YCELLS;
408 
409  infoPtr->pActiveCell = NULL;
410 
411  SetGrid(infoPtr);
412 
413  SetScrollPos(infoPtr->hParent, SB_VERT, 0, TRUE);
414 
415  Ret = TRUE;
416  }
417  }
418 
419  return Ret;
420 }
HWND hParent
Definition: precomp.h:41
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define SB_VERT
Definition: winuser.h:553
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
LONG right
Definition: windef.h:298
Definition: precomp.h:38
PCELL pActiveCell
Definition: precomp.h:46
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:324
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
SIZE CellSize
Definition: precomp.h:44
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
uint32_t DWORD_PTR
Definition: typedefs.h:63
SIZE ClientSize
Definition: precomp.h:43
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define XCELLS
Definition: precomp.h:17
HWND hMapWnd
Definition: precomp.h:40
static VOID SetGrid(PMAP infoPtr)
Definition: map.c:22
LONG bottom
Definition: windef.h:299
#define SetWindowLongPtrW
Definition: winuser.h:5215
LONG cy
Definition: windef.h:325
#define YCELLS
Definition: precomp.h:18
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)

◆ MapWndProc()

LRESULT CALLBACK MapWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 546 of file map.c.

Referenced by CGridView::GetHwnd(), and RegisterMapClasses().

550 {
551  PMAP infoPtr;
552  LRESULT Ret = 0;
553 
554  infoPtr = (PMAP)GetWindowLongPtrW(hwnd,
555  0);
556 
557  switch (uMsg)
558  {
559  case WM_CREATE:
560  {
561  if (!MapOnCreate(infoPtr,
562  hwnd,
564  {
565  return (LRESULT)-1;
566  }
567 
568  break;
569  }
570 
571  case WM_LBUTTONDOWN:
572  {
573  OnClick(infoPtr,
574  LOWORD(lParam),
575  HIWORD(lParam));
576 
577  break;
578  }
579 
580  case WM_LBUTTONDBLCLK:
581  {
582  NotifyParentOfSelection(infoPtr,
583  FM_SETCHAR,
584  infoPtr->pActiveCell->ch);
585 
586 
587  break;
588  }
589 
590  case WM_VSCROLL:
591  {
592  OnVScroll(infoPtr,
593  LOWORD(wParam),
594  HIWORD(wParam));
595 
596  break;
597  }
598 
599  case FM_SETFONT:
600  SetFont(infoPtr, (LPWSTR)lParam);
601  break;
602 
603  case FM_GETCHAR:
604  {
605  if (!infoPtr->pActiveCell) return 0;
606  return infoPtr->pActiveCell->ch;
607  }
608 
609  case FM_GETHFONT:
610  return (LRESULT)infoPtr->hFont;
611 
612  case WM_PAINT:
613  {
614  OnPaint(infoPtr,
615  wParam);
616  break;
617  }
618 
619  case WM_DESTROY:
620  {
621  DeleteObject(infoPtr->hFont);
623  0,
624  infoPtr);
625  SetWindowLongPtrW(hwnd,
626  0,
627  (DWORD_PTR)NULL);
628  break;
629  }
630 
631  default:
632  {
633  Ret = DefWindowProcW(hwnd,
634  uMsg,
635  wParam,
636  lParam);
637  break;
638  }
639  }
640 
641  return Ret;
642 }
static VOID OnClick(PMAP infoPtr, WORD ptx, WORD pty)
Definition: map.c:311
HFONT hFont
Definition: precomp.h:47
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
struct _MAP * PMAP
static BOOL MapOnCreate(PMAP infoPtr, HWND hwnd, HWND hParent)
Definition: map.c:379
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static VOID OnPaint(PMAP infoPtr, WPARAM wParam)
Definition: map.c:505
#define GetWindowLongPtrW
Definition: winuser.h:4698
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: precomp.h:38
static VOID SetFont(PMAP infoPtr, LPWSTR lpFontName)
Definition: map.c:211
PCELL pActiveCell
Definition: precomp.h:46
#define FM_SETFONT
Definition: precomp.h:22
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define WM_DESTROY
Definition: winuser.h:1591
#define FM_GETHFONT
Definition: precomp.h:25
#define GetProcessHeap()
Definition: compat.h:395
#define WM_PAINT
Definition: winuser.h:1602
#define FM_GETCHAR
Definition: precomp.h:23
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
uint32_t DWORD_PTR
Definition: typedefs.h:63
WCHAR ch
Definition: precomp.h:35
#define FM_SETCHAR
Definition: precomp.h:24
static LRESULT NotifyParentOfSelection(PMAP infoPtr, UINT code, WCHAR ch)
Definition: map.c:285
static VOID OnVScroll(PMAP infoPtr, INT Value, INT Pos)
Definition: map.c:425
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
#define SetWindowLongPtrW
Definition: winuser.h:5215
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WM_VSCROLL
Definition: winuser.h:1720

◆ MoveLargeCell()

static VOID MoveLargeCell ( PMAP  infoPtr)
static

Definition at line 180 of file map.c.

Referenced by OnClick().

181 {
182  RECT rLarge;
183 
184  CopyRect(&rLarge,
185  &infoPtr->pActiveCell->CellExt);
186 
187  MapWindowPoints(infoPtr->hMapWnd,
188  infoPtr->hParent,
189  (VOID*)&rLarge,
190  2);
191 
192  InflateRect(&rLarge,
193  XLARGE - XCELLS,
194  YLARGE - YCELLS);
195 
196  MoveWindow(infoPtr->hLrgWnd,
197  rLarge.left,
198  rLarge.top,
199  rLarge.right - rLarge.left,
200  rLarge.bottom - rLarge.top,
201  TRUE);
202 
203  InvalidateRect(infoPtr->hLrgWnd,
204  NULL,
205  TRUE);
206 }
HWND hParent
Definition: precomp.h:41
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define TRUE
Definition: types.h:120
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define XLARGE
Definition: precomp.h:19
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
PCELL pActiveCell
Definition: precomp.h:46
smooth NULL
Definition: ftsmooth.c:416
RECT CellExt
Definition: precomp.h:31
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
HWND hLrgWnd
Definition: precomp.h:42
#define XCELLS
Definition: precomp.h:17
#define YLARGE
Definition: precomp.h:20
HWND hMapWnd
Definition: precomp.h:40
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
LONG bottom
Definition: windef.h:299
#define YCELLS
Definition: precomp.h:18

◆ NotifyParentOfSelection()

static LRESULT NotifyParentOfSelection ( PMAP  infoPtr,
UINT  code,
WCHAR  ch 
)
static

Definition at line 285 of file map.c.

Referenced by MapWndProc().

288 {
289  LRESULT Ret = 0;
290 
291  if (infoPtr->hParent != NULL)
292  {
293  DWORD dwIdc = GetWindowLongPtr(infoPtr->hMapWnd, GWLP_ID);
294  /*
295  * Push directly into the event queue instead of waiting
296  * the parent to be unlocked.
297  * High word of LPARAM is still available for future needs...
298  */
299  Ret = PostMessage(infoPtr->hParent,
300  WM_COMMAND,
301  MAKELPARAM((WORD)dwIdc, (WORD)code),
302  (LPARAM)LOWORD(ch));
303  }
304 
305  return Ret;
306 }
HWND hParent
Definition: precomp.h:41
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
#define PostMessage
Definition: winuser.h:5698
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_COMMAND
Definition: winuser.h:1716
HWND hMapWnd
Definition: precomp.h:40
#define GetWindowLongPtr
Definition: treelist.c:73
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82
#define GWLP_ID
Definition: winuser.h:854

◆ OnClick()

static VOID OnClick ( PMAP  infoPtr,
WORD  ptx,
WORD  pty 
)
static

Definition at line 311 of file map.c.

Referenced by MapWndProc().

314 {
315  POINT pt;
316  INT x, y;
317 
318  pt.x = ptx;
319  pt.y = pty;
320 
321  for (x = 0; x < XCELLS; x++)
322  for (y = 0; y < YCELLS; y++)
323  {
324  if (PtInRect(&infoPtr->Cells[y][x].CellInt,
325  pt))
326  {
327  /* if the cell is not already active */
328  if (!infoPtr->Cells[y][x].bActive)
329  {
330  /* set previous active cell to inactive */
331  if (infoPtr->pActiveCell)
332  {
333  /* invalidate normal cells, required when
334  * moving a small active cell via keyboard */
335  if (!infoPtr->pActiveCell->bLarge)
336  {
337  InvalidateRect(infoPtr->hMapWnd,
338  &infoPtr->pActiveCell->CellInt,
339  TRUE);
340  }
341 
342  infoPtr->pActiveCell->bActive = FALSE;
343  infoPtr->pActiveCell->bLarge = FALSE;
344  }
345 
346  /* set new cell to active */
347  infoPtr->pActiveCell = &infoPtr->Cells[y][x];
348  infoPtr->pActiveCell->bActive = TRUE;
349  infoPtr->pActiveCell->bLarge = TRUE;
350  if (infoPtr->hLrgWnd)
351  MoveLargeCell(infoPtr);
352  else
353  CreateLargeCell(infoPtr);
354  }
355  else
356  {
357  /* flick between large and small */
358  if (infoPtr->pActiveCell->bLarge)
359  {
360  DestroyWindow(infoPtr->hLrgWnd);
361  infoPtr->hLrgWnd = NULL;
362  }
363  else
364  {
365  CreateLargeCell(infoPtr);
366  }
367 
368  infoPtr->pActiveCell->bLarge = (infoPtr->pActiveCell->bLarge) ? FALSE : TRUE;
369  }
370 
371  break;
372  }
373  }
374 }
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
BOOL WINAPI DestroyWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:56
RECT CellInt
Definition: precomp.h:32
INT INT y
Definition: msvc.h:62
PCELL pActiveCell
Definition: precomp.h:46
static BOOL CreateLargeCell(PMAP infoPtr)
Definition: map.c:143
BOOL bLarge
Definition: precomp.h:34
smooth NULL
Definition: ftsmooth.c:416
BOOL bActive
Definition: precomp.h:33
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hLrgWnd
Definition: precomp.h:42
static VOID MoveLargeCell(PMAP infoPtr)
Definition: map.c:180
#define XCELLS
Definition: precomp.h:17
CELL Cells[YCELLS][XCELLS]
Definition: precomp.h:45
INT x
Definition: msvc.h:62
HWND hMapWnd
Definition: precomp.h:40
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define YCELLS
Definition: precomp.h:18

◆ OnPaint()

static VOID OnPaint ( PMAP  infoPtr,
WPARAM  wParam 
)
static

Definition at line 505 of file map.c.

Referenced by MapWndProc().

507 {
508  PAINTSTRUCT ps;
509  HDC hdc;
510 
511 
512  if (wParam != 0)
513  {
514  if (!GetUpdateRect(infoPtr->hMapWnd,
515  &ps.rcPaint,
516  TRUE))
517  {
518  return;
519  }
520  ps.hdc = (HDC)wParam;
521  }
522  else
523  {
524  hdc = BeginPaint(infoPtr->hMapWnd,
525  &ps);
526  if (hdc == NULL)
527  {
528  return;
529  }
530  }
531 
532  DrawGrid(infoPtr, &ps);
533 
534  FillGrid(infoPtr, &ps);
535 
536  if (wParam == 0)
537  {
538  EndPaint(infoPtr->hMapWnd,
539  &ps);
540  }
541 }
#define HDC
Definition: msvc.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
static VOID DrawGrid(PMAP infoPtr, PAINTSTRUCT *ps)
Definition: map.c:59
static VOID FillGrid(PMAP infoPtr, PAINTSTRUCT *ps)
Definition: map.c:94
HWND hMapWnd
Definition: precomp.h:40

◆ OnVScroll()

static VOID OnVScroll ( PMAP  infoPtr,
INT  Value,
INT  Pos 
)
static

Definition at line 425 of file map.c.

Referenced by CGridView::GetHwnd(), and MapWndProc().

428 {
429  INT iYDiff, iOldYStart = infoPtr->iYStart;
430 
431  switch (Value)
432  {
433  case SB_LINEUP:
434  infoPtr->iYStart -= 1;
435  break;
436 
437  case SB_LINEDOWN:
438  infoPtr->iYStart += 1;
439  break;
440 
441  case SB_PAGEUP:
442  infoPtr->iYStart -= YCELLS;
443  break;
444 
445  case SB_PAGEDOWN:
446  infoPtr->iYStart += YCELLS;
447  break;
448 
449  case SB_THUMBTRACK:
450  infoPtr->iYStart = Pos;
451  break;
452 
453  default:
454  break;
455  }
456 
457  infoPtr->iYStart = max(0, infoPtr->iYStart);
458  infoPtr->iYStart = min(infoPtr->iYStart, infoPtr->NumRows);
459 
460  iYDiff = iOldYStart - infoPtr->iYStart;
461  if (iYDiff)
462  {
463  if (infoPtr->hLrgWnd != NULL)
464  {
465  ShowWindow(infoPtr->hLrgWnd, SW_HIDE);
466  }
467 
468  SetScrollPos(infoPtr->hMapWnd,
469  SB_VERT,
470  infoPtr->iYStart,
471  TRUE);
472 
473  if (abs(iYDiff) < YCELLS)
474  {
475  RECT rect;
476  GetClientRect(infoPtr->hMapWnd, &rect);
477  rect.top += 2;
478  rect.bottom -= 2;
479  ScrollWindowEx(infoPtr->hMapWnd,
480  0,
481  iYDiff * infoPtr->CellSize.cy,
482  &rect,
483  &rect,
484  NULL,
485  NULL,
486  SW_INVALIDATE);
487  }
488  else
489  {
490  InvalidateRect(infoPtr->hMapWnd,
491  NULL,
492  TRUE);
493  }
494 
495  if (infoPtr->hLrgWnd != NULL)
496  {
497  ShowWindow(infoPtr->hLrgWnd, SW_SHOW);
498  }
499  }
500 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define abs(i)
Definition: fconv.c:206
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define SB_VERT
Definition: winuser.h:553
#define SW_HIDE
Definition: winuser.h:762
ush Pos
Definition: deflate.h:92
LONG top
Definition: windef.h:297
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
INT NumRows
Definition: precomp.h:50
smooth NULL
Definition: ftsmooth.c:416
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
#define SW_SHOW
Definition: winuser.h:769
#define SB_THUMBTRACK
Definition: winuser.h:573
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
SIZE CellSize
Definition: precomp.h:44
HWND hLrgWnd
Definition: precomp.h:42
#define SW_INVALIDATE
Definition: winuser.h:2533
INT iYStart
Definition: precomp.h:49
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define min(a, b)
Definition: monoChain.cc:55
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
HWND hMapWnd
Definition: precomp.h:40
LONG bottom
Definition: windef.h:299
LONG cy
Definition: windef.h:325
#define YCELLS
Definition: precomp.h:18
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)

◆ RegisterMapClasses()

BOOL RegisterMapClasses ( HINSTANCE  hInstance)

Definition at line 646 of file map.c.

Referenced by wWinMain().

647 {
648  WNDCLASSW wc = {0};
649 
650  wc.style = CS_DBLCLKS;
651  wc.lpfnWndProc = MapWndProc;
652  wc.cbWndExtra = sizeof(PMAP);
653  wc.hInstance = hInstance;
654  wc.hCursor = LoadCursorW(NULL,
655  (LPWSTR)IDC_ARROW);
656  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
658 
659  if (RegisterClassW(&wc))
660  {
662  wc.cbWndExtra = 0;
664 
665  return RegisterClassW(&wc) != 0;
666  }
667 
668  return FALSE;
669 }
UINT style
Definition: winuser.h:3129
LRESULT CALLBACK MapWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: map.c:546
struct _MAP * PMAP
#define COLOR_WINDOW
Definition: winuser.h:908
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HINSTANCE hInstance
Definition: charmap.c:20
WNDPROC lpfnWndProc
Definition: winuser.h:3130
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3138
static const WCHAR szLrgCellWndClass[]
Definition: map.c:15
int cbWndExtra
Definition: winuser.h:3132
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define CS_DBLCLKS
Definition: winuser.h:646
HCURSOR hCursor
Definition: winuser.h:3135
HBRUSH hbrBackground
Definition: winuser.h:3136
static const WCHAR szMapWndClass[]
Definition: map.c:14
LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: lrgcell.c:68
HINSTANCE hInstance
Definition: winuser.h:3133
#define IDC_ARROW
Definition: winuser.h:682
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ SetFont()

static VOID SetFont ( PMAP  infoPtr,
LPWSTR  lpFontName 
)
static

Definition at line 211 of file map.c.

Referenced by MapWndProc(), and CStartButton::UpdateFont().

213 {
214  HDC hdc;
215  WCHAR ch[MAX_GLYPHS];
217  DWORD i, j;
218 
219  /* Destroy Zoom window, since it was created with older font */
220  DestroyWindow(infoPtr->hLrgWnd);
221  infoPtr->hLrgWnd = NULL;
222 
223  if (infoPtr->hFont)
224  DeleteObject(infoPtr->hFont);
225 
226  ZeroMemory(&infoPtr->CurrentFont,
227  sizeof(LOGFONTW));
228 
229  hdc = GetDC(infoPtr->hMapWnd);
230  infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 5;
231 
233  wcsncpy(infoPtr->CurrentFont.lfFaceName,
234  lpFontName,
235  sizeof(infoPtr->CurrentFont.lfFaceName) / sizeof(infoPtr->CurrentFont.lfFaceName[0]));
236 
237  infoPtr->hFont = CreateFontIndirectW(&infoPtr->CurrentFont);
238 
239  InvalidateRect(infoPtr->hMapWnd,
240  NULL,
241  TRUE);
242 
243  infoPtr->pActiveCell = &infoPtr->Cells[0][0];
244 
245  // Get all the valid glyphs in this font
246 
247  SelectObject(hdc, infoPtr->hFont);
248 
249  for (i = 0; i < MAX_GLYPHS; i++)
250  ch[i] = (WCHAR)i;
251 
252  if (GetGlyphIndicesW(hdc,
253  ch,
254  MAX_GLYPHS,
255  out,
257  {
258  j = 0;
259  for (i = 0; i < MAX_GLYPHS; i++)
260  {
261  if (out[i] != 0xffff)
262  {
263  infoPtr->ValidGlyphs[j] = ch[i];
264  j++;
265  }
266  }
267  infoPtr->NumValidGlyphs = j;
268  }
269 
270  ReleaseDC(infoPtr->hMapWnd, hdc);
271 
272  infoPtr->NumRows = infoPtr->NumValidGlyphs / XCELLS;
273  if (infoPtr->NumValidGlyphs % XCELLS)
274  infoPtr->NumRows += 1;
275  infoPtr->NumRows = (infoPtr->NumRows > YCELLS) ? infoPtr->NumRows - YCELLS : 0;
276 
277  SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, infoPtr->NumRows, FALSE);
278  SetScrollPos(infoPtr->hMapWnd, SB_VERT, 0, TRUE);
279  infoPtr->iYStart = 0;
280 }
#define HDC
Definition: msvc.h:22
LOGFONTW CurrentFont
Definition: precomp.h:48
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
HFONT hFont
Definition: precomp.h:47
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_VERT
Definition: winuser.h:553
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG lfHeight
Definition: dimm.idl:59
BYTE lfCharSet
Definition: dimm.idl:67
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define DEFAULT_CHARSET
Definition: wingdi.h:382
BOOL WINAPI DestroyWindow(_In_ HWND)
INT NumRows
Definition: precomp.h:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
PCELL pActiveCell
Definition: precomp.h:46
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
USHORT NumValidGlyphs
Definition: precomp.h:53
#define MAX_GLYPHS
Definition: precomp.h:15
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GGI_MARK_NONEXISTING_GLYPHS
Definition: wingdi.h:1066
USHORT ValidGlyphs[MAX_GLYPHS]
Definition: precomp.h:52
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HWND hLrgWnd
Definition: precomp.h:42
INT iYStart
Definition: precomp.h:49
#define XCELLS
Definition: precomp.h:17
CELL Cells[YCELLS][XCELLS]
Definition: precomp.h:45
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
BOOL WINAPI SetScrollRange(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ BOOL)
HWND hMapWnd
Definition: precomp.h:40
DWORD WINAPI GetGlyphIndicesW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpstr, _In_ int c, _Out_writes_(c) LPWORD pgi, _In_ DWORD fl)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define LOGPIXELSY
Definition: wingdi.h:717
#define GDI_ERROR
Definition: wingdi.h:1290
#define YCELLS
Definition: precomp.h:18
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)

◆ SetGrid()

static VOID SetGrid ( PMAP  infoPtr)
static

Definition at line 22 of file map.c.

Referenced by MapOnCreate().

23 {
24  INT x, y;
25 
26  for (y = 0; y < YCELLS; y++)
27  for (x = 0; x < XCELLS; x++)
28  {
29  infoPtr->Cells[y][x].CellExt.left = x * infoPtr->CellSize.cx + 1;
30  infoPtr->Cells[y][x].CellExt.top = y * infoPtr->CellSize.cy + 1;
31  infoPtr->Cells[y][x].CellExt.right = (x + 1) * infoPtr->CellSize.cx + 2;
32  infoPtr->Cells[y][x].CellExt.bottom = (y + 1) * infoPtr->CellSize.cy + 2;
33 
34  CopyRect(&infoPtr->Cells[y][x].CellInt,
35  &infoPtr->Cells[y][x].CellExt);
36 
37  InflateRect(&infoPtr->Cells[y][x].CellInt,
38  -1,
39  -1);
40  }
41 }
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
RECT CellInt
Definition: precomp.h:32
INT INT y
Definition: msvc.h:62
RECT CellExt
Definition: precomp.h:31
LONG cx
Definition: windef.h:324
SIZE CellSize
Definition: precomp.h:44
#define XCELLS
Definition: precomp.h:17
CELL Cells[YCELLS][XCELLS]
Definition: precomp.h:45
INT x
Definition: msvc.h:62
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
LONG bottom
Definition: windef.h:299
LONG cy
Definition: windef.h:325
#define YCELLS
Definition: precomp.h:18

◆ UnregisterMapClasses()

VOID UnregisterMapClasses ( HINSTANCE  hInstance)

Definition at line 672 of file map.c.

Referenced by wWinMain().

673 {
675  hInstance);
676 
678  hInstance);
679 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
static const WCHAR szLrgCellWndClass[]
Definition: map.c:15
static const WCHAR szMapWndClass[]
Definition: map.c:14

Variable Documentation

◆ szLrgCellWndClass

const WCHAR szLrgCellWndClass[] = L"LrgCellWnd"
static

Definition at line 15 of file map.c.

Referenced by CreateLargeCell(), RegisterMapClasses(), and UnregisterMapClasses().

◆ szMapWndClass

const WCHAR szMapWndClass[] = L"FontMapWnd"
static

Definition at line 14 of file map.c.

Referenced by RegisterMapClasses(), and UnregisterMapClasses().