⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gostypes.h

📁 一个更为先进的嵌入式操作系统.采用RMS线程调度算法,具有信号量等同步对象.亦包括GUI. 通过该系统您可以极大知道Windows的内部秘密.
💻 H
字号:
#ifndef _GOS_SHAPES_H_
#define _GOS_SHAPES_H_

#define MemberOffset(Class,Member) DWORD(&((Class*)0)->Member)

typedef struct _tagRGBQUAD{
	BYTE rgbBlue;
	BYTE rgbGreen;
	BYTE rgbRed;
	BYTE rgbReserved;
}RGBQUAD,*PRGBQUAD;

typedef struct _tagSIZE
{
	int cx;
	int cy;
}SIZE,*PSIZE,*LPSIZE;

typedef struct _tagPOINT
{
	int x;
	int y;
}POINT,*PPOINT,*LPPOINT;

typedef struct _tagRECT
{
	int left;
	int top;
    int right;
    int bottom;
}RECT,*PRECT,*LPRECT;
typedef const RECT *LPCRECT;

// CSize
class CSize : public _tagSIZE
{
public:	
// Constructors
	CSize()
		{ /* random filled */ }
	CSize(int initCX, int initCY)
		{ cx = initCX; cy = initCY; }
	CSize(SIZE initSize)
		{ *(SIZE*)this = initSize; }
	CSize(DWORD dwSize)
	{
		cx = LOWORD(dwSize);
		cy = HIWORD(dwSize);
	}
// Operations
	void SetSize(int CX, int CY)
		{ cx = CX; cy = CY; }	
	BOOL operator==(SIZE size) const
		{ return (cx == size.cx && cy == size.cy); }
	BOOL operator!=(SIZE size) const
		{ return (cx != size.cx || cy != size.cy); }
	void operator+=(SIZE size)
		{ cx += size.cx; cy += size.cy; }
	void operator-=(SIZE size)
		{ cx -= size.cx; cy -= size.cy; }
	CSize CSize::operator+(SIZE size) const
		{ return CSize(cx + size.cx, cy + size.cy); }
	CSize CSize::operator-(SIZE size) const
		{ return CSize(cx - size.cx, cy - size.cy); }
	CSize CSize::operator-() const
		{ return CSize(-cx, -cy); }
};

// CPoint
class CPoint : public _tagPOINT
{
public:	
// Constructors
	CPoint()
		{ /* random filled */ }
	CPoint(int initX, int initY)
		{ x = initX; y = initY; }
	CPoint(POINT initPt)
		{ *(POINT*)this = initPt; }
	CPoint(DWORD dwPoint)
	{
		x = LOWORD(dwPoint);
		y = HIWORD(dwPoint);
	}
// Operations
	void Offset(int xOffset, int yOffset)
		{ x += xOffset; y += yOffset; }
	void SetPoint(int X, int Y)
		{ x = X; y = Y; }
	BOOL operator==(POINT point) const
		{ return (x == point.x && y == point.y); }
	BOOL operator!=(POINT point) const
		{ return (x != point.x || y != point.y); }
	void CPoint::operator+=(SIZE size)
		{ x += size.cx; y += size.cy; }
	void CPoint::operator-=(SIZE size)
		{ x -= size.cx; y -= size.cy; }
	CSize operator-(POINT point) const
		{ CSize size; size.cx=x-point.x;
			size.cy=y-point.y; return size; }
};

// CRect
class CRect : public _tagRECT
{
public:	
// Constructors
	CRect()
		{ /* random filled */ }
	CRect(int l, int t, int r, int b)
		{ left = l; top = t; right = r; bottom = b; }
	CRect(POINT point, SIZE size)
		{ right = (left = point.x) + size.cx; bottom = (top = point.y) + size.cy; }
	CRect(POINT topLeft, POINT bottomRight)
		{ left = topLeft.x; top = topLeft.y;
			right = bottomRight.x; bottom = bottomRight.y; }
	CRect(LPCRECT lpSrcRect)
		{ *(RECT*)this = *lpSrcRect; }
	CRect(const RECT& srcRect)
		{ *(RECT*)this = srcRect; }
// Operations
	int Width() const
		{ return right - left; }
	int Height() const
		{ return bottom - top; }
	CSize Size() const
		{ return CSize(right - left, bottom - top); }
	CPoint& TopLeft()
		{ return *((CPoint*)this); }
	const CPoint& TopLeft() const
		{ return *((CPoint*)this); }
	CPoint& BottomRight()
		{ return *((CPoint*)this+1); }
	const CPoint& BottomRight() const
		{ return *((CPoint*)this+1); }
	CPoint CenterPoint() const
		{ return CPoint((left+right)>>1, (top+bottom)>>1); }
	BOOL IsRectEmpty() const
		{ return left >= right || top >= bottom; }
	BOOL PtInRect(int x,int y) const
		{ return x >= left && x < right && y >= top && y < bottom; }
	BOOL PtInRect(POINT point) const
		{ return point.x >= left && point.x < right
			&& point.y >= top && point.y < bottom; }
	BOOL IncludeRect(LPCRECT lpRect) const
		{ return left <= lpRect->left && top <= lpRect->top &&
			right >= lpRect->right && bottom >= lpRect->bottom; }
	void SetRect(int x1, int y1, int x2, int y2)
		{ left = x1; top = y1; right = x2; bottom = y2; }
	void SetRect(POINT topLeft, POINT bottomRight)
		{ left = topLeft.x; top = topLeft.y; right = bottomRight.x; bottom = bottomRight.y; }
	void SetRect(POINT point, SIZE size)
		{ right = (left = point.x) + size.cx; bottom = (top = point.y) + size.cy; }
	void CopyRect(LPCRECT lpSrcRect)
		{ *(RECT*)this = *lpSrcRect; }
	BOOL EqualRect(LPCRECT lpRect) const
		{ return left == lpRect->left && top == lpRect->top &&
			right == lpRect->right && bottom == lpRect->bottom; }
	void CRect::InflateRect(int cxy)
		{ left -= cxy; top -= cxy; right += cxy; bottom += cxy; }
	void CRect::InflateRect(int cx,int cy)
		{ left -= cx; top -= cy; right += cx; bottom += cy; }
	void CRect::InflateRect(SIZE size)
		{ left -= size.cx; top -= size.cy; right += size.cx; bottom += size.cy; }
	void CRect::InflateRect(int l, int t, int r, int b)
		{ left -= l; top -= t; right += r; bottom += b; }
	void CRect::DeflateRect(int cxy)
		{ left += cxy; top += cxy; right -= cxy; bottom -= cxy; }
	void CRect::DeflateRect(int cx,int cy)
		{ left += cx; top += cy; right -= cx; bottom -= cy; }
	void CRect::DeflateRect(SIZE size)
		{ left += size.cx; top += size.cy; right -= size.cx; bottom -= size.cy; }
	void CRect::DeflateRect(int l, int t, int r, int b)
		{ left += l; top += t; right -= r; bottom -= b; }
	void OffsetRect(int cx, int cy)
		{ left += cx; top += cy; right += cx; bottom += cy; }
	void OffsetRect(POINT pt)
		{ left += pt.x; top += pt.y; right += pt.x; bottom += pt.y; }
	void OffsetRect(SIZE size)
		{ left += size.cx; top += size.cy; right += size.cx; bottom += size.cy; }
	void OffsetRectX(int cx)
		{ left += cx; right += cx; }
	void OffsetRectY(int cy)
		{ top += cy; bottom += cy; }
	void MoveTo(int x,int y)
		{ right -= left; right += x; left = x;
			bottom -= top; bottom += y; top = y; }
	void MoveTo(POINT pt)
		{ right -= left; right += pt.x; left = pt.x;
			bottom -= top; bottom += pt.y; top = pt.y; }
	void MoveToX(int x)
		{ right -= left; right += x; left = x; }
	void MoveToY(int y)
		{ bottom -= top; bottom += y; top = y; }
	void CenterTo(int x,int y)
		{ int wh=right-left; left = x-(wh>>1); right=left+wh;
			wh=bottom-top; top=y-(wh>>1); bottom=top+wh;}
	void CenterTo(POINT pt)
		{ int wh=right-left; left = pt.x-(wh>>1); right=left+wh;
			wh=bottom-top; top=pt.y-(wh>>1); bottom=top+wh;}
	void SetSize(int cx,int cy)
		{ right = left + cx; bottom = top + cy; }
	void SetSize(SIZE size)
		{ right = left + size.cx; bottom = top + size.cy; }
	void NormalizeRect()
		{ int nTemp;
			if (left > right){nTemp = left;	left = right; right = nTemp; }
			if (top > bottom){nTemp = top; top = bottom;bottom = nTemp;	}}
	void IntersectRect(LPCRECT pRect)
		{ if(left < pRect->left)left = pRect->left;
			if(top < pRect->top)top = pRect->top;
			if(right > pRect->right)right = pRect->right;
			if(bottom > pRect->bottom)bottom = pRect->bottom; }
	void IntersectRect(LPCRECT pRect1,LPCRECT pRect2)
		{ left = pRect1->left > pRect2->left ? pRect1->left : pRect2->left;
			top = pRect1->top > pRect2->top ? pRect1->top : pRect2->top;
			right = pRect1->right < pRect2->right? pRect1->right : pRect2->right;
			bottom = pRect1->bottom < pRect2->bottom? pRect1->bottom : pRect2->bottom; }
	void UnionRect(LPCRECT pRect)
		{ if(left > pRect->left)left = pRect->left;
			if(top > pRect->top)top = pRect->top;
			if(right < pRect->right)right = pRect->right;
			if(bottom < pRect->bottom)bottom = pRect->bottom; }
	void UnionRect(LPCRECT pRect1,LPCRECT pRect2)
		{ left = pRect1->left < pRect2->left ? pRect1->left : pRect2->left;
			top = pRect1->top < pRect2->top ? pRect1->top : pRect2->top;
			right = pRect1->right > pRect2->right? pRect1->right : pRect2->right;
			bottom = pRect1->bottom > pRect2->bottom? pRect1->bottom : pRect2->bottom; }
	BOOL SubtractRect(LPCRECT pRect);
	BOOL SubtractRect(LPCRECT pRect1,LPCRECT pRect2)
		{ *(RECT*)this = *pRect1; return SubtractRect(pRect2); }
// Additional Operations
	operator LPRECT()
		{ return this; }
	operator LPCRECT() const
		{ return this; }
	void operator=(const RECT& srcRect)
		{ *(RECT*)this = srcRect; }
};

class CPlex
{
public:
	void* data() { return this+1; }
	void FreeDataChain();
	static PVOID CreateHead(CPlex* &pHead,int nBytes);
	static PVOID CreateTail(CPlex* &pTail,int nBytes);
public:
	CPlex* m_pNext;
};

#endif	// _GOS_SHAPES_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -