⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countdown.cpp

📁 EMCC源代码 Symbian S60第二版
💻 CPP
字号:
// countdown.cpp
//
// Copyright (c) Symbian Software Ltd 1999 - 2007.  All rights reserved.
//

#include "simpleex.h"
#include "countdown.h"

/*============================================================================
      CCountdown active object
      Displays a countdown from 10 after which it displays an alert dialog.
==============================================================================*/

CCountdown* CCountdown::NewL(CSimpleExAppView *aAppView)
	{
    CCountdown* self = new(ELeave) CCountdown;
    CleanupStack::PushL(self);
    self->ConstructL(aAppView);
    CleanupStack::Pop(self);
    return self;
	}

CCountdown::CCountdown() 
	: CActive(CActive::EPriorityUserInput)
	  // Construct high-priority active object
{}

void CCountdown::ConstructL(CSimpleExAppView* aAppView)
	{
    iCount=0;
    iAppView = aAppView;
    User::LeaveIfError(iTimer.CreateLocal());

    iInterval = 1000000;  // 1 second interval
	  // Add to active scheduler
	CActiveScheduler::Add(this);
	}


void CCountdown::StartCountdown()
	{
// This method is invoked when user selects the start menu item to start
// the countdown.
     
    if (iCount == 0)
    	{
        iCount=10;
        iTimer.After(iStatus,iInterval);
        SetActive();
    	}
	}

CCountdown::~CCountdown()
	{
	// Make sure we're cancelled
	Cancel();
    iTimer.Close();
	}

void CCountdown::RunL()
	{
    TBuf<50> buff;
	_LIT(KFormatString,"-%d-");
    buff.Format(KFormatString,iCount);
    iAppView->UpdateScreenText(buff);

    if (iCount)
    	{
        iTimer.After(iStatus,iInterval);
        SetActive();
        --iCount;
    	} 
    else
    	{
        iAppView->UpdateScreenText(KSimpleExText);
		_LIT(KMessage,"Start Selected!");
        CEikonEnv::Static()->AlertWin(KMessage);
    	}     
	}

void CCountdown::Stop()
	{
    iCount=0;
    iAppView->UpdateScreenText(KSimpleExText);
    Cancel();
	}

void CCountdown::DoCancel()
	{
    iTimer.Cancel();
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -