s60appengineslabcontainer.cpp

来自「S60培训教材代码」· C++ 代码 · 共 121 行

CPP
121
字号
/*
* ============================================================================
*  Name     : CS60AppEnginesLabContainer from S60AppEnginesLabContainer.h
*  Part of  : S60AppEnginesLab
*  Created  : 09/02/2004 by 
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: 
* ============================================================================
*/

// INCLUDE FILES
#include "S60AppEnginesLabContainer.h"

#include <eiklabel.h>  // for example label control

_LIT(KLabel1Text, "number of entries %d");


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

// ---------------------------------------------------------
// CS60AppEnginesLabContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
// uncomment the 2nd parameter and set the label
void CS60AppEnginesLabContainer::ConstructL(const TRect& aRect/*, TInt aCount*/)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
// uncomment the following three lines to replace the one below them
//	TBuf<128> buf;
//	buf.Format(KLabel1Text, aCount);
//  iLabel->SetTextL( buf );
	iLabel->SetTextL( _L("text label"));
    SetRect(aRect);
    ActivateL();
    }

// Destructor
CS60AppEnginesLabContainer::~CS60AppEnginesLabContainer()
    {
    delete iLabel;
    }

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

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

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

// ---------------------------------------------------------
// CS60AppEnginesLabContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CS60AppEnginesLabContainer::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 );
    }

// ---------------------------------------------------------
// CS60AppEnginesLabContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CS60AppEnginesLabContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }
/* uncomment the following
void CS60AppEnginesLabContainer::UpdateL(TInt aCount)
	{
	TBuf<128> buf;
	buf.Format(KLabel1Text, aCount);
    iLabel->SetTextL( buf );

    DrawNow();
	}
*/
// End of File  

⌨️ 快捷键说明

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