Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_text.cc @ 9908

Last change on this file since 9908 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.7 KB
RevLine 
[4744]1/*
[1853]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.
[1855]10
11   ### File Specific:
[5360]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5360]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
[1853]17
[5365]18#include "glgui_text.h"
[1853]19
[5365]20#include "text.h"
21
[7779]22namespace OrxGui
[3365]23{
[9869]24  ObjectListDefinition(GLGuiText);
[7779]25  /**
26   * standard constructor
27  */
28  GLGuiText::GLGuiText ()
29  {
30    this->init();
[4320]31
[7779]32  }
[1853]33
34
[7779]35  /**
36   * standard deconstructor
37  */
38  GLGuiText::~GLGuiText()
[8973]39  {}
[5360]40
[7779]41  /**
42   * initializes the GUI-element
43   */
44  void GLGuiText::init()
45  {
[9869]46    this->registerObject(this, GLGuiText::_objectList);
[5360]47
[8973]48    this->_text.setParent2D(this);
49    this->_text.setRelCoor2D(4,4);
50    this->_text.setFont("fonts/final_frontier.ttf", 20);
[8980]51    this->_text.setLineWidth(400);
52    this->_text.setDotsPosition(LimitedWidthText::Begin);
[8973]53    this->_text.setColor(foregroundColor());
54    this->_text.setVisibility(false);
[8991]55    this->_changedTextColor = Color::white;
[8973]56    this->resize();
[7779]57  }
[5360]58
[7779]59  /**
[8973]60  * @brief sets the Text of the Text
61  * @param text The new Text.
62   */
63  void GLGuiText::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 GLGuiText::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 GLGuiText::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 GLGuiText::removeCharacters(unsigned int chars)
96  {
97    this->_text.removeCharacters(chars);
98    this->changedText();
99  }
100
101  void GLGuiText::clear()
102  {
103    this->_text.clear();
[9656]104    this->resize();
[8973]105  }
106
[9656]107
[8973]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 GLGuiText::changedText()
114  {
115    this->resize();
[8991]116    this->setFrontColor(_changedTextColor, true);
[9406]117    this->textChanged.emit(this->_text.text());
[8973]118  }
119
[9656]120  void GLGuiText::setTextSize(float size)
121  {
122    this->_text.setSize(size);
123    this->changedText();
124  }
125
126  void GLGuiText::setFont(const Font& font)
127  {
128    GLGuiWidget::setFont(font);
129    this->_text.setFont(font);
130  }
131
[8991]132  void GLGuiText::setChangedTextColor(const Color& color)
133  {
134    this->_changedTextColor = color;
135  }
[8973]136
137  /**
138   * @brief Resizes the Widget to the new Size-constraints.
139   */
140  void GLGuiText::resize()
141  {
142    this->_text.setRelCoor2D(borderLeft(), borderTop());
143    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
[8980]144    //this->_text.setLineWidth(this->size2D);
[8973]145    GLGuiWidget::resize();
146    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
147    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
148  }
149
150  void GLGuiText::updateFrontColor()
151  {
152    this->_text.setColor(foregroundColor());
153  }
154
155  void GLGuiText::hiding()
156  {
157    this->_text.setVisibility(false);
158  }
159
160  void GLGuiText::showing()
161  {
162    this->_text.setVisibility(true);
163  }
164
165
166
167  /**
[7779]168   * draws the GLGuiText
169   */
[8973]170  void GLGuiText::draw() const
[7779]171  {
[8973]172    this->beginDraw();
173    GLGuiWidget::draw();
174
175    //     this->frontMaterial().select();
176    //     GLGuiWidget::drawRect(this->frontRect());
177
178    this->endDraw();
[7779]179  }
[5360]180}
Note: See TracBrowser for help on using the repository browser.