⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s60mmflabcontainer.cpp

📁 symbian 3版手机程序开发与实例教程源码
💻 CPP
字号:
// Copyright (c) 2006 Nokia Corporation.

// INCLUDE FILES
#include "S60MMFLabContainer.h"
#include <aknsdrawutils.h>
#include <eiklabel.h>  // for example label control
#include <aknsbasicbackgroundcontrolcontext.h>
#include <aknutils.h>

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

// ---------------------------------------------------------
// CS60MMFLabContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CS60MMFLabContainer::ConstructL(const TRect& aRect, const TDesC& aLabel)
    {
    CreateWindowL();

	iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue);
	
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( aLabel );
    
    SetRect(aRect);
    ActivateL();
    }

// Destructor
CS60MMFLabContainer::~CS60MMFLabContainer()
    {
    delete iLabel;
    delete iBgContext;
    }

// ---------------------------------------------------------
// CS60MMFLabContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CS60MMFLabContainer::SizeChanged()
    {
    TRect rect;
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
    iBgContext->SetRect(rect);
    SetLabelL(*iLabel->Text());
    }

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

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

// ---------------------------------------------------------
// CS60MMFLabContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CS60MMFLabContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    
    // Redraw the background using the default skin
	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
	AknsDrawUtils::Background( skin, cc, this, gc, aRect );
    }

// ---------------------------------------------------------
// CS60MMFLabContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CS60MMFLabContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

void CS60MMFLabContainer::SetLabelL(const TDesC& aLabel)
	{
	TPtrC text = aLabel;
	TSize minSize = iLabel->CalcMinimumSize(text);
	TInt minHeight = minSize.iHeight;
	minSize.iHeight = 2*minHeight;
	
	iLabel->SetTextL(aLabel);
	iLabel->SetExtent( TPoint(minHeight, minHeight), minSize );
	}

TTypeUid::Ptr CS60MMFLabContainer::MopSupplyObject(TTypeUid aId)
    {
    if (iBgContext )
        {
        return MAknsControlContext::SupplyMopObject( aId, iBgContext );
        }
        
    return CCoeControl::MopSupplyObject(aId);
    }

// End of File  

⌨️ 快捷键说明

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