Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_button.cc @ 8986

Last change on this file since 8986 was 8769, checked in by bensch, 18 years ago

orxonox/trunk: Font in Button-Widget used

File size: 2.2 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
[5363]18#include "glgui_button.h"
[1853]19
[5395]20#include "text.h"
21
[1853]22
[7779]23namespace OrxGui
[3365]24{
[7779]25  /**
26   * standard constructor
27  */
[7919]28  GLGuiButton::GLGuiButton (const std::string& label)
[7779]29  {
30    this->init();
[4320]31
[8115]32    this->_label.setText( label );
[7779]33  }
[1853]34
35
[7779]36  /**
37   * standard deconstructor
[5395]38  */
[7779]39  GLGuiButton::~GLGuiButton()
40  {
41    /* this does not have to be done, since the Label is a child,
42     * and will be deleted by Element2D's deletion Process
43     * delete this->label;
44    */
45  }
[5360]46
[7779]47  /**
[7919]48   * @brief initializes the GUI-element
[7779]49   */
50  void GLGuiButton::init()
51  {
52    this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton");
[8717]53
54    this->setSelectable(true);
[7919]55    this->setFocusable(true);
56    this->setClickable(true);
[5360]57
[8769]58    this->_label.setFont(this->font());
[8619]59    this->_label.setColor(this->foregroundColor() );
[7919]60
[8115]61    this->_label.setParent2D(this);
62    this->_label.setVisibility(false);
[7779]63  }
[5360]64
[7919]65
[7779]66  void GLGuiButton::setLabel(const std::string& label)
67  {
[8115]68    this->_label.setText(label);
[7919]69    this->resize();
[7779]70  }
[5395]71
[8035]72
[8448]73  void GLGuiButton::updateFrontColor()
74  {
[8619]75    this->_label.setColor(this->foregroundColor());
[8448]76  }
[8035]77
78  void GLGuiButton::clicking(const Vector2D& pos)
79  {
[8448]80    GLGuiWidget::clicking(pos);
[8035]81    emit(clicked());
82  }
[8717]83  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
[8035]84  {
[8717]85    GLGuiWidget::releasing(pos, focused);
[8035]86    emit(released());
87  }
88
[8115]89  void GLGuiButton::hiding()
90  {
91    this->_label.setVisibility(false);
92  }
93
94  void GLGuiButton::showing()
95  {
96    this->_label.setVisibility(true);
97  }
98
99
[8717]100  bool GLGuiButton::processEvent(const Event& event)
101  {
[8740]102    if (event.type == SDLK_SPACE)
[8717]103    {
[8740]104      if (event.bPressed)
105        emit(pushed());
106      else
107        emit(released());
[8717]108      return true;
109    }
110    return false;
111  }
112
113
[7779]114  /**
[7919]115   * @brief draws the GLGuiButton
[7779]116   */
117  void GLGuiButton::draw() const
118  {
119    GLGuiWidget::draw();
120  }
[5360]121}
Note: See TracBrowser for help on using the repository browser.