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

📄 cameraappview.cpp

📁 S60官方摄像头程序
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CCameraAppView from CameraAppView.h
*  Part of  : CameraApp
*  Created  : 02/09/2004 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: Nokia Corperation
* ============================================================================
*/

#include <aknviewappui.h>
#include <avkon.hrh>
#include <eikmenup.h>
#include <CameraApp.rsg>
#include "CameraAppView.h"
#include "CameraAppContainer.h" 
#include "CameraApp.hrh"
#include "CameraAppController.h"


/*
-----------------------------------------------------------------------------

	void CCameraAppView::ConstructL()

	Description: Symbian 2nd phase constructor can leave.
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::ConstructL()
    {
    BaseConstructL( R_CAMERAAPP_VIEW1 );
    }


/*
-----------------------------------------------------------------------------

	CCameraAppView* CCameraAppView::NewLC( CCameraAppController& aController )

	Description: Two-phased constructor.
	Comments   :

    Return values: CCameraAppView object pointer

-----------------------------------------------------------------------------
*/
CCameraAppView* CCameraAppView::NewLC( CCameraAppController& aController )
    {
    CCameraAppView* self = new( ELeave ) CCameraAppView( aController );
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;  
    }

/*
-----------------------------------------------------------------------------

	CCameraAppView::~CCameraAppView()

	Description: destructor, free allocated resources
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
CCameraAppView::~CCameraAppView()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }

    delete iContainer;
    }

/*
-----------------------------------------------------------------------------

	TUid CCameraAppView::Id() const

	Description: return the view ID
	Comments   :

    Return values: return the view ID

-----------------------------------------------------------------------------
*/
TUid CCameraAppView::Id() const
    {
    return KViewIdStandard;
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppView::HandleCommandL(TInt aCommand)

	Description: takes care of command handling
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::HandleCommandL(TInt aCommand)
    {   
    switch ( aCommand )
        {
        case EAknSoftkeyOk:
            {
            iEikonEnv->InfoMsg( _L("view1 ok") );
            break;
            }

        case EAknSoftkeyBack:
            {
            AppUi()->HandleCommandL(EEikCmdExit);
            break;
            }

        default:
            {
            AppUi()->HandleCommandL( aCommand );
            break;
            }
        }
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppPortraitView::HandleClientRectChange()

	Description: called by framework when client rect changes
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::HandleClientRectChange()
    {
    if ( iContainer )
        {
        iContainer->SetRect( ClientRect() );
        }
    }


/*
-----------------------------------------------------------------------------

	void CCameraAppView::DoActivateL( const TVwsViewId& aPrevViewId,
					TUid aCustomMessageId, const TDesC8& aCustomMessage )

	Description: called by framework when view is activated
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::DoActivateL(
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
   const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
        {
        iContainer = new (ELeave) CCameraAppContainer( iController );
        iContainer->SetMopParent(this);

		// Set the controller to the correct mode before the viewfinding
		iController.SetCameraMode( ECameraLandscapeMode );

        iContainer->ConstructL( ClientRect() );
        AppUi()->AddToStackL( *this, iContainer );
        iContainer->SetFocus( ETrue );
        } 
   }


/*
-----------------------------------------------------------------------------

	void CCameraAppView::DoDeactivate()

	Description: called by framework when view is deactivated
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::DoDeactivate()
    {
    if ( iContainer )
        {
        iContainer->SetFocus(EFalse);
        AppUi()->RemoveFromViewStack( *this, iContainer );
		delete iContainer;
		iContainer = NULL;
        }    
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppView::DynInitMenuPaneL(
			TInt aResourceId,CEikMenuPane* aMenuPane)

	Description: 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.
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppView::DynInitMenuPaneL(
    TInt aResourceId, CEikMenuPane* aMenuPane )
    {
    if ( aResourceId == R_CAMERAAPP_APP_MENU )
		{
		// If image has been converted, then hide the "Snap" menu item
		TEngineState state = iController.GetEngineState();

		// If the engine is not in the idle state, bar the "Snap" function
		// from being accessed.
		if ( state != EEngineIdle || iController.IsCameraUsedByAnotherApp() )
			aMenuPane->SetItemDimmed( ECameraAppCmdSnap, ETrue );

		// Only when the engine is in the converted state, show the "
		// "New image" menu item
		if ( state == EConverted )
			aMenuPane->SetItemDimmed( ECameraAppCmdNewImage, EFalse );
		else
			aMenuPane->SetItemDimmed( ECameraAppCmdNewImage, ETrue );
		}
    }

⌨️ 快捷键说明

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