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