Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

fancy mouse-cursor :)

File size: 2.7 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
24namespace OrxGui
25{
26
27  /**
28   * standard constructor
29  */
30  GLGuiWidget::GLGuiWidget ( )
31  {
32    this->init();
33  }
34
35
36  /**
37   * standard deconstructor
38   */
39  GLGuiWidget::~GLGuiWidget()
40  {
41  }
42
43
44  /**
45   * initializes the GUI-element
46   */
47  void 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
55    this->backMat.setDiffuse(1.0, 1.0, 1.0);
56
57    this->frontModel = 0;
58
59    this->widgetSignals.resize(SignalCount, SignalConnector());
60  }
61
62
63  bool 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->getSizeY2D() > 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   */
77  void GLGuiWidget::connectSignal(SignalType signalType, BaseObject* object, const Executor* signal)
78  {
79    if (signalType >= this->widgetSignals.size())
80      return;
81
82//    if (this->widgetSignals[signalType] != NULL)
83//      PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");
84
85    this->widgetSignals[signalType] = SignalConnector(object, signal);
86  }
87
88  /**
89   * @brief removes a Signal from a Gui-ELements' Event
90   * @param signalType the type of Signal to remove.
91   */
92  void GLGuiWidget::disconnectSignal(SignalType signalType)
93  {
94    if (signalType >= this->widgetSignals.size())
95      return;
96
97    this->widgetSignals[signalType] = SignalConnector();
98  }
99
100
101  void GLGuiWidget::show()
102  {
103    this->setVisibility(true);
104  }
105
106  void GLGuiWidget::hide()
107  {
108    this->setVisibility(false);
109  }
110
111
112  void GLGuiWidget::draw() const
113  {
114    this->backMat.select();
115
116    glBegin(GL_QUADS);
117    glTexCoord2i(0,1); glVertex2d(0, 0);
118    glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
119    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
120    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
121    glEnd();
122  }
123
124}
Note: See TracBrowser for help on using the repository browser.