newmemoview.cpp
来自「一个比较完整的有关移动开发的例子 vc++6.0下编译通过」· C++ 代码 · 共 197 行
CPP
197 行
/*
* ============================================================================
* Name : CNewMemoView from CAknView
* Part of : NewMemo
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include "NewMemoView.h"
#include "NewMemoContainer.h"
#include "FairyLandAppUi.h"
#include "MemoView.h"
#include <FairyLand.mbg> //for mbm
#include <akncontext.h> //for CAknContextPane
#include <akntitle.h> //for CAknTitlePane
#include "DataManagement.h"
#include <aknnotewrappers.h>
#include <eikmenup.h> //for CEikMenuPane
#include <eikmenub.h> // for CEikMenuBar
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CNewMemoView* CNewMemoView::NewL()
{
CNewMemoView* self = NewLC();
CleanupStack::Pop(self);
return self;
}
CNewMemoView* CNewMemoView::NewLC()
{
CNewMemoView* self = new (ELeave) CNewMemoView;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CNewMemoView::CNewMemoView()
{
}
// EPOC default constructor can leave.
void CNewMemoView::ConstructL()
{
BaseConstructL(R_NEWMEMO_VIEW);
//BaseConstructL();
}
// Destructor
CNewMemoView::~CNewMemoView()
{
}
// ---------------------------------------------------------
// TUid CNewMemoView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CNewMemoView::Id() const
{
return KViewId5;
}
// ---------------------------------------------------------
// CNewMemoView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CNewMemoView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EFairyLandCmdSave:
{
TBuf<10> Title;
TBuf<500> Content;
iContainer->GetTitle(Title);
iContainer->GetContent(Content);
if (Title.Length()==0)
{
TBuf<32> buf;
CEikonEnv::Static( )->ReadResource( buf, R_QTN_MH_REGISTER_WARN_USERNAME );
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(buf);
break;
}
CFairyLandAppUi* pApp=(CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
iArray=pApp->GetArray();
CDataManagemnet* data=CDataManagemnet::NewL(Title,Content);
iArray->AppendL(*data,sizeof(*data));
// CAknInformationNote* iInfo = new(ELeave) CAknInformationNote;
// iInfo->ExecuteLD(*iArray->At(0).GetTitle());
delete data;
AppUi()->ActivateLocalViewL(KViewId4);
}
break;
case EFairyLandBack:
{
AppUi()->ActivateLocalViewL(KViewId4);
}
break;
default:
{
AppUi()->HandleCommandL(aCommand);
break;
}
}
}
// ---------------------------------------------------------
// CNewMemoView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CNewMemoView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CNewMemoView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CNewMemoView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
iContainer = new (ELeave) CNewMemoContainer;
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\\FairyLand\\FairyLand.mbm"));
//#else
// CFairyLandAppUi* pApp = (CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
// pApp->GetAppPath(pathMbm);
// pathMbm.Append(_L("FairyLand.mbm"));
//#endif
CEikStatusPane* statusPane = StatusPane();
//set icon
// CAknContextPane* contextPane = (CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
// CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandNewmemo);
// CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandNewmemo_mask);
//contextPane->SetPicture(bitmap);
// contextPane->SetPicture(bitmap, bitmapMask);
//set title
// CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
// titlePane->SetTextL(_L("Hello view!"));
//load chinese words
TBuf<32> sTmpTitle;
CEikonEnv::Static()->ReadResource(sTmpTitle, R_QTN_MH_NEW_BUILD);
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
titlePane->SetTextL(sTmpTitle);
//show
// CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
// informationNote->ExecuteLD(sTmpTitle);
}
// ---------------------------------------------------------
// CNewMemoView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CNewMemoView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?