summaryrefslogtreecommitdiff
path: root/src/interface/Textblock.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-26 19:57:10 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-26 19:57:10 (GMT)
commitab6fed71d74371e2d38372eae71ee26a7ef214df (patch)
tree4f139ad5501bb66dcc9c4770d1ceb7be6e159284 /src/interface/Textblock.cpp
parente26cb8ce2f69b81442194bd2310cfc3ea6bb6f5f (diff)
downloadpowder-ab6fed71d74371e2d38372eae71ee26a7ef214df.zip
powder-ab6fed71d74371e2d38372eae71ee26a7ef214df.tar.gz
Replace textblock with new multiline label - with text selection!!!!111!!!one!!
Diffstat (limited to 'src/interface/Textblock.cpp')
-rw-r--r--src/interface/Textblock.cpp77
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
-}
-