circle.cpp

来自「s60源码」· C++ 代码 · 共 108 行

CPP
108
字号
/**
 * 
 * @brief Definition of TCircle
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDE FILES

// Class includes
#include	"circle.h"

using namespace NShapes;


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

/**
@function	TCircle
@abstract	Creates an instance of TCircle at a specified position, and of a 
specified radius.
@param	aCenter where the center of the circle is located.
@param	aRadius The radius of the circle
**/
EXPORT_C TCircle::TCircle(const TPoint& aCenter, TInt aRadius)
:	TShape(KCircle, aCenter - TSize(aRadius, aRadius)), 
	iRadius(aRadius)
    {
	//	No implementation required
    }

/**
@function	TCircle
@abstract	Creates an instance of TCircle 
**/
EXPORT_C TCircle::TCircle()
: TShape(KCircle, TPoint(0,0)), iRadius(0)
    {
	//	No implementation required
    }

EXPORT_C TShapeType TCircle::ShapeType() 
	{
	return KCircle;
	}


/**
@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 TCircle::Draw(CWindowGc& aActiveGraphicsContext) const
    {
    aActiveGraphicsContext.DrawEllipse(GetRect());
    }


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


/**
@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 TCircle::ExternalizeL(RWriteStream& aStream) const
    {
    TShape::ExternalizeL(aStream);

    aStream.WriteInt32L(iRadius);
    }

/**
@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 TCircle::InternalizeL(RReadStream& aStream)
    {
    TShape::InternalizeL(aStream);

    iRadius = aStream.ReadInt32L();
    }

EXPORT_C TInt TCircle::StorageSize() const
	{

	TInt size = TShape::StorageSize();
	size += sizeof(TInt32);
	return size;

	}

//End of File

⌨️ 快捷键说明

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