Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/lib/gui/gl/glgui_button.cc @ 10388

Last change on this file since 10388 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
Line 
1/*
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.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
17
18#include "glgui_button.h"
19
20#include "text.h"
21
22
23namespace OrxGui
24{
25  ObjectListDefinition(GLGuiButton);
26  /**
27   * standard constructor
28  */
29  GLGuiButton::GLGuiButton (const std::string& label)
30  {
31    this->init();
32
33    this->_label.setText( label );
34  }
35
36
37  /**
38   * standard deconstructor
39  */
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  }
47
48  /**
49   * @brief initializes the GUI-element
50   */
51  void GLGuiButton::init()
52  {
53    this->registerObject(this, GLGuiButton::_objectList);
54
55    this->setSelectable(true);
56    this->setFocusable(true);
57    this->setClickable(true);
58
59    this->_label.setFont(this->font());
60    this->_label.setColor(this->foregroundColor() );
61
62    this->_label.setParent2D(this);
63    this->_label.setVisibility(false);
64  }
65
66
67  void GLGuiButton::setLabel(const std::string& label)
68  {
69    this->_label.setText(label);
70    this->resize();
71  }
72
73
74  void GLGuiButton::updateFrontColor()
75  {
76    this->_label.setColor(this->foregroundColor());
77  }
78
79  void GLGuiButton::clicking(const Vector2D& pos)
80  {
81    GLGuiWidget::clicking(pos);
82    clicked.emit();
83  }
84  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
85  {
86    GLGuiWidget::releasing(pos, focused);
87    released.emit();
88  }
89
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
101  bool GLGuiButton::processEvent(const Event& event)
102  {
103    if (event.type == SDLK_SPACE)
104    {
105      if (event.bPressed)
106        clicked.emit();
107      else
108        released.emit();
109      return true;
110    }
111    return false;
112  }
113
114
115  /**
116   * @brief draws the GLGuiButton
117   */
118  void GLGuiButton::draw() const
119  {
120    GLGuiWidget::draw();
121  }
122}
Note: See TracBrowser for help on using the repository browser.