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 | |
---|
22 | using namespace std; |
---|
23 | |
---|
24 | /** |
---|
25 | * standard constructor |
---|
26 | */ |
---|
27 | GLGuiWidget::GLGuiWidget ( ) : Element2D(NULL) |
---|
28 | { |
---|
29 | this->init(); |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | /** |
---|
34 | * standard deconstructor |
---|
35 | */ |
---|
36 | GLGuiWidget::~GLGuiWidget() |
---|
37 | { |
---|
38 | |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | /** |
---|
43 | * initializes the GUI-element |
---|
44 | */ |
---|
45 | void GLGuiWidget::init() |
---|
46 | { |
---|
47 | this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget"); |
---|
48 | |
---|
49 | this->focusable = true; |
---|
50 | this->clickable = true; |
---|
51 | this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); |
---|
52 | this->setParent2D((Element2D*)NULL); |
---|
53 | this->setLayer(E2D_LAYER_EXTERN); |
---|
54 | |
---|
55 | this->backMat = NULL; |
---|
56 | this->backModel = 0; |
---|
57 | this->frontMat = NULL; |
---|
58 | this->frontModel = 0; |
---|
59 | |
---|
60 | for (unsigned int i = 0; i < GLGuiSignalCount; i++) |
---|
61 | this->widgetSignals[i] = NULL; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | bool 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 | |
---|
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 | */ |
---|
79 | void GLGuiWidget::connectSignal(GLGuiSignalType signalType, Signal* signal) |
---|
80 | { |
---|
81 | if (signal == NULL || signalType >= GLGuiSignalCount) |
---|
82 | return; |
---|
83 | |
---|
84 | if (this->widgetSignals[signalType] != NULL) |
---|
85 | PRINTF(2)("Already connected a Signal to %s (%s) type %s... overwriting\n"); |
---|
86 | |
---|
87 | this->widgetSignals[signalType] = signal; |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief removes a Signal from a Gui-ELements' Event |
---|
92 | * @param signalType the type of Signal to remove. |
---|
93 | */ |
---|
94 | void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType) |
---|
95 | { |
---|
96 | if (signalType > GLGuiSignalCount) |
---|
97 | return; |
---|
98 | |
---|
99 | this->widgetSignals[signalType] = NULL; |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | void GLGuiWidget::show() |
---|
104 | { |
---|
105 | this->setVisibility(true); |
---|
106 | } |
---|