rectangle.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 111 行

CPP
111
字号
/**
 * 
 * @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 + =
减小字号Ctrl + -
显示快捷键?