📄 stopwatchappui.cpp
字号:
/*
* ============================================================================
* Name : CStopwatchAppUi from StopwatchAppui.cpp
* Part of : Stopwatch
* Created : 05.02.2006 by ToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include <eikbtgpc.h> // for CEikButtonGroupContainer
#include <avkon.hrh>
#include <Stopwatch.rsg>
#include "StopwatchAppUi.h"
#include "StopwatchModel.h"
#include "StopwatchContainer.h"
#include "Stopwatch.hrh"
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CStopwatchAppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CStopwatchAppUi::ConstructL()
{
BaseConstructL();
iModel = new(ELeave)CStopwatchModel;
iAppContainer = CStopwatchContainer::NewL(ClientRect(), *iModel);
AddToStackL( iAppContainer );
iTimer = CStopwatchTimer::NewL(*this);
}
// ----------------------------------------------------
// CStopwatchAppUi::~CStopwatchAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CStopwatchAppUi::~CStopwatchAppUi()
{
delete iTimer;
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
delete iModel;
}
// new functions
void CStopwatchAppUi::OnTimerL(const TTime& aTime)
{
iModel->SetTime(aTime);
iAppContainer->RefreshL();
}
// ------------------------------------------------------------------------------
// CStopwatchAppUi::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 CStopwatchAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CStopwatchAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CStopwatchAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------
// CStopwatchAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CStopwatchAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EStopwatchCmdStart:
{
iTimer->Start();
SetCba(R_STOPWATCH_SOFTKEY_STOP_RESET);
break;
}
case EStopwatchCmdStop:
{
iTimer->Stop();
SetCba(R_STOPWATCH_SOFTKEY_RESUME_RESET);
break;
}
case EStopwatchCmdResume:
{
iTimer->Resume();
SetCba(R_STOPWATCH_SOFTKEY_STOP_RESET);
break;
}
case EStopwatchCmdReset:
{
iTimer->Reset();
SetCba(R_STOPWATCH_SOFTKEY_START_EXIT);
break;
}
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
default:
{
TBuf<32> buf;
_LIT(KCommandAsString, "Command ");
buf.Append(KCommandAsString);
buf.AppendNum(aCommand);
User::InfoPrint(buf);
break;
}
}
iAppContainer->RefreshL();
}
void CStopwatchAppUi::SetCba(TInt aResourceId)
{
if ( aResourceId != 0 )
{
CEikButtonGroupContainer* cba = Cba();
cba->SetCommandSetL(aResourceId);
cba->DrawDeferred();
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -