Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.older/src/lib/gui/gl/glgui_button.cc @ 10765

Last change on this file since 10765 was 8769, checked in by bensch, 19 years ago

orxonox/trunk: Font in Button-Widget used

File size: 2.2 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  /**
26   * standard constructor
27  */
28  GLGuiButton::GLGuiButton (const std::string& label)
29  {
30    this->init();
31
32    this->_label.setText( label );
33  }
34
35
36  /**
37   * standard deconstructor
38  */
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  }
46
47  /**
48   * @brief initializes the GUI-element
49   */
50  void GLGuiButton::init()
51  {
52    this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton");
53
54    this->setSelectable(true);
55    this->setFocusable(true);
56    this->setClickable(true);
57
58    this->_label.setFont(this->font());
59    this->_label.setColor(this->foregroundColor() );
60
61    this->_label.setParent2D(this);
62    this->_label.setVisibility(false);
63  }
64
65
66  void GLGuiButton::setLabel(const std::string& label)
67  {
68    this->_label.setText(label);
69    this->resize();
70  }
71
72
73  void GLGuiButton::updateFrontColor()
74  {
75    this->_label.setColor(this->foregroundColor());
76  }
77
78  void GLGuiButton::clicking(const Vector2D& pos)
79  {
80    GLGuiWidget::clicking(pos);
81    emit(clicked());
82  }
83  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
84  {
85    GLGuiWidget::releasing(pos, focused);
86    emit(released());
87  }
88
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
100  bool GLGuiButton::processEvent(const Event& event)
101  {
102    if (event.type == SDLK_SPACE)
103    {
104      if (event.bPressed)
105        emit(pushed());
106      else
107        emit(released());
108      return true;
109    }
110    return false;
111  }
112
113
114  /**
115   * @brief draws the GLGuiButton
116   */
117  void GLGuiButton::draw() const
118  {
119    GLGuiWidget::draw();
120  }
121}
Note: See TracBrowser for help on using the repository browser.