summaryrefslogtreecommitdiff
path: root/src/interface/Label.cpp
blob: ceb5a4e88e0c1042a8ac45906d3cba1a9c5a0e8f (plain)
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
#include <string>
#include "Config.h"
#include "Point.h"
#include "Label.h"

using namespace ui;

/*Label::Label(Window* parent_state, std::string labelText):
	Component(parent_state),
	text(labelText),
	textPosition(ui::Point(0, 0)),
	textVAlign(AlignMiddle),
	textHAlign(AlignCentre)
{
	TextPosition();
}*/

Label::Label(Point position, Point size, std::string labelText):
	Component(position, size),
	text(labelText),
	textColour(255, 255, 255)
{
}

/*Label::Label(std::string labelText):
	Component(),
	text(labelText),
	textPosition(ui::Point(0, 0)),
	textVAlign(AlignMiddle),
	textHAlign(AlignCentre)
{
	TextPosition();
}*/

Label::~Label()
{

}

void Label::SetText(std::string text)
{
	this->text = text;
	TextPosition(text);
}

std::string Label::GetText()
{
	return this->text;
}

void Label::Draw(const Point& screenPos)
{
	if(!drawn)
	{
		TextPosition(text);
		drawn = true;
	}
	Graphics * g = Engine::Ref().g;
	g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, text, textColour.Red, textColour.Green, textColour.Blue, 255);
}