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, 17 years ago

border made

File size: 3.9 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
[10164]18#include "glgui_multiline_text.h"
[1853]19
[5365]20#include "text.h"
21
[7779]22namespace OrxGui
[3365]23{
[10164]24  ObjectListDefinition(GLGuiMultiLineText);
[7779]25  /**
26   * standard constructor
27  */
[10164]28  GLGuiMultiLineText::GLGuiMultiLineText ()
[7779]29  {
30    this->init();
[4320]31
[7779]32  }
[1853]33
34
[7779]35  /**
36   * standard deconstructor
37  */
[10164]38  GLGuiMultiLineText::~GLGuiMultiLineText()
[8973]39  {}
[5360]40
[7779]41  /**
42   * initializes the GUI-element
43   */
[10164]44  void GLGuiMultiLineText::init()
[7779]45  {
[10164]46    this->registerObject(this, GLGuiMultiLineText::_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);
[10069]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   */
[10164]63  void GLGuiMultiLineText::setText(const std::string& text)
[8973]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   */
[10164]73  void GLGuiMultiLineText::append(const std::string& appendText)
[8973]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   */
[10164]84  void GLGuiMultiLineText::appendCharacter(char character)
[8973]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   */
[10164]95  void GLGuiMultiLineText::removeCharacters(unsigned int chars)
[8973]96  {
97    this->_text.removeCharacters(chars);
98    this->changedText();
99  }
100
[10164]101  void GLGuiMultiLineText::clear()
[8973]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   */
[10164]113  void GLGuiMultiLineText::changedText()
[8973]114  {
115    this->resize();
[8991]116    this->setFrontColor(_changedTextColor, true);
[9406]117    this->textChanged.emit(this->_text.text());
[8973]118  }
119
[10164]120  void GLGuiMultiLineText::setTextSize(float size)
[9656]121  {
122    this->_text.setSize(size);
123    this->changedText();
124  }
125
[10164]126  void GLGuiMultiLineText::setFont(const Font& font)
[9656]127  {
128    GLGuiWidget::setFont(font);
129    this->_text.setFont(font);
130  }
131
[10164]132  void GLGuiMultiLineText::setChangedTextColor(const Color& color)
[8991]133  {
134    this->_changedTextColor = color;
135  }
[8973]136
137  /**
138   * @brief Resizes the Widget to the new Size-constraints.
139   */
[10164]140  void GLGuiMultiLineText::resize()
[8973]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
[10164]150  void GLGuiMultiLineText::updateFrontColor()
[8973]151  {
152    this->_text.setColor(foregroundColor());
153  }
154
[10164]155  void GLGuiMultiLineText::hiding()
[8973]156  {
157    this->_text.setVisibility(false);
158  }
159
[10164]160  void GLGuiMultiLineText::showing()
[8973]161  {
162    this->_text.setVisibility(true);
163  }
164
165
166
167  /**
[10164]168   * draws the GLGuiMultiLineText
[7779]169   */
[10164]170  void GLGuiMultiLineText::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.