23 #ifndef __MYGUI_ALIGN_H__
24 #define __MYGUI_ALIGN_H__
40 Center = HCenter | VCenter,
44 HStretch = Left | Right,
48 VStretch = Top | Bottom,
50 Stretch = HStretch | VStretch,
55 Relative = HRelative | VRelative
60 bool isHCenter()
const {
return HCenter == (value & ((int)HStretch | (
int)HRelative)); }
61 bool isVCenter()
const {
return VCenter == (value & ((int)VStretch | (
int)VRelative)); }
62 bool isCenter()
const {
return Center == (value & ((int)Stretch | (
int)Relative)); }
64 bool isLeft()
const {
return Left == (value & ((int)HStretch | (
int)HRelative)); }
65 bool isRight()
const {
return Right == (value & ((int)HStretch | (
int)HRelative)); }
66 bool isHStretch()
const {
return HStretch == (value & ((int)HStretch | (
int)HRelative)); }
68 bool isTop()
const {
return Top == (value & ((int)VStretch | (
int)VRelative)); }
69 bool isBottom()
const {
return (Bottom == (value & ((
int)VStretch | (
int)VRelative))); }
70 bool isVStretch()
const {
return (VStretch == (value & ((
int)VStretch | (
int)VRelative))); }
72 bool isStretch()
const {
return (Stretch == (value & ((
int)Stretch | (
int)Relative))); }
73 bool isDefault()
const {
return (Default == (value & ((
int)Stretch | (
int)Relative))); }
75 bool isHRelative()
const {
return HRelative == (value & (int)HRelative); }
76 bool isVRelative()
const {
return VRelative == (value & (int)VRelative); }
77 bool isRelative()
const {
return Relative == (value & (int)Relative); }
79 Align& operator |= (
Align const& _other) { value =
Enum(
int(value) |
int(_other.value));
return *
this; }
88 static Align parse(
const std::string& _value)
91 const MapAlign& map_names = result.getValueNames();
93 for (
size_t pos=0; pos<vec.size(); pos++)
95 MapAlign::const_iterator iter = map_names.find(vec[pos]);
96 if (iter != map_names.end())
98 result.value =
Enum(
int(result.value) |
int(iter->second));
104 std::string print()
const
110 if (value & Right) result =
"HStretch";
111 else result =
"Left";
113 else if (value & Right) result =
"Right";
114 else result =
"HCenter";
118 if (value & Bottom) result +=
" VStretch";
119 else result +=
" Top";
121 else if (value & Bottom) result +=
" Bottom";
122 else result +=
" VCenter";
127 friend std::ostream& operator << ( std::ostream& _stream,
const Align& _value )
129 _stream << _value.
print();
133 friend std::istream& operator >> ( std::istream& _stream,
Align& _value )
135 _value.value =
Enum(0);
139 const MapAlign& map_names = _value.getValueNames();
140 MapAlign::const_iterator iter = map_names.find(value);
141 if (iter != map_names.end())
142 _value.value =
Enum(
int(_value.value) | int(iter->second));
149 iter = map_names.find(value2);
150 if (iter != map_names.end())
151 _value.value =
Enum(
int(_value.value) | int(iter->second));
158 const MapAlign& getValueNames()
const
160 static MapAlign map_names;
162 if (map_names.empty())
165 map_names[
"ALIGN_HCENTER"] = HCenter;
166 map_names[
"ALIGN_VCENTER"] = VCenter;
167 map_names[
"ALIGN_CENTER"] = Center;
168 map_names[
"ALIGN_LEFT"] = Left;
169 map_names[
"ALIGN_RIGHT"] = Right;
170 map_names[
"ALIGN_HSTRETCH"] = HStretch;
171 map_names[
"ALIGN_TOP"] = Top;
172 map_names[
"ALIGN_BOTTOM"] = Bottom;
173 map_names[
"ALIGN_VSTRETCH"] = VStretch;
174 map_names[
"ALIGN_STRETCH"] = Stretch;
175 map_names[
"ALIGN_DEFAULT"] = Default;
202 #endif // __MYGUI_ALIGN_H__