Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9486 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
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
[6287]18#include "glgui_bar.h"
[1853]19
[8983]20#include "debug.h"
[1853]21
[7779]22namespace OrxGui
[3365]23{
[4320]24
[7779]25  /**
26   * @brief standard constructor
27  */
28  GLGuiBar::GLGuiBar ()
29  {
30    this->init();
[1853]31
[7779]32  }
[1853]33
[5360]34
[7779]35  /**
36   * @brief standard deconstructor
37   */
38  GLGuiBar::~GLGuiBar()
[8983]39  {}
[5360]40
[7779]41  /**
42   * @brief initializes the GUI-element
43   */
44  void GLGuiBar::init()
45  {
46    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
[5360]47
[8991]48    this->setFrontColor(_changedValueColor, true);
[6295]49
[7779]50    this->setSize2D(50, 10);
[6295]51
[8983]52    this->_minimum = 0.0f;
53    this->_maximum = 1.0f;
54    this->setValue(0.5f);
55    this->resize();
[7779]56  }
[5360]57
[8983]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;
[8984]72    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
73        ,this->getSizeY2D() - borderTop() - borderBottom());
[8983]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
[8991]89  void GLGuiBar::setChangedValueColor(const Color& color)
90  {
91    this->_changedValueColor = color;
92  }
93
94
[8972]95  void GLGuiBar::resize()
96  {
97    GLGuiWidget::resize();
98
[8983]99    this->_frontRect.setTopLeft(borderLeft(), borderTop());
100    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
101                             ,this->getSizeY2D() - borderTop() - borderBottom());
[8972]102
103  }
104
105
[7779]106  /**
107   * @brief draws the GLGuiBar
108   */
109  void GLGuiBar::draw() const
110  {
[8035]111    this->beginDraw();
[7779]112    GLGuiWidget::draw();
[6287]113
[8984]114    this->foreground().select();
[8983]115    this->drawRect(this->_frontRect);
116
[7779]117    this->endDraw();
118  }
[5360]119}
Note: See TracBrowser for help on using the repository browser.