ReactOS  0.4.15-dev-3203-gacde1e0
CGridView Class Reference

#include <GridView.h>

Collaboration diagram for CGridView:

Public Member Functions

 CGridView ()
 
 ~CGridView ()
 
bool Create (_In_ HWND hParent)
 
bool SetFont (_In_ CAtlString &FontName)
 
HWND GetHwnd ()
 

Private Member Functions

LRESULT OnCreate (_In_ HWND hwnd, _In_ HWND hParent)
 
LRESULT OnSize (_In_ INT Width, _In_ INT Height)
 
VOID OnVScroll (_In_ INT Value, _In_ INT Pos)
 
LRESULT OnPaint (_In_opt_ HDC hdc)
 
bool UpdateCellCoordinates ()
 
void DrawGrid (_In_ LPPAINTSTRUCT PaintStruct)
 
void DeleteCells ()
 
void SetCellFocus (_In_ CCell *NewActiveCell)
 

Static Private Member Functions

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

Private Attributes

CAtlStringW m_szMapWndClass
 
HWND m_hwnd
 
HWND m_hParent
 
int m_xNumCells
 
int m_yNumCells
 
RECT m_ClientCoordinates
 
SIZE m_CellSize
 
CCell *** m_Cells
 
CCellm_ActiveCell
 
INT m_ScrollPosition
 
int m_NumRows
 
CurrentFont m_CurrentFont
 

Detailed Description

Definition at line 16 of file GridView.h.

Constructor & Destructor Documentation

◆ CGridView()

CGridView::CGridView ( )

Definition at line 22 of file GridView.cpp.

22  :
23  m_xNumCells(20),
24  m_yNumCells(10),
26  m_NumRows(0)
27 {
28  m_szMapWndClass = L"CharGridWClass";
29 }
int m_NumRows
Definition: GridView.h:33
INT m_ScrollPosition
Definition: GridView.h:32
static const WCHAR L[]
Definition: oid.c:1250
int m_xNumCells
Definition: GridView.h:24
CAtlStringW m_szMapWndClass
Definition: GridView.h:19
int m_yNumCells
Definition: GridView.h:25

◆ ~CGridView()

CGridView::~CGridView ( )

Definition at line 31 of file GridView.cpp.

32 {
33 }

Member Function Documentation

◆ Create()

bool CGridView::Create ( _In_ HWND  hParent)

Definition at line 36 of file GridView.cpp.

39 {
40  WNDCLASSW wc = { 0 };
41  wc.style = CS_DBLCLKS;
43  wc.cbWndExtra = sizeof(CGridView *);
46  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
48 
49  if (RegisterClassW(&wc))
50  {
53  NULL,
55  0,0,0,0,
56  hParent,
57  NULL,
59  this);
60 
61  }
62 
63  return !!(m_hwnd != NULL);
64 }
HWND m_hwnd
Definition: GridView.h:21
UINT style
Definition: winuser.h:3152
#define WS_CHILD
Definition: pedump.c:617
#define COLOR_WINDOW
Definition: winuser.h:908
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3153
LPCWSTR lpszClassName
Definition: winuser.h:3161
int cbWndExtra
Definition: winuser.h:3155
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
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)
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define CS_DBLCLKS
Definition: winuser.h:646
#define WS_TABSTOP
Definition: pedump.c:634
HCURSOR hCursor
Definition: winuser.h:3158
HBRUSH hbrBackground
Definition: winuser.h:3159
#define NULL
Definition: types.h:112
#define WS_VSCROLL
Definition: pedump.c:627
HINSTANCE hInstance
Definition: winuser.h:3156
#define IDC_ARROW
Definition: winuser.h:682
CAtlStringW m_szMapWndClass
Definition: GridView.h:19
HINSTANCE g_hInstance
Definition: MainWindow.cpp:18
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static LRESULT CALLBACK MapWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: GridView.cpp:382
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by CCharMapWindow::OnCreate().

◆ DeleteCells()

void CGridView::DeleteCells ( )
private

Definition at line 494 of file GridView.cpp.

495 {
496  if (m_Cells == nullptr)
497  return;
498 
499  // Free cells withing the 2d array
500  for (int i = 0; i < m_yNumCells; i++)
501  delete[] m_Cells[i];
502  delete[] m_Cells;
503 
504  m_Cells = nullptr;
505 }
CCell *** m_Cells
Definition: GridView.h:29
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int m_yNumCells
Definition: GridView.h:25

◆ DrawGrid()

void CGridView::DrawGrid ( _In_ LPPAINTSTRUCT  PaintStruct)
private

Definition at line 463 of file GridView.cpp.

466 {
467  // Calculate which glyph to start at based on scroll position
468  int i;
470 
471  // Make sure we have the correct font on the DC
472  HFONT hOldFont;
473  hOldFont = (HFONT)SelectFont(PaintStruct->hdc,
475 
476  // Traverse all the cells
477  for (int y = 0; y < m_yNumCells; y++)
478  for (int x = 0; x < m_xNumCells; x++)
479  {
480  // Update the glyph for this cell
482  m_Cells[y][x]->SetChar(ch);
483 
484  // Tell it to paint itself
485  m_Cells[y][x]->OnPaint(*PaintStruct);
486  i++;
487  }
488 
489  SelectObject(PaintStruct->hdc, hOldFont);
490 
491 }
CurrentFont m_CurrentFont
Definition: GridView.h:35
void SetChar(_In_ WCHAR ch)
Definition: Cell.h:27
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
INT m_ScrollPosition
Definition: GridView.h:32
CCell *** m_Cells
Definition: GridView.h:29
USHORT ValidGlyphs[MAX_GLYPHS]
Definition: GridView.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SelectFont(hdc, hfont)
Definition: windowsx.h:491
int m_xNumCells
Definition: GridView.h:24
bool OnPaint(_In_ PAINTSTRUCT &PaintStruct)
Definition: Cell.cpp:43
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HFONT hFont
Definition: GridView.h:10
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
int m_yNumCells
Definition: GridView.h:25

Referenced by OnPaint().

◆ GetHwnd()

HWND CGridView::GetHwnd ( )
inline

Definition at line 49 of file GridView.h.

49 { return m_hwnd; }
HWND m_hwnd
Definition: GridView.h:21

Referenced by CCharMapWindow::OnSize().

◆ MapWndProc()

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

Definition at line 382 of file GridView.cpp.

388 {
389  CGridView *This;
390  LRESULT RetCode = 0;
391 
392  // Get the object pointer from window context
394  if (This == NULL)
395  {
396  // Check that this isn't a create message
397  if (uMsg != WM_CREATE)
398  {
399  // Don't handle null info pointer
400  goto HandleDefaultMessage;
401  }
402  }
403 
404  switch (uMsg)
405  {
406  case WM_CREATE:
407  {
408  // Get the object pointer from the create param
409  This = (CGridView *)((LPCREATESTRUCT)lParam)->lpCreateParams;
410 
411  // Store the pointer in the window's global user data
413 
414  This->OnCreate(hwnd, ((LPCREATESTRUCTW)lParam)->hwndParent);
415  break;
416  }
417 
418  case WM_SIZE:
419  {
420  INT Width, Height;
421  Width = LOWORD(lParam);
422  Height = HIWORD(lParam);
423 
424  This->OnSize(Width, Height);
425  break;
426  }
427 
428  case WM_VSCROLL:
429  {
430  INT Value, Pos;
431  Value = LOWORD(wParam);
432  Pos = HIWORD(wParam);
433 
434  This->OnVScroll(Value, Pos);
435  break;
436  }
437 
438  case WM_PAINT:
439  {
440  This->OnPaint((HDC)wParam);
441  break;
442  }
443 
444  case WM_DESTROY:
445  {
446  This->DeleteCells();
447  break;
448  }
449 
450  default:
451  {
452 HandleDefaultMessage:
453  RetCode = DefWindowProcW(hwnd, uMsg, wParam, lParam);
454  break;
455  }
456  }
457 
458  return RetCode;
459 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HDC
Definition: imagelist.c:92
ush Pos
Definition: deflate.h:92
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWLP_USERDATA
Definition: treelist.c:63
static HWND hwndParent
Definition: cryptui.c:300
#define WM_DESTROY
Definition: winuser.h:1592
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define WM_SIZE
Definition: winuser.h:1594
#define WM_PAINT
Definition: winuser.h:1603
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
#define WM_CREATE
Definition: winuser.h:1591
#define HIWORD(l)
Definition: typedefs.h:247
#define GetWindowLongPtr
Definition: treelist.c:73
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_VSCROLL
Definition: winuser.h:1727

Referenced by Create().

◆ OnCreate()

LRESULT CGridView::OnCreate ( _In_ HWND  hwnd,
_In_ HWND  hParent 
)
private

Definition at line 175 of file GridView.cpp.

179 {
180  m_hwnd = hwnd;
181  m_hParent = hParent;
182 
183  // C++ doesn't allow : "CCells ***C = new CCell***[x * y]"
184  // so we have to build the 2d array up manually
185  m_Cells = new CCell**[m_yNumCells]; // rows
186  for (int i = 0; i < m_yNumCells; i++)
187  m_Cells[i] = new CCell*[m_xNumCells]; // columns
188 
189  for (int y = 0; y < m_yNumCells; y++)
190  for (int x = 0; x < m_xNumCells; x++)
191  {
192  m_Cells[y][x] = new CCell(m_hwnd);
193  }
194 
195  // Give the first cell focus
196  SetCellFocus(m_Cells[0][0]);
197 
198  return 0;
199 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND m_hwnd
Definition: GridView.h:21
HWND m_hParent
Definition: GridView.h:22
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
CCell *** m_Cells
Definition: GridView.h:29
void SetCellFocus(_In_ CCell *NewActiveCell)
Definition: GridView.cpp:508
Definition: Cell.h:2
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
int m_xNumCells
Definition: GridView.h:24
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
int m_yNumCells
Definition: GridView.h:25

◆ OnPaint()

LRESULT CGridView::OnPaint ( _In_opt_ HDC  hdc)
private

Definition at line 337 of file GridView.cpp.

340 {
341  PAINTSTRUCT PaintStruct = { 0 };
342  HDC LocalHdc = NULL;
343  BOOL bSuccess = FALSE;
344 
345  // Check if we were passed a DC
346  if (hdc == NULL)
347  {
348  // We weren't, let's get one
349  LocalHdc = BeginPaint(m_hwnd, &PaintStruct);
350  if (LocalHdc) bSuccess = TRUE;
351  }
352  else
353  {
354  // Use the existing DC and just get the region to paint
356  &PaintStruct.rcPaint,
357  TRUE);
358  if (bSuccess)
359  {
360  // Update the struct with the DC we were passed
361  PaintStruct.hdc = (HDC)hdc;
362  }
363  }
364 
365  // Make sure we have a valid DC
366  if (bSuccess)
367  {
368  // Paint the grid and chars
369  DrawGrid(&PaintStruct);
370 
371  if (LocalHdc)
372  {
373  EndPaint(m_hwnd, &PaintStruct);
374  }
375  }
376 
377  return 0;
378 }
HWND m_hwnd
Definition: GridView.h:21
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
static BOOLEAN bSuccess
Definition: drive.cpp:432
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: main.c:9
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
#define NULL
Definition: types.h:112
void DrawGrid(_In_ LPPAINTSTRUCT PaintStruct)
Definition: GridView.cpp:463

◆ OnSize()

LRESULT CGridView::OnSize ( _In_ INT  Width,
_In_ INT  Height 
)
private

Definition at line 202 of file GridView.cpp.

206 {
207  // Get the client area of the main dialog
208  RECT ParentRect;
209  GetClientRect(m_hParent, &ParentRect);
210 
211  // Calculate the grid size using the parent
212  m_ClientCoordinates.left = ParentRect.left + 25;
213  m_ClientCoordinates.top = ParentRect.top + 50;
216 
217  // Resize the grid window
219  NULL,
225 
226  // Get the client area we can draw on. The position we set above includes
227  // a scrollbar which we obviously can't draw on. GetClientRect gives us
228  // the size without the scroll, and it's more efficient than getting the
229  // scroll metrics and calculating the size from that
230  RECT ClientRect;
231  GetClientRect(m_hwnd, &ClientRect);
232  m_CellSize.cx = ClientRect.right / m_xNumCells;
233  m_CellSize.cy = ClientRect.bottom / m_yNumCells;
234 
235  // Let all the cells know about their new coords
237 
238  // We scale the font size up or down depending on the cell size
239  if (m_CurrentFont.hFont)
240  {
241  // Delete the existing font
243 
244  HDC hdc;
245  hdc = GetDC(m_hwnd);
246  if (hdc)
247  {
248  // Update the font size with respect to the cell size
251  ReleaseDC(m_hwnd, hdc);
252  }
253  }
254 
255  // Redraw the whole grid
256  InvalidateRect(m_hwnd, &ClientRect, TRUE);
257 
258  return 0;
259 }
CurrentFont m_CurrentFont
Definition: GridView.h:35
HWND m_hwnd
Definition: GridView.h:21
HWND m_hParent
Definition: GridView.h:22
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
bool UpdateCellCoordinates()
Definition: GridView.cpp:154
LONG lfHeight
Definition: dimm.idl:59
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1233
LONG right
Definition: windef.h:308
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
RECT m_ClientCoordinates
Definition: GridView.h:27
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
LONG cx
Definition: windef.h:334
LOGFONTW Font
Definition: GridView.h:9
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
SIZE m_CellSize
Definition: GridView.h:28
HDC hdc
Definition: main.c:9
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int m_xNumCells
Definition: GridView.h:24
HFONT hFont
Definition: GridView.h:10
#define NULL
Definition: types.h:112
#define SWP_SHOWWINDOW
Definition: winuser.h:1234
int m_yNumCells
Definition: GridView.h:25
LONG bottom
Definition: windef.h:309
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG cy
Definition: windef.h:335

◆ OnVScroll()

VOID CGridView::OnVScroll ( _In_ INT  Value,
_In_ INT  Pos 
)
private

Definition at line 262 of file GridView.cpp.

264 {
265  INT PrevScrollPosition = m_ScrollPosition;
266 
267  switch (Value)
268  {
269  case SB_LINEUP:
270  m_ScrollPosition -= 1;
271  break;
272 
273  case SB_LINEDOWN:
274  m_ScrollPosition += 1;
275  break;
276 
277  case SB_PAGEUP:
279  break;
280 
281  case SB_PAGEDOWN:
283  break;
284 
285  case SB_THUMBTRACK:
287  break;
288 
289  default:
290  break;
291  }
292 
293  // Make sure we don't scroll past row 0 or max rows
296 
297  // Check if there's a difference from the previous position
298  INT ScrollDiff;
299  ScrollDiff = PrevScrollPosition - m_ScrollPosition;
300  if (ScrollDiff)
301  {
302  // Set the new scrollbar position in the scroll box
304  SB_VERT,
306  TRUE);
307 
308  // Check if the scrollbar has moved more than the
309  // number of visible rows (draged or paged)
310  if (abs(ScrollDiff) < m_yNumCells)
311  {
312  RECT rect;
314 
315  // Scroll the visible cells which remain within the grid
316  // and invalidate any new ones which appear from the top / bottom
318  0,
319  ScrollDiff * m_CellSize.cy,
320  &rect,
321  &rect,
322  NULL,
323  NULL,
324  SW_INVALIDATE);
325  }
326  else
327  {
328  // All the cells need to be redrawn
330  NULL,
331  TRUE);
332  }
333  }
334 }
#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
HWND m_hwnd
Definition: GridView.h:21
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
ush Pos
Definition: deflate.h:92
int m_NumRows
Definition: GridView.h:33
INT m_ScrollPosition
Definition: GridView.h:32
int32_t INT
Definition: typedefs.h:58
& rect
Definition: startmenu.cpp:1413
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define SB_THUMBTRACK
Definition: winuser.h:573
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
SIZE m_CellSize
Definition: GridView.h:28
#define SW_INVALIDATE
Definition: winuser.h:2555
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define min(a, b)
Definition: monoChain.cc:55
#define SB_LINEDOWN
Definition: winuser.h:565
#define NULL
Definition: types.h:112
#define SB_LINEUP
Definition: winuser.h:564
int m_yNumCells
Definition: GridView.h:25
LONG cy
Definition: windef.h:335
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)

◆ SetCellFocus()

void CGridView::SetCellFocus ( _In_ CCell NewActiveCell)
private

Definition at line 508 of file GridView.cpp.

511 {
512  if (m_ActiveCell)
513  {
514  // Remove focus from any existing cell
515  m_ActiveCell->SetFocus(false);
517  }
518 
519  // Set the new active cell and give it focus
520  m_ActiveCell = NewActiveCell;
521  m_ActiveCell->SetFocus(true);
522 }
HWND m_hwnd
Definition: GridView.h:21
#define TRUE
Definition: types.h:120
LPRECT GetCellCoordinates()
Definition: Cell.h:24
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
CCell * m_ActiveCell
Definition: GridView.h:30
void SetFocus(_In_ bool HasFocus)
Definition: Cell.h:25

Referenced by OnCreate().

◆ SetFont()

bool CGridView::SetFont ( _In_ CAtlString FontName)

Definition at line 67 of file GridView.cpp.

70 {
71 
72  // Create a temporary container for the new font
73  CurrentFont NewFont = { 0 };
74  NewFont.FontName = FontName;
75 
76  // Get the DC for the full grid window
77  HDC hdc;
78  hdc = GetDC(m_hwnd);
79  if (hdc == NULL) return false;
80 
81  // Setup the logfont structure
82  NewFont.Font.lfHeight = 0; // This is set in WM_SIZE
83  NewFont.Font.lfCharSet = DEFAULT_CHARSET;
84  StringCchCopyW(NewFont.Font.lfFaceName, LF_FACESIZE, FontName);
85 
86  // Get a handle to the new font
87  NewFont.hFont = CreateFontIndirectW(&NewFont.Font);
88  if (NewFont.hFont == NULL)
89  {
91  return false;
92  }
93 
94  // Setup an array of all possible non-BMP indices
95  WCHAR ch[MAX_GLYPHS];
96  for (int i = 0; i < MAX_GLYPHS; i++)
97  ch[i] = (WCHAR)i;
98 
99  HFONT hOldFont;
100  hOldFont = (HFONT)SelectObject(hdc, NewFont.hFont);
101 
102  // Translate all the indices into glyphs
104  DWORD Status;
106  ch,
107  MAX_GLYPHS,
108  out,
110  ReleaseDC(m_hwnd, hdc);
111  if (Status == GDI_ERROR)
112  {
113  SelectObject(hdc, hOldFont);
114  return false;
115  }
116 
117  // Loop all the glyphs looking for valid ones
118  // and store those in our font data
119  int j = 0;
120  for (int i = 0; i < MAX_GLYPHS; i++)
121  {
122  if (out[i] != 0xffff)
123  {
124  NewFont.ValidGlyphs[j] = ch[i];
125  j++;
126  }
127  }
128  NewFont.NumValidGlyphs = j;
129 
130  // Calculate the number of rows required to hold all glyphs
132  if (NewFont.NumValidGlyphs % m_xNumCells)
133  m_NumRows += 1;
134 
135  // Set the scrollbar in relation to the rows
137 
138  // We're done, update the current font
139  m_CurrentFont = NewFont;
140 
141  // We changed the font, we'll need to repaint the whole window
143  NULL,
144  TRUE);
145 
146  return true;
147 }
CurrentFont m_CurrentFont
Definition: GridView.h:35
#define LF_FACESIZE
Definition: dimm.idl:39
HWND m_hwnd
Definition: GridView.h:21
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
LONG lfHeight
Definition: dimm.idl:59
BYTE lfCharSet
Definition: dimm.idl:67
static HDC
Definition: imagelist.c:92
int m_NumRows
Definition: GridView.h:33
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MAX_GLYPHS
Definition: precomp.h:15
Status
Definition: gdiplustypes.h:24
LOGFONTW Font
Definition: GridView.h:9
USHORT ValidGlyphs[MAX_GLYPHS]
Definition: GridView.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
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:1084
HDC hdc
Definition: main.c:9
CAtlStringW FontName
Definition: GridView.h:8
int m_xNumCells
Definition: GridView.h:24
USHORT NumValidGlyphs
Definition: GridView.h:12
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HFONT hFont
Definition: GridView.h:10
#define NULL
Definition: types.h:112
BOOL WINAPI SetScrollRange(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ BOOL)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
int m_yNumCells
Definition: GridView.h:25
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 GDI_ERROR
Definition: wingdi.h:1308

Referenced by CCharMapWindow::ChangeMapFont().

◆ UpdateCellCoordinates()

bool CGridView::UpdateCellCoordinates ( )
private

Definition at line 154 of file GridView.cpp.

156 {
157  // Go through all the cells and calculate
158  // their coordinates within the grid
159  for (int y = 0; y < m_yNumCells; y++)
160  for (int x = 0; x < m_xNumCells; x++)
161  {
162  RECT CellCoordinates;
163  CellCoordinates.left = x * m_CellSize.cx;
164  CellCoordinates.top = y * m_CellSize.cy;
165  CellCoordinates.right = (x + 1) * m_CellSize.cx + 1;
166  CellCoordinates.bottom = (y + 1) * m_CellSize.cy + 1;
167 
168  m_Cells[y][x]->SetCellCoordinates(CellCoordinates);
169  }
170 
171  return true;
172 }
LONG top
Definition: windef.h:307
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
void SetCellCoordinates(_In_ RECT &Coordinates)
Definition: Cell.cpp:89
CCell *** m_Cells
Definition: GridView.h:29
LONG cx
Definition: windef.h:334
SIZE m_CellSize
Definition: GridView.h:28
int m_xNumCells
Definition: GridView.h:24
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
int m_yNumCells
Definition: GridView.h:25
LONG bottom
Definition: windef.h:309
LONG cy
Definition: windef.h:335

Referenced by OnSize().

Member Data Documentation

◆ m_ActiveCell

CCell* CGridView::m_ActiveCell
private

Definition at line 30 of file GridView.h.

Referenced by SetCellFocus().

◆ m_Cells

CCell*** CGridView::m_Cells
private

Definition at line 29 of file GridView.h.

Referenced by DeleteCells(), DrawGrid(), OnCreate(), and UpdateCellCoordinates().

◆ m_CellSize

SIZE CGridView::m_CellSize
private

Definition at line 28 of file GridView.h.

Referenced by OnSize(), OnVScroll(), and UpdateCellCoordinates().

◆ m_ClientCoordinates

RECT CGridView::m_ClientCoordinates
private

Definition at line 27 of file GridView.h.

Referenced by OnSize().

◆ m_CurrentFont

CurrentFont CGridView::m_CurrentFont
private

Definition at line 35 of file GridView.h.

Referenced by DrawGrid(), OnSize(), and SetFont().

◆ m_hParent

HWND CGridView::m_hParent
private

Definition at line 22 of file GridView.h.

Referenced by OnCreate(), and OnSize().

◆ m_hwnd

HWND CGridView::m_hwnd
private

Definition at line 21 of file GridView.h.

Referenced by Create(), GetHwnd(), OnCreate(), OnPaint(), OnSize(), OnVScroll(), SetCellFocus(), and SetFont().

◆ m_NumRows

int CGridView::m_NumRows
private

Definition at line 33 of file GridView.h.

Referenced by OnVScroll(), and SetFont().

◆ m_ScrollPosition

INT CGridView::m_ScrollPosition
private

Definition at line 32 of file GridView.h.

Referenced by DrawGrid(), and OnVScroll().

◆ m_szMapWndClass

CAtlStringW CGridView::m_szMapWndClass
private

Definition at line 19 of file GridView.h.

Referenced by CGridView(), and Create().

◆ m_xNumCells

int CGridView::m_xNumCells
private

Definition at line 24 of file GridView.h.

Referenced by DrawGrid(), OnCreate(), OnSize(), SetFont(), and UpdateCellCoordinates().

◆ m_yNumCells

int CGridView::m_yNumCells
private

The documentation for this class was generated from the following files: