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

📄 myclockappui.cpp

📁 Symbian 平台上活动对象的一个实例。
💻 CPP
字号:
/*
============================================================================
 Name		: MyClockAppUi.cpp
 Author	  : 
 Copyright   : Your copyright notice
 Description : CMyClockAppUi implementation
============================================================================
*/

// INCLUDE FILES
#include <eikbtgpc.h>   // for CEikButtonGroupContainer
#include "MyClockAppui.h"
#include "MyClockContainer.h" 
#include "MyClock.hrh"
#include "MyClock.rsg"

#include "TimerModel.h"
#include <aknquerydialog.h> 
#include <aknglobalconfirmationquery.h>
#include <avkon.hrh>

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CMyClockAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CMyClockAppUi::ConstructL()
	{
	BaseConstructL();
	
    iModel = new(ELeave) CTimerModel();
/*	iAppContainer = new (ELeave) CMyClockContainer;
	iAppContainer->SetMopParent( this );
	iAppContainer->ConstructL( ClientRect(),*iModel);*/
    iAppContainer =CMyClockContainer::newL(ClientRect(),*iModel);
	AddToStackL( iAppContainer );
    iTimer = CCountdownTimer::NewL(*this);
	}

// ----------------------------------------------------
// CMyClockAppUi::~CMyClockAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CMyClockAppUi::~CMyClockAppUi()
	{
	delete iTimer;
	delete iModel;
	if (iAppContainer)
		{
		RemoveFromStack( iAppContainer );
		delete iAppContainer;
		}
	}

// ------------------------------------------------------------------------------
// CMyClockAppUi::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 CMyClockAppUi::DynInitMenuPaneL(
	TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
	{
	}

// ----------------------------------------------------
// CMyClockAppUi::HandleKeyEventL(
//	 const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CMyClockAppUi::HandleKeyEventL(
	const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
	{
	return EKeyWasNotConsumed;
	}

// ----------------------------------------------------
// CMyClockAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CMyClockAppUi::OnTimerL(const TTime& aTime)
    {
    iModel->SetTime(aTime);
    iAppContainer->RefreshL();
    if(aTime.Int64()<=0)
        {
        SetCbaL(R_TIMER_SOFTKEY_SET_EXIT);
        TRequestStatus status=KRequestPending;
        HBufC* prompt = iCoeEnv->AllocReadResourceLC(R_TIMER_CONFIRMATION);
        CAknGlobalConfirmationQuery* global = CAknGlobalConfirmationQuery::NewLC();
        global->ShowConfirmationQueryL(status, *prompt, R_AVKON_SOFTKEYS_OK_EMPTY, 
            R_QGN_NOTE_INFO_ANIM, KNullDesC, 0, 0, CAknQueryDialog::EConfirmationTone, ETrue);
        User::WaitForRequest(status);
        CleanupStack::PopAndDestroy(2); // prompt, global
        }
    }
void CMyClockAppUi::HandleCommandL(TInt aCommand)
	{
	switch ( aCommand )
		{
	    case ETimerCmdSet:
            {
            TTimeIntervalSeconds duration=0;
            CAknDurationQueryDialog* dlg = CAknDurationQueryDialog::NewL(
                duration, CAknQueryDialog::ENoTone );
            TInt ret = dlg->ExecuteLD( R_TIMER_QUERY );
            if(ret)
                {
                TTime time(0);
                time+=duration;
                iTimer->Start(time);
                SetCbaL(R_TIMER_SOFTKEY_EMPTY_CANCEL);
                }
            break;
            }
        case ETimerCmdCancel:
            {
            iTimer->Stop();
            TTime time(0);
            iModel->SetTime(time);
            iAppContainer->RefreshL();
            SetCbaL(R_TIMER_SOFTKEY_SET_EXIT);
            break;
            }
		case EAknSoftkeyBack:
		case EEikCmdExit:
			{
			Exit();
			break;
			}
		case EMyClockCmdAppTest:
			{
			iEikonEnv->InfoMsg(_L("test"));
			break;
			}
		// TODO: Add Your command handling code here

		default:
			break;	  
		}
	}
void CMyClockAppUi::SetCbaL(TInt aResourceId)
    {
    if ( aResourceId != 0 )
        {
        CEikButtonGroupContainer* cba = Cba();
        cba->SetCommandSetL(aResourceId);
        cba->DrawDeferred();
        }
    }

⌨️ 快捷键说明

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