📄 videocontainer.cpp
字号:
/*
* ============================================================================
* Name : CVideoContainer from VideoContainer.h
* Part of : Video
* Created : 10/14/2003 by Forum Nokia
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: Forum Nokia
* ============================================================================
*/
#include "VideoContainer.h"
#include <aknlists.h>
#include "FileList.hrh"
#include "FileListEngine.h"
#include "VideoAppUi.h"
#include <video.rsg>
#include <eikbtgpc.h>
const TInt KClientAreaScreenheight = 160;
const TInt KClientAreaScreenWidth = 176;
/*
-----------------------------------------------------------------------------
void CVideoContainer::ConstructL(const TRect& aRect)
Description: second phase constructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::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 );
// Create the file list engine and prepare for listing all the files
// in the Nokia video directory
iFileListEngine = new (ELeave) CFileListEngine;
SetFileList( EFileListVideos, EFileListDate );
SetRect(aRect);
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();
}
/*
-----------------------------------------------------------------------------
CVideoContainer::~CVideoContainer()
Description: destructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CVideoContainer::~CVideoContainer()
{
if ( iListBox )
iAvkonAppUi->RemoveFromStack(iListBox);
delete iListBox;
delete iFileListEngine;
}
/*
-----------------------------------------------------------------------------
CVideoContainer::~CVideoContainer()
Description: Called by framework when the view size is changed
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::SizeChanged()
{
if ( iListBox )
iListBox->SetExtent(TPoint(0,0),TSize(KClientAreaScreenWidth,KClientAreaScreenheight));
}
/*
-----------------------------------------------------------------------------
TInt CVideoContainer::CountComponentControls() const
Description: Called by framework to return number of controls in the
container class.
Comments :
Return values: Number of the controls in the container
-----------------------------------------------------------------------------
*/
TInt CVideoContainer::CountComponentControls() const
{
if ( iListBox )
return 1;
else
return 0;
}
/*
-----------------------------------------------------------------------------
CCoeControl* CVideoContainer::ComponentControl(TInt aIndex ) const
Description: Called by framework to control pointers according to index
Comments :
Return values: CCoeControl pointer
-----------------------------------------------------------------------------
*/
CCoeControl* CVideoContainer::ComponentControl(TInt aIndex ) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
/*
-----------------------------------------------------------------------------
void CVideoContainer::Draw(const TRect& aRect) const
Description: Called by framework to draw the screen
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
/*
-----------------------------------------------------------------------------
void CVideoContainer::HandleControlEventL(
CCoeControl* aControl,TCoeEvent aEventType )
Description: Called by framework to handle control event
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
/*
-----------------------------------------------------------------------------
void CVideoContainer::SetFileList(TInt aDirectory, TInt aSizeDate)
Description: set up filelist. Directory and Size can be changed. See
Filelist.hrh for possible values. This function is located in
the container and not in the engine, because it activates the
listbox.Called by framework to handle control event.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::SetFileList(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 listbox
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 FileList
if(iFileListEngine->StartFileList() == KErrNone)
{
// Create FileList Items in the ListBox
iFileListEngine->GetFileListItems(items);
}
// Close FileList session
iFileListEngine->EndFileList();
// Refresh the listbox due to model change
iListBox->HandleItemAdditionL();
iListBox->SetCurrentItemIndex(0);
iListBox->DrawNow();
}
/*
-----------------------------------------------------------------------------
TKeyResponse CVideoContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
Description: Called by framework when a key is pressed
Comments :
Return values: whether the key has been consumed or not.
-----------------------------------------------------------------------------
*/
TKeyResponse CVideoContainer::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
if ( static_cast<CVideoAppUi*>iAvkonAppUi->GetVideoEngine( )->GetEngineState() ==
EPPlaying || static_cast<CVideoAppUi*>iAvkonAppUi->GetVideoEngine( )->GetEngineState() ==
EPPaused )
return EKeyWasConsumed;
TFileName fileName;
iFileListEngine->GetVideoFilePathAndNameAtPositon(iListBox->CurrentItemIndex(), fileName);
static_cast<CVideoAppUi*>iAvkonAppUi->PlayVideoFileL( fileName );
// Change the menu to "pause" and "Stop"
iCba = CEikButtonGroupContainer::Current();
if( iCba)
{
iCba->SetCommandSetL( R_VIDEO_PAUSE_STOP );
iCba->DrawNow();
}
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.
if ( static_cast<CVideoAppUi*>iAvkonAppUi->GetVideoEngine( )->GetEngineState() ==
EPPlaying || static_cast<CVideoAppUi*>iAvkonAppUi->GetVideoEngine( )->GetEngineState() ==
EPPaused )
return EKeyWasConsumed;
else
return iListBox->OfferKeyEventL(aKeyEvent, aType);
break;
}
default:
// Let Listbox take care of its key handling
return iListBox->OfferKeyEventL(aKeyEvent, aType);
break;
}
}
/*
-----------------------------------------------------------------------------
void CVideoContainer::GetCurrentVideoFileNameL(TDes &aFileName)
Description: Get the current video file name.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVideoContainer::GetCurrentVideoFileNameL(TDes &aFileName)
{
iFileListEngine->GetVideoFilePathAndNameAtPositon(iListBox->CurrentItemIndex(), aFileName);
}
/*
-----------------------------------------------------------------------------
TInt CVideoContainer::GetNumOfItemsInListBox()
Description: Get the total number of items in the listbox
Comments :
Return values: number of items in the current list box
-----------------------------------------------------------------------------
*/
TInt CVideoContainer::GetNumOfItemsInListBox()
{
// Set the listbox to use the the file list model
CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
return items->Count();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -