1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* PROJECT:     ReactOS Character Map
* LICENSE:     GPL - See COPYING in the top level directory
* FILE:        base/applications/charmap/cell.cpp
* PURPOSE:     Class for each individual cell
* COPYRIGHT:   Copyright 2015 Ged Murphy <gedmurphy@reactos.org>
*/


#include "precomp.h"
#include "Cell.h"


/* DATA *****************************************************/


/* PUBLIC METHODS **********************************************/

CCell::CCell(
    _In_ HWND hParent
    ) :
    CCell(hParent, RECT{0})
{
}

CCell::CCell(
    _In_ HWND hParent,
    _In_ RECT& CellCoordinates
    ) :
    m_hParent(hParent),
    m_CellCoordinates(CellCoordinates),
    m_Char(L'*'),
    m_bHasFocus(false),
    m_bIsLarge(false)
{
}

CCell::~CCell()
{
}

bool
CCell::OnPaint(_In_ PAINTSTRUCT &PaintStruct)
{
    // Check if this cell is in our paint region
    BOOL NeedsPaint; RECT rect;
    NeedsPaint = IntersectRect(&rect,
                               &PaintStruct.rcPaint,
                               &m_CellCoordinates);
    if (NeedsPaint == FALSE)
        return false;



    // Draw the cell border
    BOOL b = Rectangle(PaintStruct.hdc,
                       m_CellCoordinates.left,
                       m_CellCoordinates.top,
                       m_CellCoordinates.right,
                       m_CellCoordinates.bottom);

    // Calculate an internal drawing canvas for the cell
    RECT Internal;
    CopyRect(&Internal, &m_CellCoordinates);
    InflateRect(&Internal, -1, -1);

    // Check if this cell has focus
    if (m_bHasFocus)
    {
        // Draw the smaller cell to make it look selected
        Rectangle(PaintStruct.hdc,
                  Internal.left,
                  Internal.top,
                  Internal.right,
                  Internal.bottom);
    }

    int Success;
    Success = DrawTextW(PaintStruct.hdc,
                        &m_Char,
                        1,
                        &Internal,
                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);

    return (Success != 0);
}

void
CCell::SetCellCoordinates(
    _In_ RECT& Coordinates<--- Parameter 'Coordinates' can be declared with const
    )
{
    m_CellCoordinates = Coordinates;
}