Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/gui/gl/glgui_checkbutton.cc @ 8605

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

orxonox/gui: fading works again

File size: 3.0 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
[5366]18#include "glgui_checkbutton.h"
[1853]19
[5395]20#include "text.h"
21
[7779]22namespace OrxGui
[3365]23{
[4320]24
[1853]25
[7779]26  /**
27   * standard constructor
28  */
[7919]29  GLGuiCheckButton::GLGuiCheckButton (const std::string& label, bool active)
30  : GLGuiButton(label)
[7779]31  {
32    this->init();
[7919]33    this->bActive = active;
[1853]34
[7919]35    this->resize();
[7779]36  }
[5360]37
38
[7779]39  /**
40   * standard deconstructor
41  */
42  GLGuiCheckButton::~GLGuiCheckButton()
43  {
44  }
[5360]45
[7779]46  /**
47   * initializes the GUI-element
48   */
[7919]49  void GLGuiCheckButton::init()
[7779]50  {
51    this->setClassID(CL_GLGUI_CHECKBUTTON, "GLGuiCheckButton");
[7919]52  }
[5360]53
[8035]54  void GLGuiCheckButton::setActivity(bool bActive)
55  {
56    this->bActive = bActive;
57    emit(this->toggled(this->bActive));
58  }
[7919]59
60  void GLGuiCheckButton::toggleActiveState()
61  {
[8035]62    this->setActivity(!this->isActive());
[7779]63  }
[5360]64
[7919]65  void GLGuiCheckButton::resize()
66  {
[8448]67
[8598]68    this->labelText().setRelCoor2D( borderLeft() + 15.0, borderTop() + 5);
69    this->setSize2D(this->labelText().getSizeX2D() + 15.0 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom());
[8035]70    GLGuiWidget::resize();
[8448]71
72    this->_checkBox.setSize(10.0, 10.0);
[8598]73    this->_checkBox.setCenter( borderLeft() + _checkBox.height()/2.0, borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0);
[8448]74
75/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
76    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));*/
[7919]77  }
78
79
[8035]80  void GLGuiCheckButton::releasing(const Vector2D& pos)
[7919]81  {
[8035]82    GLGuiButton::releasing(pos);
[7919]83    this->toggleActiveState();
84  }
85
[8035]86
87
[7779]88  /**
[7919]89   * @brief draws the GLGuiPushButton
[7779]90   */
91  void GLGuiCheckButton::draw() const
92  {
[8035]93    this->beginDraw();
[7919]94    GLGuiButton::draw();
95
[8448]96//     this->frontMaterial().select();
97//     this->drawRect(this->frontRect());
[7919]98    if (this->bActive)
99    {
[8598]100      glColor3fv( &this->foregroundColor()[0]);
[8448]101      this->drawRect(this->_checkBox);
[7919]102
103
104      // DRAW a cross :)
[8448]105      Vector2D center = this->_checkBox.center();
106      glColor4f(1,1,1, 1.0);
[7919]107      glLineWidth(3.0);
[8448]108
[7919]109      glBegin(GL_LINE_LOOP);
[8448]110      glVertex2d(_checkBox.left(), _checkBox.top());
111      glVertex2d(center.x, center.y);
[7919]112
[8448]113      glVertex2d(_checkBox.right(), _checkBox.top());
114      glVertex2d(center.x, center.y);
[7919]115
[8448]116      glVertex2d(_checkBox.right(), _checkBox.bottom());
117      glVertex2d(center.x, center.y);
[7919]118
[8448]119      glVertex2d(_checkBox.left(), _checkBox.bottom());
120      glVertex2d(center.x, center.y);
[7919]121      glEnd();
122    }
123    else
124    {
[8598]125      glColor3fv( &this->foregroundColor()[0]);
[8448]126      this->drawRect(this->_checkBox);
[7919]127    }
128
129    this->endDraw();
[7779]130  }
[5360]131}
Note: See TracBrowser for help on using the repository browser.