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

📄 settingexamplelistview.cpp

📁 基于 symbian OS的屏幕设置经典程序,很不错,欢迎下载学习
💻 CPP
字号:
/*
 * ============================================================================
 *  Name     : CSettingListView from SettingExampleListView.cpp
 *  Part of  : SettingExample
 *  Created  : 29/05/2006 by Forum Nokia
 *  Version  : 2.0
 *  Copyright: Forum Nokia
 * ============================================================================
 */
 
#include "SettingExampleListView.h"
#include <SettingExample.rsg>
#include "SettingExample.hrh"
#include "SettingExampleUi.h"
#include "SettingExampleSettingList.h"
#include <barsread.h>

// UID of view
const TUid KViewId = {1};


// factory constructor leaving instance on cleanup
CSettingListView* CSettingListView::NewLC(CSettingsData &aData)
	{
	CSettingListView* self = new (ELeave) CSettingListView(aData);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

// factory constructor - no instance left on cleanup
CSettingListView* CSettingListView::NewL(CSettingsData &aData)
	{
	CSettingListView* self = CSettingListView::NewLC(aData);
	CleanupStack::Pop(self);
	return self;
	}

// second phase constructor
void CSettingListView::ConstructL()
	{
	// construct from resource
	BaseConstructL(R_FIRSTVIEW);
	}

// first phase (non-leaving) constructor
CSettingListView::CSettingListView(CSettingsData &aData)
: CAknView(), iSettingsData(aData)
	{
	}

// activation of view
void CSettingListView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, 
										 TUid /*aCustomMessageId*/, 
								   const TDesC8& /*aCustomMessage*/)
	{
	if(!iSettingList)	// if we haven't already created iSettingList
		{
		// construct control and set parent
		iSettingList = CExampleSettingList::NewL(iSettingsData);
		iSettingList->SetMopParent(this);

		// construct control based on resource definition
		TResourceReader reader;

		// CreateResourceReaderLC will allocate a buffer to be used by
		// the TResourceReader. This buffer is pushed onto the cleanup
		// stack - not the TResourceReader itself
		CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SETTINGS);
		iSettingList->ConstructFromResourceL(reader);

		// Clean up the buffer allocated above, NOT the reader itself.
		// Cannot use expected item overload of PopAndDestroy() as buffer 
		// is inaccessible. 
		CleanupStack::PopAndDestroy();	

		// register view and activate
		AppUi()->AddToViewStackL(*this, iSettingList);
		iSettingList->ActivateL();
		}
	}

// deactivation of view
void CSettingListView::DoDeactivate()
	{
	if(iSettingList)	// if setting list has been created
		{
		// remove setting list from stack
		AppUi()->RemoveFromViewStack(*this, iSettingList);

		// clean up 
		delete iSettingList;
		iSettingList = NULL;
		}
	}

TUid CSettingListView::Id() const
	{
	return KViewId;
	}

void CSettingListView::HandleCommandL(TInt aCommand)
    {
	switch(aCommand)
		{
	case ESettingCmdEdit :					// edit current item
		iSettingList->EditCurrentItemL();
		break;
	default :								// anything else
		AppUi()->HandleCommandL(aCommand);	// handled by AppUi
		break;
		}
	}
	
// ---------------------------------------------------------
// CSettingListView::HandleResourceChange()
// Called by framework when resource is changed.
// ------
void CSettingListView::HandleStatusPaneSizeChange()
	{
	CAknView::HandleStatusPaneSizeChange(); //call to upper class
	iSettingList->SetRect(ClientRect());
	}

//EOF

⌨️ 快捷键说明

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