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

📄 geometryex.hpp

📁 一个完整的桌面日历程序
💻 HPP
字号:
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// -																																					-
// - File:			geometryex.hpp.																														-
// -																																					-
// - Contents: 		Interfaces and implementation of geometry classes based on CPoint, CRect etc.														-
// -																																					-
// - Purpose:  		-																																	-
// -																																					-
// - Remarks:    	-																																	-
// -																																					-
// - Originator: 	Michael Mogensen, MM-IT Consult 2003.																								-
// -																																					-
// - Compiler:		MS Visual C++ ver6.0.																											    -
// -																																					-
// - Period:		00.00.00 - 00.00.00.																											    -
// -																																					-
// - Version:		1.00. 																																-
// -																																					-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Miscellaneous.																																		-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Header(s).																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
#pragma once

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Miscellaneous.																																		-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - CPointEx.																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
class CPointEx : public CPoint
{
	public:
		// 1. Object. (alphabetical).
		inline CPointEx() :
			CPoint(0, 0)
			{}
		CPointEx(const int iX, const int iY) :
			CPoint(iX, iY)
			{}
		CPointEx(POINT ipPoint) :
			CPoint(ipPoint)
			{}
		CPointEx(SIZE isSize) :
			CPoint(isSize)
			{}
		CPointEx(DWORD dwPoint) :
			CPoint(dwPoint)
			{}
		CPointEx(const CPoint &ipPoint) :
			CPoint(ipPoint.x, ipPoint.y)
			{}
		CPointEx(const CPointEx &ipPoint) :
			CPoint(ipPoint.x, ipPoint.y)
			{}
		~CPointEx()
		{}
		// 4. Slaves. (alphabetical).
		inline const bool operator<(const CPointEx &ipPoint) const
		{ return(x < ipPoint.x || y < ipPoint.y); }
		inline const bool operator<=(const CPointEx &ipPoint) const
		{ return(x <= ipPoint.x || y <= ipPoint.y); }
		inline const bool operator==(const CPointEx &ipPoint) const
		{ return(x == ipPoint.x && y == ipPoint.y); }
		inline const bool operator>=(const CPointEx &ipPoint) const
		{ return(x >= ipPoint.x || y >= ipPoint.y); }
		inline const bool operator>(const CPointEx &ipPoint) const
		{ return(x > ipPoint.x || y > ipPoint.y); }
		inline const bool Exist() const
		{ return(x != 0 || y != 0); }
		inline const bool Is(const int iX, const int iY) const
		{ return(x == iX && y == iY); }
		inline const bool Is(const CPointEx &ipPoint) const
		{ return(*this == ipPoint); }
		inline const bool IsBetween(const int iLeft, const int iTop, const int iRight, const int iBottom) const
		{ return(x >= iLeft && x >= iTop && y <= iRight && y <= iBottom); }
		inline const bool IsBetween(const CPointEx &ipLeftTop, const CPointEx &ipRightBottom) const
		{ return(*this >= ipLeftTop && *this <= ipRightBottom); }
		inline const bool IsGreatherThan(const CPointEx &ipPoint) const
		{ return(*this > ipPoint); }
		inline const bool IsLessThan(const CPointEx &ipPoint) const
		{ return *this < ipPoint; }
		inline const bool Is_X(const int iNum) const
		{ return(x == iNum); }
		inline const bool Is_X_GreatherThan(const int iNum) const
		{ return(x > iNum); }
		inline const bool Is_X_LessThan(const int iNum) const
		{ return(x < iNum); }
		inline const bool Is_Y(const int iNum) const
		{ return(y == iNum); }
		inline const bool Is_Y_GreatherThan(const int iNum) const
		{ return(y > iNum); }
		inline const bool Is_Y_LessThan(const int iNum) const
		{ return(y < iNum); }
		inline const void Offset(const int iDelta_X, const int iDelta_Y)
		{ CPoint::Offset(iDelta_X, iDelta_Y); }
		inline const CPointEx OffsetBy(const int iDelta_X, const int iDelta_Y)
		{ CPointEx ipPoint(x, y); ipPoint.Offset(iDelta_X, iDelta_Y); return ipPoint; }
		inline const void Set(const int iX, const int iY)
		{ x = iX; y = iY; }
		inline const void SetAbs()
		{ x = abs(x); y = abs(y); }
		inline const void SetNull()
		{ x = 0; y = 0; }
};

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - CRectEx.																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
class CRectEx : public CRect
{
	public:
		// 1. Object. (alphabetical).
		inline CRectEx() : CRect(0, 0, 0, 0)
			{}
		inline CRectEx(const int iLeft, const int iTop, const int iRightOrWidth, const int iBottomOrHeight, const bool bIsRighBottom = true) : 
		CRect(iLeft, iTop, iRightOrWidth + (bIsRighBottom ? 0 : iLeft), iBottomOrHeight + (bIsRighBottom ? 0 : iTop))
			{}
		inline CRectEx(const RECT &irRect) : 
			CRect(irRect)
			{}
		inline CRectEx(LPCRECT lpirRect) : 
			CRect(lpirRect)
			{}
		inline CRectEx(POINT ipPoint, SIZE isSize) : 
			CRect(ipPoint, isSize)
			{}
		inline CRectEx(POINT ipTopLeft, POINT ipBottomRight) : 
			CRect(ipTopLeft, ipBottomRight)
			{}
		inline CRectEx(const CRectEx &irRect) : 
			CRect(irRect.left, irRect.top, irRect.right, irRect.bottom)
			{}
		virtual ~CRectEx()
		{}
		// 4. Slaves. (alphabetical).
		inline const CPointEx BottomLeft() const
		{
			const CPointEx ipPoint(left, bottom);
			return ipPoint;
		}
		inline const CPointEx CenterPoint() const
		{
			CPointEx ipPoint(TopLeft());
			ipPoint.x += (long)(0.5 * Width());
			ipPoint.y += (long)(0.5 * Height());
			return ipPoint;
		}
		inline const CRectEx DeflateRectBy(const int iDelta_X, const int iDelta_Y) const
		{
			CRectEx irRect;
			irRect.CopyRect(this);
			irRect.DeflateRect(iDelta_X, iDelta_Y);
			return irRect;
		}
		inline const CRectEx InflateRectBy(const int iDelta_X, const int iDelta_Y) const
		{
			CRectEx irRect;
			irRect.CopyRect(this);
			irRect.InflateRect(iDelta_X, iDelta_Y);
			return irRect;
		}
		inline const bool IsPtInsideRect(const CPointEx &ipPoint) const
		{ return PtInRect(ipPoint) != 0; }
		inline const void MoveTo(const int iPos_X, const int iPos_Y)
		{
			SetWH(iPos_X, iPos_Y, Width(), Height());
		}
		inline const CRectEx MoveSide(
			const int iDelta_Left = 0, 
			const int iDelta_Top = 0, 
			const int iDelta_Right = 0, 
			const int iDelta_Bottom = 0)
		{
			left += iDelta_Left;
			top += iDelta_Top;
			right += iDelta_Right;
			bottom += iDelta_Bottom;
			return *this;
		}
		inline const CRectEx MovedSide(
			const int iDelta_Left = 0, 
			const int iDelta_Top = 0, 
			const int iDelta_Right = 0, 
			const int iDelta_Bottom = 0) const
		{
			const CRectEx irRect(
				left + iDelta_Left, 
				top + iDelta_Top, 
				right + iDelta_Right, 
				bottom + iDelta_Bottom);
			return *irRect;
		}
		inline const CRectEx MovedTo(const int iPos_X, const int iPos_Y)
		{
			CRectEx irRect;
			irRect.SetWH(iPos_X, iPos_Y, Width(), Height());
			return irRect;
		}
		inline const CRectEx OffsetRectBy(const int iDelta_X, const int iDelta_Y) const
		{
			CRectEx irRect;
			irRect.CopyRect(this);
			irRect.OffsetRect(iDelta_X, iDelta_Y);
			return irRect;
		}
		inline const void RestrictTo(const CRectEx &irRect)
		{
			left = max(irRect.left, left);
			top = max(irRect.top, top);
			right = min(irRect.right, right);
			bottom = min(irRect.bottom, bottom);
		}
		inline const void Set(const int iLeft, const int iTop, const int iRight, const int iBottom)
		{
			CRect::SetRect(iLeft, iTop, iRight, iBottom);
		}
		inline const void Set(POINT ipLeftTop, POINT ipRightBottom)
		{
			CRect::SetRect(ipLeftTop, ipRightBottom);
		}
		inline const void SetPositive()
		{
			left = max(left, 0);
			top = max(top, 0);
			right = max(right, 0);
			bottom = max(bottom, 0);
		}
		inline const void SetWH(const int iLeft, const int iTop, const int iWidth, const int iHeight)
		{ SetRect(iLeft, iTop, iLeft + iWidth, iTop + iHeight); }
		inline const CPointEx TopRight()
		{
			const CPointEx ipPoint(top, right);
			return ipPoint;
		}
		inline const void Transfere(int &iLeft, int &iTop, int &iRight, int &iBottom)
		{
			iLeft = left;
			iTop = top;
			iRight = right;
			iBottom = bottom;		
		}
		inline const void TransfereWH(int &iLeft, int &iTop, int &iWidth, int &iHeight)
		{
			iLeft = left;
			iTop = top;
			iWidth = Width();
			iHeight = Height();		
		}
		inline const int X() const
		{ return left; }
		inline const int Y() const
		{ return top; }
};

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - CSizeEx.																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
class CSizeEx : public CSize
{
	public:
		// 1. Object. (alphabetical).
		inline CSizeEx() :
			CSize(0, 0)
			{}
		inline CSizeEx(const int iX, const int iY) :
			CSize(iX, iY)
			{}
		inline CSizeEx(const SIZE isSize) :
			CSize(isSize)
			{}
		inline CSizeEx(const POINT ipPoint) :
			CSize(ipPoint)
			{}
		inline CSizeEx(const DWORD dwSize) :
			CSize(dwSize)
			{}
		inline CSizeEx(const CRectEx irRect) :
			CSize(irRect.Width(), irRect.Height())
			{}
		inline CSizeEx(const CSizeEx &isSize) :
			CSize(isSize.cx, isSize.cy)
			{}
		virtual ~CSizeEx()
		{}
		// 4. Slaves. (alphabetical).
		inline const void Set(const int iX, const int iY)
		{ cx = iX; cy = iY; }
};

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// -																																				  	-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// 0. Data. (alphabetical).
// 1. Object. (alphabetical).
// 2. Event's. (alphabetical).
// 3.0. Menu choice. (menu order).
// 3.1. Menu choice, enablers. (menu order).
// 4. Slaves. (alphabetical).
// 5. Other. (alphabetical).

⌨️ 快捷键说明

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