📄 aknexmenuappui.cpp
字号:
/* Copyright (c) 2005, Nokia. All rights reserved */
// INCLUDE FILES
#include <avkon.hrh>
#include <barsread.h>
#include <akntitle.h>
#include <aknnavi.h>
#include <akncontext.h>
#include <eikmenub.h>
#include <AknExMenu.rsg>
#include "AknExMenu.hrh"
#include "AknExMenuAppUi.h"
#include "AknExMenuView.h"
#include "AknExMenuContainer.h"
#include "AknExMenuSubView.h"
#include "AknExMenuSubContainer.h"
#include "AknExMenuOkView.h"
// ========================= MEMBER FUNCTIONS ==================================
// -----------------------------------------------------------------------------
// CAknExMenuAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAknExMenuAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL( EAknEnableSkin );
// Show tabs for main views from resources
CEikStatusPane *sp = StatusPane();
iTitlePane = static_cast<CAknTitlePane*>
( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle) ) ) ;
// Fetch pointer to the default navi pane control
iNaviPane = static_cast<CAknNavigationControlContainer*>
( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
if ( iDecoratedTabGroup )
{
iTabGroup = static_cast<CAknTabGroup*> ( iDecoratedTabGroup->
DecoratedControl() );
}
CAknExMenuView* view1 = new( ELeave ) CAknExMenuView;
CleanupStack::PushL( view1 );
view1->ConstructL( R_AKNEXMENU_NO_SUB_MENU );
CleanupStack::Pop();
// Transfer ownership to CAknViewAppUi
AddViewL( view1 );
CAknExMenuSubView* view2 = new( ELeave ) CAknExMenuSubView;
CleanupStack::PushL( view2 );
view2->ConstructL( R_AKNEXMENU_SUB_MENU );
CleanupStack::Pop();
// Transfer ownership to CAknViewAppUi
AddViewL( view2 );
CAknExMenuOkView* view3 = new( ELeave ) CAknExMenuOkView;
CleanupStack::PushL( view3 );
view3->ConstructL( R_AKNEXMENU_OK_MENU );
CleanupStack::Pop();
// Transfer ownership to CAknViewAppUi
AddViewL( view3 );
ActivateLocalViewL( view1->Id() );
}
// -----------------------------------------------------------------------------
// CAknExMenuAppUi::~CAknExMenuAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CAknExMenuAppUi::~CAknExMenuAppUi()
{
delete iDecoratedTabGroup;
delete iAppContainer;
}
// -----------------------------------------------------------------------------
// CAknExMenuAppUi::DynInitMenuPaneL()
// 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 CAknExMenuAppUi::DynInitMenuPaneL( TInt /*aResourceId*/,
CEikMenuPane* /*aMenuPane*/ )
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CAknExMenuAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CAknExMenuAppUi::HandleCommandL( TInt aCommand )
{
switch ( aCommand )
{
case EEikCmdExit:
case EAknCmdExit:
User::Exit( 0 );
break;
// TODO: Add Your command handling code here
default:
break;
}
}
// -----------------------------------------------------------------------------
// CAknExMenuAppUi::HandleKeyEventL()
// Takes care of key event handling.
// -----------------------------------------------------------------------------
//
TKeyResponse CAknExMenuAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
TEventCode /*aType*/ )
{
iTabGroup = static_cast<CAknTabGroup*> ( iDecoratedTabGroup->
DecoratedControl() );
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;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -