Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_COMMON_STATE_INFO_H__
00024 #define __MYGUI_COMMON_STATE_INFO_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_IStateInfo.h"
00028 #include "MyGUI_CoordConverter.h"
00029 #include "MyGUI_LanguageManager.h"
00030 #include "MyGUI_TextureUtility.h"
00031
00032 namespace MyGUI
00033 {
00034
00035 class MYGUI_EXPORT SubSkinStateInfo :
00036 public IStateInfo
00037 {
00038 MYGUI_RTTI_DERIVED( SubSkinStateInfo );
00039
00040 public:
00041 virtual ~SubSkinStateInfo() { }
00042
00043 const FloatRect& getRect() { return mRect; }
00044
00045 private:
00046 virtual void deserialization(xml::ElementPtr _node, Version _version)
00047 {
00048 std::string texture = _node->getParent()->getParent()->findAttribute("texture");
00049
00050
00051 if (_version >= Version(1, 1))
00052 {
00053 texture = LanguageManager::getInstance().replaceTags(texture);
00054 }
00055
00056 const IntSize& size = texture_utility::getTextureSize(texture);
00057 const IntCoord& coord = IntCoord::parse(_node->findAttribute("offset"));
00058 mRect = CoordConverter::convertTextureCoord(coord, size);
00059 }
00060
00061 private:
00062 FloatRect mRect;
00063 };
00064
00065 class MYGUI_EXPORT TileRectStateInfo :
00066 public IStateInfo
00067 {
00068 MYGUI_RTTI_DERIVED( TileRectStateInfo );
00069
00070 public:
00071 TileRectStateInfo() : mTileH(true), mTileV(true) { }
00072 virtual ~TileRectStateInfo() { }
00073
00074 const FloatRect& getRect() { return mRect; }
00075 const IntSize& getTileSize() { return mTileSize; }
00076 bool getTileH() { return mTileH; }
00077 bool getTileV() { return mTileV; }
00078
00079 private:
00080 virtual void deserialization(xml::ElementPtr _node, Version _version)
00081 {
00082 std::string texture = _node->getParent()->getParent()->findAttribute("texture");
00083
00084
00085 if (_version >= Version(1, 1))
00086 {
00087 texture = LanguageManager::getInstance().replaceTags(texture);
00088 }
00089
00090 const IntSize& size = texture_utility::getTextureSize(texture);
00091 const IntCoord& coord = IntCoord::parse(_node->findAttribute("offset"));
00092 mRect = CoordConverter::convertTextureCoord(coord, size);
00093
00094 xml::ElementEnumerator prop = _node->getElementEnumerator();
00095 while (prop.next("Property"))
00096 {
00097 const std::string& key = prop->findAttribute("key");
00098 const std::string& value = prop->findAttribute("value");
00099 if (key == "TileH") mTileH = utility::parseBool(value);
00100 else if (key == "TileV") mTileV = utility::parseBool(value);
00101 else if (key == "TileSize") mTileSize = IntSize::parse(value);
00102 }
00103 }
00104
00105 private:
00106 FloatRect mRect;
00107 IntSize mTileSize;
00108 bool mTileH;
00109 bool mTileV;
00110 };
00111
00112 class MYGUI_EXPORT EditTextStateInfo :
00113 public IStateInfo
00114 {
00115 MYGUI_RTTI_DERIVED( EditTextStateInfo );
00116
00117 public:
00118 EditTextStateInfo() : mColour(Colour::White), mShift(false) { }
00119 virtual ~EditTextStateInfo() { }
00120
00121 const Colour& getColour() { return mColour; }
00122 bool getShift() { return mShift; }
00123
00124 private:
00125 virtual void deserialization(xml::ElementPtr _node, Version _version)
00126 {
00127 mShift = utility::parseBool(_node->findAttribute("shift"));
00128
00129 std::string colour = _node->findAttribute("colour");
00130 if (_version >= Version(1, 1))
00131 {
00132 colour = LanguageManager::getInstance().replaceTags(colour);
00133 }
00134
00135 mColour = Colour::parse(colour);
00136 }
00137
00138 private:
00139 Colour mColour;
00140 bool mShift;
00141 };
00142
00143 }
00144
00145 #endif // __MYGUI_COMMON_STATE_INFO_H__