xoreos  0.0.5
nwnwidget.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/ustring.h"
26 
29 
30 namespace Engines {
31 
32 namespace NWN {
33 
34 NWNWidget::NWNWidget(::Engines::GUI &gui, const Common::UString &tag) : Widget(gui, tag) {
35 }
36 
38 }
39 
41  if (!isVisible())
42  return;
43 
44  if (_tooltip)
45  _tooltip->hide();
46 
47  Widget::hide();
48 }
49 
51  if (_tooltip)
53 }
54 
56  if (_tooltip)
57  _tooltip->hide();
58 }
59 
60 void NWNWidget::setPosition(float x, float y, float z) {
61  Widget::setPosition(x, y, z);
62 
63  if (_tooltip)
64  _tooltip->updatePosition();
65 }
66 
68  createTooltip();
69 
70  _tooltip->clearLines();
71  _tooltip->addLine(text, 1.0f, 1.0f, 1.0f, 1.0f);
72 }
73 
74 void NWNWidget::setTooltipPosition(float x, float y, float z) {
75  createTooltip();
76 
77  _tooltip->setPosition(x, y, z);
78 }
79 
81  if (_tooltip)
82  return;
83 
84  _tooltip.reset(new Tooltip(Tooltip::kTypeHelp, *this));
85  _tooltip->setAlign(0.5f);
86 }
87 
88 } // End of namespace NWN
89 
90 } // End of namespace Engines
A NWN widget.
Help string when mousing over a GUI widget.
Definition: tooltip.h:53
A class holding an UTF-8 string.
Definition: ustring.h:48
virtual void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: widget.cpp:119
bool isVisible() const
Is the widget visible?
Definition: widget.cpp:59
A tooltip.
void hide()
Hide the widget.
Definition: nwnwidget.cpp:40
void leave()
The mouse left the widget.
Definition: nwnwidget.cpp:55
A GUI.
Definition: gui.h:43
void setTooltip(const Common::UString &text)
Definition: nwnwidget.cpp:67
static uint32 getDefaultDelay()
Returns the configured default delay, in ms, before a tooltip appears.
Definition: tooltip.cpp:539
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: nwnwidget.cpp:60
void enter()
The mouse entered the widget.
Definition: nwnwidget.cpp:50
Unicode string handling.
A tooltip.
Definition: tooltip.h:50
virtual void hide()
Hide the widget.
Definition: widget.cpp:90
A widget in a GUI.
Definition: widget.h:40
NWNWidget(::Engines::GUI &gui, const Common::UString &tag)
Definition: nwnwidget.cpp:34
void setTooltipPosition(float x, float y, float z)
Definition: nwnwidget.cpp:74
Common::ScopedPtr< Tooltip > _tooltip
Definition: nwnwidget.h:61