/usr/include/MYGUI/MyGUI_TRect.h is in libmygui-dev 3.2.1-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 | /*
* 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_TRECT_H__
#define __MYGUI_TRECT_H__
#include "MyGUI_Prerequest.h"
namespace MyGUI
{
namespace types
{
template<typename T>
struct TRect
{
T left;
T top;
T right;
T bottom;
TRect() :
left(0),
top(0),
right(0),
bottom(0)
{
}
TRect(T const& _left, T const& _top, T const& _right, T const& _bottom) :
left(_left),
top(_top),
right(_right),
bottom(_bottom)
{
}
TRect(TRect const& _obj) :
left(_obj.left),
top(_obj.top),
right(_obj.right),
bottom(_obj.bottom)
{
}
TRect& operator -= (TRect const& _obj)
{
left -= _obj.left;
top -= _obj.top;
right -= _obj.right;
bottom -= _obj.bottom;
return *this;
}
TRect& operator += (TRect const& _obj)
{
left += _obj.left;
top += _obj.top;
right += _obj.right;
bottom += _obj.bottom;
return *this;
}
TRect operator - (TRect const& _obj) const
{
return TRect(left - _obj.left, top - _obj.top, right - _obj.right, bottom - _obj.bottom);
}
TRect operator + (TRect const& _obj) const
{
return TRect(left + _obj.left, top + _obj.top, right + _obj.right, bottom + _obj.bottom);
}
TRect& operator = (TRect const& _obj)
{
left = _obj.left;
top = _obj.top;
right = _obj.right;
bottom = _obj.bottom;
return *this;
}
template<typename U>
TRect& operator = (TRect<U> const& _obj)
{
left = _obj.left;
top = _obj.top;
right = _obj.right;
bottom = _obj.bottom;
return *this;
}
bool operator == (TRect const& _obj) const
{
return ((left == _obj.left) && (top == _obj.top) && (right == _obj.right) && (bottom == _obj.bottom));
}
bool operator != (TRect const& _obj) const
{
return !((left == _obj.left) && (top == _obj.top) && (right == _obj.right) && (bottom == _obj.bottom));
}
T width() const
{
return right - left;
}
T height() const
{
return bottom - top;
}
void clear()
{
left = top = right = bottom = 0;
}
void set(T const& _left, T const& _top, T const& _right, T const& _bottom)
{
left = _left;
top = _top;
right = _right;
bottom = _bottom;
}
void swap(TRect& _value)
{
TRect tmp = _value;
_value = *this;
*this = tmp;
}
bool empty() const
{
return ((left == 0) && (top == 0) && (right == 0) && (bottom == 0));
}
bool inside(const TRect<T>& _value) const
{
return ((_value.left >= left) && (_value.right <= right) && (_value.top >= top) && (_value.bottom <= bottom));
}
bool intersect(const TRect<T>& _value) const
{
return ((_value.left <= right) && (_value.right >= left) && (_value.top <= bottom) && (_value.bottom >= top));
}
bool inside(const TPoint<T>& _value) const
{
return ((_value.left >= left) && (_value.left <= right) && (_value.top >= top) && (_value.top <= bottom));
}
std::string print() const
{
std::ostringstream stream;
stream << *this;
return stream.str();
}
static TRect<T> parse(const std::string& _value)
{
TRect<T> result;
std::istringstream stream(_value);
stream >> result.left >> result.top >> result.right >> result.bottom;
if (stream.fail())
{
return TRect<T>();
}
else
{
int item = stream.get();
while (item != -1)
{
if (item != ' ' && item != '\t')
return TRect<T>();
item = stream.get();
}
}
return result;
}
friend std::ostream& operator << (std::ostream& _stream, const TRect<T>& _value)
{
_stream << _value.left << " " << _value.top << " " << _value.right << " " << _value.bottom;
return _stream;
}
friend std::istream& operator >> (std::istream& _stream, TRect<T>& _value)
{
_stream >> _value.left >> _value.top >> _value.right >> _value.bottom;
if (_stream.fail())
_value.clear();
return _stream;
}
};
} // namespace types
} // namespace MyGUI
#endif // __MYGUI_TRECT_H__
|