filmreel2appui.cpp

来自「最新官方例子,图形,描述副,基本控件,通讯协议,等等,」· C++ 代码 · 共 191 行

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

// INCLUDE FILES

// Class include
#include "FilmReel2AppUi.h"

// System includes
#include <AknNoteWrappers.h>	// CAknWarningNote
#include <AknQueryDialog.h>		// CAknQueryDialog 
#include <eikmenup.h>			// CEikMenuPane
#include <StringLoader.h>		// StringLoader 

// User includes
#include <FilmReel2.rsg>			// own resources
#include "FilmReel2.hrh"			// own enumerations
#include "FilmReel2Container.h"	// CFilmReel2Container

// Constants
// REMOVED AT REQUEST OF NOKIA--
//const TUid KMediaGalleryAppUid = {  };	// UID of Photo album application
//const TUid KMediaGalleryViewUid = {  };		// 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 CFilmReel2AppUi::ConstructL()
	{
	// Enable skin option.
	BaseConstructL(EAknEnableSkin);

	iAppContainer = CFilmReel2Container::NewL(ClientRect());
	iAppContainer->SetMopParent(this);
	AddToStackL(iAppContainer);
	}

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

/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
*/
void CFilmReel2AppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case EFilmReel2Record:
			iAppContainer->RecordModeL();
			break;
		case EFilmReel2Continue:
			iAppContainer->PreviewModeL();
			break;
		case EFilmReel2LaunchPhotoAlbum:
			{
			// Launch photo album app
// REMOVED AT REQUEST OF NOKIA--
//			CCoeAppUi::ActivateViewL(TVwsViewId(KMediaGalleryAppUid, KMediaGalleryViewUid));
//--
// Instead show warning--
			_LIT(KNoSwitch, "Cannot switch to Media Gallery");
			CAknWarningNote* note = new (ELeave) CAknWarningNote;
			note->ExecuteLD(KNoSwitch);
//--
			break;
			}
		case EFilmReel2Delete:
			{
			// 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 CFilmReel2AppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_FILMREEL2_OPTIONS_MENU)
        {
        switch (iAppContainer->CurrentState())
            {
			case CFilmReel2Container::EPreviewing:
				aMenuPane->SetItemDimmed(EFilmReel2Continue, ETrue);
				break;
			case CFilmReel2Container::ERecording:
				aMenuPane->SetItemDimmed(EFilmReel2Record, ETrue);
				aMenuPane->SetItemDimmed(EFilmReel2Continue, ETrue);
				break;
			case CFilmReel2Container::EDisplayingResult:
				aMenuPane->SetItemDimmed(EFilmReel2Record, ETrue);
				break;
			case CFilmReel2Container::ESavingImage:
				aMenuPane->SetItemDimmed(EFilmReel2Record, ETrue);
				aMenuPane->SetItemDimmed(EFilmReel2Continue, ETrue);
				break;
			case CFilmReel2Container::EPoweredDown:
				aMenuPane->SetItemDimmed(EFilmReel2Record, ETrue);
				break;
			case CFilmReel2Container::ENotReady:
				aMenuPane->SetItemDimmed(EFilmReel2Record, ETrue);
				aMenuPane->SetItemDimmed(EFilmReel2Continue, ETrue);
				break;
			default:
				break;
			}
		}
    }

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

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

	// Default return value
    return(EKeyWasNotConsumed); 
    }

TBool CFilmReel2AppUi::ShowDeleteConfirmationQueryL()
	{
	HBufC* prompt = StringLoader::LoadLC(R_DELETE_IMAGE_TEXT, iAppContainer->ImageName());
	CAknQueryDialog* dlg = CAknQueryDialog::NewL();

	dlg->SetPromptL(prompt->Des());
	CleanupStack::PopAndDestroy(prompt);

    return dlg->ExecuteLD(R_DELETE_GAME_CONFIRMATION_QUERY );
	}

// End of File	

⌨️ 快捷键说明

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