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

📄 simpleex_ui.cpp

📁 Developing.Software.for.Symbian.OS 书籍配套源码
💻 CPP
字号:
/*=================================================================

      File: simpleEx_ui.cpp

      This file contains the application UI class for SimpleEx.
      Enhanced to contain active object for Chapter 8 example.

==================================================================*/

#include "SimpleEx.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;
        buff.Format(_L("-%d-"),iCount);
        iAppView->UpdateScreenText(buff);


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

void CCountdown::Stop()

{
      iCount=0;
      iAppView->UpdateScreenText(KSimpleExText);
      Cancel();
}

void CCountdown::DoCancel()
{
      iTimer.Cancel();
}
/*-------------------------------------------------------------
     CSimpleExAppUi class
--------------------------------------------------------------*/

void CSimpleExAppUi::ConstructL()
{
    BaseConstructL();
	           
    iAppView = CSimpleExAppView::NewL(ClientRect());
    iCountdown = CCountdown::NewL(iAppView);
    iAppView->UpdateScreenText(KSimpleExText);
 
}


CSimpleExAppUi::~CSimpleExAppUi()
    {
    
     delete iAppView;
     iAppView = NULL;
     delete iCountdown;
    }
void CSimpleExAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case ESimpleExCommand:
           iCountdown->StartCountdown();
           break;
        
        case ESimpleExStop:
           iCountdown->Stop();
            
           break;

      }
    }

⌨️ 快捷键说明

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