sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "TestCameraApp.h" sl@0: #include "TestCameraApp.hrh" sl@0: #include "TestCamera.h" sl@0: sl@0: const TInt KMaxErrLength=50; sl@0: _LIT(KErrorFormat,"Error - %d (%S)"); sl@0: sl@0: // sl@0: // CTCamAppUi sl@0: // sl@0: sl@0: void CTCamAppUi::ConstructL() sl@0: { sl@0: CEikAppUi::ConstructL(); sl@0: iAppView = new(ELeave) CTCamAppView; sl@0: iAppView->ConstructL(ClientRect()); sl@0: AddToStackL(iAppView); sl@0: sl@0: // The plugin relies on a specific file existing sl@0: // hence this has to be created. sl@0: CreateDependencyFileL(); sl@0: sl@0: iCamera = CCamera::NewL(*this,0,0); sl@0: sl@0: iCameraAdvSet = CCamera::CCameraAdvancedSettings::NewL(*iCamera); sl@0: iCameraPresets = CCamera::CCameraPresets::NewL(*iCamera); sl@0: iCameraImgProc = CCamera::CCameraImageProcessing::NewL(*iCamera); sl@0: iCameraSnapshot = CCamera::CCameraSnapshot::NewL(*iCamera); sl@0: sl@0: iCamera->Reserve(); sl@0: } sl@0: sl@0: CTCamAppUi::~CTCamAppUi() sl@0: { sl@0: if (iCamera!=NULL) sl@0: iCamera->Release(); sl@0: sl@0: delete iCameraSnapshot; sl@0: delete iCameraImgProc; sl@0: delete iCameraPresets; sl@0: delete iCameraAdvSet; sl@0: delete iCamera; sl@0: sl@0: // as the application is being closed, delete the file sl@0: // so that the plugin will not be reactivated accidentaly sl@0: RemoveDependencyFile(); sl@0: sl@0: if (iAppView) sl@0: { sl@0: RemoveFromStack(iAppView); sl@0: delete iAppView; sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::HandleCommandL(TInt aCommand) sl@0: { sl@0: switch (aCommand) sl@0: { sl@0: case ETCamCmdPowerOn: sl@0: iCamera->PowerOn(); sl@0: break; sl@0: case ETCamCmdPowerOff: sl@0: iCamera->PowerOff(); sl@0: break; sl@0: case ETCamCmdViewFinder: sl@0: ViewFinderL(); sl@0: break; sl@0: case ETCamCmdCaptureImage: sl@0: SingleShotL(); sl@0: break; sl@0: case ETCamCmdBurstMode: sl@0: BurstModeL(); sl@0: break; sl@0: case ETCamCmdCaptureVideo: sl@0: CaptureVideoL(); sl@0: break; sl@0: case ETCamCmdIncBrightness: sl@0: iCamera->SetBrightnessL(iCamera->Brightness() + 10); sl@0: break; sl@0: case ETCamCmdIncContrast: sl@0: iCamera->SetContrastL(iCamera->Contrast() + 10); sl@0: break; sl@0: case ETCamCmdDecBrightness: sl@0: iCamera->SetBrightnessL(iCamera->Brightness() - 10); sl@0: break; sl@0: case ETCamCmdDecContrast: sl@0: iCamera->SetContrastL(iCamera->Contrast() - 10); sl@0: break; sl@0: case ETCamCmdResetBrightness: sl@0: iCamera->SetBrightnessL(0); sl@0: break; sl@0: case ETCamCmdResetContrast: sl@0: iCamera->SetContrastL(0); sl@0: break; sl@0: case ETCamCmdIncNumBurstImages: sl@0: iCameraAdvSet->SetBurstImages(iCameraAdvSet->BurstImages() + 1); sl@0: break; sl@0: case ETCamCmdDecNumBurstImages: sl@0: iCameraAdvSet->SetBurstImages(iCameraAdvSet->BurstImages() - 1); sl@0: break; sl@0: case ETCamCmdResetNumBurstImages: sl@0: iCameraAdvSet->SetBurstImages(4); sl@0: break; sl@0: sl@0: case ETCamCmdFactoryPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetFactoryDefault); sl@0: break; sl@0: sl@0: case ETCamCmdOutdoorPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetOutdoor); sl@0: break; sl@0: sl@0: case ETCamCmdOutdoorSportPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetOutdoorSport); sl@0: break; sl@0: sl@0: case ETCamCmdFogPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetFog); sl@0: break; sl@0: sl@0: case ETCamCmdNightPartyIndoorPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetNightPartyIndoor); sl@0: break; sl@0: sl@0: case ETCamCmdTextDocumentPreset: sl@0: iCameraPresets->SetPreset(KUidECamPresetTextDocument); sl@0: break; sl@0: sl@0: case ETCamCmdImgProcIncBrightness: sl@0: IncImgProcAdjustmentL(KUidECamEventImageProcessingAdjustBrightness); sl@0: break; sl@0: sl@0: case ETCamCmdImgProcDecBrightness: sl@0: DecImgProcAdjustmentL(KUidECamEventImageProcessingAdjustBrightness); sl@0: break; sl@0: sl@0: case ETCamCmdImgProcIncContrast: sl@0: IncImgProcAdjustmentL(KUidECamEventImageProcessingAdjustContrast); sl@0: break; sl@0: sl@0: case ETCamCmdImgProcDecContrast: sl@0: DecImgProcAdjustmentL(KUidECamEventImageProcessingAdjustContrast); sl@0: break; sl@0: sl@0: case ETCamCmdEnableSnapshot: sl@0: EnableSnapshotL(); sl@0: break; sl@0: sl@0: case ETCamCmdDisableSnapshot: sl@0: DisableSnapshot(); sl@0: break; sl@0: sl@0: case EEikCmdExit: sl@0: Exit(); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::ViewFinderL() sl@0: { sl@0: TSize imageSize; sl@0: iCamera->EnumerateCaptureSizes(imageSize,1,CCamera::EFormatFbsBitmapColor16M); sl@0: const TPoint pos = iAppView->DrawBorders(imageSize); sl@0: TRect screenRect(pos,imageSize); sl@0: TRect clipRect; sl@0: sl@0: if (!iCamera->ViewFinderActive()) sl@0: { sl@0: iCamera->StartViewFinderDirectL(iCoeEnv->WsSession(),*iCoeEnv->ScreenDevice(),*iAppView->DrawableWindow(),screenRect,clipRect); sl@0: } sl@0: else sl@0: { sl@0: iCamera->StopViewFinder(); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::BurstModeL() sl@0: { sl@0: if (!iCameraAdvSet) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: if(CCamera::CCameraAdvancedSettings::EDriveModeBurst & iCameraAdvSet->SupportedDriveModes() ) sl@0: { sl@0: iCameraAdvSet->SetDriveMode(CCamera::CCameraAdvancedSettings::EDriveModeBurst); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::EnableSnapshotL() sl@0: { sl@0: if(!iCameraSnapshot->IsSnapshotActive()) sl@0: { sl@0: TSize size; sl@0: iCamera->EnumerateCaptureSizes(size,1,CCamera::EFormatFbsBitmapColor16M); sl@0: if(iCameraSnapshot->SupportedFormats() & CCamera::EFormatFbsBitmapColor4K) sl@0: { sl@0: iCameraSnapshot->PrepareSnapshotL(CCamera::EFormatFbsBitmapColor4K, TPoint(0,0), size, KRgbWhite, EFalse); sl@0: iCameraSnapshot->StartSnapshot(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::DisableSnapshot() sl@0: { sl@0: if(iCameraSnapshot->IsSnapshotActive()) sl@0: { sl@0: iCameraSnapshot->StopSnapshot(); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::SingleShotL() sl@0: { sl@0: if (!iCameraAdvSet) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: if(CCamera::CCameraAdvancedSettings::EDriveModeSingleShot & iCameraAdvSet->SupportedDriveModes() ) sl@0: { sl@0: iCameraAdvSet->SetDriveMode(CCamera::CCameraAdvancedSettings::EDriveModeSingleShot); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::CaptureImageL() sl@0: { sl@0: TSize size; sl@0: iCamera->EnumerateCaptureSizes(size,1,CCamera::EFormatFbsBitmapColor16M); sl@0: iCamera->PrepareImageCaptureL(CCamera::EFormatFbsBitmapColor16M,1); sl@0: iCamera->CaptureImage(); sl@0: } sl@0: sl@0: void CTCamAppUi::CaptureVideoL() sl@0: { sl@0: if (!iCamera->VideoCaptureActive()) sl@0: { sl@0: iCameraSnapshot->StopSnapshot(); sl@0: sl@0: TSize size; sl@0: TReal32 rate = 0; sl@0: iCamera->EnumerateVideoFrameSizes(size,0,CCamera::EFormatFbsBitmapColor16M); sl@0: iCamera->EnumerateVideoFrameRates(rate,0,CCamera::EFormatFbsBitmapColor16M,0); sl@0: iCamera->PrepareVideoCaptureL(CCamera::EFormatFbsBitmapColor16M,0,0,2,1); sl@0: iCamera->StartVideoCapture(); sl@0: } sl@0: else sl@0: { sl@0: iCamera->StopVideoCapture(); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::IncImgProcAdjustmentL(TUid aTransformation) sl@0: { sl@0: if(!iCameraImgProc) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: RArray supportedTransformations; sl@0: CleanupClosePushL(supportedTransformations); sl@0: iCameraImgProc->GetSupportedTransformationsL(supportedTransformations); sl@0: sl@0: TInt error = supportedTransformations.Find(aTransformation); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: if(error == KErrNotFound) sl@0: { sl@0: User::Leave(error); sl@0: } sl@0: sl@0: TInt valuetx; sl@0: User::LeaveIfError(iCameraImgProc->GetTransformationValue(aTransformation, valuetx)); sl@0: sl@0: iCameraImgProc->SetTransformationValue(aTransformation, valuetx + 10); sl@0: } sl@0: sl@0: void CTCamAppUi::DecImgProcAdjustmentL(TUid aTransformation) sl@0: { sl@0: if(!iCameraImgProc) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: RArray supportedTransformations; sl@0: CleanupClosePushL(supportedTransformations); sl@0: iCameraImgProc->GetSupportedTransformationsL(supportedTransformations); sl@0: sl@0: TInt error = supportedTransformations.Find(aTransformation); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: if(error == KErrNotFound) sl@0: { sl@0: User::Leave(error); sl@0: } sl@0: sl@0: TInt valuetx; sl@0: User::LeaveIfError(iCameraImgProc->GetTransformationValue(aTransformation, valuetx)); sl@0: sl@0: iCameraImgProc->SetTransformationValue(aTransformation, valuetx - 10); sl@0: } sl@0: sl@0: void CTCamAppUi::ReserveComplete(TInt /*aError*/) sl@0: { sl@0: } sl@0: sl@0: void CTCamAppUi::PowerOnComplete(TInt /*aError*/) sl@0: { sl@0: } sl@0: sl@0: void CTCamAppUi::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/) sl@0: { sl@0: } sl@0: sl@0: void CTCamAppUi::ImageReady(CFbsBitmap* aBitmap,HBufC8* /*aData*/,TInt aError) sl@0: { sl@0: TBuf msgBuffer; sl@0: _LIT(KErrMessage,"CTCamAppUi::ImageReady"); sl@0: if (aBitmap) sl@0: { sl@0: iAppView->DrawImage(aBitmap); sl@0: delete aBitmap; sl@0: } sl@0: if (aError) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,aError,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::FrameBufferReady(MFrameBuffer* aFrameBuffer,TInt aError) sl@0: { sl@0: TBuf msgBuffer; sl@0: _LIT(KErrMessage,"CTCamAppUi::FrameBufferReady"); sl@0: if (aError) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,aError,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: return; sl@0: } sl@0: TRAPD(error,iAppView->DrawImage(aFrameBuffer->FrameL(0))); sl@0: aFrameBuffer->Release(); sl@0: if (error) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,error,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::HandleEvent(const TECAMEvent& aEvent) sl@0: { sl@0: if(!TECAMEvent2::IsEventEncapsulationValid(aEvent)) sl@0: { sl@0: HandleEvent1(aEvent); sl@0: } sl@0: else sl@0: { sl@0: HandleEvent2(static_cast(aEvent)); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::HandleEvent2(const TECAMEvent2& /*aEvent2*/) sl@0: { sl@0: sl@0: } sl@0: sl@0: void CTCamAppUi::HandleEvent1(const TECAMEvent& aEvent) sl@0: { sl@0: TBuf msgBuffer; sl@0: sl@0: switch(aEvent.iEventType.iUid) sl@0: { sl@0: case KUidECamEventCameraSettingDriveModeUidValue: sl@0: { sl@0: if(!aEvent.iErrorCode) sl@0: { sl@0: TRAPD(error,CaptureImageL()); sl@0: if(error) sl@0: { sl@0: _LIT(KErrMessage,"CaptureImage"); sl@0: msgBuffer.Format(KErrorFormat,error,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: _LIT(KErrMessage,"SettingDriveMode"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: case KUidECamEventBurstImagesUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"SettingNumOfBurstImage"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: case KUidECamEventSnapshotUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"SnapshotDataNotification"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: else sl@0: { sl@0: if(iCamera->ViewFinderActive()) sl@0: { sl@0: iCamera->StopViewFinder(); sl@0: } sl@0: sl@0: TRAPD(error, SnapshotDataDisplayL()); sl@0: sl@0: if(error != KErrNone) sl@0: { sl@0: _LIT(KErrMessage,"SnapshotDataDisplay"); sl@0: msgBuffer.Format(KErrorFormat,error,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetFactoryDefaultUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"FactoryPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetOutdoorUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"OutdoorPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetOutdoorSportUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"OutdoorSportPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetFogUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"FogPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetNightPartyIndoorUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"NightPartyIndoorPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamPresetTextDocumentUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"TextDocumentPreset"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamEventImageProcessingAdjustBrightnessUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"ImageProcessingAdjustBrightness"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: case KUidECamEventImageProcessingAdjustContrastUidValue: sl@0: { sl@0: if(aEvent.iErrorCode) sl@0: { sl@0: _LIT(KErrMessage,"ImageProcessingAdjustContrast"); sl@0: msgBuffer.Format(KErrorFormat,aEvent.iErrorCode,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::ViewFinderReady(MCameraBuffer& /*aCameraBuffer*/,TInt /*aError*/) sl@0: { sl@0: sl@0: } sl@0: sl@0: void CTCamAppUi::ImageBufferReady(MCameraBuffer& aCameraBuffer,TInt aError) sl@0: { sl@0: TBuf msgBuffer; sl@0: _LIT(KErrMessage,"CTCamAppUi::ImageBufferReady"); sl@0: if(aError) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,aError,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: return; sl@0: } sl@0: if(!iCameraSnapshot->IsSnapshotActive()) sl@0: { sl@0: if (iCamera->ViewFinderActive()) sl@0: { sl@0: iCamera->StopViewFinder(); sl@0: } sl@0: TRAP(aError,iAppView->DrawImage(&aCameraBuffer.BitmapL(0))); sl@0: } sl@0: sl@0: aCameraBuffer.Release(); sl@0: sl@0: if (aError) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,aError,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: sl@0: } sl@0: sl@0: void CTCamAppUi::VideoBufferReady(MCameraBuffer& aCameraBuffer,TInt aError) sl@0: { sl@0: TBuf msgBuffer; sl@0: _LIT(KErrMessage,"CTCamAppUi::FrameBufferReady"); sl@0: if (aError) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,aError,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: return; sl@0: } sl@0: TRAPD(error,iAppView->DrawImage(&aCameraBuffer.BitmapL(0))); sl@0: aCameraBuffer.Release(); sl@0: if (error) sl@0: { sl@0: msgBuffer.Format(KErrorFormat,error,&KErrMessage); sl@0: iEikonEnv->InfoMsg(msgBuffer); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::SnapshotDataDisplayL() sl@0: { sl@0: RArray array; sl@0: array.Reset(); sl@0: RTestCameraFrameBuffer& buffer = static_cast(iCameraSnapshot->SnapshotDataL(array)); sl@0: iAppView->DrawImage(&buffer.BitmapL(0)); sl@0: array.Close(); sl@0: buffer.Release(); sl@0: } sl@0: sl@0: void CTCamAppUi::CreateDependencyFileL() sl@0: { sl@0: // enforce dependency sl@0: // create the file the plugin depends on. sl@0: User::LeaveIfError(ifsSession.Connect()); sl@0: RFile file; sl@0: TInt err = file.Replace(ifsSession, KTestCameraPluginName, EFileShareAny); sl@0: file.Close(); sl@0: if(err != KErrNone) sl@0: { sl@0: User::LeaveIfError(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: void CTCamAppUi::RemoveDependencyFile() sl@0: { sl@0: ifsSession.Delete(KTestCameraPluginName); sl@0: ifsSession.Close(); sl@0: } sl@0: sl@0: // sl@0: // CTCamAppView sl@0: // sl@0: sl@0: CTCamAppView::CTCamAppView(): sl@0: CCoeControl() sl@0: { sl@0: } sl@0: sl@0: void CTCamAppView::ConstructL(const TRect& /*aRect*/) sl@0: { sl@0: CreateWindowL(); sl@0: EnableDragEvents(); sl@0: SetExtentToWholeScreen(); sl@0: ActivateL(); sl@0: } sl@0: sl@0: CTCamAppView::~CTCamAppView() sl@0: { sl@0: } sl@0: sl@0: void CTCamAppView::DrawImage(CFbsBitmap* aImage) const sl@0: { sl@0: CWindowGc& gc = SystemGc(); sl@0: gc.Activate(Window()); sl@0: TRect drawRect=Rect(); sl@0: TPoint pos; sl@0: pos.iX = (3 * drawRect.iBr.iX / 4) - (aImage->SizeInPixels().iWidth / 2); sl@0: pos.iY = (drawRect.iBr.iY - aImage->SizeInPixels().iWidth) / 2; sl@0: gc.BitBlt(pos,aImage); sl@0: TRect border(pos,aImage->SizeInPixels()); sl@0: border.Grow(1,1); sl@0: gc.DrawRect(border); sl@0: gc.Deactivate(); sl@0: iCoeEnv->WsSession().Flush(); sl@0: } sl@0: sl@0: void CTCamAppView::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: CWindowGc& gc = SystemGc(); sl@0: TRect drawRect(Rect()); sl@0: drawRect.Shrink(1,1); sl@0: gc.DrawRect(drawRect); sl@0: gc.Clear(); sl@0: } sl@0: sl@0: TPoint CTCamAppView::DrawBorders(const TSize& aSize) const sl@0: { sl@0: CWindowGc& gc = SystemGc(); sl@0: gc.Activate(Window()); sl@0: TRect drawRect(Rect()); sl@0: TPoint pos; sl@0: pos.iX = (drawRect.iBr.iX / 4) - (aSize.iWidth / 2); sl@0: pos.iY = (drawRect.iBr.iY - aSize.iWidth) / 2; sl@0: TRect border(pos,aSize); sl@0: border.Grow(1,1); sl@0: gc.SetPenColor(KRgbBlack); sl@0: gc.DrawRect(border); sl@0: gc.Deactivate(); sl@0: iCoeEnv->WsSession().Flush(); sl@0: return pos; sl@0: } sl@0: sl@0: // sl@0: // CTCamDocument sl@0: // sl@0: sl@0: CTCamDocument::CTCamDocument(CEikApplication& aApp) sl@0: : CEikDocument(aApp) sl@0: { sl@0: } sl@0: sl@0: CEikAppUi* CTCamDocument::CreateAppUiL() sl@0: { sl@0: return new(ELeave) CTCamAppUi; sl@0: } sl@0: sl@0: // sl@0: // CTCamApp sl@0: // sl@0: sl@0: TUid CTCamApp::AppDllUid() const sl@0: { sl@0: return KUidTestCameraApp; sl@0: } sl@0: sl@0: CApaDocument* CTCamApp::CreateDocumentL() sl@0: { sl@0: return new(ELeave) CTCamDocument(*this); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // Base factory function sl@0: // sl@0: sl@0: #include sl@0: LOCAL_C CApaApplication* NewApplication() sl@0: { sl@0: return new CTCamApp; sl@0: } sl@0: sl@0: // sl@0: // EXE Entry point sl@0: // sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: return EikStart::RunApplication(NewApplication); sl@0: } sl@0: sl@0: sl@0: sl@0: