📄 vibraappui.cpp
字号:
/*
============================================================================
Name : CVibraAppUi from VibraAppui.cpp
Author :
Version :
Copyright : Your copyright notice
Description : CVibraAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include "VibraAppui.h"
#include "VibraView.h"
#include "VibraView2.h"
#include <Vibra.rsg>
#include "Vibra.hrh"
#include "Vibra.h"
#include <avkon.hrh>
#include <aknnotewrappers.h> // for CAknInformationNote
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CVibraAppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CVibraAppUi::ConstructL()
{
BaseConstructL();
iVibra = CVibra::NewL();
iVibra->StartVibraL(2000, 100);
// 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();
iTabGroup->SetObserver( this );
}
CVibraView* view1 = new (ELeave) CVibraView;
CleanupStack::PushL( view1 );
view1->ConstructL();
AddViewL( view1 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(); // view1
CVibraView2* view2 = new (ELeave) CVibraView2;
CleanupStack::PushL( view2 );
view2->ConstructL();
AddViewL( view2 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(); // view2
SetDefaultViewL(*view1);
}
// ----------------------------------------------------
// CVibraAppUi::~CVibraAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CVibraAppUi::~CVibraAppUi()
{
delete iDecoratedTabGroup;
delete iVibra;
}
// ------------------------------------------------------------------------------
// CVibraAppUi::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 CVibraAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CVibraAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CVibraAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
if ( iTabGroup == NULL )
{
return EKeyWasNotConsumed;
}
if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
{
return iTabGroup->OfferKeyEventL( aKeyEvent, aType );
}
else
{
return EKeyWasNotConsumed;
}
}
// ----------------------------------------------------
// CVibraAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CVibraAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EEikCmdExit:
{
Exit();
break;
}
case EVibraCmdAppTest:
{
iEikonEnv->InfoMsg(_L("test"));
break;
}
// TODO: Add Your command handling code here
case EVibraCmdStartVibra:
iVibra->StartVibraL(300, 16);
break;
case EVibraCmdStopVibra:
iVibra->StopVibraL();
break;
case EVibraCmdStepVibra:
iVibra->VibraGraduallyUp(100, 50, 60);
break;
case EVibraCmdStatusVibra:
{
CVibraControl::TVibraModeState status = iVibra->VibraSettings();
if (status == CVibraControl::EVibraModeON)
{
_LIT(KVibraModeOnPromot, "EVibraModeON");
CAknInformationNote* informationNote =new ( ELeave )CAknInformationNote;
informationNote->ExecuteLD(KVibraModeOnPromot());
}
else
{
_LIT(KVibraModeOffPromot, "EVibraModeOFF");
CAknInformationNote* informationNote =new ( ELeave )CAknInformationNote;
informationNote->ExecuteLD(KVibraModeOffPromot());
}
}
break;
default:
break;
}
}
// ----------------------------------------------------
// CVibraAppUi::TabChangedL(TInt aIndex)
// This method gets called when CAknTabGroup active
// tab has changed.
// ----------------------------------------------------
//
void CVibraAppUi::TabChangedL(TInt aIndex)
{
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(aIndex)));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -