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

📄 worldcontainer.cpp

📁 symbian 二版本的自定义控件
💻 CPP
字号:

#include <gulicon.h>
#include <aknutils.h>    // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include "ListboxAppui.h"

#include "WorldContainer.h"


//////////////////////////////////////////////////////////////////////////
CWorldContainer::CWorldContainer()
{
	iList = NULL;
	iArray = NULL;
}

// EPOC default constructor can leave.
void CWorldContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();

	CListboxAppUi* pApp = (CListboxAppUi*)CEikonEnv::Static()->AppUi();
	CFbsBitmap* icon = pApp->LoadGraphicsL(1);
	CFbsBitmap*	iconSelect = pApp->LoadGraphicsL(0);
	iList = new CNDList;
	iList->ContructL(icon,iconSelect);

	iArray = new(ELeave) CDesC16ArrayFlat(10);
	iArray->AppendL(_L("hello"));
	iArray->AppendL(_L("nihao"));
	iArray->AppendL(_L("how"));
	iArray->AppendL(_L("world"));
	iArray->AppendL(_L("china"));
	iArray->AppendL(_L("happy"));
	iArray->AppendL(_L("hello"));
	iArray->AppendL(_L("nihao"));
	iArray->AppendL(_L("how"));
	iArray->AppendL(_L("world"));
	iArray->AppendL(_L("china"));
	iArray->AppendL(_L("happy"));
	for(TInt i=0;i<iArray->Count();i++)
	{
		iList->AppendAnItem((*iArray)[i]);
	}
    SetRect( aRect );
    ActivateL();
}

// destructor
CWorldContainer::~CWorldContainer()
{
	if(iList)
	{
		delete iList;
		iList = NULL;
	}
	if(iArray)
	{
		iArray->Reset();
		delete iArray;
		iArray = NULL;
	}
}

void CWorldContainer::SizeChanged()
{
}

// ---------------------------------------------------------
// CWorldContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CWorldContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 0; 
}

// ---------------------------------------------------------
// CWorldContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CWorldContainer::ComponentControl( TInt /*aIndex*/ ) const
{
	return NULL;
}

// ---------------------------------------------------------
// CWorldContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CWorldContainer::Draw( const TRect& /*aRect*/ ) const
{
	CWindowGc& gc = SystemGc();
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.SetBrushColor(KRgbWhite);
	gc.DrawRect(Rect());

	gc.SetBrushColor(KRgbCyan);	
	const CFont* iFontTemp = iEikonEnv->LegendFont();
	gc.UseFont(iFontTemp);

	iList->Draw(gc);
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CWorldContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
	iList->OfferKeyEventL(aKeyEvent,aType);
	DrawDeferred();
	return EKeyWasConsumed;
}



⌨️ 快捷键说明

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