Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_textfield.cc @ 10727

Last change on this file since 10727 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.6 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
[7919]18#include "glgui_textfield.h"
[9015]19
20#include "text.h"
21
[7779]22namespace OrxGui
[3365]23{
[9869]24  ObjectListDefinition(GLGuiTextfield);
[7779]25  /**
26   * standard constructor
27  */
28  GLGuiTextfield::GLGuiTextfield ()
29  {
30    this->init();
[1853]31
[7779]32  }
[1853]33
[5360]34
[7779]35  /**
36   * standard deconstructor
37  */
38  GLGuiTextfield::~GLGuiTextfield()
[9015]39  {}
[5360]40
[7779]41  /**
42   * initializes the GUI-element
43   */
44  void GLGuiTextfield::init()
45  {
[9869]46    this->registerObject(this, GLGuiTextfield::_objectList);
[9015]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.setColor(foregroundColor());
53    this->_text.setVisibility(false);
54    this->_changedTextColor = Color::white;
55    this->resize();
[7779]56  }
[5360]57
[7779]58  /**
[9015]59  * @brief sets the Text of the Text
60  * @param text The new Text.
[7779]61   */
[9015]62  void GLGuiTextfield::setText(const std::string& text)
63  {
64    this->_text.setText(text);
65    this->changedText();
66  }
67
68  /**
69   * @brief appends text to the Text
70   * @param appendText the Text to append
71   */
72  void GLGuiTextfield::append(const std::string& appendText)
73  {
74    this->_text.append(appendText);
75    this->changedText();
76  }
77
78
79  /**
80   * @brief appends a Character to the Text
81   * @param character the Character to append.
82   */
83  void GLGuiTextfield::appendCharacter(char character)
84  {
85    this->_text.appendCharacter(character);
86    this->changedText();
87  }
88
89
90  /**
91   * @brief Removes Characters from the Text
92   * @param chars The count of characters to remove
93   */
94  void GLGuiTextfield::removeCharacters(unsigned int chars)
95  {
96    this->_text.removeCharacters(chars);
97    this->changedText();
98  }
99
100  void GLGuiTextfield::clear()
101  {
102    this->_text.clear();
103    this->changedText();
104  }
105
106  /**
107  * @brief If the Text has been changed this function is called.
108  *
109  * This Function also emits the Signal textChanged.
110   */
111  void GLGuiTextfield::changedText()
112  {
113    this->resize();
114    this->setFrontColor(_changedTextColor, true);
[9406]115    this->textChanged.emit(this->_text.text());
[9015]116  }
117
118  void GLGuiTextfield::setChangedTextColor(const Color& color)
119  {
120    this->_changedTextColor = color;
121  }
122
123  /**
124   * @brief Resizes the Widget to the new Size-constraints.
125   */
126  void GLGuiTextfield::resize()
127  {
128    this->_text.setRelCoor2D(borderLeft(), borderTop());
129    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
130    //this->_text.setLineWidth(this->size2D);
131    GLGuiWidget::resize();
132    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
133    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
134  }
135
136  void GLGuiTextfield::updateFrontColor()
137  {
138    this->_text.setColor(foregroundColor());
139  }
140
141  void GLGuiTextfield::hiding()
142  {
143    this->_text.setVisibility(false);
144  }
145
146  void GLGuiTextfield::showing()
147  {
148    this->_text.setVisibility(true);
149  }
150
151
152
153  /**
154   * draws the GLGuiTextfield
155   */
[7919]156  void GLGuiTextfield::draw() const
[7779]157  {
[8035]158    this->beginDraw();
159    GLGuiWidget::draw();
160
[9015]161    //     this->frontMaterial().select();
162    //     GLGuiWidget::drawRect(this->frontRect());
163
[8035]164    this->endDraw();
[7779]165  }
[5360]166}
Note: See TracBrowser for help on using the repository browser.