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

📄 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 "TreeAppUi.h"
#include "WorldContainer.h"


//////////////////////////////////////////////////////////////////////////
CWorldContainer::CWorldContainer()
{
}

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

	iTree = new(ELeave) CNDTree;
	iTree->SetContainerWindowL(*this);

	CTreeAppUi* pApp = (CTreeAppUi*)CEikonEnv::Static()->AppUi();
	CFbsBitmap* fold = pApp->LoadGraphicsL(0);
	CFbsBitmap* spread = pApp->LoadGraphicsL(1);
	CFbsBitmap* shrink = pApp->LoadGraphicsL(2);
	iTree->ConstructL(fold,spread,shrink);

	CTreeNode* node = CTreeNode::NewL();
	node->SetContent(_L("root1"));
	iTreeArray.Append(node);

	node = CTreeNode::NewL();
	node->SetContent(_L("root2"));
	iTreeArray.Append(node);

	node = CTreeNode::NewL();
	node->SetContent(_L("root3"));
	iTreeArray.Append(node);

	node = CTreeNode::NewL();
	node->SetContent(_L("root4"));
	iTreeArray.Append(node);

	iTree->SetNodeArray(iTreeArray);

    SetRect( aRect );
    ActivateL();
}

// destructor
CWorldContainer::~CWorldContainer()
{
	if (iTree)
	{
		delete iTree;
		iTree = NULL;
	}
	iTreeArray.ResetAndDestroy();
}

void CWorldContainer::SizeChanged()
{
	if(iTree)
	{
		iTree->SetRect(Rect());
	}
}

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

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

// ---------------------------------------------------------
// 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(KRgbBlack);
	gc.DrawRect(Rect());
}

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



⌨️ 快捷键说明

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