📄 gdiplustypes.h
字号:
REAL GetLeft() const
{
return X;
}
REAL GetTop() const
{
return Y;
}
REAL GetRight() const
{
return X+Width;
}
REAL GetBottom() const
{
return Y+Height;
}
// Determine if the rectangle is empty
BOOL IsEmptyArea() const
{
return (Width <= REAL_EPSILON) || (Height <= REAL_EPSILON);
}
BOOL Equals(IN const RectF & rect) const
{
return X == rect.X &&
Y == rect.Y &&
Width == rect.Width &&
Height == rect.Height;
}
BOOL Contains(IN REAL x,
IN REAL y) const
{
return x >= X && x < X+Width &&
y >= Y && y < Y+Height;
}
BOOL Contains(IN const PointF& pt) const
{
return Contains(pt.X, pt.Y);
}
BOOL Contains(IN const RectF& rect) const
{
return (X <= rect.X) && (rect.GetRight() <= GetRight()) &&
(Y <= rect.Y) && (rect.GetBottom() <= GetBottom());
}
VOID Inflate(IN REAL dx,
IN REAL dy)
{
X -= dx;
Y -= dy;
Width += 2*dx;
Height += 2*dy;
}
VOID Inflate(IN const PointF& point)
{
Inflate(point.X, point.Y);
}
// Intersect the current rect with the specified object
BOOL Intersect(IN const RectF& rect)
{
return Intersect(*this, *this, rect);
}
// Intersect rect a and b and save the result into c
// Notice that c may be the same object as a or b.
static BOOL Intersect(OUT RectF& c,
IN const RectF& a,
IN const RectF& b)
{
REAL right = min(a.GetRight(), b.GetRight());
REAL bottom = min(a.GetBottom(), b.GetBottom());
REAL left = max(a.GetLeft(), b.GetLeft());
REAL top = max(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
// Determine if the specified rect intersects with the
// current rect object.
BOOL IntersectsWith(IN const RectF& rect) const
{
return (GetLeft() < rect.GetRight() &&
GetTop() < rect.GetTop() &&
GetRight() > rect.GetLeft() &&
GetBottom() > rect.GetTop());
}
static BOOL Union(OUT RectF& c,
IN const RectF& a,
IN const RectF& b)
{
REAL right = max(a.GetRight(), b.GetRight());
REAL bottom = max(a.GetBottom(), b.GetBottom());
REAL left = min(a.GetLeft(), b.GetLeft());
REAL top = min(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
VOID Offset(IN const PointF& point)
{
Offset(point.X, point.Y);
}
VOID Offset(IN REAL dx,
IN REAL dy)
{
X += dx;
Y += dy;
}
public:
REAL X;
REAL Y;
REAL Width;
REAL Height;
};
//--------------------------------------------------------------------------
// Represents a rectangle in a 2D coordinate system
// (integer coordinates)
//--------------------------------------------------------------------------
class Rect
{
public:
// Default constructor
Rect()
{
X = Y = Width = Height = 0;
}
Rect(IN INT x,
IN INT y,
IN INT width,
IN INT height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
Rect(IN const Point& location,
IN const Size& size)
{
X = location.X;
Y = location.Y;
Width = size.Width;
Height = size.Height;
}
Rect* Clone() const
{
return new Rect(X, Y, Width, Height);
}
VOID GetLocation(OUT Point* point) const
{
point->X = X;
point->Y = Y;
}
VOID GetSize(OUT Size* size) const
{
size->Width = Width;
size->Height = Height;
}
VOID GetBounds(OUT Rect* rect) const
{
rect->X = X;
rect->Y = Y;
rect->Width = Width;
rect->Height = Height;
}
// Return the left, top, right, and bottom
// coordinates of the rectangle
INT GetLeft() const
{
return X;
}
INT GetTop() const
{
return Y;
}
INT GetRight() const
{
return X+Width;
}
INT GetBottom() const
{
return Y+Height;
}
// Determine if the rectangle is empty
BOOL IsEmptyArea() const
{
return (Width <= 0) || (Height <= 0);
}
BOOL Equals(IN const Rect & rect) const
{
return X == rect.X &&
Y == rect.Y &&
Width == rect.Width &&
Height == rect.Height;
}
BOOL Contains(IN INT x,
IN INT y) const
{
return x >= X && x < X+Width &&
y >= Y && y < Y+Height;
}
BOOL Contains(IN const Point& pt) const
{
return Contains(pt.X, pt.Y);
}
BOOL Contains(IN Rect& rect) const
{
return (X <= rect.X) && (rect.GetRight() <= GetRight()) &&
(Y <= rect.Y) && (rect.GetBottom() <= GetBottom());
}
VOID Inflate(IN INT dx,
IN INT dy)
{
X -= dx;
Y -= dy;
Width += 2*dx;
Height += 2*dy;
}
VOID Inflate(IN const Point& point)
{
Inflate(point.X, point.Y);
}
// Intersect the current rect with the specified object
BOOL Intersect(IN const Rect& rect)
{
return Intersect(*this, *this, rect);
}
// Intersect rect a and b and save the result into c
// Notice that c may be the same object as a or b.
static BOOL Intersect(OUT Rect& c,
IN const Rect& a,
IN const Rect& b)
{
INT right = min(a.GetRight(), b.GetRight());
INT bottom = min(a.GetBottom(), b.GetBottom());
INT left = max(a.GetLeft(), b.GetLeft());
INT top = max(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
// Determine if the specified rect intersects with the
// current rect object.
BOOL IntersectsWith(IN const Rect& rect) const
{
return (GetLeft() < rect.GetRight() &&
GetTop() < rect.GetTop() &&
GetRight() > rect.GetLeft() &&
GetBottom() > rect.GetTop());
}
static BOOL Union(OUT Rect& c,
IN const Rect& a,
IN const Rect& b)
{
INT right = max(a.GetRight(), b.GetRight());
INT bottom = max(a.GetBottom(), b.GetBottom());
INT left = min(a.GetLeft(), b.GetLeft());
INT top = min(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
VOID Offset(IN const Point& point)
{
Offset(point.X, point.Y);
}
VOID Offset(IN INT dx,
IN INT dy)
{
X += dx;
Y += dy;
}
public:
INT X;
INT Y;
INT Width;
INT Height;
};
// A user must mange memory for PathData.
class PathData
{
public:
PathData()
{
Count = 0;
Points = NULL;
Types = NULL;
}
~PathData()
{
if (Points != NULL)
{
delete Points;
}
if (Types != NULL)
{
delete Types;
}
}
#ifdef DCR_USE_NEW_250932
private:
PathData(const PathData &);
PathData& operator=(const PathData &);
#endif
public:
INT Count;
PointF* Points;
BYTE* Types;
};
//-----------------------------
// text character range
//-----------------------------
class CharacterRange
{
public:
CharacterRange(
INT first,
INT length
) :
First (first),
Length (length)
{}
CharacterRange() : First(0), Length(0)
{}
CharacterRange & operator = (const CharacterRange &rhs)
{
First = rhs.First;
Length = rhs.Length;
return *this;
}
INT First;
INT Length;
};
#endif // !_GDIPLUSTYPES_HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -