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

📄 camdecode_3rdappview.cpp

📁 PartiTekSDK.chm is for windows, Unix/Linux and WinCE/WinMobile platform. SDK_Manul_Symbian.pdf i
💻 CPP
字号:
/*
============================================================================
 Name        : CamDecode_3rdView.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Application view
============================================================================
*/

// INCLUDE FILES
#include <coemain.h>
#include "CamDecode_3rdAppView.h"
#include "CamEngine.h"
#include <eikclb.h>
#include <aknlists.h> 
#include <barsread.h>
#include <CamDecode_3rd.rsg>
#include "listbox.mbg"
#include "avkon.hrh" 

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

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

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

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

	iEngine = CCamEngine::NewL(*this);
	CreateWindowL();
	LoadBmp();

	iColListBox = new (ELeave) CAknSingleStyleListBox();
	iColListBox->SetContainerWindowL( *this );
	iColListBox->SetListBoxObserver(this);   
	TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC( reader, R_CAMDECODE_LISTBOX);
    iColListBox->ConstructFromResourceL( reader );

	
	iColListBox->CreateScrollBarFrameL( ETrue );
	iColListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
	CleanupStack::PopAndDestroy();
	iColListBox->SetRect(Rect());
	
	iColListBox->ActivateL();
	iColListBox->DrawNow();
//	iColListBox->MakeVisible(ETrue);

	// Set the windows size
	SetRect( aRect );

	// Activate the window, which makes it ready to be drawn
	ActivateL();
	}

// ---------------------------------------------------------
// CCamDecodeContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CCamDecode_3rdAppView::SizeChanged()
	{
	// TODO: Add here control resize code etc.
//	iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
//	iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
		iColListBox->SetExtent( TPoint(0,50), iColListBox->MinimumSize() );
	}

// ---------------------------------------------------------
// CCamDecodeContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CCamDecode_3rdAppView::CountComponentControls() const
	{
	return 1; // return nbr of controls inside this container
	}

// ---------------------------------------------------------
// CCamDecodeContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CCamDecode_3rdAppView::ComponentControl(TInt aIndex) const
	{
	switch ( aIndex )
		{
		case 0:
			return iColListBox;
/*	    case 1:
			return iToDoLabel;*/
		default:
			return NULL;
		}
	}
// -----------------------------------------------------------------------------
// CCamDecode_3rdAppView::CCamDecode_3rdAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CCamDecode_3rdAppView::CCamDecode_3rdAppView()
	{
	// No implementation required
	}


// -----------------------------------------------------------------------------
// CCamDecode_3rdAppView::~CCamDecode_3rdAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CCamDecode_3rdAppView::~CCamDecode_3rdAppView()
	{
	// No implementation required
		delete iEngine;
		delete iColListBox;
		delete iBitmap;
		delete iLogo;
	}


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

	// Clears the screen
	gc.Clear( aRect );

	if(!iClear)
	{
		if(!iCamStart)
			{
				TPoint topLeft(0, 0); // create TPoint object for top left of bitmap
				TRect iRect;
				iRect=TRect(TSize(aRect.Width(),50));
				gc.DrawBitmap(iRect, iLogo);
			}
		else
			{
				gc.BitBlt(TPoint(0,0),iBitmap,aRect);
			}
	}
}


void CCamDecode_3rdAppView::HandleControlEventL(CCoeControl*, TCoeEvent)
    {
    }

TKeyResponse CCamDecode_3rdAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
	if(EFalse == iCamStart)
	{
		return iColListBox->OfferKeyEventL(aKeyEvent,aType);
	}
	else
	{
		return EKeyWasNotConsumed;
	}
}

void CCamDecode_3rdAppView::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
	if( aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed)
	{
		if(iColListBox->CurrentItemIndex()==EFalse)
		{
			iDecodeType = EFalse;
		}
		else
		{
			iDecodeType = ETrue;
		}
		iEngine->Reserve();
		CEikButtonGroupContainer   *cba   =   CEikButtonGroupContainer::Current();  
		cba-> MakeCommandVisible(EAknSoftkeyOptions,false); 
		iColListBox->MakeVisible(EFalse);
	}
}

void CCamDecode_3rdAppView::StartFromMenu()
{
		if(iColListBox->CurrentItemIndex()==EFalse)
		{
			iDecodeType = EFalse;
		}
		else
		{
			iDecodeType = ETrue;
		}
		iEngine->Reserve();
		CEikButtonGroupContainer   *cba   =   CEikButtonGroupContainer::Current();  
		cba-> MakeCommandVisible(EAknSoftkeyOptions,false); 
		iColListBox->MakeVisible(EFalse);
}

void CCamDecode_3rdAppView::CloseCam()
   {
		iEngine->Exit();
		iCamStart=EFalse;
   }

void CCamDecode_3rdAppView::DrawImageNow(CFbsBitmap* aBitmap)
  {
	  iBitmap=aBitmap;
	  DrawNow();
  }

void CCamDecode_3rdAppView::SetZoomL(TBool aEnable)
 {
      iEngine->SetZoomFactorL( aEnable );
 }

void CCamDecode_3rdAppView::LoadBmp()
	{
		iLogo=new(ELeave)CFbsBitmap();
		_LIT(KMBMFILE,"\\resource\\apps\\listbox.mbm");
		TFileName file(KMBMFILE);
		User::LeaveIfError (CompleteWithAppPath (file));
		User::LeaveIfError(iLogo->Load(file,EMbmListboxPartitek));
	}

void CCamDecode_3rdAppView::ClearScr()
 {
	 iClear=ETrue;
     DrawNow();
	 iClear=EFalse;
 }
// End of File

⌨️ 快捷键说明

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