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

📄 gridview.cpp

📁 symbian有关文件操作的一个很好的例子
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CGridView from CAknView
*  Part of  : Hello
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <akntitle.h> 
#include <avkon.hrh>
#include <HelloLdci.rsg>
#include <HelloLdci.mbg>	//for mbm
#include "HelloLdci.hrh"
#include "HelloLdciAppUi.h"	//for CMyHelloAppUi
#include "GridView.h"
#include "GridContainer.h" 


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

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

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

CGridView::CGridView()
{
}

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

// Destructor
CGridView::~CGridView()
{
	
}

// ---------------------------------------------------------
// TUid CGridView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CGridView::Id() const
{
    return TUid::Uid(EGridViewID);
}

// ---------------------------------------------------------
// CGridView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CGridView::HandleCommandL(TInt aCommand)
{   
	
	switch(aCommand)
	{
	case ELDGridOpen:
		{
			TInt aflag = iContainer->GetCurrentIndex();
			switch(aflag)
			{
			case 0:
				AppUi()->ActivateLocalViewL(TUid::Uid(EColorViewID));
				break;
			case 1:
				AppUi()->ActivateLocalViewL(TUid::Uid(ESingleListViewID));
			    break;
			default:
			    break;
			}
		}


		break;
	default:
		{
			AppUi()->HandleCommandL(aCommand);
			break;
		}
	}
}
// ---------------------------------------------------------
// CGridView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CGridView::HandleClientRectChange()
{
    if (iContainer)
    {
        iContainer->SetRect(ClientRect());
    }
}

// ---------------------------------------------------------
// CGridView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CGridView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
							 TUid /*aCustomMessageId*/,
							 const TDesC8& /*aCustomMessage*/)
{
    iContainer = new (ELeave) CGridContainer;
    iContainer->SetMopParent(this);
	
    TRect rc;
    rc.SetRect(ClientRect().iTl, TSize(176, 144));
    iContainer->ConstructL(rc);
    AppUi()->AddToStackL(*this, iContainer);    

	//修改标题
	CEikStatusPane* sp=StatusPane();
	CAknTitlePane* titlePane = (CAknTitlePane*) sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	titlePane->SetTextL(_L("Grid View"));
}

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

// End of File

⌨️ 快捷键说明

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