Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/water/src/lib/gui/gl_gui/glgui_checkbutton.cc @ 8063

Last change on this file since 8063 was 8035, checked in by bensch, 19 years ago

gui: merged the gui back to the trunk

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