MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_CommonStateInfo.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_COMMON_STATE_INFO_H__
23 #define __MYGUI_COMMON_STATE_INFO_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_IStateInfo.h"
27 #include "MyGUI_CoordConverter.h"
28 #include "MyGUI_LanguageManager.h"
29 #include "MyGUI_TextureUtility.h"
30
31 namespace MyGUI
32 {
33
34 class MYGUI_EXPORT SubSkinStateInfo :
35 public IStateInfo
36 {
37 MYGUI_RTTI_DERIVED( SubSkinStateInfo )
38
39 public:
40 virtual ~SubSkinStateInfo() { }
41
42 const FloatRect& getRect() const
43 {
44 return mRect;
45 }
46
47 private:
48 virtual void deserialization(xml::ElementPtr _node, Version _version)
49 {
50 std::string texture = _node->getParent()->getParent()->findAttribute("texture");
51
52 // поддержка замены тегов в скинах
53 if (_version >= Version(1, 1))
54 {
55 texture = LanguageManager::getInstance().replaceTags(texture);
56 }
57
58 const IntSize& size = texture_utility::getTextureSize(texture);
59 const IntCoord& coord = IntCoord::parse(_node->findAttribute("offset"));
60 mRect = CoordConverter::convertTextureCoord(coord, size);
61 }
62
63 private:
64 FloatRect mRect;
65 };
66
67 class MYGUI_EXPORT TileRectStateInfo :
68 public IStateInfo
69 {
70 MYGUI_RTTI_DERIVED( TileRectStateInfo )
71
72 public:
73 TileRectStateInfo() :
74 mTileH(true),
75 mTileV(true)
76 {
77 }
78
79 virtual ~TileRectStateInfo() { }
80
81 const FloatRect& getRect() const
82 {
83 return mRect;
84 }
85
86 const IntSize& getTileSize() const
87 {
88 return mTileSize;
89 }
90
91 bool getTileH() const
92 {
93 return mTileH;
94 }
95
96 bool getTileV() const
97 {
98 return mTileV;
99 }
100
101 private:
102 virtual void deserialization(xml::ElementPtr _node, Version _version)
103 {
104 std::string texture = _node->getParent()->getParent()->findAttribute("texture");
105
106 // поддержка замены тегов в скинах
107 if (_version >= Version(1, 1))
108 {
109 texture = LanguageManager::getInstance().replaceTags(texture);
110 }
111
112 const IntSize& size = texture_utility::getTextureSize(texture);
113 const IntCoord& coord = IntCoord::parse(_node->findAttribute("offset"));
114 mRect = CoordConverter::convertTextureCoord(coord, size);
115
116 xml::ElementEnumerator prop = _node->getElementEnumerator();
117 while (prop.next("Property"))
118 {
119 const std::string& key = prop->findAttribute("key");
120 const std::string& value = prop->findAttribute("value");
121 if (key == "TileH") mTileH = utility::parseBool(value);
122 else if (key == "TileV") mTileV = utility::parseBool(value);
123 else if (key == "TileSize") mTileSize = IntSize::parse(value);
124 }
125 }
126
127 private:
128 FloatRect mRect;
129 IntSize mTileSize;
130 bool mTileH;
131 bool mTileV;
132 };
133
134 class MYGUI_EXPORT EditTextStateInfo :
135 public IStateInfo
136 {
137 MYGUI_RTTI_DERIVED( EditTextStateInfo )
138
139 public:
140 EditTextStateInfo() :
141 mColour(Colour::White),
142 mShift(false)
143 {
144 }
145
146 virtual ~EditTextStateInfo() { }
147
148 const Colour& getColour() const
149 {
150 return mColour;
151 }
152
153 bool getShift() const
154 {
155 return mShift;
156 }
157
158 private:
159 virtual void deserialization(xml::ElementPtr _node, Version _version)
160 {
161 mShift = utility::parseBool(_node->findAttribute("shift"));
162
163 std::string colour = _node->findAttribute("colour");
164 if (_version >= Version(1, 1))
165 {
166 colour = LanguageManager::getInstance().replaceTags(colour);
167 }
168
169 mColour = Colour::parse(colour);
170 }
171
172 private:
173 Colour mColour;
174 bool mShift;
175 };
176
177 } // namespace MyGUI
178
179 #endif // __MYGUI_COMMON_STATE_INFO_H__
MyGUI_TextureUtility.h
MyGUI_Prerequest.h
MyGUI::IntSize
types::TSize< int > IntSize
Definition: MyGUI_Types.h:44
MyGUI::IStateInfo
Definition: MyGUI_IStateInfo.h:31
MyGUI::types::TSize< int >
MyGUI::Singleton< LanguageManager >::getInstance
static LanguageManager & getInstance()
Definition: MyGUI_Singleton.h:53
MyGUI::texture_utility::getTextureSize
const IntSize & getTextureSize(const std::string &_texture, bool _cache=true)
Definition: MyGUI_TextureUtility.cpp:34
MyGUI::EditTextStateInfo::getColour
const Colour & getColour() const
Definition: MyGUI_CommonStateInfo.h:148
MyGUI::xml::Element::findAttribute
bool findAttribute(const std::string &_name, std::string &_value)
Definition: MyGUI_XmlDocument.cpp:261
MyGUI::TileRectStateInfo::getRect
const FloatRect & getRect() const
Definition: MyGUI_CommonStateInfo.h:81
MyGUI::types::TSize< int >::parse
static TSize< int > parse(const std::string &_value)
Definition: MyGUI_TSize.h:135
MyGUI_LanguageManager.h
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:50
MyGUI_IStateInfo.h
MyGUI::TileRectStateInfo::getTileV
bool getTileV() const
Definition: MyGUI_CommonStateInfo.h:96
MyGUI::TileRectStateInfo::getTileH
bool getTileH() const
Definition: MyGUI_CommonStateInfo.h:91
MyGUI::EditTextStateInfo
Definition: MyGUI_CommonStateInfo.h:134
MyGUI::TileRectStateInfo::getTileSize
const IntSize & getTileSize() const
Definition: MyGUI_CommonStateInfo.h:86
MyGUI_CoordConverter.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::types::TRect< float >
MyGUI::EditTextStateInfo::~EditTextStateInfo
virtual ~EditTextStateInfo()
Definition: MyGUI_CommonStateInfo.h:146
MyGUI::xml::Element
Definition: MyGUI_XmlDocument.h:168
MyGUI::Version
Definition: MyGUI_Version.h:32
MyGUI::TileRectStateInfo
Definition: MyGUI_CommonStateInfo.h:67
MyGUI::FloatRect
types::TRect< float > FloatRect
Definition: MyGUI_Types.h:48
MyGUI::SubSkinStateInfo
Definition: MyGUI_CommonStateInfo.h:34
MyGUI::TileRectStateInfo::~TileRectStateInfo
virtual ~TileRectStateInfo()
Definition: MyGUI_CommonStateInfo.h:79
MyGUI::utility::parseBool
bool parseBool(const std::string &_value)
Definition: MyGUI_StringUtility.h:206
MyGUI::SubSkinStateInfo::getRect
const FloatRect & getRect() const
Definition: MyGUI_CommonStateInfo.h:42
MyGUI::xml::Element::getElementEnumerator
ElementEnumerator getElementEnumerator()
Definition: MyGUI_XmlDocument.cpp:367
MyGUI::Colour::parse
static Colour parse(const std::string &_value)
Definition: MyGUI_Colour.cpp:95
MyGUI::LanguageManager::replaceTags
UString replaceTags(const UString &_line)
Definition: MyGUI_LanguageManager.cpp:210
MyGUI::Colour
Definition: MyGUI_Colour.h:31
MyGUI::CoordConverter::convertTextureCoord
static FloatRect convertTextureCoord(const IntCoord &_coord, const IntSize &_textureSize)
Definition: MyGUI_CoordConverter.h:35
MyGUI::types::TCoord< int >::parse
static TCoord< int > parse(const std::string &_value)
Definition: MyGUI_TCoord.h:222
MyGUI::EditTextStateInfo::getShift
bool getShift() const
Definition: MyGUI_CommonStateInfo.h:153
MyGUI::xml::Element::getParent
ElementPtr getParent() const
Definition: MyGUI_XmlDocument.cpp:362