Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/lib/gui/gl_gui/glgui_widget.cc @ 6474

Last change on this file since 6474 was 6431, checked in by bensch, 19 years ago

orxonox/trunk: projectile inherits Energies from WorldEntity

File size: 2.5 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_widget.h"
19
20#include "material.h"
21
22#include "debug.h"
23
24using namespace std;
25
26/**
27 * standard constructor
28*/
29GLGuiWidget::GLGuiWidget ( )
30{
31  this->init();
32}
33
34
35/**
36 * standard deconstructor
37 */
38GLGuiWidget::~GLGuiWidget()
39{
40
41}
42
43
44/**
45 * initializes the GUI-element
46 */
47void GLGuiWidget::init()
48{
49  this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget");
50
51  this->focusable = true;
52  this->clickable = true;
53  this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
54//  this->setParent2D((Element2D*)NULL);
55
56  this->backMat.setDiffuse(.1, .5, .5);
57  this->backMat.setTransparency(.9);
58
59  this->frontModel = 0;
60
61  for (unsigned int i = 0; i < GLGuiSignalCount; i++)
62    this->widgetSignals[i] = NULL;
63}
64
65
66bool GLGuiWidget::focusOverWidget(float x, float y)
67{
68  if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x+ this->getSizeX2D() > x &&
69      this->getAbsCoor2D().y < y && this->getAbsCoor2D().y+ this->getSizeX2D() > y)
70    return true;
71  else
72    return false;
73}
74
75/**
76 * @brief connects a Signal to the Gui-Elements' Event.
77 * @param sinalType the Type of Signal to set. @see GLGuiSignalType
78 * @param signal the name of the Signal
79 */
80void GLGuiWidget::connectSignal(GLGuiSignalType signalType, const Executor& signal)
81{
82  if (signalType >= GLGuiSignalCount)
83    return;
84
85  if (this->widgetSignals[signalType] != NULL)
86    PRINTF(2)("Already connected a Signal to %s (%s) type %s... overwriting\n");
87
88  this->widgetSignals[signalType] = signal.clone();
89}
90
91/**
92 * @brief removes a Signal from a Gui-ELements' Event
93 * @param signalType the type of Signal to remove.
94 */
95void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType)
96{
97  if (signalType > GLGuiSignalCount)
98    return;
99
100  this->widgetSignals[signalType] = NULL;
101}
102
103
104void GLGuiWidget::show()
105{
106  this->setVisibility(true);
107}
108
109void GLGuiWidget::hide()
110{
111  this->setVisibility(false);
112}
113
114
115void GLGuiWidget::draw() const
116{
117  this->backMat.select();
118
119  glBegin(GL_QUADS);
120   glVertex2d(0, 0);
121   glVertex2d(0, this->getSizeY2D());
122   glVertex2d(this->getSizeX2D(), this->getSizeY2D());
123   glVertex2d(this->getSizeX2D(), 0);
124  glEnd();
125}
126
Note: See TracBrowser for help on using the repository browser.