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

📄 alarmappui.cpp

📁 Symbian s60 闹钟程序
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAlarmAppUi from AlarmAppui.cpp
*  Part of  : Alarm
*  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 <Alarm.rsg>

#include "AlarmAppUi.h"
#include "AlarmModel.h"
#include "AlarmContainer.h" 
#include "Alarm.hrh"

#include <aknquerydialog.h> 
#include <aknglobalconfirmationquery.h> 

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CAlarmAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CAlarmAppUi::ConstructL()
    {
    BaseConstructL();

    iModel = new(ELeave) CAlarmModel();
    iAppContainer = CAlarmContainer::NewL(ClientRect(), *iModel);
    AddToStackL( iAppContainer );
    iAlarm = CAlarmTimer::NewL(*this);
    }

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

// new functions
void CAlarmAppUi::OnTimerL(TInt aError)
    {
    TTime time = TInt64(0);
    iModel->SetTime(time);
    iAppContainer->RefreshL();
    SetCbaL(R_ALARM_SOFTKEY_SET_EXIT);
    if(aError==KErrNone)
        {
        TRequestStatus status=KRequestPending;
        HBufC* prompt = iCoeEnv->AllocReadResourceLC(R_ALARM_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
        }
    }

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

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

// ----------------------------------------------------
// CAlarmAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CAlarmAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
        case EAlarmCmdSet:
            {
            TTime date;
            date.HomeTime();
            TTime time;
            time.HomeTime();
            CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(date, time);
            TInt ret = dlg->ExecuteLD(R_ALARM_QUERY);
            if(ret)
                {
                TDateTime temp = date.DateTime();
                TDateTime target = time.DateTime();
                target.SetYear(temp.Year());
                target.SetMonth(temp.Month());
                target.SetDay(temp.Day());
                iModel->SetTime(target);
                iAppContainer->RefreshL();
                iAlarm->Start(target);
                SetCbaL(R_ALARM_SOFTKEY_EMPTY_CANCEL);
                }
            break;
            }
        case EAlarmCmdCancel:
            {
            iAlarm->Stop();
            TTime time = TInt64(0);
            iModel->SetTime(time);
            iAppContainer->RefreshL();
            SetCbaL(R_ALARM_SOFTKEY_SET_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 CAlarmAppUi::SetCbaL(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 + -