Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_bar.cc @ 9468

Last change on this file since 9468 was 8991, checked in by bensch, 18 years ago

orxonox/trunk: added a Radar class, to display radar as Widget

File size: 2.4 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_bar.h"
19
20#include "debug.h"
21
22namespace OrxGui
23{
24
25  /**
26   * @brief standard constructor
27  */
28  GLGuiBar::GLGuiBar ()
29  {
30    this->init();
31
32  }
33
34
35  /**
36   * @brief standard deconstructor
37   */
38  GLGuiBar::~GLGuiBar()
39  {}
40
41  /**
42   * @brief initializes the GUI-element
43   */
44  void GLGuiBar::init()
45  {
46    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
47
48    this->setFrontColor(_changedValueColor, true);
49
50    this->setSize2D(50, 10);
51
52    this->_minimum = 0.0f;
53    this->_maximum = 1.0f;
54    this->setValue(0.5f);
55    this->resize();
56  }
57
58  void GLGuiBar::setValue(float value)
59  {
60    if (value > _maximum)
61    {
62      value = _maximum;
63      PRINTF(2)("Oversteped range, set Value to %f\n", _maximum);
64    }
65    if (value < _minimum)
66    {
67      value = _minimum;
68      PRINTF(2)("Oversteped range, set Value to %f\n", _minimum);
69    }
70
71    this->_value = value;
72    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
73        ,this->getSizeY2D() - borderTop() - borderBottom());
74  }
75  void GLGuiBar::setMinimum(float minimum)
76  {
77    this->_minimum = minimum;
78  }
79  void GLGuiBar::setMaximum(float maximum)
80  {
81    this->_maximum = maximum;
82  }
83  void GLGuiBar::setRange(float minimum, float maximum)
84  {
85    this->setMinimum(minimum);
86    this->setMaximum(maximum);
87  }
88
89  void GLGuiBar::setChangedValueColor(const Color& color)
90  {
91    this->_changedValueColor = color;
92  }
93
94
95  void GLGuiBar::resize()
96  {
97    GLGuiWidget::resize();
98
99    this->_frontRect.setTopLeft(borderLeft(), borderTop());
100    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
101                             ,this->getSizeY2D() - borderTop() - borderBottom());
102
103  }
104
105
106  /**
107   * @brief draws the GLGuiBar
108   */
109  void GLGuiBar::draw() const
110  {
111    this->beginDraw();
112    GLGuiWidget::draw();
113
114    this->foreground().select();
115    this->drawRect(this->_frontRect);
116
117    this->endDraw();
118  }
119}
Note: See TracBrowser for help on using the repository browser.