simplecontrol.cpp

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

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

// INCLUDES

//  Class include
#include "SimpleControl.h"

// System includes

// CONSTANTS


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

/**
* Symbian OS 2 phase constructor.
* Constructs the CSimpleControl using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CSimpleControl
*/
CSimpleControl* CSimpleControl::NewL(const TRect& aRect, const CCoeControl* aParent)
{
    CSimpleControl* self = CSimpleControl::NewLC(aRect, aParent);
    CleanupStack::Pop(self);
    return self;
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CSimpleControl using the constructor and ConstructL 
* method, leaving the constructed object on the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CSimpleControl
*/
CSimpleControl* CSimpleControl::NewLC(const TRect& aRect, const CCoeControl* aParent)
{
    CSimpleControl* self = new (ELeave) CSimpleControl;
    CleanupStack::PushL(self);
    self->ConstructL(aRect, aParent);
    return self;
}

/**
* Symbian OS 2nd phase constructor.  Creates a Window for the controls, which it contains.
* Constructs a label and adds it to the window, which it then activates.
* @param aRect The rectangle for this window
*/ 
void CSimpleControl::ConstructL(const TRect& aRect, const CCoeControl* aParent)
{
    if (aParent == NULL)
    {
        // No parent control, so create as window-owning
        CreateWindowL();
    }
    else
    {
        // Part of a compound control, so just share
        // the parent's window
        SetContainerWindowL(*aParent);
    }

    SetRect(aRect);
    ActivateL();
}

/**
*
* Called by framework when the view size is changed.  Resizes the
* iLabel accordingly.
*
*/
void CSimpleControl::SizeChanged()
{
}

/** 
* Destructor.  Frees up memory for the iLabel.
*/
CSimpleControl::~CSimpleControl()
{
}

/**
* Called by the framework to draw this control.  Clears the area in 
* aRect.
* @param aRect in which to draw
*/
void CSimpleControl::Draw(const TRect& /*aRect*/) const
{
    CWindowGc& gc = SystemGc();
    gc.Clear(Rect());

    // Set GC pen & brush styles
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetPenColor(KRgbBlack);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetBrushColor(KRgbRed);

    gc.DrawEllipse(Rect());
}

// End of File

⌨️ 快捷键说明

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