7 #ifndef __MYGUI_ALIGN_H__
8 #define __MYGUI_ALIGN_H__
25 Center = HCenter | VCenter,
35 Stretch = HStretch | VStretch,
44 bool isHCenter()
const
46 return HCenter == (mValue & ((int)HStretch));
49 bool isVCenter()
const
51 return VCenter == (mValue & ((int)VStretch));
56 return Center == (mValue & ((int)Stretch));
61 return Left == (mValue & ((int)HStretch));
66 return Right == (mValue & ((int)HStretch));
69 bool isHStretch()
const
71 return HStretch == (mValue & ((int)HStretch));
76 return Top == (mValue & ((int)VStretch));
81 return (
Bottom == (mValue & ((
int)VStretch)));
84 bool isVStretch()
const
86 return (VStretch == (mValue & ((
int)VStretch)));
89 bool isStretch()
const
91 return (Stretch == (mValue & ((
int)Stretch)));
94 bool isDefault()
const
96 return (Default == (mValue & ((
int)Stretch)));
101 mValue =
Enum(
int(mValue) |
int(_other.mValue));
112 return Align(
Enum(
int(a.mValue) |
int(b.mValue)));
117 return a.mValue == b.mValue;
122 return a.mValue != b.mValue;
127 static Align parse(
const std::string& _value)
130 const MapAlign& map_names = result.getValueNames();
132 for (
size_t pos = 0; pos < vec.size(); pos++)
134 MapAlign::const_iterator iter = map_names.find(vec[pos]);
135 if (iter != map_names.end())
137 result.mValue =
Enum(
int(result.mValue) |
int(iter->second));
143 std::string print()
const
154 else if (mValue &
Right)
162 result +=
" VStretch";
169 result +=
" VCenter";
174 friend std::ostream& operator << ( std::ostream& _stream,
const Align& _value )
176 _stream << _value.
print();
180 friend std::istream& operator >> ( std::istream& _stream,
Align& _value )
182 _value.mValue =
Enum(0);
186 const MapAlign& map_names = _value.getValueNames();
187 MapAlign::const_iterator iter = map_names.find(value);
188 if (iter != map_names.end())
189 _value.mValue =
Enum(
int(_value.mValue) | int(iter->second));
195 iter = map_names.find(value2);
196 if (iter != map_names.end())
197 _value.mValue =
Enum(
int(_value.mValue) | int(iter->second));
209 const MapAlign& getValueNames()
const
211 static MapAlign map_names;
213 if (map_names.empty())
216 map_names[
"ALIGN_HCENTER"] = HCenter;
217 map_names[
"ALIGN_VCENTER"] = VCenter;
218 map_names[
"ALIGN_CENTER"] = Center;
219 map_names[
"ALIGN_LEFT"] =
Left;
220 map_names[
"ALIGN_RIGHT"] =
Right;
221 map_names[
"ALIGN_HSTRETCH"] = HStretch;
222 map_names[
"ALIGN_TOP"] =
Top;
223 map_names[
"ALIGN_BOTTOM"] =
Bottom;
224 map_names[
"ALIGN_VSTRETCH"] = VStretch;
225 map_names[
"ALIGN_STRETCH"] = Stretch;
226 map_names[
"ALIGN_DEFAULT"] = Default;
250 #endif // __MYGUI_ALIGN_H__