Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624/* * ReactOS ATL * * Copyright 2016 Mark Jansen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#pragma once
class CSize;class CRect;
class CPoint : public tagPOINT{public:
CPoint() noexcept { x = y = 0; }
CPoint(int initX, int initY) noexcept { x = initX; y = initY; }
CPoint(POINT initPt) noexcept { *((POINT*)this) = initPt; }
CPoint(SIZE initSize) noexcept { *((SIZE*)this) = initSize; }
CPoint(LPARAM dwPoint) noexcept { x = LOWORD(dwPoint); y = HIWORD(dwPoint); }
void Offset(int xOffset, int yOffset) noexcept { x += xOffset; y += yOffset; }
void Offset(POINT point) noexcept { Offset(point.x, point.y); }
void Offset(SIZE size) noexcept { Offset(size.cx, size.cy); }
BOOL operator==(POINT point) const noexcept { return (x == point.x && y == point.y); }
BOOL operator!=(POINT point) const noexcept { return !(*this == point); }
void operator+=(SIZE size) noexcept { Offset(size); }
void operator+=(POINT point) noexcept { Offset(point); }
void operator-=(SIZE size) noexcept { Offset(-size.cx, -size.cy); }
void operator-=(POINT point) noexcept { Offset(-point.x, -point.y); }
CPoint operator+(SIZE size) const noexcept { return CPoint(x + size.cx, y + size.cy); }
CPoint operator+(POINT point) const noexcept { return CPoint(x + point.x, y + point.y); }
CRect operator+(const RECT* lpRect) const noexcept;
CSize operator-(POINT point) const noexcept;
CPoint operator-(SIZE size) const noexcept { return CPoint(x - size.cx, y - size.cy); }
CRect operator-(const RECT* lpRect) const noexcept;
CPoint operator-() const noexcept { return CPoint(-x, -y); }};
class CSize : public tagSIZE{public: CSize() noexcept { cx = cy = 0; }
CSize(int initCX, int initCY) noexcept { cx = initCX; cy = initCY; }
CSize(SIZE initSize) noexcept { *((SIZE*)this) = initSize; }
CSize(POINT initPt) noexcept { *((POINT*)this) = initPt; }
CSize(DWORD dwSize) noexcept { cx = LOWORD(dwSize); cy = HIWORD(dwSize); }
BOOL operator==(SIZE size) const noexcept { return (size.cx == cx && size.cy == cy); }
BOOL operator!=(SIZE size) const noexcept { return !(*this == size); }
void operator+=(SIZE size) noexcept { cx += size.cx; cy += size.cy; }
void operator-=(SIZE size) noexcept { cx -= size.cx; cy -= size.cy; }
CSize operator+(SIZE size) const noexcept { return CSize(cx + size.cx, cy + size.cy); }
CPoint operator+(POINT point) const noexcept { return CPoint(cx + point.x, cy + point.y); }
CRect operator+(const RECT* lpRect) const noexcept;
CSize operator-(SIZE size) const noexcept { return CSize(cx - size.cx, cy - size.cy); }
CPoint operator-(POINT point) const noexcept { return CPoint(cx - point.x, cy - point.y); }
CRect operator-(const RECT* lpRect) const noexcept;
CSize operator-() const noexcept { return CSize(-cx, -cy); }};
inline CSize CPoint::operator-(POINT point) const noexcept{ return CSize(x - point.x, y - point.y);}
class CRect : public tagRECT{public: CRect() noexcept { left = top = right = bottom = 0; }
CRect(int l, int t, int r, int b) noexcept { left = l; top = t; right = r; bottom = b; }
CRect(const RECT& srcRect) noexcept { left = srcRect.left; top = srcRect.top; right = srcRect.right; bottom = srcRect.bottom; }
CRect(LPCRECT lpSrcRect) noexcept { left = lpSrcRect->left; top = lpSrcRect->top; right = lpSrcRect->right; bottom = lpSrcRect->bottom; }
CRect(POINT point, SIZE size) noexcept { left = point.x; top = point.y; right = point.x + size.cx; bottom = point.y + size.cy; }
CRect(POINT topLeft, POINT bottomRight) noexcept { left = topLeft.x; top = topLeft.y; right = bottomRight.x; bottom = bottomRight.y; }
CPoint& BottomRight() noexcept { return ((CPoint*)this)[1]; }
const CPoint& BottomRight() const noexcept { return ((const CPoint*)this)[1]; }
CPoint CenterPoint() const noexcept { return CPoint(left + (Width() >> 1), top + (Height() >> 1)); }
void CopyRect(LPCRECT lpSrcRect) noexcept { ::CopyRect(this, lpSrcRect); }
void DeflateRect(int x, int y) noexcept { ::InflateRect(this, -x, -y); }
void DeflateRect(SIZE size) noexcept { ::InflateRect(this, -size.cx, -size.cy); }
void DeflateRect(LPCRECT lpRect) noexcept { DeflateRect(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); }
void DeflateRect(int l, int t, int r, int b) noexcept { left += l; top += t; right -= r; bottom -= b; }
BOOL EqualRect(LPCRECT lpRect) const noexcept { return ::EqualRect(this, lpRect); }
int Height() const noexcept { return bottom - top; }
void InflateRect(int x, int y) noexcept { ::InflateRect(this, x, y); }
void InflateRect(SIZE size) noexcept { ::InflateRect(this, size.cx, size.cy); }
void InflateRect(LPCRECT lpRect) noexcept { InflateRect(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); }
void InflateRect(int l, int t, int r, int b) noexcept { left -= l; top -= t; right += r; bottom += b; }
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept { return ::IntersectRect(this, lpRect1, lpRect2); }
BOOL IsRectEmpty() const noexcept { return ::IsRectEmpty(this); }
BOOL IsRectNull() const noexcept { return (left == 0 && right == 0 && top == 0 && bottom == 0); }
void MoveToX(int x) noexcept { int dx = x - left; left = x; right += dx; }
void MoveToY(int y) noexcept { int dy = y - top; top = y; bottom += dy; }
void MoveToXY(int x, int y) noexcept { MoveToX(x); MoveToY(y); }
void MoveToXY(POINT point) noexcept { MoveToXY(point.x, point.y); }
void NormalizeRect() noexcept { if (left > right) { LONG tmp = left; left = right; right = tmp; } if (top > bottom) { LONG tmp = top; top = bottom; bottom = tmp; } }
void OffsetRect(int x, int y) noexcept { ::OffsetRect(this, x, y); }
void OffsetRect(POINT point) noexcept { ::OffsetRect(this, point.x, point.y); }
void OffsetRect(SIZE size) noexcept { ::OffsetRect(this, size.cx, size.cy); }
BOOL PtInRect(POINT point) const noexcept { return ::PtInRect(this, point); }
void SetRect(int x1, int y1, int x2, int y2) noexcept { left = x1; top = y1; right = x2; bottom = y2; }
void SetRectEmpty() noexcept { ZeroMemory(this, sizeof(*this)); }
CSize Size() const noexcept { return CSize(Width(), Height()); }
BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2) noexcept { return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); }
CPoint& TopLeft() noexcept { return ((CPoint*)this)[0]; }
const CPoint& TopLeft() const noexcept { return ((const CPoint*)this)[0]; }
BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept { return ::UnionRect(this, lpRect1, lpRect2); }
int Width() const noexcept { return right - left; }
BOOL operator==(const RECT& rect) const noexcept { return (left == rect.left && top == rect.top && right == rect.right && bottom == rect.bottom); }
BOOL operator!=(const RECT& rect) const noexcept { return !(*this == rect); }
void operator=(const RECT& srcRect) noexcept { left = srcRect.left; top = srcRect.top; right = srcRect.right; bottom = srcRect.bottom; }
void operator+=(POINT point) noexcept { OffsetRect(point); }
void operator+=(SIZE size) noexcept { OffsetRect(size); }
void operator+=(LPCRECT lpRect) noexcept { InflateRect(lpRect); }
void operator-=(POINT point) noexcept { OffsetRect(-point.x, -point.y); }
void operator-=(SIZE size) noexcept { OffsetRect(-size.cx, -size.cy); }
void operator-=(LPCRECT lpRect) noexcept { DeflateRect(lpRect); }
CRect operator+(POINT point) const noexcept { CRect r(this); r.OffsetRect(point); return r; }
CRect operator+(LPCRECT lpRect) const noexcept { CRect r(this); r.InflateRect(lpRect); return r; }
CRect operator+(SIZE size) const noexcept { CRect r(this); r.OffsetRect(size); return r; }
CRect operator-(POINT point) const noexcept { CRect r(this); r.OffsetRect(-point.x, -point.y); return r; }
CRect operator-(SIZE size) const noexcept { CRect r(this); r.OffsetRect(-size.cx, -size.cy); return r; }
CRect operator-(LPCRECT lpRect) const noexcept { CRect r(this); r.DeflateRect(lpRect); return r; }
void operator&=(const RECT& rect) noexcept { IntersectRect(this, &rect); }
CRect operator&(const RECT& rect2) const noexcept { CRect r; r.IntersectRect(this, &rect2); return r; }
void operator|=(const RECT& rect) noexcept { UnionRect(this, &rect); }
CRect operator|(const RECT& rect2) const noexcept { CRect r; r.UnionRect(this, &rect2); return r; }
operator LPRECT() noexcept { return this; }
operator LPCRECT() const noexcept { return this; }};
inline CRect CPoint::operator+(const RECT* lpRect) const noexcept{ CRect r(lpRect); r += *this; return r;}
inline CRect CPoint::operator-(const RECT* lpRect) const noexcept{ CRect r(lpRect); r -= *this; return r;}
inline CRect CSize::operator+(const RECT* lpRect) const noexcept{ CRect r(lpRect); r += *this; return r;}
inline CRect CSize::operator-(const RECT* lpRect) const noexcept{ CRect r(lpRect); r -= *this; return r;}