Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl_gui/glgui_widget.cc @ 5395

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

orxonox/trunk: first element of the GLGui is visible… there is a long way to go…

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