40 if (valid && r.valid && (GetLeft() == r.GetLeft()) && (GetRight() == r.GetRight()) &&
41 (GetTop() == r.GetTop()) && (GetBottom() == r.GetBottom()))
43 else if (!valid && !r.valid)
58 if (!valid || !r.valid)
60 else if ((GetLeft() != r.GetLeft()) || (GetRight() != r.GetRight()) ||
61 (GetTop() != r.GetTop()) || (GetBottom() != r.GetBottom()))
78 int left, right, top, bottom;
83 if ((left <= right) && (top <= bottom))
85 return Rect(left, top, right, bottom);
126 if (valid && r.valid)
128 int left, right, top, bottom;
133 return Rect(left, top, right, bottom);
136 return Rect(bx, ex, by, ey);
138 return Rect(r.bx, r.ex, r.by, r.ey);
149 if (valid && r.valid)
151 int left, right, top, bottom;
156 if (left > right || top > bottom)
180 if (valid && r.valid)
182 int left, right, top, bottom;
192 else if (!valid && r.valid)
226 return String(
_(
"The rectangle isn't initialized."));
241 direction = sort_direction;
246 _(
"Wrong direction."));
323 direction = sort_direction;
328 _(
"Wrong direction."));
475 if (!valid && !other.valid)
477 if ((valid && other.valid) && (pos == other.pos) &&
478 (minx == other.minx) && (maxx == other.maxx) && (maxy == other.maxy))
555 _(
"Wrong XML element."));
583 el.SetAttribute(
"ex", ex);
584 el.SetAttribute(
"by", by);
585 el.SetAttribute(
"ey", ey);
586 el.SetAttribute(
"v", valid ? 1 : 0);
621 framel = rectl + border;
622 framet = rectl + border;
623 framer = rectr - border;
624 frameb = rectb - border;
625 if (((framel == framer) || (framet == frameb)) && (r.
GetWidth() != r.
GetHeight()))
628 if (framel == framer)
640 limit = pos.
Y - r.
GetTop() - 1;
649 if (!valid && !other.valid)
651 if ((valid && other.valid) && (pos == other.pos) &&
652 (rectl == other.rectl) && (rectt == other.rectt) &&
653 (rectr == other.rectr) && (rectb == other.rectb))
676 pos.X = rectl + offset;
678 pos.Y = rectt + offset;
683 pos.X = rectr - offset;
685 pos.Y = rectb - offset;
692 if (pos.X + 1 > framer)
701 if (pos.Y + 1 > frameb)
710 if (pos.X - 1 < framel)
719 if (pos.Y - 1 < framet)
740 void Rect::spiral_iterator::update()
751 framel = rectl + border;
752 framet = rectt + border;
753 framer = rectr - border;
754 frameb = rectb - border;
virtual const iterator & operator++() noexcept
bool operator()(const Rect &r1, const Rect &r2) const
Comparison function.
OrthogonalSorter(Direction sort_direction)
Constructor.
bool operator==(const spiral_iterator &other) const
bool operator()(const Rect &r1, const Rect &r2) const
Comparison function.
Orientation
An enumeration of orientations.
bool operator()(const Rect &r1, const Rect &r2) const
Comparison function.
int Overlap(const Rect &r, Orientation orientation) const
Compute overlap in a given orientation.
StringUTF8 GetName() const
Gets the label of the element.
const T & Max(const T &a, const T &b)
Returns the max of two values.
int GetBottom() const
Returns the bottommost coordinate.
Unintialized object error.
bool operator()(const Rect &r1, const Rect &r2) const
Comparison function.
Direction
An enumeration of directions.
int SetHeight(int hei)
Changes the height of the rectangle.
Rect operator|(const Rect &r) const
Computes the union of two rectangles.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
int GetTop() const
Returns the topmost coordinate.
int GetLeft() const
Returns the leftmost coordinate.
A UTF32 character string class.
void Deserialize(xml::Element &el)
Initializes the object from an XML element. Unsafe.
int SetBottom(int endY) noexcept
Changes the bottommost coordinate.
int SetWidth(int wid)
Changes the width of the rectangle.
bool Contains(int x, int y) const noexcept
Checks if the rectangle contains a point.
const Rect & operator*=(double s)
Scales the rectangle.
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
xml::Element Serialize(xml::Element &parent) const
Dumps the object to an XML element. Unsafe.
Sorter(Direction sort_direction)
Constructor.
void SetAttribute(const StringUTF8 &name, const StringUTF8 &value)
Sets the value of an attribute.
void operator&=(const Rect &r)
Keeps only the intersecting part with another rectangle.
const spiral_iterator & operator++()
T GetAttribute(const StringUTF8 &name, bool silent=true) const
Gets an attribute.
void Translate(int x, int y)
Translates the rectangle.
int GetHeight() const
Returns the height of the rectangle.
Rect operator&(const Rect &r) const
Computes the intersection of two rectangles.
const T & Min(const T &a, const T &b)
Returns the min of two values.
Rect() noexcept
Dummy constructor. DO NOT USE.
bool operator==(const iterator &other) const noexcept
int SetRight(int endX) noexcept
Changes the rightmost coordinate.
int SetTop(int begY) noexcept
Changes the topmost coordinate.
int GetWidth() const
Returns the width of the rectangle.
int GetCenterX() const
Returns the horizontal center coordinate.
Rect operator*(double s) const
Creates a scaled rectangle.
void operator|=(const Rect &r)
Merges with another rectangle.
String ToString() const
Dumps to a string.
bool operator==(const Rect &r) const noexcept
Checks if two rectangles are identical.
A character string class.
bool operator!=(const Rect &r) const noexcept
Checks if two rectangles are different.
int GetRight() const
Returns the rightmost coordinate.
int GetCenterY() const
Returns the vertical center coordinate.
Spiral iterator for a Rect.
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
int SetLeft(int begX) noexcept
Changes the leftmost coordinate.
An item was not found in a container.