Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/gui/gl/glgui_multiline_text.cc @ 10164

Last change on this file since 10164 was 10164, checked in by hejja, 14 years ago

border made

File size: 3.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program 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, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
17
18#include "glgui_multiline_text.h"
19
20#include "text.h"
21
22namespace OrxGui
23{
24  ObjectListDefinition(GLGuiMultiLineText);
25  /**
26   * standard constructor
27  */
28  GLGuiMultiLineText::GLGuiMultiLineText ()
29  {
30    this->init();
31
32  }
33
34
35  /**
36   * standard deconstructor
37  */
38  GLGuiMultiLineText::~GLGuiMultiLineText()
39  {}
40
41  /**
42   * initializes the GUI-element
43   */
44  void GLGuiMultiLineText::init()
45  {
46    this->registerObject(this, GLGuiMultiLineText::_objectList);
47
48    this->_text.setParent2D(this);
49    this->_text.setRelCoor2D(4,4);
50    this->_text.setFont("fonts/final_frontier.ttf", 20);
51    this->_text.setLineWidth(400);
52//     this->_text.setDotsPosition(LimitedWidthText::Begin);
53    this->_text.setColor(foregroundColor());
54    this->_text.setVisibility(false);
55    this->_changedTextColor = Color::white;
56    this->resize();
57  }
58
59  /**
60  * @brief sets the Text of the Text
61  * @param text The new Text.
62   */
63  void GLGuiMultiLineText::setText(const std::string& text)
64  {
65    this->_text.setText(text);
66    this->changedText();
67  }
68
69  /**
70   * @brief appends text to the Text
71   * @param appendText the Text to append
72   */
73  void GLGuiMultiLineText::append(const std::string& appendText)
74  {
75    this->_text.append(appendText);
76    this->changedText();
77  }
78
79
80  /**
81   * @brief appends a Character to the Text
82   * @param character the Character to append.
83   */
84  void GLGuiMultiLineText::appendCharacter(char character)
85  {
86    this->_text.appendCharacter(character);
87    this->changedText();
88  }
89
90
91  /**
92   * @brief Removes Characters from the Text
93   * @param chars The count of characters to remove
94   */
95  void GLGuiMultiLineText::removeCharacters(unsigned int chars)
96  {
97    this->_text.removeCharacters(chars);
98    this->changedText();
99  }
100
101  void GLGuiMultiLineText::clear()
102  {
103    this->_text.clear();
104    this->resize();
105  }
106
107
108  /**
109  * @brief If the Text has been changed this function is called.
110  *
111  * This Function also emits the Signal textChanged.
112   */
113  void GLGuiMultiLineText::changedText()
114  {
115    this->resize();
116    this->setFrontColor(_changedTextColor, true);
117    this->textChanged.emit(this->_text.text());
118  }
119
120  void GLGuiMultiLineText::setTextSize(float size)
121  {
122    this->_text.setSize(size);
123    this->changedText();
124  }
125
126  void GLGuiMultiLineText::setFont(const Font& font)
127  {
128    GLGuiWidget::setFont(font);
129    this->_text.setFont(font);
130  }
131
132  void GLGuiMultiLineText::setChangedTextColor(const Color& color)
133  {
134    this->_changedTextColor = color;
135  }
136
137  /**
138   * @brief Resizes the Widget to the new Size-constraints.
139   */
140  void GLGuiMultiLineText::resize()
141  {
142    this->_text.setRelCoor2D(borderLeft(), borderTop());
143    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
144    //this->_text.setLineWidth(this->size2D);
145    GLGuiWidget::resize();
146    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
147    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
148  }
149
150  void GLGuiMultiLineText::updateFrontColor()
151  {
152    this->_text.setColor(foregroundColor());
153  }
154
155  void GLGuiMultiLineText::hiding()
156  {
157    this->_text.setVisibility(false);
158  }
159
160  void GLGuiMultiLineText::showing()
161  {
162    this->_text.setVisibility(true);
163  }
164
165
166
167  /**
168   * draws the GLGuiMultiLineText
169   */
170  void GLGuiMultiLineText::draw() const
171  {
172    this->beginDraw();
173    GLGuiWidget::draw();
174
175    //     this->frontMaterial().select();
176    //     GLGuiWidget::drawRect(this->frontRect());
177
178    this->endDraw();
179  }
180}
Note: See TracBrowser for help on using the repository browser.