xoreos
0.0.5
src
engines
nwn
gui
widgets
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
27
#include "
src/engines/nwn/gui/widgets/nwnwidget.h
"
28
#include "
src/engines/nwn/gui/widgets/tooltip.h
"
29
30
namespace
Engines
{
31
32
namespace
NWN {
33
34
NWNWidget::NWNWidget
(::
Engines::GUI
&gui,
const
Common::UString
&tag) :
Widget
(gui, tag) {
35
}
36
37
NWNWidget::~NWNWidget
() {
38
}
39
40
void
NWNWidget::hide
() {
41
if
(!
isVisible
())
42
return
;
43
44
if
(
_tooltip
)
45
_tooltip
->hide();
46
47
Widget::hide
();
48
}
49
50
void
NWNWidget::enter
() {
51
if
(
_tooltip
)
52
_tooltip
->show(
Tooltip::getDefaultDelay
());
53
}
54
55
void
NWNWidget::leave
() {
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
67
void
NWNWidget::setTooltip
(
const
Common::UString
&text) {
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
80
void
NWNWidget::createTooltip
() {
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
nwnwidget.h
A NWN widget.
Engines::NWN::Tooltip::kTypeHelp
Help string when mousing over a GUI widget.
Definition:
tooltip.h:53
Common::UString
A class holding an UTF-8 string.
Definition:
ustring.h:48
Engines::Widget::setPosition
virtual void setPosition(float x, float y, float z)
Set the widget's position.
Definition:
widget.cpp:119
Engines::Widget::isVisible
bool isVisible() const
Is the widget visible?
Definition:
widget.cpp:59
tooltip.h
A tooltip.
Engines::NWN::NWNWidget::hide
void hide()
Hide the widget.
Definition:
nwnwidget.cpp:40
Engines::NWN::NWNWidget::leave
void leave()
The mouse left the widget.
Definition:
nwnwidget.cpp:55
Engines::GUI
A GUI.
Definition:
gui.h:43
Engines::NWN::NWNWidget::setTooltip
void setTooltip(const Common::UString &text)
Definition:
nwnwidget.cpp:67
Engines::NWN::Tooltip::getDefaultDelay
static uint32 getDefaultDelay()
Returns the configured default delay, in ms, before a tooltip appears.
Definition:
tooltip.cpp:539
Engines
Definition:
console.cpp:69
Engines::NWN::NWNWidget::setPosition
void setPosition(float x, float y, float z)
Set the widget's position.
Definition:
nwnwidget.cpp:60
Engines::NWN::NWNWidget::enter
void enter()
The mouse entered the widget.
Definition:
nwnwidget.cpp:50
ustring.h
Unicode string handling.
Engines::NWN::Tooltip
A tooltip.
Definition:
tooltip.h:50
Engines::Widget::hide
virtual void hide()
Hide the widget.
Definition:
widget.cpp:90
Engines::Widget
A widget in a GUI.
Definition:
widget.h:40
Engines::NWN::NWNWidget::NWNWidget
NWNWidget(::Engines::GUI &gui, const Common::UString &tag)
Definition:
nwnwidget.cpp:34
Engines::NWN::NWNWidget::setTooltipPosition
void setTooltipPosition(float x, float y, float z)
Definition:
nwnwidget.cpp:74
Engines::NWN::NWNWidget::~NWNWidget
~NWNWidget()
Definition:
nwnwidget.cpp:37
Engines::NWN::NWNWidget::createTooltip
void createTooltip()
Definition:
nwnwidget.cpp:80
Engines::NWN::NWNWidget::_tooltip
Common::ScopedPtr< Tooltip > _tooltip
Definition:
nwnwidget.h:61
Generated on Sun Nov 18 2018 15:13:40 for xoreos by
1.8.14