[CHARMAP]
[reactos.git] / reactos / base / applications / charmap_new / Cell.cpp
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
19 CCell::CCell(
20 _In_ HWND hParent
21 ) :
22 CCell(hParent, RECT{0})
23 {
24 }
25
26 CCell::CCell(
27 _In_ HWND hParent,
28 _In_ RECT& CellCoordinates
29 ) :
30 m_hParent(hParent),
31 m_CellCoordinates(CellCoordinates),
32 ch(L'*'),
33 m_bHasFocus(false),
34 m_bIsLarge(false)
35 {
36 }
37
38 CCell::~CCell()
39 {
40 }
41
42 bool
43 CCell::OnPaint(_In_ PAINTSTRUCT &PaintStruct)
44 {
45 // Check if this cell is in our paint region
46 BOOL NeedsPaint; RECT rect;
47 NeedsPaint = IntersectRect(&rect,
48 &PaintStruct.rcPaint,
49 &m_CellCoordinates);
50 if (NeedsPaint == FALSE)
51 return false;
52
53 // Draw the cell border
54 BOOL b = Rectangle(PaintStruct.hdc,
55 m_CellCoordinates.left,
56 m_CellCoordinates.top,
57 m_CellCoordinates.right,
58 m_CellCoordinates.bottom);
59
60 // Check if this cell has focus
61 if (m_bHasFocus)
62 {
63 // Take a copy of the border dims and make it slightly smaller
64 RECT Internal;
65 CopyRect(&Internal, &m_CellCoordinates);
66 InflateRect(&Internal, -1, -1);
67
68 // Draw the smaller cell to make it look selected
69 Rectangle(PaintStruct.hdc,
70 Internal.left,
71 Internal.top,
72 Internal.right,
73 Internal.bottom);
74 }
75
76 return true;
77 }
78
79 void
80 CCell::SetCellCoordinates(
81 _In_ RECT& Coordinates
82 )
83 {
84 m_CellCoordinates = Coordinates;
85 }