-
Notifications
You must be signed in to change notification settings - Fork 0
/
Control.cpp
197 lines (157 loc) · 2.99 KB
/
Control.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include "Control.h"
Control* Control::_focused = nullptr;
void Control::draw(Graphics& g, uint32_t x, uint32_t y, uint32_t z) const
{
}
void Control::mousePressed(uint32_t x, uint32_t y, bool isLeft)
{
}
void Control::mouseHover(uint32_t x, uint32_t y, bool isLeft)
{
return;
}
void Control::keyDown(uint32_t keyCode, char character)
{
}
Control* Control::getFocus()
{
return _focused;
}
void Control::setFocus(Control& control)
{
_focused = &control;
control.setCursorToEnd();
}
void Control::getAllControls(std::vector<Control*>& fill)
{
}
bool Control::canGetFocus() const
{
return _isFocusable;
}
void Control::setHidden(bool isHidden)
{
_isHidden = isHidden;
}
bool Control::getHidden(void) const
{
return _isHidden;
}
bool Control::isClickAble(void) const
{
return _isClickable;
}
void Control::setCoords(uint32_t x, uint32_t y)
{
_coords.X = x;
_coords.Y = y;
}
COORD Control::getCoords(void) const
{
return _coords;
}
uint32_t Control::getCursorPosition(void) const
{
return 0;
}
uint32_t Control::getWidth(void) const
{
return _width;
}
uint32_t Control::getHeight(void) const
{
return _height;
}
void Control::setHeight(uint32_t height)
{
_height = height;
}
uint32_t Control::getLeft(void) const
{
return _coords.X;
}
uint32_t Control::getTop(void) const
{
return _coords.Y;
}
void Control::setLayer(uint32_t layer)
{
if (layer < 5)
_layer = layer;
}
uint32_t Control::getLayer(void) const
{
return _layer;
}
void Control::setCursorToEnd(void)
{
}
void Control::setBackground(Color color)
{
_background = color;
}
void Control::setForeground(Color color)
{
_foreground = color;
}
Color Control::getBackground(void) const
{
return _background;
}
Color Control::getForeground(void) const
{
return _foreground;
}
bool Control::isTabAble() const
{
return false;
}
void Control::Show()
{
_isHidden = false;
_layer = 0;
}
void Control::Hide()
{
_isHidden = true;
_layer = 5;
}
void Control::setRedrawFlag(bool flag)
{
}
bool Control::getRedrawFlag(void) const
{
return false;
}
void Control::closeBox()
{
}
void Control::setBorder(BorderType bt)
{
switch (bt)
{
case BorderType::None:
setBorderDrawer(SimpleBorderFactory::instance().getNull());
break;
case BorderType::Single:
setBorderDrawer(SimpleBorderFactory::instance().getSingle());
break;
case BorderType::Double:
setBorderDrawer(SimpleBorderFactory::instance().getDouble());
break;
default:
break;
}
}
Control::Control(const uint32_t& width, const uint32_t& height, const bool& isFocusable, const bool& isClickable) : _width(width), _height(height), _isFocusable(isFocusable), _layer(0),
_background(Color::Black), _foreground(Color::White), _isHidden(false), _isClickable(isClickable)
{
}
Control::~Control()
{
}
void Control::drawBorder(Graphics& g, uint32_t x, uint32_t y, uint32_t z) const
{
if (_borderDrawer)
_borderDrawer->draw(g, getLeft(), getTop(), getWidth(), getHeight());
}