Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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