#include "cLabel.hpp" using GUIEngine::cLabel; /*static*/ const cString cLabel::sNAME = "label"; /*static*/ const GUIHelpers::eLayout cLabel::sLAYOUT = GUIHelpers::eLayout::WRAP_CONTENT; cLabel::cLabel(cWindow* parent, const signed int id, const cString& label /*= ""*/, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/, const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding /*= sPADDING*/, const cString& name /*= sNAME*/) { mp_text = new TextTypeEngine::cText(label); Create(parent, id, label, align, layout, pos, size, padding, name); } /*virtual*/ cLabel::~cLabel() { delete mp_text; mp_text = nullptr; } ///Functions void cLabel::Create(cWindow* parent, const signed int id, const cString& label /*= ""*/, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/, const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding /*= sPADDING*/, const cString& name /*= sNAME*/) { cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name); if (this->getParent() != nullptr) { this->getParent()->AddChild(this); } setText(label); } /*virtual*/ void cLabel::Display() { GenerateTexture(); cSprite::setPosition(cWindow::getPosition()); cSprite::Draw(); cSprite::SaveImage("test.bmp", "xml/"); } void cLabel::GenerateTexture() { this->setImage((VideoEngine::cImage**)(&mp_text)); this->setImageArea(mp_text->getWH()); //this->setTransparent(); //this->setPosition() } //Sets void cLabel::setFontColour(const GUIHelpers::RBGA& colour) { mp_text->setColour(colour); } void cLabel::setFontSize(const unsigned long int size) { mp_text->setSize(size); } void cLabel::setText(const cString& text) { mp_text->setText(text); } void cLabel::setFont(const TextTypeEngine::cFont* font) { mp_text->setFont((TextTypeEngine::cFont**)(&font)); } ///Gets const GUIHelpers::RBGA& cLabel::getFontColour() const { return mp_text->getColour(); } const unsigned long int cLabel::getFontSize() const { return mp_text->getSize(); } const TextTypeEngine::cFont* cLabel::getFont() const { return mp_text->getFont(); } const cString& cLabel::getText() const { return mp_text->getText(); } /*virtual*/ const GUIHelpers::eType cLabel::getType() const { return GUIHelpers::eType::CLABEL; } /*virtual*/ void cLabel::Resize() { RebuildLayout(this->getLayout()); cWindow::Resize(); } /*virtual*/ void cLabel::RebuildLayout(const GUIHelpers::eLayout& layout) { switch (layout) { case GUIHelpers::eLayout::MATCH_PARENT: case GUIHelpers::eLayout::FILL_PARENT: //break; case GUIHelpers::eLayout::WRAP_CONTENT: long int x = (mp_text->getText().length() * mp_text->getSize()); GUIHelpers::Size size = { x, 8 }; // size.x += this->getPadding().x + this->getPadding().w; // size.y += this->getPadding().y + this->getPadding().z; this->setSize(size); break; } }