xoreos  0.0.5
quadwidget.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 #include "src/common/ustring.h"
27 
29 
31 
32 namespace Engines {
33 
34 namespace NWN {
35 
37  const Common::UString &texture,
38  float x1, float y1, float x2, float y2,
39  float tX1, float tY1, float tX2, float tY2) :
40  NWNWidget(gui, tag) {
41 
42  _quad.reset(new Graphics::Aurora::GUIQuad(texture, x1, y1, x2, y2, tX1, tY1, tX2, tY2));
43  _quad->setTag(tag);
44  _quad->setClickable(true);
45 
46  _width = ABS(x2 - x1);
47  _height = ABS(y2 - y1);
48 }
49 
51 }
52 
54  _quad->show();
55 }
56 
58  _quad->hide();
59 }
60 
61 void QuadWidget::setPosition(float x, float y, float z) {
62  NWNWidget::setPosition(x, y, z);
63 
64  getPosition(x, y, z);
65  _quad->setPosition(x, y, z);
66 }
67 
68 void QuadWidget::setColor(float r, float g, float b, float a) {
69  _quad->setColor(r, g, b, a);
70 }
71 
73  _quad->setTexture(texture);
74 }
75 
76 void QuadWidget::setWidth(float w) {
77  _quad->setWidth(w);
78 }
79 
80 void QuadWidget::setHeight(float h) {
81  _quad->setHeight(h);
82 }
83 
84 float QuadWidget::getWidth() const {
85  return _width;
86 }
87 
88 float QuadWidget::getHeight() const {
89  return _height;
90 }
91 
92 } // End of namespace NWN
93 
94 } // End of namespace Engines
T ABS(T x)
Definition: util.h:69
A class holding an UTF-8 string.
Definition: ustring.h:48
float getWidth() const
Get the widget&#39;s width.
Definition: quadwidget.cpp:84
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
void setWidth(float w)
Definition: quadwidget.cpp:76
Common::ScopedPtr< Graphics::Aurora::GUIQuad > _quad
Definition: quadwidget.h:74
Base class for all widgets in NWN.
Definition: nwnwidget.h:45
QuadWidget(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &texture, float x1, float y1, float x2, float y2, float tX1=0.0f, float tY1=0.0f, float tX2=1.0f, float tY2=1.0f)
Definition: quadwidget.cpp:36
A GUI.
Definition: gui.h:43
A NWN quad widget.
Utility templates and functions.
float getHeight() const
Get the widget&#39;s height.
Definition: quadwidget.cpp:88
void show()
Show the widget.
Definition: quadwidget.cpp:53
void setHeight(float h)
Definition: quadwidget.cpp:80
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: nwnwidget.cpp:60
void hide()
Hide the widget.
Definition: quadwidget.cpp:57
void setColor(float r, float g, float b, float a)
Definition: quadwidget.cpp:68
Unicode string handling.
void setTexture(const Common::UString &texture)
Definition: quadwidget.cpp:72
A textured quad for a GUI element.
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: quadwidget.cpp:61