/usr/include/MYGUI/MyGUI_Align.h is in libmygui-dev 3.2.2+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | /*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_ALIGN_H_
#define MYGUI_ALIGN_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Macros.h"
#include "MyGUI_Diagnostic.h"
#include "MyGUI_StringUtility.h"
#include <map>
namespace MyGUI
{
struct MYGUI_EXPORT Align
{
enum Enum
{
HCenter = MYGUI_FLAG_NONE, /**< center horizontally */
VCenter = MYGUI_FLAG_NONE, /**< center vertically */
Center = HCenter | VCenter, /**< center in the dead center */
Left = MYGUI_FLAG(1), /**< value from the left (and center vertically) */
Right = MYGUI_FLAG(2), /**< value from the right (and center vertically) */
HStretch = Left | Right, /**< stretch horizontally proportionate to parent window (and center vertically) */
Top = MYGUI_FLAG(3), /**< value from the top (and center horizontally) */
Bottom = MYGUI_FLAG(4), /**< value from the bottom (and center horizontally) */
VStretch = Top | Bottom, /**< stretch vertically proportionate to parent window (and center horizontally) */
Stretch = HStretch | VStretch, /**< stretch proportionate to parent window */
Default = Left | Top /**< default value (value from left and top) */
};
Align(Enum _value = Default) :
mValue(_value)
{
}
bool isHCenter() const
{
return HCenter == (mValue & ((int)HStretch));
}
bool isVCenter() const
{
return VCenter == (mValue & ((int)VStretch));
}
bool isCenter() const
{
return Center == (mValue & ((int)Stretch));
}
bool isLeft() const
{
return Left == (mValue & ((int)HStretch));
}
bool isRight() const
{
return Right == (mValue & ((int)HStretch));
}
bool isHStretch() const
{
return HStretch == (mValue & ((int)HStretch));
}
bool isTop() const
{
return Top == (mValue & ((int)VStretch));
}
bool isBottom() const
{
return (Bottom == (mValue & ((int)VStretch)));
}
bool isVStretch() const
{
return (VStretch == (mValue & ((int)VStretch)));
}
bool isStretch() const
{
return (Stretch == (mValue & ((int)Stretch)));
}
bool isDefault() const
{
return (Default == (mValue & ((int)Stretch)));
}
Align& operator |= (Align const& _other)
{
mValue = Enum(int(mValue) | int(_other.mValue));
return *this;
}
friend Align operator | (Enum const& a, Enum const& b)
{
return Align(Enum(int(a) | int(b)));
}
friend Align operator | (Align const& a, Align const& b)
{
return Align(Enum(int(a.mValue) | int(b.mValue)));
}
friend bool operator == (Align const& a, Align const& b)
{
return a.mValue == b.mValue;
}
friend bool operator != (Align const& a, Align const& b)
{
return a.mValue != b.mValue;
}
typedef std::map<std::string, int> MapAlign;
static Align parse(const std::string& _value)
{
Align result(Enum(0));
const MapAlign& map_names = result.getValueNames();
const std::vector<std::string>& vec = utility::split(_value);
for (size_t pos = 0; pos < vec.size(); pos++)
{
MapAlign::const_iterator iter = map_names.find(vec[pos]);
if (iter != map_names.end())
{
result.mValue = Enum(int(result.mValue) | int(iter->second));
}
}
return result;
}
std::string print() const
{
std::string result;
if (mValue & Left)
{
if (mValue & Right)
result = "HStretch";
else
result = "Left";
}
else if (mValue & Right)
result = "Right";
else
result = "HCenter";
if (mValue & Top)
{
if (mValue & Bottom)
result += " VStretch";
else
result += " Top";
}
else if (mValue & Bottom)
result += " Bottom";
else
result += " VCenter";
return result;
}
friend std::ostream& operator << ( std::ostream& _stream, const Align& _value )
{
_stream << _value.print();
return _stream;
}
friend std::istream& operator >> ( std::istream& _stream, Align& _value )
{
_value.mValue = Enum(0);
std::string value;
_stream >> value;
const MapAlign& map_names = _value.getValueNames();
MapAlign::const_iterator iter = map_names.find(value);
if (iter != map_names.end())
_value.mValue = Enum(int(_value.mValue) | int(iter->second));
if (!_stream.eof())
{
std::string value2;
_stream >> value2;
iter = map_names.find(value2);
if (iter != map_names.end())
_value.mValue = Enum(int(_value.mValue) | int(iter->second));
}
return _stream;
}
int getValue() const
{
return mValue;
}
private:
const MapAlign& getValueNames() const
{
static MapAlign map_names;
if (map_names.empty())
{
// OBSOLETE
map_names["ALIGN_HCENTER"] = HCenter;
map_names["ALIGN_VCENTER"] = VCenter;
map_names["ALIGN_CENTER"] = Center;
map_names["ALIGN_LEFT"] = Left;
map_names["ALIGN_RIGHT"] = Right;
map_names["ALIGN_HSTRETCH"] = HStretch;
map_names["ALIGN_TOP"] = Top;
map_names["ALIGN_BOTTOM"] = Bottom;
map_names["ALIGN_VSTRETCH"] = VStretch;
map_names["ALIGN_STRETCH"] = Stretch;
map_names["ALIGN_DEFAULT"] = Default;
MYGUI_REGISTER_VALUE(map_names, HCenter);
MYGUI_REGISTER_VALUE(map_names, VCenter);
MYGUI_REGISTER_VALUE(map_names, Center);
MYGUI_REGISTER_VALUE(map_names, Left);
MYGUI_REGISTER_VALUE(map_names, Right);
MYGUI_REGISTER_VALUE(map_names, HStretch);
MYGUI_REGISTER_VALUE(map_names, Top);
MYGUI_REGISTER_VALUE(map_names, Bottom);
MYGUI_REGISTER_VALUE(map_names, VStretch);
MYGUI_REGISTER_VALUE(map_names, Stretch);
MYGUI_REGISTER_VALUE(map_names, Default);
}
return map_names;
}
private:
Enum mValue;
};
} // namespace MyGUI
#endif // MYGUI_ALIGN_H_
|