📄 helloworld2appui.cpp
字号:
/*
* ============================================================================
* Name : CHelloWorld2AppUi from HelloWorld2AppUi.cpp
* Part of : HelloWorld2
* Created : 2006-3-14 by
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include "HelloWorld2AppUi.h"
#include "HelloWorld2View.h"
#include "HelloWorld2View2.h"
#include <HelloWorld2.rsg>
#include "helloworld2.hrh"
#include <avkon.hrh>
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CHelloWorld2AppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CHelloWorld2AppUi::ConstructL()
{
BaseConstructL();
// Show tabs for main views from resources
CEikStatusPane* sp = StatusPane();
// Fetch pointer to the default navi pane control
iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
TUid::Uid(EEikStatusPaneUidNavi));
// Tabgroup has been read from resource and it were pushed to the navi pane.
// Get pointer to the navigation decorator with the ResourceDecorator() function.
// Application owns the decorator and it has responsibility to delete the object.
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
if (iDecoratedTabGroup)
{
iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
}
CHelloWorld2View* view1 = new (ELeave) CHelloWorld2View;
CleanupStack::PushL( view1 );
view1->ConstructL();
AddViewL( view1 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(); // view1
CHelloWorld2View2* view2 = new (ELeave) CHelloWorld2View2;
CleanupStack::PushL( view2 );
view2->ConstructL();
AddViewL( view2 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(); // view2
SetDefaultViewL(*view1);
}
// ----------------------------------------------------
// CHelloWorld2AppUi::~CHelloWorld2AppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CHelloWorld2AppUi::~CHelloWorld2AppUi()
{
delete iDecoratedTabGroup;
}
// ------------------------------------------------------------------------------
// CHelloWorld2AppUi::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 CHelloWorld2AppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CHelloWorld2AppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CHelloWorld2AppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
{
if ( iTabGroup == NULL )
{
return EKeyWasNotConsumed;
}
TInt active = iTabGroup->ActiveTabIndex();
TInt count = iTabGroup->TabCount();
switch ( aKeyEvent.iCode )
{
case EKeyLeftArrow:
if ( active > 0 )
{
active--;
iTabGroup->SetActiveTabByIndex( active );
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
}
break;
case EKeyRightArrow:
if( (active + 1) < count )
{
active++;
iTabGroup->SetActiveTabByIndex( active );
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
}
break;
default:
return EKeyWasNotConsumed;
break;
}
return EKeyWasConsumed;
}
// ----------------------------------------------------
// CHelloWorld2AppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CHelloWorld2AppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EEikCmdExit:
{
Exit();
break;
}
case EHelloWorld2CmdAppTest:
{
iEikonEnv->InfoMsg(_L("test"));
break;
}
// TODO: Add Your command handling code here
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -