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