Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

hud

File size: 2.5 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:
[5359]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5359]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
[1853]17
[5362]18#include "glgui_widget.h"
[1853]19
[6287]20#include "material.h"
21
[5392]22#include "debug.h"
23
[1856]24using namespace std;
[1853]25
[3245]26/**
[4838]27 * standard constructor
[3245]28*/
[6300]29GLGuiWidget::GLGuiWidget ( )
[3365]30{
[5359]31  this->init();
[3365]32}
[1853]33
34
[3245]35/**
[4838]36 * standard deconstructor
[5395]37 */
[5362]38GLGuiWidget::~GLGuiWidget()
[3543]39{
[5359]40
[3543]41}
[5359]42
[5362]43
[5392]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;
[5397]53  this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
[5406]54//  this->setParent2D((Element2D*)NULL);
[5392]55
[7062]56  this->backMat.setDiffuse(1.0, 1.0, 1.0);
[6287]57
[5392]58  this->frontModel = 0;
59
60  for (unsigned int i = 0; i < GLGuiSignalCount; i++)
61    this->widgetSignals[i] = NULL;
62}
63
64
[5391]65bool GLGuiWidget::focusOverWidget(float x, float y)
66{
67  if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x+ this->getSizeX2D() > x &&
68      this->getAbsCoor2D().y < y && this->getAbsCoor2D().y+ this->getSizeX2D() > y)
69    return true;
70  else
71    return false;
72}
73
[5392]74/**
75 * @brief connects a Signal to the Gui-Elements' Event.
76 * @param sinalType the Type of Signal to set. @see GLGuiSignalType
77 * @param signal the name of the Signal
78 */
[5690]79void GLGuiWidget::connectSignal(GLGuiSignalType signalType, const Executor& signal)
[5392]80{
[5690]81  if (signalType >= GLGuiSignalCount)
[5392]82    return;
[5391]83
[5392]84  if (this->widgetSignals[signalType] != NULL)
85    PRINTF(2)("Already connected a Signal to %s (%s) type %s... overwriting\n");
86
[5690]87  this->widgetSignals[signalType] = signal.clone();
[5392]88}
89
[5359]90/**
[5392]91 * @brief removes a Signal from a Gui-ELements' Event
92 * @param signalType the type of Signal to remove.
[5359]93 */
[5392]94void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType)
[5359]95{
[5392]96  if (signalType > GLGuiSignalCount)
97    return;
[5359]98
[5392]99  this->widgetSignals[signalType] = NULL;
100}
[5366]101
[5395]102
103void GLGuiWidget::show()
104{
105  this->setVisibility(true);
106}
[6287]107
[6431]108void GLGuiWidget::hide()
109{
110  this->setVisibility(false);
111}
[6287]112
[6431]113
[6287]114void GLGuiWidget::draw() const
115{
[6295]116  this->backMat.select();
[6287]117
118  glBegin(GL_QUADS);
[7062]119   glTexCoord2i(0,1); glVertex2d(0, 0);
120   glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
121   glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
122   glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
[6287]123  glEnd();
124}
125
Note: See TracBrowser for help on using the repository browser.