]> git.vomp.tv Git - vompclient.git/blob - wtextbox.cc
German updates
[vompclient.git] / wtextbox.cc
1 /*
2     Copyright 2005 Brian Walton
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "wtextbox.h"
22
23 #include "colour.h"
24
25 WTextbox::WTextbox(const char* ttext)
26 {
27 //  int fontHeight = Surface::getFontHeight();
28   //setDimensions(70, fontHeight);
29   //setDimensions(100,100);
30   setSize(100, 100);
31   text = NULL;
32   foreColour = Colour::LIGHTTEXT;
33   textX = 5;
34   textY = 2;
35   
36   paraMode = true;
37   
38   if (ttext) setText(ttext);
39 }
40
41 WTextbox::~WTextbox()
42 {
43   if (text) delete[] text;
44 }
45
46 void WTextbox::setParaMode(bool mode)
47 {
48   paraMode = mode;
49 }
50
51 void WTextbox::setText(const char* takeText)
52 {
53   if (text) delete[] text;
54   int length = strlen(takeText);
55   text = new char[length + 1];
56   strcpy(text, takeText);
57 }
58
59 void WTextbox::setForegroundColour(Colour fcolour)
60 {
61   foreColour = fcolour;
62 }
63
64 void WTextbox::draw()
65 {
66   Boxx::draw();
67   if (text)
68   {
69     if (paraMode) drawPara(text, textX, textY, foreColour);
70     else          drawText(text, textX, textY, foreColour);
71   }
72 }
73
74 void WTextbox::setTextPos(int x, int y)
75 {
76   textX = x;
77   textY = y;
78 }