📄 layoutmanager1.cpp
字号:
//
// LayoutManager1.cpp - Layout Manager example
//
// Copyright (C) UIQ Technology AB, 2007
//
// This material is provided "as is" without any warranty to its performance or functionality.
// In no event shall UIQ Technology be liable for any damages whatsoever arising out of the
// use or inabilty to use this material.
//
#include "LayoutManager1.h"
#include "LayoutManager1.hrh"
#include <LayoutManager1.rsg>
#include <LayoutManager1.mbg>
#include <QikMultiPageViewBase.h>
#include <QikCommand.h>
#include <eikstart.h>
//////////////////////////////////////////////////////////////////////////////
// The application Uid here MUST match UID3 defined in the MMP file
// This is a development UID and must NOT be used in production type software
const TUid KAppSpecificUid={0xEDEAD004};
// internal secondary view id, must be unique amongst this applications views
const TUid KUidListView={0x00000001};
// views within applications are fully identified by the app Uid and secondary view id
#define KViewIdListView TVwsViewId(KAppSpecificUid,KUidListView)
//////////////////////////////////////////////////////////////////////////////////
class CAppEngine : public CBase
{
protected:
public:
CAppEngine(const TInt aZoomLevel);
TInt ListViewZoomState() const;
protected:
// The 'engine' stores 'UI' information since UI components come and go, yet we want to preserve
// UI configuration information between invocations of the view.
TInt iZoomLevel;
};
CAppEngine::CAppEngine(const TInt aZoomLevel) :
iZoomLevel(aZoomLevel)
{}
TInt CAppEngine::ListViewZoomState() const
// Report the currently stored zoom state
{
return(iZoomLevel);
}
//////////////////////////////////////////////////////////////////////////////////
class CAppSpecificListView : public CQikMultiPageViewBase
{
protected:
// from CQikMultiPageViewBase
TVwsViewId ViewId() const;
void HandleCommandL(CQikCommand& aCommand);
void ViewConstructL();
void ViewDeactivated();
void ViewActivatedL(const TVwsViewId& aPrevViewId,const TUid aCustomMessageId,const TDesC8& aCustomMessage);
public:
// new methods
CAppSpecificListView(CAppSpecificUi& aAppUi,CAppEngine* aEngine);
protected:
CAppEngine* iEngine;
};
CAppSpecificListView::CAppSpecificListView(CAppSpecificUi& aAppUi,CAppEngine* aEngine) :
CQikMultiPageViewBase(aAppUi,KNullViewId),iEngine(aEngine)
{
}
TVwsViewId CAppSpecificListView::ViewId() const
//
// All views are uniquely identified within the entire system. A TVwsViewId consists of
// the application uid (uid3) and app specific view uid
//
{
return(KViewIdListView);
}
void CAppSpecificListView::HandleCommandL(CQikCommand& aCommand)
//
// Handle the commands coming in from the controls that can deliver cmds..
//
{
switch (aCommand.Id())
{
case EAppCmdAbout:
iEikonEnv->InfoWinL(R_STR_HELP_TITLE,R_STR_HELP_TEXT);
break;
default: // e.g. the back button...
CQikViewBase::HandleCommandL(aCommand);
break;
}
}
void CAppSpecificListView::ViewConstructL()
//
// Construct the view from resources.
//
{
ViewConstructFromResourceL(R_LIST_VIEW_CONFIGURATIONS);
CQikViewBase::SetZoomFactorL(CQikAppUi::ZoomFactorL(iEngine->ListViewZoomState(),*iEikonEnv));
}
void CAppSpecificListView::ViewDeactivated()
{
}
void CAppSpecificListView::ViewActivatedL(
const TVwsViewId& aPrevViewId,
const TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
}
//////////////////////////////////////////////////////////////////////////////
CAppSpecificUi::~CAppSpecificUi()
{
delete(iEngine);
}
void CAppSpecificUi::ConstructL()
//
// Normal primary entry point to a Symbian App
//
{
CQikAppUi::ConstructL();
iEngine=new(ELeave)CAppEngine(EQikCmdZoomLevel2);
CAppSpecificListView* q=new(ELeave)CAppSpecificListView(*this,iEngine);
CleanupStack::PushL(q);
q->ConstructL();
AddViewL(*q); // takes ownership
CleanupStack::Pop(q);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application framework code when creating an application
class CAppSpecificDocument : public CQikDocument
{
protected:
CQikAppUi* CreateAppUiL();
public:
CAppSpecificDocument(CQikApplication& aApp);
static CAppSpecificDocument* NewL(CQikApplication& aApp);
protected:
};
CAppSpecificDocument::CAppSpecificDocument(CQikApplication& aApp) :
CQikDocument(aApp)
{
__DECLARE_NAME(_S("CAppSpecificDocument"));
}
CAppSpecificDocument* CAppSpecificDocument::NewL(CQikApplication& aApp)
{
return(new(ELeave)CAppSpecificDocument(aApp));
}
CQikAppUi* CAppSpecificDocument::CreateAppUiL()
{
return(new(ELeave)CAppSpecificUi);
}
//////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application framework code when creating an application
class CAppSpecificApplication : public CQikApplication
{
protected:
TUid AppDllUid() const;
CApaDocument* CreateDocumentL();
};
TUid CAppSpecificApplication::AppDllUid() const
{
return(KAppSpecificUid);
}
CApaDocument* CAppSpecificApplication::CreateDocumentL()
{
return(CAppSpecificDocument::NewL(*this));
}
//////////////////////////////////////////////////////////////////////////////////
// Standard Symbian application start up code
LOCAL_C CApaApplication* NewApplication()
{
return(new CAppSpecificApplication);
}
GLDEF_C TInt E32Main()
{
return(EikStart::RunApplication(NewApplication));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -