blinkcontainer.cpp

来自「《基于Symbian OS的手机开发与应用实践》这本书的配套源码。」· C++ 代码 · 共 102 行

CPP
102
字号
/*
* ============================================================================
*  Name     : CBlinkContainer from BlinkContainer.h
*  Part of  : Blink
*  Created  : 05.02.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include "BlinkContainer.h"
#include "BlinkLabel.h"

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

// ---------------------------------------------------------
// CBlinkContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CBlinkContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iBlinkLabel = new (ELeave) CBlinkLabel;
    iBlinkLabel->SetContainerWindowL( *this );
    iBlinkLabel->SetTextL( _L("Example View") );
    iBlinkLabel->SetBlinkL(ETrue);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CBlinkContainer::~CBlinkContainer()
    {
    delete iBlinkLabel;
    }

void CBlinkContainer::SetBlinkL()
    {
    if(iBlinkLabel!=NULL)
        {
        iBlinkLabel->SetBlinkL(!iBlinkLabel->Blink());
        }
    }

// ---------------------------------------------------------
// CBlinkContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CBlinkContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iBlinkLabel->SetExtent( TPoint(10,10), iBlinkLabel->MinimumSize() );
    }

// ---------------------------------------------------------
// CBlinkContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CBlinkContainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CBlinkContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CBlinkContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iBlinkLabel;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CBlinkContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CBlinkContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

// End of File  

⌨️ 快捷键说明

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