-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCell.cpp
73 lines (56 loc) · 1.24 KB
/
Cell.cpp
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
#include "Cell.h"
const Cell Cell::emptyCell(Cell::Type::Empty, Cell::CHAR_EMPTY, static_cast<WORD>(ConsoleColor::Black));
const Cell Cell::borderCell(Cell::Type::Border, Cell::CHAR_BLOCK, static_cast<WORD>(ConsoleColor::White) << 4);
const Cell Cell::blockCell(Cell::Type::Block, Cell::CHAR_BLOCK);
Cell::Cell(Type type)
: mType(type) {}
Cell::Cell(Type type, WCHAR c)
: mType(type)
, mChar(c) {}
Cell::Cell(Type type, WCHAR c, WORD colorAttr)
: mType(type)
, mChar(c)
, mColorAttr(colorAttr) {}
Cell::Cell(WORD colorAttr)
: mColorAttr(colorAttr) {}
CHAR_INFO Cell::ToCharInfo() const
{
CHAR_INFO info = {};
info.Char.UnicodeChar = mChar;
info.Attributes = mColorAttr;
return info;
}
Cell::Type Cell::GetType() const
{
return mType;
}
void Cell::SetType(Type type)
{
mType = type;
}
WCHAR Cell::GetChar() const
{
return mChar;
}
void Cell::SetChar(WCHAR c)
{
mChar = c;
}
WORD Cell::GetAttributes() const
{
return mColorAttr;
}
void Cell::SetAttributes(WORD ColorAttr)
{
mColorAttr = ColorAttr;
}
void Cell::SetForegroundColor(ConsoleColor color)
{
mColorAttr &= 0xFFF0;
mColorAttr |= static_cast<WORD>(color);
}
void Cell::SetBackgroundColor(ConsoleColor color)
{
mColorAttr &= 0xFF0F;
mColorAttr |= static_cast<WORD>(color) << 4;
}