Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_checkbutton.cc @ 8275

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

trunk: merged the gui back
merged with command:
svn merge -r8114:HEAD https://svn.orxonox.net/orxonox/branches/gui .
→ no conflicts

File size: 3.7 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  {
[8116]67    this->labelText().setRelCoor2D(borderLeft() + 25, borderTop() + 5);
68    this->setSize2D(this->labelText().getSizeX2D() + 30 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom());
[8035]69    GLGuiWidget::resize();
[8115]70    this->frontRect().setTopLeft(borderLeft(), borderTop());
71    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));
[7919]72  }
73
74
[8035]75  void GLGuiCheckButton::releasing(const Vector2D& pos)
[7919]76  {
[8035]77    GLGuiButton::releasing(pos);
[7919]78    this->toggleActiveState();
79  }
80
[8035]81
82
[7779]83  /**
[7919]84   * @brief draws the GLGuiPushButton
[7779]85   */
86  void GLGuiCheckButton::draw() const
87  {
[8035]88    this->beginDraw();
[7919]89    GLGuiButton::draw();
90
91    this->frontMaterial().select();
[8035]92    this->drawRect(this->frontRect());
[7919]93
94    if (this->bActive)
95    {
[8035]96      glBegin(GL_QUADS);
[7919]97      glColor3f( 1, 1 ,1);
[8117]98      glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8);
99      glTexCoord2i(0,1); glVertex2d(borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
100      glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
101      glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8);
[7919]102      glEnd();
103
104
105      // DRAW a cross :)
106      glColor3f(0,0,0);
107      glLineWidth(3.0);
108      glBegin(GL_LINE_LOOP);
[8117]109      glVertex2d(borderLeft()+8,borderTop() +8);
110      glVertex2d(this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2 - 1);
[7919]111
[8117]112      glVertex2d(this->getSizeY2D()-8 + borderLeft(), borderTop()+8);
113      glVertex2d(this->getSizeY2D()/2 +1 + borderLeft(), this->getSizeY2D()/2);
[7919]114
[8117]115      glVertex2d(this->getSizeY2D()-8 + borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
116      glVertex2d(this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2+1);
[7919]117
[8117]118      glVertex2d(borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
119      glVertex2d(this->getSizeY2D()/2 -1 + borderLeft(), this->getSizeY2D()/2);
[7919]120      glEnd();
121    }
122    else
123    {
[8035]124      glBegin(GL_QUADS);
[7919]125      glColor3f(0, 0, 0);
[8117]126      glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8);
127      glTexCoord2i(0,1); glVertex2d(borderLeft()+ 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
128      glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
129      glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8);
[7919]130      glEnd();
131    }
132
133    this->endDraw();
[7779]134  }
[5360]135}
Note: See TracBrowser for help on using the repository browser.