?? exerciseevent.cpp
字號:
#include "ExerciseEvent.h"
//pbserver's pattern
CExerciseEvent::CExerciseEvent(MEventObserver& aObserver)
:CActive(CActive::EPriorityStandard),iObserver(aObserver)
{
iStop=EFalse;
}
CExerciseEvent::~CExerciseEvent()
{
Cancel();
iTimer.Close();
}
void CExerciseEvent::DoCancel()
{
iTimer.Cancel();
iStop = ETrue;
}
void CExerciseEvent::ConstructL()
{
iTimer.CreateLocal();//create colock
CActiveScheduler::Add(this);//and add it to CActiveScheduler
Start();
}
CExerciseEvent* CExerciseEvent::NewL(MEventObserver& aObserver)
{
CExerciseEvent* self=CExerciseEvent::NewLC(aObserver);
CleanupStack::Pop( self );
return self;
}
CExerciseEvent* CExerciseEvent::NewLC(MEventObserver& aObserver)
{
CExerciseEvent* self = new(ELeave) CExerciseEvent(aObserver);
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
void CExerciseEvent::Start()
{
if(IsActive())
return;
iTimer.After(iStatus,1000);//set 1000ms
SetActive();
}
void CExerciseEvent::RunL()//implenment RunL
{
if(!iStop)
{
iTime.HomeTime();//get time
TDateTime dt;
dt=iTime.DateTime();//store time in dt
_LIT(KTIME,"Time: %d:%d:%d\n");
TBuf<100> buf;
buf.Format(KTIME,dt.Hour(),dt.Minute(),dt.Second());
iObserver.UpdateEvent(buf);//update label's text
Start();
}
else
CActiveScheduler::Stop();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -