YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
MenuItem.cpp
Go to the documentation of this file.
1
#include <SFML/Graphics/Text.hpp>
2
3
#include "
YAPOG/Graphics/Gui/MenuItem.hpp
"
4
#include "
YAPOG/Graphics/IDrawingContext.hpp
"
5
#include "
YAPOG/Graphics/Gui/Padding.hpp
"
6
#include "
YAPOG/Graphics/Gui/WidgetBorder.hpp
"
7
8
namespace
yap
9
{
10
MenuItem::MenuItem
()
11
: label_ (
""
)
12
, isScalable_ (false)
13
{
14
label_
.
SetPosition
(
GetPosition
());
15
}
16
17
MenuItem::MenuItem
(
bool
isScalable)
18
: label_ (
""
)
19
, isScalable_ (isScalable)
20
{
21
label_
.
SetPosition
(
GetPosition
());
22
}
23
24
MenuItem::~MenuItem
()
25
{
26
}
27
28
void
MenuItem::Refresh
()
29
{
30
/* if (!isScalable_)
31
label_.SetPosition (GetPosition ()
32
+ Vector2 (GetUserSize ().x / 2 - label_.GetSize ().x / 2 + 7,
33
GetUserSize ().y / 2
34
- label_.GetSize ().y / 2 + label_.GetCharHeight ()));
35
else
36
{*/
37
label_
.
SetPosition
(
GetPosition
() +
38
((
border_
!=
nullptr
) ?
border_
->
GetSize
() :
Vector2
()));
39
// }
40
BaseWidget::Refresh
();
41
}
42
43
void
MenuItem::Do
()
44
{
45
46
}
47
48
String
MenuItem::GetContent
()
const
49
{
50
return
label_
.
GetText
();
51
}
52
53
void
MenuItem::SetContent
(
String
content)
54
{
55
label_
.
SetText
(content);
56
Refresh
();
57
}
58
59
bool
MenuItem::IsFocusable
()
const
60
{
61
return
false
;
62
}
63
64
Vector2
MenuItem::HandleGetSize
()
const
65
{
66
Vector2
result;
67
if
(!
isScalable_
)
68
result =
GetUserSize
()
69
+ ((
border_
!=
nullptr
) ?
border_
->
GetSize
() :
Vector2
());
70
else
71
result =
label_
.
GetSize
()
72
+ ((
border_
!=
nullptr
) ?
border_
->
GetSize
() :
Vector2
());
73
return
result;
74
}
75
76
void
MenuItem::HandleDraw
(
IDrawingContext
& context)
77
{
78
label_
.
Draw
(context);
79
}
80
81
void
MenuItem::HandleShow
(
bool
isVisible)
82
{
83
}
84
85
void
MenuItem::HandleMove
(
const
Vector2
& offset)
86
{
87
label_
.
Move
(offset);
88
}
89
90
void
MenuItem::HandleScale
(
const
Vector2
& factor)
91
{
92
label_
.
Scale
(factor);
93
}
94
95
void
MenuItem::HandleUpdate
(
const
Time
& dt)
96
{
97
label_
.
Update
(dt);
98
}
99
100
void
MenuItem::HandleChangeColor
(
const
sf::Color& color)
101
{
102
label_
.
ChangeColor
(color);
103
}
104
}
// namespace yap
YAPOG
src
YAPOG
Graphics
Gui
MenuItem.cpp
Generated on Mon Sep 17 2012 22:24:26 for YAPOG by
1.8.1.1