sl@0: // Copyright (c) 2000-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 "scrdevextension.h" sl@0: #include "../SERVER/w32cmd.h" sl@0: #include sl@0: #include "CLIENT.H" sl@0: #include "w32comm.h" sl@0: sl@0: CWsScreenDevice::CScrDevExtension::CScrDevExtension(RWsBuffer *aBuffer,TInt32 aWsHandle): MWsClientClass(aBuffer) sl@0: { sl@0: iWsHandle=aWsHandle; sl@0: __ASSERT_DEBUG(aBuffer,Panic(EW32PanicBadClientInterface)); sl@0: __ASSERT_DEBUG(aWsHandle,Panic(EW32PanicBadClientInterface)); sl@0: } sl@0: sl@0: CWsScreenDevice::CScrDevExtension::~CScrDevExtension() sl@0: { sl@0: //typeface store is not owned by this class, and is created/destroyed in CWsScreenDevice sl@0: } sl@0: /** Interface Extension capability sl@0: * Use of this interface going forward will allow the published client interface to be dynamically extended. sl@0: * Note that the pointer returned is only good for the lifetime of the called CBase derived object. sl@0: * @pre caller has already checked that the implementation is initialised using RepeatableConstruct sl@0: * @param aInterfaceId uniqueid or well known id of interface sl@0: * @return pointer to interface object matching this ID or NULL if no match. sl@0: **/ sl@0: void* CWsScreenDevice::CScrDevExtension::GetInterface(TUint aInterfaceId) sl@0: { sl@0: __ASSERT_DEBUG(this!=NULL,Panic(EW32PanicBadClientInterface)); sl@0: __ASSERT_DEBUG(iBuffer,Panic(EW32PanicBadClientInterface)); sl@0: __ASSERT_DEBUG(iWsHandle!=NULL,Panic(EW32PanicBadClientInterface)); sl@0: sl@0: switch (aInterfaceId) sl@0: { sl@0: case MTestScreenCapture::ETypeId: sl@0: { sl@0: return static_cast(this); sl@0: } sl@0: default: sl@0: break; sl@0: } sl@0: return NULL; sl@0: } sl@0: //Accessor to typeface store instance sl@0: CFbsTypefaceStore* CWsScreenDevice::CScrDevExtension::TypefaceStore() sl@0: { sl@0: return iTypefaceStore; sl@0: } sl@0: //Accessor to typeface store instance sl@0: void CWsScreenDevice::CScrDevExtension::SetTypefaceStore(CFbsTypefaceStore* aTypeFaceStore) sl@0: { sl@0: iTypefaceStore=aTypeFaceStore; sl@0: } sl@0: sl@0: sl@0: TInt CWsScreenDevice::CScrDevExtension::TranslateExtent(const TRect& aInitial, TRect& aTarget) const sl@0: { sl@0: // Current screen mode scale sl@0: TPckgBuf pntPkg; sl@0: TInt err = WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScale); sl@0: TSize scale = pntPkg(); sl@0: sl@0: // Current screen mode offset sl@0: TPckgBuf soPkg; sl@0: err = WriteReplyP(&soPkg,EWsSdOpGetCurrentScreenModeScaledOrigin); sl@0: TPoint offset = soPkg(); sl@0: sl@0: // Calculate the top left point taking into account scale and offset sl@0: TInt startingPointWidth = (scale.iWidth * aInitial.iTl.iX) + offset.iX; sl@0: TInt startingPointHeight = (scale.iHeight * aInitial.iTl.iY) + offset.iY; sl@0: TPoint targetXY(startingPointWidth,startingPointHeight); sl@0: sl@0: // Calculate the extent size taking into account scale sl@0: TInt targetWidth = (scale.iWidth * aInitial.Width()); sl@0: TInt targetHeight = (scale.iHeight * aInitial.Height()); sl@0: TSize targetSize(targetWidth,targetHeight); sl@0: sl@0: aTarget.SetRect(targetXY,targetSize); sl@0: return err; sl@0: } sl@0: sl@0: sl@0: /** Gets the size of the screen device area in pixels. sl@0: sl@0: This function always causes a flush of the window server buffer. sl@0: sl@0: @return The x and y dimensions of the screen device area, in pixels. sl@0: @see CGraphicsDevice::SizeInPixels() */ sl@0: TInt CWsScreenDevice::CScrDevExtension::GetCompositedSize(TSize& aSize) const sl@0: { sl@0: TPckgBuf sizePkg; sl@0: TInt err = WriteReplyP(&sizePkg,EWsSdOpPixelSize); sl@0: aSize = sizePkg(); sl@0: return err; sl@0: } sl@0: sl@0: sl@0: sl@0: /** Saves the entire screen to a bitmap. sl@0: sl@0: This function always causes a flush of the window server buffer. sl@0: sl@0: @param aBitmap Bitmap to be filled with the screen image. sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */ sl@0: TInt CWsScreenDevice::CScrDevExtension::ComposeScreen(const CFbsBitmap& aBitmap) const sl@0: { sl@0: TInt bitmapHandle = aBitmap.Handle(); sl@0: AddToBitmapArray(bitmapHandle); sl@0: TWsSdCmdCopyScreenToBitmap rectCompare(bitmapHandle); sl@0: return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap)); sl@0: }