MyGUI
3.4.0
MyGUIEngine
include
MyGUI_CommonStateInfo.h
Go to the documentation of this file.
1
/*
2
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
3
* Distributed under the MIT License
4
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5
*/
6
7
#ifndef MYGUI_COMMON_STATE_INFO_H_
8
#define MYGUI_COMMON_STATE_INFO_H_
9
10
#include "
MyGUI_Prerequest.h
"
11
#include "
MyGUI_IStateInfo.h
"
12
#include "
MyGUI_CoordConverter.h
"
13
#include "
MyGUI_LanguageManager.h
"
14
#include "
MyGUI_TextureUtility.h
"
15
16
namespace
MyGUI
17
{
18
19
class
MYGUI_EXPORT
SubSkinStateInfo
:
20
public
IStateInfo
21
{
22
MYGUI_RTTI_DERIVED
(
SubSkinStateInfo
)
23
24
public
:
25
const
FloatRect
&
getRect
()
const
26
{
27
return
mRect;
28
}
29
30
private
:
31
void
deserialization(
xml::ElementPtr
_node,
Version
_version)
override
32
{
33
std::string texture = _node->
getParent
()->
getParent
()->
findAttribute
(
"texture"
);
34
35
// tags replacement support for Skins
36
if
(_version >=
Version
(1, 1))
37
{
38
texture =
LanguageManager::getInstance
().
replaceTags
(texture);
39
}
40
41
const
IntSize
& size =
texture_utility::getTextureSize
(texture);
42
const
IntCoord
& coord =
IntCoord::parse
(_node->
findAttribute
(
"offset"
));
43
mRect =
CoordConverter::convertTextureCoord
(coord, size);
44
}
45
46
private
:
47
FloatRect
mRect;
48
};
49
50
class
MYGUI_EXPORT
TileRectStateInfo
:
51
public
IStateInfo
52
{
53
MYGUI_RTTI_DERIVED
(
TileRectStateInfo
)
54
55
public
:
56
TileRectStateInfo
() :
57
mTileH(true),
58
mTileV(true)
59
{
60
}
61
62
const
FloatRect
&
getRect
()
const
63
{
64
return
mRect;
65
}
66
67
const
IntSize
&
getTileSize
()
const
68
{
69
return
mTileSize;
70
}
71
72
bool
getTileH
()
const
73
{
74
return
mTileH;
75
}
76
77
bool
getTileV
()
const
78
{
79
return
mTileV;
80
}
81
82
private
:
83
void
deserialization(
xml::ElementPtr
_node,
Version
_version)
override
84
{
85
std::string texture = _node->
getParent
()->
getParent
()->
findAttribute
(
"texture"
);
86
87
// tags replacement support for Skins
88
if
(_version >=
Version
(1, 1))
89
{
90
texture =
LanguageManager::getInstance
().
replaceTags
(texture);
91
}
92
93
const
IntSize
& size =
texture_utility::getTextureSize
(texture);
94
const
IntCoord
& coord =
IntCoord::parse
(_node->
findAttribute
(
"offset"
));
95
mRect =
CoordConverter::convertTextureCoord
(coord, size);
96
97
xml::ElementEnumerator prop = _node->
getElementEnumerator
();
98
while
(prop.next(
"Property"
))
99
{
100
const
std::string& key = prop->
findAttribute
(
"key"
);
101
const
std::string& value = prop->findAttribute(
"value"
);
102
if
(key ==
"TileH"
) mTileH =
utility::parseBool
(value);
103
else
if
(key ==
"TileV"
) mTileV =
utility::parseBool
(value);
104
else
if
(key ==
"TileSize"
) mTileSize =
IntSize::parse
(value);
105
}
106
}
107
108
private
:
109
FloatRect
mRect;
110
IntSize
mTileSize;
111
bool
mTileH;
112
bool
mTileV;
113
};
114
115
class
MYGUI_EXPORT
RotatingSkinStateInfo
:
116
public
IStateInfo
117
{
118
MYGUI_RTTI_DERIVED
(
RotatingSkinStateInfo
)
119
120
public
:
121
RotatingSkinStateInfo
() :
122
mAngle(0)
123
{
124
}
125
126
float
getAngle
()
const
127
{
128
return
mAngle;
129
}
130
131
const
IntPoint
&
getCenter
()
const
132
{
133
return
mCenter;
134
}
135
136
const
FloatRect
&
getRect
()
const
137
{
138
return
mRect;
139
}
140
141
private
:
142
void
deserialization(
xml::ElementPtr
_node,
Version
_version)
override
143
{
144
xml::ElementEnumerator
prop = _node->
getElementEnumerator
();
145
while
(prop.
next
(
"Property"
))
146
{
147
const
std::string& key = prop->
findAttribute
(
"key"
);
148
const
std::string& value = prop->
findAttribute
(
"value"
);
149
if
(key ==
"Angle"
) mAngle =
utility::parseFloat
(value);
150
if
(key ==
"Center"
) mCenter =
IntPoint::parse
(value);
151
}
152
153
std::string texture = _node->
getParent
()->
getParent
()->
findAttribute
(
"texture"
);
154
155
// tags replacement support for Skins
156
if
(_version >= Version(1, 1))
157
{
158
texture =
LanguageManager::getInstance
().
replaceTags
(texture);
159
}
160
161
const
IntSize
& size =
texture_utility::getTextureSize
(texture);
162
const
IntCoord
& coord =
IntCoord::parse
(_node->
findAttribute
(
"offset"
));
163
mRect =
CoordConverter::convertTextureCoord
(coord, size);
164
}
165
166
private
:
167
FloatRect
mRect;
168
IntPoint
mCenter;
169
float
mAngle;
// Angle in radians
170
};
171
172
173
class
MYGUI_EXPORT
EditTextStateInfo
:
174
public
IStateInfo
175
{
176
MYGUI_RTTI_DERIVED
(
EditTextStateInfo
)
177
178
public
:
179
EditTextStateInfo
() :
180
mColour(
Colour
::White),
181
mShift(false)
182
{
183
}
184
185
const
Colour
&
getColour
()
const
186
{
187
return
mColour;
188
}
189
190
bool
getShift
()
const
191
{
192
return
mShift;
193
}
194
195
private
:
196
void
deserialization(
xml::ElementPtr
_node,
Version
_version)
override
197
{
198
mShift =
utility::parseBool
(_node->
findAttribute
(
"shift"
));
199
200
std::string colour = _node->
findAttribute
(
"colour"
);
201
if
(_version >=
Version
(1, 1))
202
{
203
colour =
LanguageManager::getInstance
().
replaceTags
(colour);
204
}
205
206
mColour =
Colour::parse
(colour);
207
}
208
209
private
:
210
Colour mColour;
211
bool
mShift;
212
};
213
214
}
// namespace MyGUI
215
216
#endif // MYGUI_COMMON_STATE_INFO_H_
MyGUI::Singleton< LanguageManager >::getInstance
static LanguageManager & getInstance()
Definition:
MyGUI_Singleton.h:44
MyGUI::EditTextStateInfo
Definition:
MyGUI_CommonStateInfo.h:175
MyGUI::types::TCoord< int >::parse
static TCoord< int > parse(const std::string &_value)
Definition:
MyGUI_TCoord.h:207
MyGUI::utility::parseBool
bool parseBool(const std::string &_value)
Definition:
MyGUI_StringUtility.h:189
MyGUI::EditTextStateInfo::getShift
bool getShift() const
Definition:
MyGUI_CommonStateInfo.h:190
MyGUI::TileRectStateInfo::TileRectStateInfo
TileRectStateInfo()
Definition:
MyGUI_CommonStateInfo.h:56
MyGUI::types::TRect< float >
MyGUI::Colour::parse
static Colour parse(const std::string &_value)
Definition:
MyGUI_Colour.cpp:80
MyGUI::SubSkinStateInfo::getRect
const FloatRect & getRect() const
Definition:
MyGUI_CommonStateInfo.h:25
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition:
MyGUI_Types.h:35
MyGUI::TileRectStateInfo::getTileH
bool getTileH() const
Definition:
MyGUI_CommonStateInfo.h:72
MyGUI::types::TPoint< int >
MyGUI::RotatingSkinStateInfo::getRect
const FloatRect & getRect() const
Definition:
MyGUI_CommonStateInfo.h:136
MyGUI_CoordConverter.h
MyGUI::xml::Element
Definition:
MyGUI_XmlDocument.h:159
MyGUI::utility::parseFloat
float parseFloat(const std::string &_value)
Definition:
MyGUI_StringUtility.h:179
MyGUI::xml::Element::findAttribute
bool findAttribute(const std::string &_name, std::string &_value)
Definition:
MyGUI_XmlDocument.cpp:246
MyGUI::xml::Element::getParent
ElementPtr getParent() const
Definition:
MyGUI_XmlDocument.cpp:347
MyGUI::TileRectStateInfo::getTileV
bool getTileV() const
Definition:
MyGUI_CommonStateInfo.h:77
MyGUI::IStateInfo
Definition:
MyGUI_IStateInfo.h:18
MyGUI::RotatingSkinStateInfo::getAngle
float getAngle() const
Definition:
MyGUI_CommonStateInfo.h:126
MyGUI::Version
Definition:
MyGUI_Version.h:18
MyGUI::types::TPoint< int >::parse
static TPoint< int > parse(const std::string &_value)
Definition:
MyGUI_TPoint.h:120
MyGUI_Prerequest.h
MyGUI::xml::ElementEnumerator
Definition:
MyGUI_XmlDocument.h:115
MyGUI::EditTextStateInfo::EditTextStateInfo
EditTextStateInfo()
Definition:
MyGUI_CommonStateInfo.h:179
MyGUI::SubSkinStateInfo
Definition:
MyGUI_CommonStateInfo.h:21
MyGUI::TileRectStateInfo::getTileSize
const IntSize & getTileSize() const
Definition:
MyGUI_CommonStateInfo.h:67
MyGUI::FloatRect
types::TRect< float > FloatRect
Definition:
MyGUI_Types.h:33
MyGUI_LanguageManager.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition:
MyGUI_RTTI.h:48
MyGUI_TextureUtility.h
MyGUI::CoordConverter::convertTextureCoord
static FloatRect convertTextureCoord(const IntCoord &_coord, const IntSize &_textureSize)
Definition:
MyGUI_CoordConverter.h:20
MyGUI::types::TSize< int >
MyGUI::Colour
Definition:
MyGUI_Colour.h:17
MyGUI::RotatingSkinStateInfo::RotatingSkinStateInfo
RotatingSkinStateInfo()
Definition:
MyGUI_CommonStateInfo.h:121
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition:
MyGUI_Platform.h:89
MyGUI::IntSize
types::TSize< int > IntSize
Definition:
MyGUI_Types.h:29
MyGUI::RotatingSkinStateInfo::getCenter
const IntPoint & getCenter() const
Definition:
MyGUI_CommonStateInfo.h:131
MyGUI::types::TSize< int >::parse
static TSize< int > parse(const std::string &_value)
Definition:
MyGUI_TSize.h:120
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition:
MyGUI_Types.h:26
MyGUI::LanguageManager::replaceTags
UString replaceTags(const UString &_line)
Definition:
MyGUI_LanguageManager.cpp:195
MyGUI_IStateInfo.h
MyGUI::TileRectStateInfo::getRect
const FloatRect & getRect() const
Definition:
MyGUI_CommonStateInfo.h:62
MyGUI::texture_utility::getTextureSize
const IntSize & getTextureSize(const std::string &_texture, bool _cache=true)
Definition:
MyGUI_TextureUtility.cpp:20
MyGUI::TileRectStateInfo
Definition:
MyGUI_CommonStateInfo.h:52
MyGUI::xml::Element::getElementEnumerator
ElementEnumerator getElementEnumerator()
Definition:
MyGUI_XmlDocument.cpp:352
MyGUI::RotatingSkinStateInfo
Definition:
MyGUI_CommonStateInfo.h:117
MyGUI
Definition:
MyGUI_ActionController.h:15
MyGUI::EditTextStateInfo::getColour
const Colour & getColour() const
Definition:
MyGUI_CommonStateInfo.h:185
MyGUI::xml::ElementEnumerator::next
bool next()
Definition:
MyGUI_XmlDocument.cpp:100
Generated by
1.8.18