-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanel.cpp
91 lines (76 loc) · 2 KB
/
Panel.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
/**
* Panel.cpp
*
* $Revision$
* $Id$
*
* @see Panel.h
*/
#include "Panel.h"
// asetetaan jonkinlaiset defaultit
VPanel::VPanel() {
m_borderStyle = SGraphics::BORDER_SIMPLE;
m_borderBG = SGraphics::GCOLOR_BLACK;
m_borderFG = SGraphics::GCOLOR_LIGHTGREEN;
m_foreground = SGraphics::GCOLOR_WHITE;
m_background = SGraphics::GCOLOR_BLACK;
m_border = true;
m_x = 1;
m_y = 1;
m_width = 10;
m_height = 10;
}
void VPanel::setLocation(const int x, const int y) {
m_x = (x > 0) ? x : m_x;
m_y = (y > 0) ? y : m_y;
}
int VPanel::getX() {
return m_x;
}
int VPanel::getY() {
return m_y;
}
void VPanel::setX(const int newX) {
m_x = newX;
}
void VPanel::setY(const int newY) {
m_y = newY;
}
int VPanel::getWidth(void) {
return (m_border) ? m_width+2 : m_width;
}
int VPanel::getHeight(void) {
return (m_border) ? m_height+2 : m_height;
}
/*
void VPanel::setBorderVisible(bool visible) {
return; // TODO: tämä ei ole vielä kokonaan tuettu, pidetään borderit toistaiseksi päällä..
m_border = visible;
drawBorder();
}*/
void VPanel::setBorderColor(const SGraphics::GCOLOR fg, const SGraphics::GCOLOR bg) {
m_borderFG = fg;
m_borderBG = bg;
}
void VPanel::setBorderStyle(const SGraphics::BORDER_STYLE bs) {
m_borderStyle = bs;
drawBorder();
}
// panelin tulee piirtää itsensä kun tätä kutsutaan
void VPanel::draw(void) {
drawBorder();
}
// piirretään borderi
void VPanel::drawBorder(void) {
if(m_border) {
SGraphics::getInstance().setColors(m_borderFG, m_borderBG);
SGraphics::getInstance().drawBox(m_x, m_y, m_x+m_width+1, m_y+m_height+1, m_borderStyle);
}
}
void VPanel::hide(void) {
int w = (m_border) ? m_width+2 : m_width;
int h = (m_border) ? m_height+2 : m_height;
for(int x = m_x; x<m_x+w; x++)
for(int y = m_y; y<m_y+h; y++)
SGraphics::getInstance().drawChar(x, y, SGraphics::GCOLOR_BLACK, SGraphics::GCOLOR_BLACK, ' ');
}