filmreelappui.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 180 行

CPP
180
字号
/**
* 
* @brief Definition of CFilmReelAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "FilmReelAppUi.h"

// System includes
#include <AknQueryDialog.h>        // CAknQueryDialog 
#include <eikmenup.h>            // CEikMenuPane
#include <StringLoader.h>        // StringLoader 
#include <FilmReel.rsg>            // own resources

// User includes
#include "FilmReel.hrh"            // own enumerations
#include "FilmReelContainer.h"    // CFilmReelContainer

// Constants
const TUid KPhotoAlbumAppUid = { 0x101F4CD1 };    // UID of Photo album application
const TUid KPhotoAlbumViewUid = { 0x1 };        // UID of Photo album main view

// ================= MEMBER FUNCTIONS =======================

/**
* Symbian OS 2nd phase constructor.  Constructs the application's container, 
* setting itself as the container's MOP parent, and adds it to the control 
* stack.
*/        
void CFilmReelAppUi::ConstructL()
{
    BaseConstructL();
    iAppContainer = CFilmReelContainer::NewL(ClientRect());
    iAppContainer->SetMopParent(this);
    AddToStackL(iAppContainer);
}

/**
* Destructor.
* Removes the application's container from the stack and deletes it.
*/    
CFilmReelAppUi::~CFilmReelAppUi()
{
    if (iAppContainer)
    {
        RemoveFromStack(iAppContainer);
        delete iAppContainer;
    }
}

/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
*/
void CFilmReelAppUi::HandleCommandL(TInt aCommand)
{
    switch (aCommand)
    {
        case EFilmReelRecord:
            iAppContainer->RecordModeL();
            break;
        case EFilmReelContinue:
            iAppContainer->PreviewModeL();
            break;
        case EFilmReelLaunchPhotoAlbum:
            // Launch photo album app
            CCoeAppUi::ActivateViewL(TVwsViewId(KPhotoAlbumAppUid, KPhotoAlbumViewUid));
            break;
        case EFilmReelDelete:
        {
            // Delete filename
            // Launch dialog to confirm that the image should be deleted 
            if (ShowDeleteConfirmationQueryL())
            {
                CCoeEnv::Static()->FsSession().Delete(iAppContainer->FileName());
                iAppContainer->PreviewModeL();
            }
        }
            break;
        case EAknSoftkeyExit:
        case EAknSoftkeyBack:
        case EEikCmdExit:
        {
            Exit();
            break;
        }
        default:
            break;        
    }
}

/**
* From CEikAppUi, updates menu based on current state of appContainer
*
* @param aResourceId resource id of the menu pane
* @param aMenuPane menu pane
*/
void CFilmReelAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
    if (aResourceId == R_FILMREEL_OPTIONS_MENU)
    {
        switch (iAppContainer->CurrentState())
        {
            case CFilmReelContainer::EPreviewing:
                aMenuPane->SetItemDimmed(EFilmReelContinue, ETrue);
                break;
            case CFilmReelContainer::ERecording:
                aMenuPane->SetItemDimmed(EFilmReelRecord, ETrue);
                aMenuPane->SetItemDimmed(EFilmReelContinue, ETrue);
                break;
            case CFilmReelContainer::EDisplayingResult:
                aMenuPane->SetItemDimmed(EFilmReelRecord, ETrue);
                break;
            case CFilmReelContainer::ESavingImage:
                aMenuPane->SetItemDimmed(EFilmReelRecord, ETrue);
                aMenuPane->SetItemDimmed(EFilmReelContinue, ETrue);
                break;
            case CFilmReelContainer::EPoweredDown:
                aMenuPane->SetItemDimmed(EFilmReelRecord, ETrue);
                break;
            case CFilmReelContainer::ENotReady:
                aMenuPane->SetItemDimmed(EFilmReelRecord, ETrue);
                aMenuPane->SetItemDimmed(EFilmReelContinue, ETrue);
                break;
            default:
                break;
        }
    }
}

TKeyResponse CFilmReelAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
{
    TInt code = aKeyEvent.iCode;

    switch(code)
    {
        // navigator button is pressed
        case EKeyOK:
        {
            if (iAppContainer->CurrentState() == CFilmReelContainer::EPreviewing)
            {
                iAppContainer->RecordModeL();
            }
            else if ((iAppContainer->CurrentState() == CFilmReelContainer::EDisplayingResult)
                || (iAppContainer->CurrentState() == CFilmReelContainer::EPoweredDown))
            {
                iAppContainer->PreviewModeL();
            }
            return (EKeyWasConsumed);
        }
        default:
            break;
    }

    // Default return value
    return EKeyWasNotConsumed; 
}

TBool CFilmReelAppUi::ShowDeleteConfirmationQueryL()
{
    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
    CleanupStack::PushL(dlg);

    HBufC* prompt = StringLoader::LoadLC(R_DELETE_IMAGE_TEXT, iAppContainer->ImageName());
    dlg->SetPromptL(prompt->Des());

    CleanupStack::PopAndDestroy(prompt);
    CleanupStack::Pop(dlg);

    return dlg->ExecuteLD(R_DELETE_GAME_CONFIRMATION_QUERY );
}

// End of File    

⌨️ 快捷键说明

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