📄 noteview.cpp
字号:
/*
* ============================================================================
* Name : CNoteView from CAknView
* Part of : Note
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <eikmenub.h> // for CEikMenuBar
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "NoteView.h"
#include "NoteContainer.h"
#include <akncontext.h> //for CAknContextPane
#include <akntitle.h> //for CAknTitlePane
#include "HelperGeniusAppUi.h"
#include "BrowseNoteView.h"
#include "AddNoteView.h"
#include "ModifyNoteView.h"
#include "HelpView.h"
#include "MyGridView.h"
#include <HelperGenius.mbg> //for mbm
#include "NoteInfo.h"
#include <s32file.h>
#include "File.h"
#include <eikmobs.h>
// ================= MEMBER NoteS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
#define DELPTR(p) if(p!=NULL){ delete p;p=NULL;}
CNoteView* CNoteView::NewL(MLink* alink , MLink* aLinkToRework)
{
CNoteView* self = NewLC(alink , aLinkToRework);
CleanupStack::Pop(self);
return self;
}
CNoteView* CNoteView::NewLC(MLink* alink , MLink* aLinkToRework)
{
CNoteView* self = new (ELeave) CNoteView(alink , aLinkToRework);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CNoteView::CNoteView(MLink* alink , MLink* aLinkToRework)
{
mlink = alink;
m_LinkToRework = aLinkToRework;
iFile = NULL;
iContainer = NULL;
}
// EPOC default constructor can leave.
void CNoteView::ConstructL()
{
BaseConstructL(R_NOTE_VIEW);
}
// Destructor
CNoteView::~CNoteView()
{
DELPTR(iFile);
//DELPTR(iContainer);
}
// ---------------------------------------------------------
// TUid CNoteView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CNoteView::Id() const
{
return KNoteId;
}
// ---------------------------------------------------------
// CNoteView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CNoteView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EHelperGeniusCmdBrowseNote://查看
{
mlink->SendData(iContainer->GetIndex());
AppUi()->ActivateLocalViewL(KBrowseId);
break;
}
case EHelperGeniusCmdAddNote://新建
{
AppUi()->ActivateLocalViewL(KAddNoteId);
break;
}
case EHelperGeniusCmdModifyNote://修改
{
m_LinkToRework->SendData(iContainer->GetIndex());
AppUi()->ActivateLocalViewL(KModifyNoteId);
break;
}
case EHelperGeniusCmdHelp://帮助
{
TBuf8<1> buf;
AppUi()->ActivateLocalViewL(KHelpId,KNoteId,buf);
break;
}
case EHelperGeniusCmdGrid://返回
{
CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
CArrayVarFlat<CNoteInfo>* iNoteInfo;
iNoteInfo = pApp->GetArray();
if(iContainer->GetListBoxArray()->Count())
{
iFile->WriteNoteInfoToFileByStream(iNoteInfo);
}
AppUi()->ActivateLocalViewL(KMyGridId);
break;
}
default:
AppUi()->HandleCommandL(aCommand);
break;
}
}
// ---------------------------------------------------------
// CNoteView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CNoteView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CNoteView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CNoteView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
iContainer = new (ELeave) CNoteContainer;
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\\HelperGenius\\HelperGenius.mbm"));
#else
CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
pApp->GetAppPath(pathMbm);
pathMbm.Append(_L("HelperGenius.mbm"));
#endif
CEikStatusPane* statusPane = StatusPane();
//set icon
CAknContextPane* contextPane=(CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelpergeniusHelpergenius_icon_18);
CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelpergeniusHelpergenius_mask_18);
//contextPane->SetPicture(bitmap);
contextPane->SetPicture(bitmap, bitmapMask);
TBuf<32> sTmpTitle;
CEikonEnv::Static()->ReadResource(sTmpTitle, R_QTN_MH_NOTE_TITLE);
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
titlePane->SetTextL(sTmpTitle);
if(iContainer->GetListBoxArray()->Count())
m_nMenuFlag = 1;
else
m_nMenuFlag = 0;
}
// ---------------------------------------------------------
// CNoteView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CNoteView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
}
void CNoteView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
if(aResourceId != R_NOTE_MENU)
return;
//标志位:相当于显示或不显示菜单栏的开关
switch(m_nMenuFlag)
{
case 0://当m_nMenuFlag==0时,隐藏部分菜单栏,即不隐藏菜单栏
{
aMenuPane->SetItemDimmed(EHelperGeniusCmdAddNote, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdModifyNote, ETrue);
aMenuPane->SetItemDimmed(EHelperGeniusCmdBrowseNote, ETrue);
aMenuPane->SetItemDimmed(EHelperGeniusCmdHelp, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdGrid, EFalse);
break;
}
case 1://当m_nMenuFlag==1时,显示所有菜单栏
{
aMenuPane->SetItemDimmed(EHelperGeniusCmdAddNote, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdModifyNote, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdBrowseNote, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdHelp, EFalse);
aMenuPane->SetItemDimmed(EHelperGeniusCmdGrid, EFalse);
break;
}
default:
{
break;
}
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -