📄 myappui.cpp
字号:
// INCLUDE FILES
#include "MyAppUi.h"
#include <MyApp.rsg>
#include "MyApp.hrh"
#include <eikenv.h>
#include "MyDialog.h"
#include "MyViews.h"
#include "MyEngine.h"
#include "MyApp.h"
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CMyAppUi::ConstructL()
// ?implementation_description
// ----------------------------------------------------------
//
void CMyAppUi::ConstructL()
{
BaseConstructL();
// engine
iEngine = new (ELeave) CMyEngine();
iEngine->ConstructL();
// view stuff
iHelloViewOne = new (ELeave) CMyViewOne();
iHelloViewOne->ConstructL(ClientRect());
RegisterViewL(*iHelloViewOne);
AddToStackL(*iHelloViewOne,iHelloViewOne);
// do not construct fully
iHelloViewTwo = new (ELeave) CMyViewTwo();
RegisterViewL(*iHelloViewTwo);
SetDefaultViewL(*iHelloViewOne);
}
// ----------------------------------------------------
// CMyAppUi::~CMyAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CMyAppUi::~CMyAppUi()
{
if (iHelloViewOne)
{
RemoveFromStack(iHelloViewOne);
DeregisterView(*iHelloViewOne);
delete iHelloViewOne;
}
if (iHelloViewTwo)
{
RemoveFromStack(iHelloViewTwo);
DeregisterView(*iHelloViewTwo);
delete iHelloViewTwo;
}
delete iEngine;
}
// ------------------------------------------------------------------------------
// CMyAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CMyAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CMyAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// ?implementation_description
// ----------------------------------------------------
//
TKeyResponse CMyAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
void CMyAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EMyAppCmdViewOne:
{
iEikonEnv->InfoMsg(_L("View One"));
TVwsViewId id(KUidMyApp, KUidMyAppViewOne);
ActivateViewL(id);
break;
}
case EMyAppCmdViewTwo:
{
iEikonEnv->InfoMsg(_L("View Two"));
TVwsViewId id(KUidMyApp, KUidMyAppViewTwo);
ActivateViewL(id);
break;
}
case EMyAppCmdInformationDialog:
{
_LIT(KDialogTitle,"Information Dialog");
_LIT(KDialogMessage,"This is an information Dialog");
// Launch Info window with the specified title and message.
iEikonEnv->InfoWinL(KDialogTitle, KDialogMessage);
break;
}
case EMyAppCmdAlertDialog:
{
_LIT(KAlertMessage1,"1st message line.");
_LIT(KAlertMessage2,"2nd message line.");
// Launch Alert window - this example shows 2 lines of text.
iEikonEnv->AlertWin(KAlertMessage1, KAlertMessage2);
break;
}
case EMyToolbarButtonTwo:
{
_LIT(KInfoMessage, "This is an info message");
iEikonEnv->InfoMsg(KInfoMessage);
break;
}
case EMyToolbarButtonOne:
{
CEikDialog* dialog = new(ELeave) CMyDialog();
dialog->ExecuteLD(R_MYAPP_DIALOG);
break;
}
default:
break;
}
}
CMyEngine* CMyAppUi::GetEngine()
{
return iEngine;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -