-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcbtn.cpp
49 lines (40 loc) · 1.01 KB
/
cbtn.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
#include <cstring>
#include "cbtn.h"
button::button(short top, short left, short sizeX, short sizeY) {
topLeft.X = top;
topLeft.Y = left;
size.X = sizeX;
size.Y = sizeY;
bgColor = 0;
textColor = 7;
content = new unsigned char[size.X * size.Y];
for(int i = 0; i < size.X * size.Y; i++) {
content[i] = 32; // " " space
}
}
button::button( short top, short left, short sizeX, short sizeY, short bgColor,
short textColor) {
topLeft.X = top;
topLeft.Y = left;
size.X = sizeX;
size.Y = sizeY;
this->bgColor = bgColor;
this->textColor = textColor;
content = new unsigned char[size.X * size.Y];
for(int i = 0; i < size.X * size.Y; i++) {
content[i] = 32; // " " space
}
}
button::~button() {
delete content;
}
bool button::addContent(short posX, short posY, const char text[]) {
if(posX < 0 || size.X <= posX || posY < 0 || size.Y <= posY) {
// checking for starting index out of bounds
return false;
}
if(size.X <= + strlen(text) -1) {
// checking for ending index out of bounds
return false;
}
}