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

📄 vrexview.cpp

📁 nokia S60_video_operation
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CVRexView from VRexView.h
*  Part of  : Video Recording Example (VRex)
*  Created  : 16.03.2004 by Nokia Forum
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDE FILES
#include "VRexView.h"

#include "FileList.hrh"
#include "FileListEngine.h"
#include "VRexAppUi.h"
#include "VideoViewFinder.h"

#include <aknlists.h>
#include <vrex.rsg>

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

	void CVRexView::ConstructL(const TRect& aRect)

	Description: Second phase constructor.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

	iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
	iListBox->SetContainerWindowL(*this);
	iListBox->ConstructL(this, EAknListBoxMarkableList);
	iListBox->CreateScrollBarFrameL(ETrue);
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, 
			  CEikScrollBarFrame::EAuto);

	iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
    iListBox->ActivateL();

	iAvkonAppUi->AddToStackL(iListBox);

	// Get the file list of clips in video gallery
	UpdateFileListL();
	
	// Create video view finder
	iFinder = new (ELeave) CVideoViewFinder();
	iFinder->SetContainerWindowL(*this);
	iFinder->ConstructL(0);	// Use the first camera	

    // Set window size
    SetRect(aRect);

	// Set up the video player rectangle
	iVideoRect = Rect();
	TPoint point = PositionRelativeToScreen();
	iVideoRect.iTl.iX += point.iX;
	iVideoRect.iTl.iY += point.iY;
	iVideoRect.iBr.iX += point.iX;
	iVideoRect.iBr.iY += point.iY;
	iVideoRect.Shrink(1, 1);

    ActivateL();
    }

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

	void CVRexView::UpdateFileListL()

	Description: This method updates file list in list box.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::UpdateFileListL()
	{
	// Create the file list engine and prepare for listing all the files
	// in the Nokia video directory
	if(!iFileListEngine) 
		{
		iFileListEngine = new (ELeave) CFileListEngine;
		}
			
	SetFileListL(EFileListVideos, EFileListDate);
	}

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

	CVRexView::~CVRexView()	

	Description: Destructor.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
CVRexView::~CVRexView()
    {
	if(iListBox)
		{
		iAvkonAppUi->RemoveFromStack(iListBox);
		delete iListBox;
		iListBox = NULL;
		}		

	delete iFileListEngine;
	iFileListEngine = NULL;
	
	delete iFinder;
	iFinder = NULL;
    }

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

	void CVRexView::SizeChanged()
	
	Description: This method is called by framework when the view size is changed.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::SizeChanged()
    {
	if(iListBox)
		{
		iListBox->SetRect(Rect());
		}
	if(iFinder)
		{
		iFinder->SetRect(Rect());
		}

    }

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

	TInt CVRexView::CountComponentControls() const
	
	Description: This method is called by framework to get count of child controls.
	Comments   : 

    Return values: Component count

-----------------------------------------------------------------------------
*/
TInt CVRexView::CountComponentControls() const
    {
	if(iListBox || iFinder)
		return 1;
	else
		return 0;
    }

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

	CCoeControl* CVRexView::ComponentControl(TInt aIndex) const
	
	Description: This method is called by framework to get pointer to child control.
	Comments   : 

    Return values: CCoeControl object pointer

-----------------------------------------------------------------------------
*/
CCoeControl* CVRexView::ComponentControl(TInt aIndex) const
    {
    switch(aIndex)
        {
        case 0:
        	if(iFinder->State() == CVideoViewFinder::EFinderActive)
        		return iFinder;
        	else
	            return iListBox;
        default:
            return NULL;
        }
    }

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

	void CVRexView::Draw(const TRect& aRect) const
	
	Description: This method is called by framework to draw the view.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

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

	void CVRexView::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
	
	Description: This method handles an event from an observed control.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::HandleControlEventL(
	CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
	{  
	}

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

	void CVRexView::SetFileListL(TInt aDirectory, TInt aSizeDate)
	
	Description: This method sets directory listing to list box.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::SetFileListL(TInt aDirectory, TInt aSizeDate)
    {
    // Set the listbox to use the the file list model
    CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());

    // If there are items, they will be removed here
    if (iFileListEngine->RemoveItems(items)) 
        {
        // This makes changes to the actual list box
        iListBox->HandleItemRemovalL();  
        }

    // Let's show directory
    iFileListEngine->SetDirectory(aDirectory);  

    // Let's decide whether to show file size or modification date
    iFileListEngine->SetSizeDate(aSizeDate);

    // Do preparations for the file list
    if(iFileListEngine->StartFileList() == KErrNone)
        {        
        // Create file list items in the list box
        iFileListEngine->GetFileListItems(items);       
        }
    // Close file server session
    iFileListEngine->EndFileList();                  

    // Refresh the list box due to model change
	iListBox->HandleItemAdditionL();
    iListBox->SetCurrentItemIndex(0);
    iListBox->DrawNow();
    }

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

	TKeyResponse CVRexView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	
	Description: This method handles key events.
	Comments   : 

    Return values: TKeyResponse

-----------------------------------------------------------------------------
*/
TKeyResponse CVRexView::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    // See if we have a selection
    TInt code = aKeyEvent.iCode;
    switch(code)
        {
		// is navigator button pressed
    	case EKeyOK:
			{
			// During paused/playing state, pressing OK key should not replay 
			// the playing video clip
			CVideoPlayerAdapter::TPlayerState playerState = static_cast<CVRexAppUi*>iAvkonAppUi->iEngine->iVPlayer->State();

			if((playerState == CVideoPlayerAdapter::EPlaying) || 
			   (playerState == CVideoPlayerAdapter::EPaused))
				 return EKeyWasConsumed;

			TFileName fileName;
            iFileListEngine->GetVideoFilePathAndNameAtPositon(iListBox->CurrentItemIndex(), fileName);
			static_cast<CVRexAppUi*>iAvkonAppUi->PlayVideoFileL(fileName);

            return (EKeyWasConsumed);
            break;
			}

		case EKeyLeftArrow:
		case EKeyRightArrow:
		case EKeyUpArrow:
		case EKeyDownArrow:
			{
			// Just in case it refreshes the screen to flicker the screen during 
			// playing/paused when the key event is passed to the list box.
			TInt recState = static_cast<CVRexAppUi*>iAvkonAppUi->iEngine->iVRecorder->State();

			if(recState == CVideoRecorderAdapter::ERecording)
				 return EKeyWasConsumed;
			else
				return iListBox->OfferKeyEventL(aKeyEvent, aType);
			break;
			}

        default:
            // Let list box take care of its key handling
            return iListBox->OfferKeyEventL(aKeyEvent, aType);
            break;
        }
    }

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

	void CVRexView::GetCurrentVideoFileNameL(TDes &aFileName)
	
	Description: This method gets the current video file name.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::GetCurrentVideoFileNameL(TDes &aFileName)
	{
    iFileListEngine->GetVideoFilePathAndNameAtPositon(iListBox->CurrentItemIndex(), aFileName);
	}

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

	TInt CVRexView::GetNumOfItemsInListBox()
	
	Description: This method gets the total number of items in the list box.
	Comments   : 

    Return values: Number of items

-----------------------------------------------------------------------------
*/
TInt CVRexView::GetNumOfItemsInListBox()
	{
    // Set the list box to use the the file list model
    CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());

	return items->Count();
	}

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

	void CVRexView::StartFinderL()
	
	Description: This method starts video view finder display.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::StartFinderL()
	{
	if(iFinder)
		{
		iFinder->StartL();
		}
	}

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

	void CVRexView::StopFinder()
	
	Description: This method stops video view finder display.
	Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVRexView::StopFinder()
	{
	if(iFinder)
		{
		iFinder->Stop();
		}
	}

// End of File  

⌨️ 快捷键说明

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