YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BaseWidget.hpp
Go to the documentation of this file.
1
#ifndef YAPOG_WIDGETBASE_HPP
2
# define YAPOG_WIDGETBASE_HPP
3
4
# include "
YAPOG/Macros.hpp
"
5
# include "
YAPOG/Graphics/Gui/IWidget.hpp
"
6
# include "
YAPOG/Graphics/SpatialInfo.hpp
"
7
# include "
YAPOG/Collection/List.hpp
"
8
# include "
YAPOG/Collection/Array.hpp
"
9
# include "
YAPOG/System/Event/Event.hpp
"
10
# include "
YAPOG/System/IntTypes.hpp
"
11
# include "
YAPOG/Graphics/Gui/Padding.hpp
"
12
13
namespace
yap
14
{
15
class
WidgetBackground;
16
class
WidgetBorder;
17
18
class
YAPOG_LIB
BaseWidget
:
public
IWidget
19
{
20
DISALLOW_COPY
(
BaseWidget
);
21
22
public
:
23
24
struct
EventArgs
25
{
26
EventArgs
(
const
Vector2
& content)
27
{
28
newContent = content;
29
}
30
Vector2
newContent
;
31
};
32
33
struct
EventArgsDraw
34
{
35
EventArgsDraw
(
IDrawingContext
& content)
36
: newContent (content)
37
{
38
}
39
IDrawingContext
&
newContent
;
40
};
41
42
struct
EventArgsColor
43
{
44
EventArgsColor
(
const
sf::Color& content)
45
: newContent (content)
46
{
47
}
48
const
sf::Color&
newContent
;
49
};
50
51
struct
EventArgsIWidget
52
{
53
IWidget
&
newContent
;
54
55
EventArgsIWidget
(
IWidget
& content)
56
: newContent (content)
57
{
58
}
59
};
60
61
Event<const BaseWidget&, const EventArgs&>
OnMoved
;
62
Event<const BaseWidget&, const EventArgs&>
OnScaled
;
63
Event<const BaseWidget&, const EventArgs&>
OnSizeSet
;
64
Event<const BaseWidget&, const EventArgsDraw&>
OnDraw
;
65
Event<const BaseWidget&, const EventArgsColor&>
OnColorChanged
;
66
Event<const BaseWidget&, const EventArgsIWidget&>
OnChildAdded
;
67
68
BaseWidget
();
69
virtual
~
BaseWidget
();
70
73
virtual
const
Vector2
& GetPosition ()
const
;
74
virtual
const
Vector2
& GetSize ()
const
;
75
76
virtual
const
Vector2
& GetTopLeft ()
const
;
77
virtual
const
Vector2
& GetBottomRight ()
const
;
78
virtual
const
Vector2
& GetCenter ()
const
;
79
80
virtual
const
sf::FloatRect
& GetRectangle ()
const
;
81
virtual
WidgetBorder
* GetBorder ()
const
;
82
83
virtual
void
Move (
const
Vector2
& offset);
84
virtual
void
Scale (
const
Vector2
& factor);
85
86
virtual
void
SetPosition (
const
Vector2
& position);
87
virtual
void
SetSize (
const
Vector2
& size);
89
92
virtual
void
Draw (
IDrawingContext
& context);
93
94
virtual
bool
IsVisible ()
const
;
95
virtual
void
Show (
bool
isVisible);
96
97
virtual
void
ChangeColor (
const
sf::Color& color);
99
102
virtual
bool
OnEvent (
const
GuiEvent
& guiEvent);
103
virtual
bool
OnPriorityEvent (
const
GuiEvent
& guiEvent);
105
108
virtual
void
Update (
const
Time
& dt);
110
111
virtual
void
AddDrawable (
IDrawable
& drawable);
112
virtual
void
AddChild (
IWidget
& child);
113
virtual
void
FrontAddChild (
IWidget
& child);
114
virtual
void
RemoveChild (
IWidget
& child);
115
virtual
IWidget
& GetRoot ()
const
;
116
virtual
void
SetDefaultColor (
const
sf::Color& color);
117
virtual
void
SetParent (
IWidget
& parent);
118
virtual
void
SetPadding (
const
Padding
& padding);
119
virtual
void
SetBackground (
WidgetBackground
& background);
120
virtual
void
SetBorder (
WidgetBorder
& border,
uint
width);
121
virtual
void
SetBorder (
WidgetBorder
& border);
122
virtual
void
UnsetBackground ();
123
virtual
void
UnsetBorder ();
124
virtual
bool
IsFocusable ()
const
= 0;
125
Vector2
GetUserSize ()
const
;
126
127
virtual
void
SetToTop();
128
129
virtual
void
SetEnable (
bool
enable);
130
virtual
void
Open ();
131
virtual
void
Close ();
132
protected
:
133
134
void
RefreshBorder ();
135
virtual
void
SetFocused (
bool
state);
136
virtual
void
Refresh ();
137
virtual
Vector2
HandleGetSize ()
const
;
138
139
virtual
void
HandleMove (
const
Vector2
& offset);
140
virtual
void
HandleScale (
const
Vector2
& factor);
141
virtual
void
HandleDraw (
IDrawingContext
& context);
142
virtual
void
HandleShow (
bool
isVisible);
143
virtual
void
HandleChangeColor (
const
sf::Color& color);
144
virtual
void
HandleUpdate (
const
Time
& dt);
145
146
virtual
bool
HandleOnEvent (
const
GuiEvent
& guiEvent);
147
virtual
bool
HandleOnPriorityEvent (
const
GuiEvent
& guiEvent);
148
149
static
const
bool
DEFAULT_VISIBLE_STATE
;
150
static
const
bool
DEFAULT_ENABLED_STATE
;
151
152
static
const
sf::Color
DEFAULT_COLOR
;
153
154
mutable
SpatialInfo
spatialInfo_
;
155
bool
isVisible_
;
156
bool
isEnabled_
;
157
sf::Color
color_
;
158
collection::List<IDrawable*>
drawables_
;
159
collection::List<IEventHandler*>
eventHandlers_
;
160
collection::List<IWidget*>
childen_
;
161
collection::List<IUpdateable*>
updatables_
;
162
IWidget
*
root_
;
163
IWidget
*
parent_
;
164
Padding
padding_
;
165
WidgetBackground
*
background_
;
166
WidgetBorder
*
border_
;
167
Vector2
userSize_
;
168
bool
isExtensible_
;
169
bool
isFocused_
;
170
sf::Color
userColor_
;
171
bool
isChangeColorCall_
;
172
private
:
173
void
SetPosAfterBorder (
uint
width,
uint
height,
bool
refreshing);
174
};
175
}
// namespace yap
176
177
#endif // YAPOG_WIDGETBASE_HPP
YAPOG
include
YAPOG
Graphics
Gui
BaseWidget.hpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1