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

📄 singlelistview.cpp

📁 symbian中讲述的一个有关grid的简单例子
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CSingleListView from CAknView
*  Part of  : Hello
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>

#include <MyHello.rsg>

#include "MyHello.hrh"
#include "SingleListView.h"
#include "SingleListContainer.h" 
#include <MyHello.mbg>		//for mbm file
#include <akncontext.h>		//for CAknContextPane
#include <akntitle.h>			//for CAknTitlePane

#include "MyHelloAppUi.h"		//for CMyHelloAppUi

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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CSingleListView* CSingleListView::NewL()
{
    CSingleListView* self = NewLC();
    CleanupStack::Pop(self);
    return self;
}

CSingleListView* CSingleListView::NewLC()
{
    CSingleListView* self = new (ELeave) CSingleListView;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CSingleListView::CSingleListView()
    {
    }

// EPOC default constructor can leave.
void CSingleListView::ConstructL()
    {
    BaseConstructL(R_HELLO_VIEW);
    }

// Destructor
CSingleListView::~CSingleListView()
    {

    }

// ---------------------------------------------------------
// TUid CSingleListView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CSingleListView::Id() const
    {
    return KViewId3;
    }


// ---------------------------------------------------------
// CSingleListView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CSingleListView::HandleCommandL(TInt aCommand)
{   
	switch(aCommand)
	{
	case EMyHelloCmdLogon:
		{
			//AppUi()->ActivateLocalViewL(KViewId2);
			TBuf<32> strDate;
			strDate.Append(_L("hello list"));
			iContainer->AddInfoToList(m_nIndex++, strDate);
			break;
		}
	case EMyHelloCmdWorldDel:
		break;
	case EMyHelloCmdWorldNew:
		break;
	case EMyHelloCmdWorldMod:
		//AppUi()->ActivateLocalViewL(KViewId1);
		break;
	default:
		AppUi()->HandleCommandL(aCommand);
		break;
	}
}
// ---------------------------------------------------------
// CSingleListView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CSingleListView::HandleClientRectChange()
    {
    if (iContainer)
        {
        iContainer->SetRect(ClientRect());
        }
    }

// ---------------------------------------------------------
// CSingleListView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CSingleListView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
    iContainer = new (ELeave) CSingleListContainer;
    iContainer->SetMopParent(this);

	TRect rc;
	rc.SetRect(ClientRect().iTl, TSize(176, 144));
    iContainer->ConstructL(rc);
    AppUi()->AddToStackL(*this, iContainer);
	TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\myhello\\myhello.mbm"));
#else
	CMyHelloAppUi* pApp = (CMyHelloAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	pathMbm.Append(_L("myhello.mbm"));
#endif
	
	CEikStatusPane* statusPane = StatusPane();
	
	CAknContextPane* contextPane = (CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
	CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmMyhelloSnoopy_1_icon);
	contextPane->SetPicture(bitmap);
	
	//load chinese words
	TBuf<32> sTmpTitle;
	CEikonEnv::Static()->ReadResource(sTmpTitle, R_QTN_MH_WORLD_TITLE);
	
	CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	titlePane->SetTextL(sTmpTitle);//titlePane->SetTextL(_L("World view!"));
    
	m_nIndex = 0;
	}

// ---------------------------------------------------------
// CSingleListView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CSingleListView::DoDeactivate()
    {
    if (iContainer)
        {
        AppUi()->RemoveFromStack(iContainer);
    
    delete iContainer;
    iContainer = NULL;
}
    }

// End of File

⌨️ 快捷键说明

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