/usr/include/MYGUI/MyGUI_ICroppedRectangle.h is in libmygui-dev 3.2.2-4.
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 251 252 253 254 | /*
* 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_I_CROPPED_RECTANGLE_H_
#define MYGUI_I_CROPPED_RECTANGLE_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Types.h"
namespace MyGUI
{
class MYGUI_EXPORT ICroppedRectangle
{
public:
ICroppedRectangle() :
mIsMargin(false),
mCroppedParent(nullptr)
{ }
virtual ~ICroppedRectangle() { }
/** Get parent ICroppedRectangle */
ICroppedRectangle* getCroppedParent()
{
return mCroppedParent;
}
/** Set position */
virtual void setPosition(const IntPoint& _value)
{
mCoord.left = _value.left;
mCoord.top = _value.top;
}
/** Set size */
virtual void setSize(const IntSize& _value)
{
mCoord.width = _value.width;
mCoord.height = _value.height;
}
/** Set coordinates (position and size) */
virtual void setCoord(const IntCoord& _value)
{
mCoord = _value;
}
/** Get position */
IntPoint getPosition() const
{
return mCoord.point();
}
/** Get size */
IntSize getSize() const
{
return mCoord.size();
}
/** Get coordinates (position and size) */
const IntCoord& getCoord() const
{
return mCoord;
}
/** Get position in screen coordinates */
const IntPoint& getAbsolutePosition() const
{
return mAbsolutePosition;
}
/** Get rectangle in screen coordinates */
IntRect getAbsoluteRect() const
{
return IntRect(mAbsolutePosition.left, mAbsolutePosition.top, mAbsolutePosition.left + mCoord.width, mAbsolutePosition.top + mCoord.height);
}
/** Get coordinate in screen coordinates */
IntCoord getAbsoluteCoord() const
{
return IntCoord(mAbsolutePosition.left, mAbsolutePosition.top, mCoord.width, mCoord.height);
}
/** Get X in screen coordinates */
int getAbsoluteLeft() const
{
return mAbsolutePosition.left;
}
/** Get Y in screen coordinates */
int getAbsoluteTop() const
{
return mAbsolutePosition.top;
}
/** Get left x-coordinate */
int getLeft() const
{
return mCoord.left;
}
/** Get right x-coordinate */
int getRight() const
{
return mCoord.right();
}
/** Get top y-coordinate */
int getTop() const
{
return mCoord.top;
}
/** Get bottom y-coordinate */
int getBottom() const
{
return mCoord.bottom();
}
/** Get width */
int getWidth() const
{
return mCoord.width;
}
/** Get height */
int getHeight() const
{
return mCoord.height;
}
/*internal:*/
/** True if rectangle is cropped by parent rectangle */
bool _isMargin() const
{
return mIsMargin;
}
// Get cropped by parent rectangle coordinates
int _getViewLeft() const
{
return mCoord.left + mMargin.left;
}
int _getViewRight() const
{
return mCoord.right() - mMargin.right;
}
int _getViewTop() const
{
return mCoord.top + mMargin.top;
}
int _getViewBottom() const
{
return mCoord.bottom() - mMargin.bottom;
}
int _getViewWidth() const
{
return mCoord.width - mMargin.left - mMargin.right;
}
int _getViewHeight() const
{
return mCoord.height - mMargin.top - mMargin.bottom;
}
void _setCroppedParent(ICroppedRectangle* _parent)
{
mCroppedParent = _parent;
}
const IntRect& _getMargin() const
{
return mMargin;
}
int _getMarginLeft() const
{
return mMargin.left;
}
int _getMarginRight() const
{
return mMargin.right;
}
int _getMarginTop() const
{
return mMargin.top;
}
int _getMarginBottom() const
{
return mMargin.bottom;
}
protected:
bool _checkMargin()
{
bool margin = false;
//вылезли ли налево
if (getLeft() < mCroppedParent->mMargin.left)
{
mMargin.left = mCroppedParent->mMargin.left - getLeft();
margin = true;
}
else
{
mMargin.left = 0;
}
//вылезли ли направо
if (getRight() > mCroppedParent->getWidth() - mCroppedParent->mMargin.right)
{
mMargin.right = getRight() - (mCroppedParent->getWidth() - mCroppedParent->mMargin.right);
margin = true;
}
else
{
mMargin.right = 0;
}
//вылезли ли вверх
if (getTop() < mCroppedParent->mMargin.top)
{
mMargin.top = mCroppedParent->mMargin.top - getTop();
margin = true;
}
else
{
mMargin.top = 0;
}
//вылезли ли вниз
if (getBottom() > mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom)
{
mMargin.bottom = getBottom() - (mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom);
margin = true;
}
else
{
mMargin.bottom = 0;
}
return margin;
}
bool _checkOutside() const // проверка на полный выход за границу
{
return ( (getRight() < mCroppedParent->mMargin.left ) || // совсем уехали налево
(getLeft() > mCroppedParent->getWidth() - mCroppedParent->mMargin.right ) || // совсем уехали направо
(getBottom() < mCroppedParent->mMargin.top ) || // совсем уехали вверх
(getTop() > mCroppedParent->getHeight() - mCroppedParent->mMargin.bottom ) ); // совсем уехали вниз
}
protected:
IntRect mMargin; // перекрытие
IntCoord mCoord; // координаты
IntPoint mAbsolutePosition; // обсолютные координаты
bool mIsMargin;
ICroppedRectangle* mCroppedParent;
};
} // namespace MyGUI
#endif // MYGUI_I_CROPPED_RECTANGLE_H_
|