Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9015 in orxonox.OLD


Ignore:
Timestamp:
Jul 2, 2006, 3:04:20 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: text-field

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/glgui.h

    r8619 r9015  
    1919#include "glgui_slider.h"
    2020#include "glgui_cursor.h"
     21#include "glgui_text.h"
    2122#include "glgui_inputline.h"
    2223#include "glgui_textfield.h"
  • trunk/src/lib/gui/gl/glgui_textfield.cc

    r8448 r9015  
    1717
    1818#include "glgui_textfield.h"
     19
     20#include "text.h"
     21
    1922namespace OrxGui
    2023{
    21 
    2224  /**
    2325   * standard constructor
     
    3436  */
    3537  GLGuiTextfield::~GLGuiTextfield()
    36   {
    37   }
     38  {}
    3839
    3940  /**
     
    4344  {
    4445    this->setClassID(CL_GLGUI_TEXTFIELD, "GLGuiTextfield");
     46
     47    this->_text.setParent2D(this);
     48    this->_text.setRelCoor2D(4,4);
     49    this->_text.setFont("fonts/final_frontier.ttf", 20);
     50    this->_text.setLineWidth(400);
     51    this->_text.setColor(foregroundColor());
     52    this->_text.setVisibility(false);
     53    this->_changedTextColor = Color::white;
     54    this->resize();
    4555  }
    4656
    4757  /**
    48    * @brief draws the GLGuiTextfield
     58  * @brief sets the Text of the Text
     59  * @param text The new Text.
     60   */
     61  void GLGuiTextfield::setText(const std::string& text)
     62  {
     63    this->_text.setText(text);
     64    this->changedText();
     65  }
     66
     67  /**
     68   * @brief appends text to the Text
     69   * @param appendText the Text to append
     70   */
     71  void GLGuiTextfield::append(const std::string& appendText)
     72  {
     73    this->_text.append(appendText);
     74    this->changedText();
     75  }
     76
     77
     78  /**
     79   * @brief appends a Character to the Text
     80   * @param character the Character to append.
     81   */
     82  void GLGuiTextfield::appendCharacter(char character)
     83  {
     84    this->_text.appendCharacter(character);
     85    this->changedText();
     86  }
     87
     88
     89  /**
     90   * @brief Removes Characters from the Text
     91   * @param chars The count of characters to remove
     92   */
     93  void GLGuiTextfield::removeCharacters(unsigned int chars)
     94  {
     95    this->_text.removeCharacters(chars);
     96    this->changedText();
     97  }
     98
     99  void GLGuiTextfield::clear()
     100  {
     101    this->_text.clear();
     102    this->changedText();
     103  }
     104
     105  /**
     106  * @brief If the Text has been changed this function is called.
     107  *
     108  * This Function also emits the Signal textChanged.
     109   */
     110  void GLGuiTextfield::changedText()
     111  {
     112    this->resize();
     113    this->setFrontColor(_changedTextColor, true);
     114    emit(this->textChanged(this->_text.text()));
     115  }
     116
     117  void GLGuiTextfield::setChangedTextColor(const Color& color)
     118  {
     119    this->_changedTextColor = color;
     120  }
     121
     122  /**
     123   * @brief Resizes the Widget to the new Size-constraints.
     124   */
     125  void GLGuiTextfield::resize()
     126  {
     127    this->_text.setRelCoor2D(borderLeft(), borderTop());
     128    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
     129    //this->_text.setLineWidth(this->size2D);
     130    GLGuiWidget::resize();
     131    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     132    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
     133  }
     134
     135  void GLGuiTextfield::updateFrontColor()
     136  {
     137    this->_text.setColor(foregroundColor());
     138  }
     139
     140  void GLGuiTextfield::hiding()
     141  {
     142    this->_text.setVisibility(false);
     143  }
     144
     145  void GLGuiTextfield::showing()
     146  {
     147    this->_text.setVisibility(true);
     148  }
     149
     150
     151
     152  /**
     153   * draws the GLGuiTextfield
    49154   */
    50155  void GLGuiTextfield::draw() const
     
    53158    GLGuiWidget::draw();
    54159
    55 /*    this->frontMaterial().select();
    56     this->drawRect(this->frontRect());*/
     160    //     this->frontMaterial().select();
     161    //     GLGuiWidget::drawRect(this->frontRect());
     162
    57163    this->endDraw();
    58164  }
  • trunk/src/lib/gui/gl/glgui_textfield.h

    r8145 r9015  
    11/*!
    22 * @file glgui_textfield.h
    3  * The gl_ widget of th openglGUI
     3 * The gl_TEXTFIELD widget of th openglGUI
    44 *
    55 */
     
    99
    1010#include "glgui_widget.h"
    11 
    12 #include "text.h"
    13 #include <vector>
    14 
     11#include "multi_line_text.h"
    1512// FORWARD DECLARATION
    16 class Text;
    1713namespace OrxGui
    1814{
     
    2925    virtual ~GLGuiTextfield();
    3026
    31     void init();
     27    void setText(const std::string& text);
     28    void append(const std::string& appendText);
     29    void appendCharacter(char character);
     30    void removeCharacters(unsigned int chars);
     31    void clear();
    3232
    33     void process(const Event& event);
     33    void setChangedTextColor(const Color& color);
     34
     35    const std::string& text() const { return _text.text(); };
     36
    3437
    3538    virtual void draw() const;
    3639
     40    DeclareSignal1(textChanged, const std::string&);
     41
     42  protected:
     43    virtual void updateFrontColor();
     44    virtual void hiding();
     45    virtual void showing();
     46    virtual void resize();
     47
    3748  private:
    38     std::vector<Text>        textLines;
     49    void init();
     50    void changedText();
    3951
     52
     53  private:
     54    MultiLineText      _text;
     55
     56    Color               _changedTextColor;
    4057  };
    4158}
    42 #endif /* _GLGUI__H */
     59
     60#endif /* _GLGUI_TEXTFIELD_H */
  • trunk/src/story_entities/menu/game_menu.cc

    r9014 r9015  
    251251    this->optionsBox = new OrxGui::GLGuiBox();
    252252    {
     253      OrxGui::GLGuiTextfield* WARNtext = new OrxGui::GLGuiTextfield();
     254      WARNtext->setText("PLEASE USE THE EXTERNAL GUI\n FOR ORXONOX CONFIGURATION\n (start with './orxonox -g')");
     255      optionsBox->pack(WARNtext);
     256
     257
    253258      OrxGui::GLGuiButton* generalButton = new OrxGui::GLGuiPushButton("General");
    254259      optionsBox->pack(generalButton);
Note: See TracChangeset for help on using the changeset viewer.