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

📄 readicoappview.cpp

📁 symbian 平台下
💻 CPP
字号:
/*
 ============================================================================
 Name		: ReadICOAppView.cpp
 Author	  : 
 Copyright   : Your copyright notice
 Description : Application view implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include "ReadICOAppView.h"

_LIT(KPath,"C:\\data\\tv"); // Give your path here
_LIT(KFileName,"*.jpg"); // Give file name here

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

// -----------------------------------------------------------------------------
// CReadICOAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CReadICOAppView* CReadICOAppView::NewL(const TRect& aRect)
	{
	CReadICOAppView* self = CReadICOAppView::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

// -----------------------------------------------------------------------------
// CReadICOAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CReadICOAppView* CReadICOAppView::NewLC(const TRect& aRect)
	{
	CReadICOAppView* self = new ( ELeave ) CReadICOAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

// -----------------------------------------------------------------------------
// CReadICOAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CReadICOAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();

	// Set the windows size
	SetRect(aRect);

	// Activate the window, which makes it ready to be drawn
	ActivateL();
	iFilesArray = new (ELeave) CDesCArrayFlat(5);
	FindFiles();
//	iImage_Reader = CImage_Reader::NewL(KICOFile,*this);
	iImage_Reader = CImage_Reader::NewL((*iFilesArray)[0],*this);
	iCurentMap = 0;
	}

// -----------------------------------------------------------------------------
// CReadICOAppView::CReadICOAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CReadICOAppView::CReadICOAppView()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CReadICOAppView::~CReadICOAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CReadICOAppView::~CReadICOAppView()
	{
	// No implementation required
	delete iFilesArray;
	delete iImage_Reader;
	}

// -----------------------------------------------------------------------------
// CReadICOAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CReadICOAppView::Draw(const TRect& /*aRect*/) const
	{
	// Get the standard graphics context
	CWindowGc& gc = SystemGc();

	// Gets the control's extent
	TRect drawRect(Rect());

	// Clears the screen
	gc.Clear(drawRect);
	if (iBitmap)
		{
		gc.BitBlt(TPoint(0,0), iBitmap);
		}

	}

// -----------------------------------------------------------------------------
// CReadICOAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CReadICOAppView::SizeChanged()
	{
	DrawNow();
	}
void CReadICOAppView::FindFiles()
{
 RFs aFs=iCoeEnv->FsSession();
 StartScanL(aFs, KPath, KFileName, iFilesArray);
}
void CReadICOAppView::StartScanL(RFs aFs, const TDesC& aPath, 
		const TDesC& aWild, CDesCArray* aArray)
    {
    CDirScan* DirScan = CDirScan::NewLC(aFs);
    DirScan->SetScanDataL(aPath, 
        KEntryAttDir|KEntryAttMatchExclusive, 
        ESortNone, CDirScan::EScanDownTree);
 
    while(1)
        {
        CDir* dir = NULL;
        TRAPD(error, DirScan->NextL(dir));
        if (error || !dir)
            break;
		
        delete dir;
 
        ScanDirectoryL(aFs, DirScan->FullPath(), aWild, aArray);
        };
    CleanupStack::PopAndDestroy(DirScan);
    }
void CReadICOAppView::ScanDirectoryL(
    RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aArray)
    {
    TParse parse;
    parse.Set(aWild, &aDir, NULL);
    TPtrC spec(parse.FullName());
 
    TFindFile FindFile(aFs);
    CDir* dir;
 
    if (!FindFile.FindWildByPath(parse.FullName(), NULL, dir))
        {
        CleanupStack::PushL(dir);
 
        for(TInt i = 0; i < dir->Count(); i++)
            {
            parse.Set((*dir)[i].iName, &spec, NULL);
            aArray->AppendL(parse.FullName());
            }
        CleanupStack::PopAndDestroy(dir);
        }
    }
void CReadICOAppView::DisplayImageL( TInt aIndex )
	{
	TInt index;
	TInt count = iFilesArray->Count();
	if ( 0 == count )
		{
		return;
		}
	
	if ( 0 > aIndex )
		{
		iCurentMap--;
		}
	else
		{
		iCurentMap++;
		}
	
	
	if ( iCurentMap >= count )
		{
		iCurentMap = 0;
		}
	else if (iCurentMap < 0 )
		{
		iCurentMap = count-1;
		}	
	
	delete iImage_Reader;
	iImage_Reader = CImage_Reader::NewL((*iFilesArray)[iCurentMap],*this);
	}
void CReadICOAppView::ImageReadyL(const TInt& aError)
	{
	iBitmap = iImage_Reader->Bitmap();
	DrawNow();
	}

TKeyResponse CReadICOAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	TKeyResponse ret = EKeyWasNotConsumed;
	if ( aType == EEventKeyUp )
		{
		switch (aKeyEvent.iScanCode)
			{
			case EStdKeyLeftArrow:
				{
				DisplayImageL( 1 );
				ret = EKeyWasConsumed;
				}
				break;
			case EStdKeyRightArrow:
				{
				DisplayImageL( -1 );
				ret = EKeyWasConsumed;
				}
				break;
			default:
				{
				ret = EKeyWasNotConsumed;
				}
				break;
			}
		}
	return ret;
  }
// End of File

⌨️ 快捷键说明

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