Nokia N97 SDK
Example Applications Guide

rectangle.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : rectangle.cpp
00004 *  Part of     : GuiEngine
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2004 - 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include    "rectangle.h"
00018 
00019 using namespace NShapes;
00020 
00021 // ========================== OTHER EXPORTED FUNCTIONS =========================
00022 
00023 // -----------------------------------------------------------------------------
00024 // TRectangle::TRectangle()
00025 // C++ default constructor can NOT contain any code, that might leave.
00026 // -----------------------------------------------------------------------------
00027 //
00028 EXPORT_C TRectangle::TRectangle( const TPoint& aOrigin, TInt aWidth, TInt aHeight ):
00029                                  TShape( KRectangle, aOrigin ),
00030                                  iWidth( aWidth ),
00031                                  iHeight( aHeight )
00032     {
00033     // Create an instance of TRectangle at a specified position,
00034     // and of a specified size.
00035     // No implementation required
00036     }
00037 
00038 
00039 // -----------------------------------------------------------------------------
00040 // TRectangle::TRectangle()
00041 // C++ default constructor can NOT contain any code, that might leave.
00042 // -----------------------------------------------------------------------------
00043 //
00044 EXPORT_C TRectangle::TRectangle() : TShape( KRectangle, TPoint( 0,0 ) ),
00045                                             iWidth( 0 ),
00046                                             iHeight( 0 )
00047     {
00048     // Create an instance of TRectangle
00049     //  No implementation required
00050     }
00051 
00052 // -----------------------------------------------------------------------------
00053 // TRectangle::Draw() const
00054 // Virtual method that draws the shape to the specified graphics context.
00055 // -----------------------------------------------------------------------------
00056 //
00057 EXPORT_C void TRectangle::Draw( CWindowGc& aActiveGraphicsContext ) const
00058     {
00059     aActiveGraphicsContext.DrawRect( GetRect() );
00060     }
00061 
00062 // -----------------------------------------------------------------------------
00063 // TRectangle::GetRect() const
00064 // Return the smallest bounding rectangle that entirely contains the shape.
00065 // -----------------------------------------------------------------------------
00066 //
00067 EXPORT_C TRect TRectangle::GetRect() const
00068     {
00069     return TRect( iOrigin, TSize( iWidth, iHeight ) );
00070     }
00071 
00072 // -----------------------------------------------------------------------------
00073 // TRectangle::ExternalizeL() const
00074 // Virtual method that writes the shape to the specified write stream.
00075 // -----------------------------------------------------------------------------
00076 //
00077 EXPORT_C void TRectangle::ExternalizeL( RWriteStream& aStream ) const
00078     {
00079     TShape::ExternalizeL( aStream );
00080     aStream.WriteInt32L( iWidth );
00081     aStream.WriteInt32L( iHeight );
00082     }
00083 
00084 // -----------------------------------------------------------------------------
00085 // TRectangle::InternalizeL() const
00086 // Virtual method that reads the shape from the specified read stream.
00087 // -----------------------------------------------------------------------------
00088 //
00089 EXPORT_C void TRectangle::InternalizeL( RReadStream& aStream )
00090     {
00091     TShape::InternalizeL( aStream );
00092     iWidth = aStream.ReadInt32L();
00093     iHeight = aStream.ReadInt32L();
00094     }
00095 
00096 
00097 // End of File

© Nokia 2009

Back to top