diff options
Diffstat (limited to 'src/interface/Textblock.cpp')
| -rw-r--r-- | src/interface/Textblock.cpp | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/interface/Textblock.cpp b/src/interface/Textblock.cpp deleted file mode 100644 index f003a6a..0000000 --- a/src/interface/Textblock.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Textblock.cpp - * - * Created on: Jan 29, 2012 - * Author: Simon - */ - -#include <iostream> -#include "Textblock.h" - -using namespace ui; - -Textblock::Textblock(Point position, Point size, std::string textboxText): - Label(position, size, textboxText) -{ - if(size.Y==-1) - autoHeight = true; - else - autoHeight = false; - updateMultiline(); -} - -void Textblock::SetText(std::string text) -{ - this->text = text; - updateMultiline(); -} - -void Textblock::updateMultiline() -{ - char * rawText = new char[text.length()+1]; - std::copy(text.begin(), text.end(), rawText); - rawText[text.length()] = 0; - - int lines = 1; - int currentWidth = 0; - char * lastSpace = NULL; - char * currentWord = rawText; - char * nextSpace; - while(true) - { - nextSpace = strchr(currentWord+1, ' '); - if(nextSpace) - nextSpace[0] = 0; - int width = Graphics::textwidth(currentWord); - if(width+currentWidth > Size.X-6) - { - currentWidth = width; - currentWord[0] = '\n'; - lines++; - } - else - currentWidth += width; - if(nextSpace) - nextSpace[0] = ' '; - if(!(currentWord = strchr(currentWord+1, ' '))) - break; - } - if(autoHeight) - { - Size.Y = lines*12; - } - textLines = std::string(rawText); - delete[] rawText; -} - -void Textblock::Draw(const Point &screenPos) -{ - Graphics * g = ui::Engine::Ref().g; - //g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, textColour.Red, textColour.Green, textColour.Blue, 255); - g->drawtext(screenPos.X+3, screenPos.Y+3, textLines, textColour.Red, textColour.Green, textColour.Blue, 255); -} - -Textblock::~Textblock() { - // TODO Auto-generated destructor stub -} - |
