Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8973 in orxonox.OLD


Ignore:
Timestamp:
Jul 1, 2006, 11:37:42 AM (18 years ago)
Author:
bensch
Message:

trunk: gui: full functionality of Text

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r8894 r8973  
    370370  CL_GLGUI_BAR                  =    0x00000b30,
    371371  CL_GLGUI_CURSOR               =    0x00000b50,
     372  CL_GLGUI_TEXT                 =    0x00000b51,
    372373  CL_GLGUI_INPUTLINE            =    0x00000b60,
    373374  CL_GLGUI_TEXTFIELD            =    0x00000b61,
  • trunk/src/lib/gui/gl/Makefile.am

    r8717 r8973  
    2424                glgui_box.cc \
    2525                glgui_frame.cc \
     26                glgui_text.cc \
    2627                glgui_inputline.cc \
    2728                glgui_textfield.cc \
     
    5152                glgui_box.h \
    5253                glgui_frame.h \
     54                glgui_text.h \
    5355                glgui_inputline.h \
    5456                glgui_textfield.h \
  • trunk/src/lib/gui/gl/glgui_text.cc

    r8145 r8973  
    3636  */
    3737  GLGuiText::~GLGuiText()
    38   {
    39   }
     38  {}
    4039
    4140  /**
     
    4443  void GLGuiText::init()
    4544  {
    46     this->setClassID(CL_GLGUI_, "GLGuiText");
     45    this->setClassID(CL_GLGUI_TEXT, "GLGuiText");
    4746
     47    this->_text.setParent2D(this);
     48    this->_text.setRelCoor2D(4,4);
     49    this->_text.setFont("fonts/final_frontier.ttf", 20);
     50    this->_text.setColor(foregroundColor());
     51    this->_text.setVisibility(false);
     52    this->resize();
    4853  }
     54
     55  /**
     56  * @brief sets the Text of the Text
     57  * @param text The new Text.
     58   */
     59  void GLGuiText::setText(const std::string& text)
     60  {
     61    this->_text.setText(text);
     62    this->changedText();
     63  }
     64
     65  /**
     66   * @brief appends text to the Text
     67   * @param appendText the Text to append
     68   */
     69  void GLGuiText::append(const std::string& appendText)
     70  {
     71    this->_text.append(appendText);
     72    this->changedText();
     73  }
     74
     75
     76  /**
     77   * @brief appends a Character to the Text
     78   * @param character the Character to append.
     79   */
     80  void GLGuiText::appendCharacter(char character)
     81  {
     82    this->_text.appendCharacter(character);
     83    this->changedText();
     84  }
     85
     86
     87  /**
     88   * @brief Removes Characters from the Text
     89   * @param chars The count of characters to remove
     90   */
     91  void GLGuiText::removeCharacters(unsigned int chars)
     92  {
     93    this->_text.removeCharacters(chars);
     94    this->changedText();
     95  }
     96
     97  void GLGuiText::clear()
     98  {
     99    this->_text.clear();
     100    this->changedText();
     101  }
     102
     103  /**
     104  * @brief If the Text has been changed this function is called.
     105  *
     106  * This Function also emits the Signal textChanged.
     107   */
     108  void GLGuiText::changedText()
     109  {
     110    this->resize();
     111    this->setFrontColor(Color(1,1,1,1), true);
     112    emit(this->textChanged(this->_text.text()));
     113  }
     114
     115
     116
     117  /**
     118   * @brief Resizes the Widget to the new Size-constraints.
     119   */
     120  void GLGuiText::resize()
     121  {
     122    this->_text.setRelCoor2D(borderLeft(), borderTop());
     123    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
     124    GLGuiWidget::resize();
     125    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     126    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
     127  }
     128
     129  void GLGuiText::updateFrontColor()
     130  {
     131    this->_text.setColor(foregroundColor());
     132  }
     133
     134  void GLGuiText::hiding()
     135  {
     136    this->_text.setVisibility(false);
     137  }
     138
     139  void GLGuiText::showing()
     140  {
     141    this->_text.setVisibility(true);
     142  }
     143
     144
    49145
    50146  /**
    51147   * draws the GLGuiText
    52148   */
    53   void GLGuiText::draw()
     149  void GLGuiText::draw() const
    54150  {
     151    this->beginDraw();
     152    GLGuiWidget::draw();
     153
     154    //     this->frontMaterial().select();
     155    //     GLGuiWidget::drawRect(this->frontRect());
     156
     157    this->endDraw();
    55158  }
    56159}
  • trunk/src/lib/gui/gl/glgui_text.h

    r8972 r8973  
    2525    virtual ~GLGuiText();
    2626
    27     void setText();
     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();
    2832
    29     virtual void draw();
     33    const std::string& text() const { return _text.text(); };
     34
     35
     36    virtual void draw() const;
     37
     38    DeclareSignal1(textChanged, const std::string&);
     39
     40  protected:
     41    virtual void updateFrontColor();
     42    virtual void hiding();
     43    virtual void showing();
     44    virtual void resize();
    3045
    3146  private:
    3247    void init();
     48    void changedText();
    3349
    3450
    3551  private:
    36     Text              text;
     52    Text              _text;
    3753  };
    3854}
  • trunk/src/world_entities/elements/glgui_energywidget.cc

    r8972 r8973  
    2727  {
    2828    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
     29
     30    this->text.setParent2D(this);
     31    this->bar.setParent2D(this);
    2932  }
    3033
  • trunk/src/world_entities/elements/glgui_energywidget.h

    r8972 r8973  
    1818  {
    1919
    20     public:
     20  public:
    2121    GLGuiEnergyWidget();
    2222    virtual ~GLGuiEnergyWidget();
    2323
     24  protected:
     25    virtual void resize();
    2426
    25     private:
    26       GLGuiBar                bar;
    27       GLGuiText               text;
     27  private:
     28    GLGuiBar                bar;
     29    GLGuiText               text;
    2830
    2931  };
Note: See TracChangeset for help on using the changeset viewer.