ReactOS  0.4.12-dev-18-gf469aca
Cell.cpp
Go to the documentation of this file.
1 /*
2 * PROJECT: ReactOS Character Map
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/charmap/cell.cpp
5 * PURPOSE: Class for each individual cell
6 * COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy@reactos.org>
7 */
8 
9 
10 #include "precomp.h"
11 #include "Cell.h"
12 
13 
14 /* DATA *****************************************************/
15 
16 
17 /* PUBLIC METHODS **********************************************/
18 
21  ) :
22  CCell(hParent, RECT{0})
23 {
24 }
25 
28  _In_ RECT& CellCoordinates
29  ) :
30  m_hParent(hParent),
31  m_CellCoordinates(CellCoordinates),
32  m_Char(L'*'),
35 {
36 }
37 
39 {
40 }
41 
42 bool
44 {
45  // Check if this cell is in our paint region
46  BOOL NeedsPaint; RECT rect;
47  NeedsPaint = IntersectRect(&rect,
48  &PaintStruct.rcPaint,
50  if (NeedsPaint == FALSE)
51  return false;
52 
53 
54 
55  // Draw the cell border
56  BOOL b = Rectangle(PaintStruct.hdc,
61 
62  // Calculate an internal drawing canvas for the cell
63  RECT Internal;
64  CopyRect(&Internal, &m_CellCoordinates);
65  InflateRect(&Internal, -1, -1);
66 
67  // Check if this cell has focus
68  if (m_bHasFocus)
69  {
70  // Draw the smaller cell to make it look selected
71  Rectangle(PaintStruct.hdc,
72  Internal.left,
73  Internal.top,
74  Internal.right,
75  Internal.bottom);
76  }
77 
78  int Success;
79  Success = DrawTextW(PaintStruct.hdc,
80  &m_Char,
81  1,
82  &Internal,
84 
85  return (Success != 0);
86 }
87 
88 void
90  _In_ RECT& Coordinates
91  )
92 {
93  m_CellCoordinates = Coordinates;
94 }
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HWND m_hParent
Definition: Cell.h:5
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
& rect
Definition: startmenu.cpp:1413
void SetCellCoordinates(_In_ RECT &Coordinates)
Definition: Cell.cpp:89
bool m_bIsLarge
Definition: Cell.h:9
#define DT_VCENTER
Definition: winuser.h:543
bool m_bHasFocus
Definition: Cell.h:8
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: Cell.h:2
#define false
Definition: stdbool.h:38
static const WCHAR L[]
Definition: oid.c:1087
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define _In_
Definition: no_sal2.h:204
#define DT_SINGLELINE
Definition: winuser.h:540
bool OnPaint(_In_ PAINTSTRUCT &PaintStruct)
Definition: Cell.cpp:43
RECT m_CellCoordinates
Definition: Cell.h:6
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
LONG bottom
Definition: windef.h:299
#define DT_CENTER
Definition: winuser.h:527
CCell(_In_ HWND hParent)
Definition: Cell.cpp:19
~CCell()
Definition: Cell.cpp:38
WCHAR m_Char
Definition: Cell.h:10
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17