toneplayercontainer.cpp

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

CPP
100
字号
/*
* ============================================================================
*  Name     : CTonePlayerContainer from TonePlayerContainer.h
*  Part of  : TonePlayer
*  Created  : 31.01.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <coemain.h>
#include <eiklabel.h>
#include <TonePlayer.rsg>

#include "TonePlayerContainer.h"


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

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

    HBufC* tip = iCoeEnv->AllocReadResourceLC(R_QTN_APPL_HOWTOPLAY);
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL(*tip);
    CleanupStack::PopAndDestroy(); // tip

    SetRect(aRect);
    ActivateL();
    }

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


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

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

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

// ---------------------------------------------------------
// CTonePlayerContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CTonePlayerContainer::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 + -
显示快捷键?