📄 helloview.cpp
字号:
/*
* ============================================================================
* Name : CHelloView 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 "HelloView.h"
#include "HelloContainer.h"
#include "MyHelloAppUi.h"
#include "WorldView.h"
#include <myhello.mbg> //for mbm
#include <akncontext.h> //for CAknContextPane
#include <akntitle.h> //for CAknTitlePane
#include "MyHelloAppUi.h" //for CMyHelloAppUi
#include <aknnotewrappers.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CHelloView* CHelloView::NewL()
{
CHelloView* self = NewLC();
CleanupStack::Pop(self);
return self;
}
CHelloView* CHelloView::NewLC()
{
CHelloView* self = new (ELeave) CHelloView;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CHelloView::CHelloView()
{
}
// EPOC default constructor can leave.
void CHelloView::ConstructL()
{
BaseConstructL(R_HELLO_VIEW);
}
// Destructor
CHelloView::~CHelloView()
{
}
// ---------------------------------------------------------
// TUid CHelloView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CHelloView::Id() const
{
return KViewId1;
}
// ---------------------------------------------------------
// CHelloView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CHelloView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EMyHelloCmdLogon:
{
//AppUi()->ActivateLocalViewL(KViewId2);
TBuf<256> strName;
iContainer->GetLoginName(strName);
CAknInformationNote* information = new(ELeave) CAknInformationNote;
information->ExecuteLD(strName);
break;
}
default:
{
AppUi()->HandleCommandL(aCommand);
break;
}
}
}
// ---------------------------------------------------------
// CHelloView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CHelloView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CHelloView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CHelloView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
iContainer = new (ELeave) CHelloContainer;
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();
//set icon
CAknContextPane* contextPane = (CAknContextPane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext));
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmMyhelloSnoopy_1_icon);
CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmMyhelloSnoopy_1_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_HELLO_TITLE);
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
titlePane->SetTextL(sTmpTitle);
//show
// CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
// informationNote->ExecuteLD(sTmpTitle);
}
// ---------------------------------------------------------
// CHelloView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CHelloView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -