913 lines
20 KiB
Text
913 lines
20 KiB
Text
//DLU ist definiert als:
|
|
//DLUx := 4/CharBreite, also 4/BaseUnit.cx
|
|
//DLUy := 8/CharHöhe; also (/BaseUnit.cy
|
|
|
|
|
|
/*
|
|
|
|
bu/4 = pix/dlu==>
|
|
4/bu = dlu/pix
|
|
pix*4/bu =dlu
|
|
|
|
*/
|
|
|
|
#define TBU PixSize
|
|
struct ActBaseUnit
|
|
{static TBU& val(){static TBU x(0,0);
|
|
return x;
|
|
}
|
|
static void val(const PixSize& s){val().cx=s.cx;
|
|
val().cy=s.cy;
|
|
PixSize tst=val();
|
|
}
|
|
};
|
|
|
|
typedef struct tagDLURECT
|
|
{
|
|
LONG left;
|
|
LONG top;
|
|
LONG right;
|
|
LONG bottom;
|
|
} DLURECT, *PDLURECT, NEAR *NPDLURECT, FAR *LPDLURECT;
|
|
|
|
typedef const DLURECT FAR* LPCDLURECT;
|
|
|
|
typedef struct _DLURECTL /* rcl */
|
|
{
|
|
LONG left;
|
|
LONG top;
|
|
LONG right;
|
|
LONG bottom;
|
|
} DLURECTL, *PDLURECTL, *LPDLURECTL;
|
|
|
|
typedef const DLURECTL FAR* LPCDLURECTL;
|
|
|
|
typedef struct tagDLUPOINT
|
|
{
|
|
LONG x;
|
|
LONG y;
|
|
} DLUPOINT, *PDLUPOINT, NEAR *NPDLUPOINT, FAR *LPDLUPOINT;
|
|
|
|
typedef struct _DLUPOINTL /* ptl */
|
|
{
|
|
LONG x;
|
|
LONG y;
|
|
} DLUPOINTL, *PDLUPOINTL;
|
|
|
|
typedef struct tagDLUSIZE
|
|
{
|
|
LONG cx;
|
|
LONG cy;
|
|
} DLUSIZE, *PDLUSIZE, *LPDLUSIZE;
|
|
|
|
typedef DLUSIZE DLUSIZEL;
|
|
typedef DLUSIZE *PDLUSIZEL, *LPDLUSIZEL;
|
|
|
|
typedef struct tagDLUPOINTS
|
|
{
|
|
#ifndef _MAC
|
|
SHORT x;
|
|
SHORT y;
|
|
#else
|
|
SHORT y;
|
|
SHORT x;
|
|
#endif
|
|
} DLUPOINTS, *PDLUPOINTS, *LPDLUPOINTS;
|
|
|
|
class DLUSize;
|
|
class DLUPoint;
|
|
class DLURect;
|
|
|
|
struct xDlu
|
|
{LONG n;
|
|
operator xPix(){xPix erg;erg.n= MulDiv(n, ActBaseUnit().val().cx, 4);return erg;}
|
|
xPix pix(){return xPix(MulDiv(n, ActBaseUnit().val().cx, 4));}
|
|
xDlu& operator=(const xPix& x){n=MulDiv(x.n, 4,ActBaseUnit().val().cx);return *this;}
|
|
xDlu():n(0){}
|
|
explicit xDlu(LONG x):n(x){}
|
|
};
|
|
struct yDlu
|
|
{LONG n;
|
|
operator yPix(){yPix erg;erg.n= MulDiv(n, ActBaseUnit().val().cx, 8);return erg;}
|
|
yPix pix(){return yPix(MulDiv(n, ActBaseUnit().val().cx, 8));}
|
|
yDlu& operator=(const yPix& x){n=MulDiv(x.n, 8,ActBaseUnit().val().cx);return *this;}
|
|
yDlu():n(0){}
|
|
explicit yDlu(LONG x):n(x){}
|
|
};
|
|
class DLUSize : public DLUSIZE
|
|
{
|
|
public:typedef DLUSize Tp;
|
|
operator xDlu(){return xDlu(cx);}
|
|
xDlu dluX(){return xDlu(cx);}
|
|
|
|
operator yDlu(){return yDlu(cy);}
|
|
yDlu dluY(){return yDlu(cy);}
|
|
|
|
operator xPix(){return xDlu(cx);}
|
|
xPix pixX(){return xPix(pix().cx);}
|
|
|
|
operator yPix(){return yDlu(cy);}
|
|
yPix pixY(){return yPix(pix().cy);}
|
|
|
|
PixSize pix(){return *this;}
|
|
|
|
operator PixSize(){PixSize erg;erg.cx=MulDiv(cx, ActBaseUnit().val().cx, 4);
|
|
erg.cy=MulDiv(cy, ActBaseUnit().val().cy, 8);
|
|
return erg;
|
|
}
|
|
DLUSize& operator=(const PixSize& x){DLUSize erg;erg.cx=MulDiv(x.cx, 4,ActBaseUnit().val().cx);
|
|
erg.cy=MulDiv(x.cy, 8, ActBaseUnit().val().cy);
|
|
*this=erg;
|
|
return *this;
|
|
}
|
|
// Constructors
|
|
DLUSize& operator+=(const DLUSize& x){cx+=x.cx;
|
|
cy+=x.cy;
|
|
return *this;
|
|
}
|
|
DLUSize()
|
|
{
|
|
cx = 0;
|
|
cy = 0;
|
|
}
|
|
|
|
DLUSize(int initCX, int initCY)
|
|
{
|
|
cx = initCX;
|
|
cy = initCY;
|
|
}
|
|
|
|
DLUSize(DLUSIZE initSize)
|
|
{
|
|
*(DLUSIZE*)this = initSize;
|
|
}
|
|
|
|
DLUSize(DLUPOINT initPt)
|
|
{
|
|
*(DLUPOINT*)this = initPt;
|
|
}
|
|
|
|
DLUSize(DWORD dwSize)
|
|
{
|
|
cx = (short)LOWORD(dwSize);
|
|
cy = (short)HIWORD(dwSize);
|
|
}
|
|
|
|
// Operations
|
|
DLUSize& operator=(const DLURECT& r) {cx =r.right-r.left;return *this;}
|
|
DLUSize& operator=(LONG sz) {cx =sz;cy=sz ;return *this;}
|
|
|
|
BOOL operator ==(DLUSIZE size) const
|
|
{
|
|
return (cx == size.cx && cy == size.cy);
|
|
}
|
|
|
|
BOOL operator !=(DLUSIZE size) const
|
|
{
|
|
return (cx != size.cx || cy != size.cy);
|
|
}
|
|
|
|
void operator +=(DLUSIZE size)
|
|
{
|
|
cx += size.cx;
|
|
cy += size.cy;
|
|
}
|
|
|
|
void operator -=(DLUSIZE size)
|
|
{
|
|
cx -= size.cx;
|
|
cy -= size.cy;
|
|
}
|
|
|
|
void SetSize(int CX, int CY)
|
|
{
|
|
cx = CX;
|
|
cy = CY;
|
|
}
|
|
|
|
// Operators returning DLUSize values
|
|
DLUSize operator +(DLUSIZE size) const
|
|
{
|
|
return DLUSize(cx + size.cx, cy + size.cy);
|
|
}
|
|
|
|
DLUSize operator -(DLUSIZE size) const
|
|
{
|
|
return DLUSize(cx - size.cx, cy - size.cy);
|
|
}
|
|
|
|
DLUSize operator -() const
|
|
{
|
|
return DLUSize(-cx, -cy);
|
|
}
|
|
|
|
// Operators returning DLUPoint values
|
|
DLUPoint operator +(DLUPOINT point) const;
|
|
DLUPoint operator -(DLUPOINT point) const;
|
|
|
|
// Operators returning DLURect values
|
|
DLURect operator +(const DLURECT* lpRect) const;
|
|
DLURect operator -(const DLURECT* lpRect) const;
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// DLUPoint - Wrapper for Windows DLUPOINT structure.
|
|
|
|
class DLUPoint : public DLUPOINT
|
|
{
|
|
public:
|
|
PixPoint pix(){return *this;}
|
|
|
|
operator PixPoint(){PixPoint erg;erg.x=MulDiv(x, ActBaseUnit().val().cx, 4);
|
|
erg.y=MulDiv(y, ActBaseUnit().val().cy, 8);
|
|
return erg;
|
|
}
|
|
DLUPoint& operator=(const PixPoint& x){DLUPoint erg;erg.x=MulDiv(x.x, 4,ActBaseUnit().val().cx);
|
|
erg.y=MulDiv(x.y, 8, ActBaseUnit().val().cy);
|
|
*this=erg;
|
|
return *this;
|
|
}
|
|
// Constructors
|
|
DLUPoint& operator+=(const DLUSize& x){this->x+=x.cx;
|
|
this->y+=x.cy;
|
|
return *this;
|
|
}
|
|
// Constructors
|
|
DLUPoint(const DLUSize& a){x =a.cx;y=a.cy;}
|
|
|
|
DLUPoint()
|
|
{
|
|
x = 0;
|
|
y = 0;
|
|
}
|
|
|
|
DLUPoint(int initX, int initY)
|
|
{
|
|
x = initX;
|
|
y = initY;
|
|
}
|
|
|
|
DLUPoint(DLUPOINT initPt)
|
|
{
|
|
*(DLUPOINT*)this = initPt;
|
|
}
|
|
|
|
DLUPoint(DLUSIZE initSize)
|
|
{
|
|
*(DLUSIZE*)this = initSize;
|
|
}
|
|
|
|
DLUPoint(DWORD dwPoint)
|
|
{
|
|
x = (short)LOWORD(dwPoint);
|
|
y = (short)HIWORD(dwPoint);
|
|
}
|
|
|
|
// Operations
|
|
DLUPoint& operator=(const DLURECT& b) {x =b.left;y=b.top;return *this;}
|
|
|
|
void Offset(int xOffset, int yOffset)
|
|
{
|
|
x += xOffset;
|
|
y += yOffset;
|
|
}
|
|
|
|
void Offset(DLUPOINT point)
|
|
{
|
|
x += point.x;
|
|
y += point.y;
|
|
}
|
|
|
|
void Offset(DLUSIZE size)
|
|
{
|
|
x += size.cx;
|
|
y += size.cy;
|
|
}
|
|
|
|
BOOL operator ==(DLUPOINT point) const
|
|
{
|
|
return (x == point.x && y == point.y);
|
|
}
|
|
|
|
BOOL operator !=(DLUPOINT point) const
|
|
{
|
|
return (x != point.x || y != point.y);
|
|
}
|
|
|
|
void operator +=(DLUSIZE size)
|
|
{
|
|
x += size.cx;
|
|
y += size.cy;
|
|
}
|
|
|
|
void operator -=(DLUSIZE size)
|
|
{
|
|
x -= size.cx;
|
|
y -= size.cy;
|
|
}
|
|
|
|
void operator +=(DLUPOINT point)
|
|
{
|
|
x += point.x;
|
|
y += point.y;
|
|
}
|
|
|
|
void operator -=(DLUPOINT point)
|
|
{
|
|
x -= point.x;
|
|
y -= point.y;
|
|
}
|
|
|
|
void SetPoint(int X, int Y)
|
|
{
|
|
x = X;
|
|
y = Y;
|
|
}
|
|
|
|
// Operators returning DLUPoint values
|
|
DLUPoint operator +(DLUSIZE size) const
|
|
{
|
|
return DLUPoint(x + size.cx, y + size.cy);
|
|
}
|
|
|
|
DLUPoint operator -(DLUSIZE size) const
|
|
{
|
|
return DLUPoint(x - size.cx, y - size.cy);
|
|
}
|
|
|
|
DLUPoint operator -() const
|
|
{
|
|
return DLUPoint(-x, -y);
|
|
}
|
|
|
|
DLUPoint operator +(DLUPOINT point) const
|
|
{
|
|
return DLUPoint(x + point.x, y + point.y);
|
|
}
|
|
|
|
// Operators returning DLUSize values
|
|
DLUSize operator -(DLUPOINT point) const
|
|
{
|
|
return DLUSize(x - point.x, y - point.y);
|
|
}
|
|
|
|
// Operators returning DLURect values
|
|
DLURect operator +(const DLURECT* lpRect) const;
|
|
DLURect operator -(const DLURECT* lpRect) const;
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// DLURect - Wrapper for Windows DLURECT structure.
|
|
|
|
class DLURect : public DLURECT
|
|
{
|
|
public:
|
|
DLURect& adjust()const{const_cast<DLURect*>(this)->right =max(left,right);
|
|
const_cast<DLURect*>(this)->bottom=max(top ,bottom);
|
|
return *const_cast<DLURect*>(this);
|
|
}
|
|
PixRect pix(){adjust();return *this;}
|
|
|
|
operator PixRect(){adjust();
|
|
PixRect erg;erg.left=::MulDiv(left, ActBaseUnit().val().cx, 4);
|
|
erg.right=::MulDiv(right, ActBaseUnit().val().cx, 4);
|
|
erg.top=::MulDiv(top, ActBaseUnit().val().cy, 8);
|
|
erg.bottom=::MulDiv(bottom, ActBaseUnit().val().cy, 8);
|
|
return erg;
|
|
}
|
|
DLURect& operator=(const PixRect& x){DLURect erg;erg.left =::MulDiv(x.left, 4,ActBaseUnit().val().cx);
|
|
erg.right =::MulDiv(x.right, 4,ActBaseUnit().val().cx);
|
|
erg.top =::MulDiv(x.top, 8, ActBaseUnit().val().cy);
|
|
erg.bottom=::MulDiv(x.bottom, 8, ActBaseUnit().val().cy);
|
|
*this=erg;
|
|
return *this;
|
|
}
|
|
public:
|
|
// Constructors
|
|
DLUSize size(){adjust();
|
|
if(right < left) right=left;
|
|
if(bottom < top) bottom=top;
|
|
|
|
DLUSize s;
|
|
s.cx=right-left;
|
|
s.cy=bottom-top;
|
|
return s;
|
|
}
|
|
DLURect(const DLUSize& s){adjust();
|
|
*this =s;}
|
|
DLURect(const DLUPoint& x){*this =x;}
|
|
DLURect& sizeMax(const DLURect& plt ,const DLURect& prb)
|
|
{adjust();
|
|
plt.adjust();
|
|
prb.adjust();
|
|
DLUSize nsz=DLURect(plt.left,plt.top,prb.right,prb.bottom).size();
|
|
DLUSize sz =size();
|
|
DLUSize mx(max(nsz.cx,sz.cx)
|
|
,max(nsz.cy,sz.cy)
|
|
);
|
|
*this =mx;
|
|
return *this;
|
|
}
|
|
|
|
DLURect()
|
|
{
|
|
left = 0;
|
|
top = 0;
|
|
right = 0;
|
|
bottom = 0;
|
|
}
|
|
|
|
DLURect(int l, int t, int r, int b)
|
|
{
|
|
left = l;
|
|
top = t;
|
|
right = r;
|
|
bottom = b;
|
|
}
|
|
|
|
DLURect(DLURect& srDLURect)
|
|
{
|
|
srDLURect.adjust();
|
|
*this =srDLURect;//::CopyRect(this, (LPDLURECT)&srDLURect);
|
|
}
|
|
|
|
DLURect(const DLURECT& srDLURect)
|
|
{
|
|
*this =srDLURect;//::CopyRect(this, (LPDLURECT)&srDLURect);
|
|
adjust();
|
|
}
|
|
|
|
DLURect(LPCDLURECT lpSrDLURect)
|
|
{
|
|
*this=lpSrDLURect;//::CopyRect(this, lpSrDLURect);
|
|
adjust();
|
|
}
|
|
|
|
DLURect(DLUPOINT point, DLUSIZE size)
|
|
{
|
|
right = (left = point.x) + size.cx;
|
|
bottom = (top = point.y) + size.cy;
|
|
}
|
|
|
|
DLURect(DLUPOINT topLeft, DLUPOINT bottomRight)
|
|
{
|
|
left = topLeft.x;
|
|
top = topLeft.y;
|
|
right = bottomRight.x;
|
|
bottom = bottomRight.y;
|
|
}
|
|
|
|
// Attributes (in addition to DLURECT members)
|
|
int Width() const
|
|
{ adjust();
|
|
return right - left;
|
|
}
|
|
|
|
int Height() const
|
|
{
|
|
adjust();
|
|
return bottom - top;
|
|
}
|
|
|
|
DLUSize Size() const
|
|
{
|
|
adjust();
|
|
return DLUSize(right - left, bottom - top);
|
|
}
|
|
|
|
DLUPoint& TopLeft()
|
|
{
|
|
return *((DLUPoint*)this);
|
|
}
|
|
DLUPoint& point()
|
|
{
|
|
return *((DLUPoint*)this);
|
|
}
|
|
|
|
DLUPoint& BottomRight()
|
|
{
|
|
return *((DLUPoint*)this + 1);
|
|
}
|
|
|
|
const DLUPoint& TopLeft() const
|
|
{
|
|
return *((DLUPoint*)this);
|
|
}
|
|
|
|
const DLUPoint& BottomRight() const
|
|
{
|
|
adjust();
|
|
return *((DLUPoint*)this + 1);
|
|
}
|
|
|
|
DLUPoint CenterPoint() const
|
|
{
|
|
adjust();
|
|
return DLUPoint((left + right) / 2, (top + bottom) / 2);
|
|
}
|
|
|
|
// convert between DLURect and LPRECT/LPCRECT (no need for &)
|
|
operator LPDLURECT()
|
|
{
|
|
adjust();
|
|
return this;
|
|
}
|
|
|
|
operator LPCDLURECT() const
|
|
{
|
|
adjust();
|
|
return this;
|
|
}
|
|
|
|
BOOL IsRectEmpty() const
|
|
{
|
|
adjust();
|
|
return ::IsRectEmpty((RECT*)this);
|
|
}
|
|
|
|
BOOL IsRectNull() const
|
|
{
|
|
return (left == 0 && right == 0 && top == 0 && bottom == 0);
|
|
}
|
|
|
|
BOOL PtInRect(DLUPOINT point) const
|
|
{
|
|
adjust();
|
|
return ::PtInRect((RECT*)this, *((POINT*)&point));
|
|
}
|
|
|
|
// Operations
|
|
void SetRect(int x1, int y1, int x2, int y2)
|
|
{
|
|
::SetRect((RECT*)this, x1, y1, x2, y2);
|
|
}
|
|
|
|
void SetRect(DLUPOINT topLeft, DLUPOINT bottomRight)
|
|
{
|
|
::SetRect((RECT*)this, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
|
|
}
|
|
|
|
void SetRectEmpty()
|
|
{
|
|
::SetRectEmpty((RECT*)this);
|
|
}
|
|
|
|
void CopyRect(LPCRECT lpSrDLURect)
|
|
{
|
|
adjust();
|
|
::CopyRect((RECT*)this, (RECT*)lpSrDLURect);
|
|
}
|
|
|
|
BOOL EqualRect(LPCRECT lpRect) const
|
|
{
|
|
adjust();
|
|
return ::EqualRect((RECT*)this, (RECT*)lpRect);
|
|
}
|
|
|
|
void InflateRect(int x, int y)
|
|
{
|
|
adjust();
|
|
::InflateRect((RECT*)this, x, y);
|
|
}
|
|
|
|
void InflateRect(DLUSIZE size)
|
|
{
|
|
adjust();
|
|
::InflateRect((RECT*)this, size.cx, size.cy);
|
|
}
|
|
|
|
void InflatDLURect(LPCRECT lpRect)
|
|
{
|
|
adjust();
|
|
left -= lpRect->left;
|
|
top -= lpRect->top;
|
|
right += lpRect->right;
|
|
bottom += lpRect->bottom;
|
|
}
|
|
|
|
void InflatDLURect(int l, int t, int r, int b)
|
|
{
|
|
adjust();
|
|
left -= l;
|
|
top -= t;
|
|
right += r;
|
|
bottom += b;
|
|
}
|
|
|
|
void DeflateRect(int x, int y)
|
|
{
|
|
adjust();
|
|
::InflateRect((RECT*)this, -x, -y);
|
|
}
|
|
|
|
void Deflateect(DLUSIZE size)
|
|
{
|
|
adjust();
|
|
::InflateRect((RECT*)this, -size.cx, -size.cy);
|
|
}
|
|
|
|
void DeflateRect(LPCRECT lpRect)
|
|
{
|
|
adjust();
|
|
left += lpRect->left;
|
|
top += lpRect->top;
|
|
right -= lpRect->right;
|
|
bottom -= lpRect->bottom;
|
|
}
|
|
|
|
void DeflateRect(int l, int t, int r, int b)
|
|
{
|
|
adjust();
|
|
left += l;
|
|
top += t;
|
|
right -= r;
|
|
bottom -= b;
|
|
}
|
|
|
|
void OffsetRect(int x, int y)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, x, y);
|
|
}
|
|
void OffsetRect(DLUSIZE size)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, size.cx, size.cy);
|
|
}
|
|
|
|
void OffsetRect(DLUPOINT point)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, point.x, point.y);
|
|
}
|
|
|
|
void NormalizDLURect()
|
|
{
|
|
adjust();
|
|
int nTemp;
|
|
if (left > right)
|
|
{
|
|
nTemp = left;
|
|
left = right;
|
|
right = nTemp;
|
|
}
|
|
if (top > bottom)
|
|
{
|
|
nTemp = top;
|
|
top = bottom;
|
|
bottom = nTemp;
|
|
}
|
|
}
|
|
|
|
// absolute position of rectangle
|
|
void MoveToY(int y)
|
|
{
|
|
adjust();
|
|
bottom = Height() + y;
|
|
top = y;
|
|
}
|
|
|
|
void MoveToX(int x)
|
|
{
|
|
adjust();
|
|
right = Width() + x;
|
|
left = x;
|
|
}
|
|
|
|
void MoveToXY(int x, int y)
|
|
{
|
|
adjust();
|
|
MoveToX(x);
|
|
MoveToY(y);
|
|
}
|
|
|
|
void MoveToXY(DLUPOINT pt)
|
|
{
|
|
adjust();
|
|
MoveToX(pt.x);
|
|
MoveToY(pt.y);
|
|
}
|
|
|
|
// operations that fill '*this' with result
|
|
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2)
|
|
{
|
|
adjust();
|
|
return ::IntersectRect((RECT*)this, (RECT*)lpRect1, (RECT*)lpRect2);
|
|
}
|
|
|
|
BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2)
|
|
{
|
|
adjust();
|
|
return ::UnionRect((RECT*)this, (RECT*)lpRect1, (RECT*)lpRect2);
|
|
}
|
|
|
|
BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2)
|
|
{
|
|
adjust();
|
|
return ::SubtractRect((RECT*)this, (RECT*)lpRectSrc1, (RECT*)lpRectSrc2);
|
|
}
|
|
|
|
// Additional Operations
|
|
DLURect& operator=(const DLUPOINT& p){left =p.x;top=p.y;return *this;}
|
|
DLURect& operator=(const DLUSIZE& s){right =left+s.cx; bottom=top+s.cy;return *this;}
|
|
|
|
void operator =(const DLURECT& srDLURect)
|
|
{
|
|
::CopyRect((RECT*)this, (RECT*)&srDLURect);
|
|
}
|
|
|
|
BOOL operator ==(const DLURECT& rect) const
|
|
{
|
|
adjust();
|
|
return ::EqualRect((RECT*)this, (RECT*)&rect);
|
|
}
|
|
|
|
BOOL operator !=(const DLURECT& rect) const
|
|
{
|
|
adjust();
|
|
return !::EqualRect((RECT*)this, (RECT*)&rect);
|
|
}
|
|
|
|
void operator +=(DLUPOINT point)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, point.x, point.y);
|
|
}
|
|
|
|
void operator +=(DLUSIZE size)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, size.cx, size.cy);
|
|
}
|
|
|
|
void operator +=(LPCRECT lpRect)
|
|
{
|
|
adjust();
|
|
InflatDLURect(lpRect);
|
|
}
|
|
|
|
void operator -=(DLUPOINT point)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, -point.x, -point.y);
|
|
}
|
|
|
|
void operator -=(DLUSIZE size)
|
|
{
|
|
adjust();
|
|
::OffsetRect((RECT*)this, -size.cx, -size.cy);
|
|
}
|
|
|
|
void operator -=(LPCRECT lpRect)
|
|
{
|
|
adjust();
|
|
DeflateRect(lpRect);
|
|
}
|
|
|
|
void operator &=(const DLURECT& rect)
|
|
{
|
|
adjust();
|
|
::IntersectRect((RECT*)this, (RECT*)this, (RECT*)&rect);
|
|
}
|
|
|
|
void operator |=(const DLURECT& rect)
|
|
{
|
|
adjust();
|
|
::UnionRect((RECT*)this, (RECT*)this, (RECT*)&rect);
|
|
}
|
|
|
|
// Operators returning DLURect values
|
|
DLURect operator +(DLUPOINT pt) const
|
|
{
|
|
adjust();
|
|
DLURect rect(*this);
|
|
::OffsetRect((RECT*)&rect, pt.x, pt.y);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator -(DLUPOINT pt) const
|
|
{
|
|
adjust();
|
|
DLURect rect(*this);
|
|
::OffsetRect((RECT*)&rect, -pt.x, -pt.y);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator +(LPCRECT lpRect) const
|
|
{
|
|
adjust();
|
|
DLURect rect(this);
|
|
rect.InflatDLURect(lpRect);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator +(DLUSIZE size) const
|
|
{
|
|
adjust();
|
|
DLURect rect(*this);
|
|
::OffsetRect((RECT*)&rect, size.cx, size.cy);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator -(DLUSIZE size) const
|
|
{
|
|
adjust();
|
|
DLURect rect(*this);
|
|
::OffsetRect((RECT*)&rect, -size.cx, -size.cy);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator -(LPCRECT lpRect) const
|
|
{
|
|
adjust();
|
|
DLURect rect(this);
|
|
rect.DeflateRect(lpRect);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator &(const DLURECT& rect2) const
|
|
{
|
|
adjust();
|
|
DLURect rect;
|
|
::IntersectRect((RECT*)&rect, (RECT*)this, (RECT*)&rect2);
|
|
return rect;
|
|
}
|
|
|
|
DLURect operator |(const DLURECT& rect2) const
|
|
{
|
|
adjust();
|
|
DLURect rect;
|
|
::UnionRect((RECT*)&rect, (RECT*)this, (RECT*)&rect2);
|
|
return rect;
|
|
}
|
|
|
|
DLURect MulDiv(int nMultiplier, int nDivisor) const
|
|
{
|
|
adjust();
|
|
return DLURect(
|
|
::MulDiv(left, nMultiplier, nDivisor),
|
|
::MulDiv(top, nMultiplier, nDivisor),
|
|
::MulDiv(right, nMultiplier, nDivisor),
|
|
::MulDiv(bottom, nMultiplier, nDivisor));
|
|
}
|
|
};
|
|
|
|
|
|
// DLUSize implementation
|
|
|
|
inline DLUPoint DLUSize::operator +(DLUPOINT point) const
|
|
{ return DLUPoint(cx + point.x, cy + point.y); }
|
|
|
|
inline DLUPoint DLUSize::operator -(DLUPOINT point) const
|
|
{ return DLUPoint(cx - point.x, cy - point.y); }
|
|
|
|
inline DLURect DLUSize::operator +(const DLURECT* lpRect) const
|
|
{ return DLURect(lpRect) + *this; }
|
|
|
|
inline DLURect DLUSize::operator -(const DLURECT* lpRect) const
|
|
{ return DLURect(lpRect) - *this; }
|
|
|
|
|
|
// DLUPoint implementation
|
|
|
|
inline DLURect DLUPoint::operator +(const DLURECT* lpRect) const
|
|
{ return DLURect(lpRect) + *this; }
|
|
|
|
inline DLURect DLUPoint::operator -(const DLURECT* lpRect) const
|
|
{ return DLURect(lpRect) - *this; }
|
|
|
|
|
|
|
|
#if !defined(_WTL_NO_SIZE_SCALAR) && (!defined(_WTL_NO_WTYPES) || defined(__ATLTYPES_H__))
|
|
#ifndef __ATLMISC_H__
|
|
|
|
template <class Num>
|
|
inline DLUSize operator *(DLUSIZE s, Num n)
|
|
{
|
|
return DLUSize((int)(s.cx * n), (int)(s.cy * n));
|
|
};
|
|
|
|
template <class Num>
|
|
inline void operator *=(DLUSIZE & s, Num n)
|
|
{
|
|
s = s * n;
|
|
};
|
|
|
|
template <class Num>
|
|
inline DLUSize operator /(DLUSIZE s, Num n)
|
|
{
|
|
return DLUSize((int)(s.cx / n), (int)(s.cy / n));
|
|
};
|
|
|
|
template <class Num>
|
|
inline void operator /=(DLUSIZE & s, Num n)
|
|
{
|
|
s = s / n;
|
|
};
|
|
#endif
|
|
#endif
|
|
|
|
DLUSize size(const DLURect& plt ,const DLURect& prb) {return DLUSize()=DLURect(plt.left,plt.top,prb.right,prb.bottom);}
|
|
|