diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-15 17:13:17 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-05-15 17:13:17 (GMT) |
| commit | 136675b56a8a1862afb41ccee5c14e93e483b964 (patch) | |
| tree | 8f679477c5e1c0984a5cb9c169e339c1ca0d6e0c /src/interface/Label.cpp | |
| parent | 45563e97e813cfd21724ad1111e5de3e04679e1a (diff) | |
| download | powder-136675b56a8a1862afb41ccee5c14e93e483b964.zip powder-136675b56a8a1862afb41ccee5c14e93e483b964.tar.gz | |
Move style into Component
Diffstat (limited to 'src/interface/Label.cpp')
| -rw-r--r-- | src/interface/Label.cpp | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index b6fbb5f..ceb5a4e 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -18,12 +18,8 @@ using namespace ui; Label::Label(Point position, Point size, std::string labelText): Component(position, size), text(labelText), - textPosition(ui::Point(0, 0)), - textVAlign(AlignMiddle), - textHAlign(AlignCentre), textColour(255, 255, 255) { - TextPosition(); } /*Label::Label(std::string labelText): @@ -41,44 +37,24 @@ Label::~Label() } -void Label::TextPosition() +void Label::SetText(std::string text) { - //Position.X+(Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2, Position.Y+(Size.Y-10)/2 - switch(textVAlign) - { - case AlignTop: - textPosition.Y = 3; - break; - case AlignMiddle: - textPosition.Y = (Size.Y-10)/2; - break; - case AlignBottom: - textPosition.Y = Size.Y-11; - break; - } - - switch(textHAlign) - { - case AlignLeft: - textPosition.X = 3; - break; - case AlignCentre: - textPosition.X = (Size.X-Graphics::textwidth((char *)text.c_str()))/2; - break; - case AlignRight: - textPosition.X = (Size.X-Graphics::textwidth((char *)text.c_str()))-2; - break; - } + this->text = text; + TextPosition(text); } -void Label::SetText(std::string text) +std::string Label::GetText() { - this->text = text; - TextPosition(); + 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); } |
