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

📄 rectangle.cpp

📁 最新官方例子,图形,描述副,基本控件,通讯协议,等等,
💻 CPP
字号:
/**
 * 
 * @brief Definition of TRectangle
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDE FILES

// Class includes
#include	"rectangle.h"

using namespace NShapes;

// ================= MEMBER FUNCTIONS =======================

/**
@function	TRectangle
@abstract	Creates an instance of TRectangle at a specified position, 
and of a specified size.
@param	aOrigin where the origin of the shape is located.
@param	aWidth The width of the rectangle
@param	aHeight The height of the rectangle
**/
EXPORT_C TRectangle::TRectangle(const TPoint& aOrigin, TInt aWidth, TInt aHeight)
:	TShape(KRectangle, aOrigin), 
	iWidth(aWidth), 
	iHeight(aHeight)
    {
	//	No implementation required
    }

/**
@function	TRectangle
@abstract	Creates an instance of TRectangle.
**/
EXPORT_C TRectangle::TRectangle()
:	TShape(KRectangle, TPoint(0,0)), 
	iWidth(0), 
	iHeight(0)
    {
	//	No implementation required
    }

EXPORT_C TShapeType TRectangle::ShapeType() 
	{
	return KRectangle;
	}

/**
@function	Draw
@abstract	Virtual method that draws the shape to the specified
graphics context.
@param	aActiveGraphicsContext the active context to draw the shape into.
**/
EXPORT_C void TRectangle::Draw(CWindowGc& aActiveGraphicsContext) const
    {
    aActiveGraphicsContext.DrawRect(GetRect());
    }

/**
@function	GetRect
@abstract	Returns the smallest bounding
rectangle that entirely contains the shape.
**/
EXPORT_C TRect TRectangle::GetRect() const
    {
    return TRect(iOrigin, TSize(iWidth, iHeight));
    }

/**
@function	ExternalizeL
@abstract	Virtual method that writes the shape to the specified
write stream.
@param	aStream the stream to write the shape to.
**/
EXPORT_C void TRectangle::ExternalizeL(RWriteStream& aStream) const
    {
    TShape::ExternalizeL(aStream);

    aStream.WriteInt32L(iWidth);
    aStream.WriteInt32L(iHeight);
    }

/**
@function	InternalizeL
@abstract	Virtual method that reads the shape from the specified
read stream.
@param	aStream the stream to read the shape from.
**/
EXPORT_C void TRectangle::InternalizeL(RReadStream& aStream)
    {
    TShape::InternalizeL(aStream);

    iWidth = aStream.ReadInt32L();
    iHeight = aStream.ReadInt32L();
    }


EXPORT_C TInt TRectangle::StorageSize() const
	{
	TInt size = TShape::StorageSize();
	size += 2 * sizeof(TInt32);
	return size;
	}	

//End of File


⌨️ 快捷键说明

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