sl@0
|
1 |
// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "scrdevextension.h"
|
sl@0
|
17 |
#include "../SERVER/w32cmd.h"
|
sl@0
|
18 |
#include <graphics/displaycontrolbase.h>
|
sl@0
|
19 |
#include "CLIENT.H"
|
sl@0
|
20 |
#include "w32comm.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
CWsScreenDevice::CScrDevExtension::CScrDevExtension(RWsBuffer *aBuffer,TInt32 aWsHandle): MWsClientClass(aBuffer)
|
sl@0
|
23 |
{
|
sl@0
|
24 |
iWsHandle=aWsHandle;
|
sl@0
|
25 |
__ASSERT_DEBUG(aBuffer,Panic(EW32PanicBadClientInterface));
|
sl@0
|
26 |
__ASSERT_DEBUG(aWsHandle,Panic(EW32PanicBadClientInterface));
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
CWsScreenDevice::CScrDevExtension::~CScrDevExtension()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
//typeface store is not owned by this class, and is created/destroyed in CWsScreenDevice
|
sl@0
|
32 |
}
|
sl@0
|
33 |
/** Interface Extension capability
|
sl@0
|
34 |
* Use of this interface going forward will allow the published client interface to be dynamically extended.
|
sl@0
|
35 |
* Note that the pointer returned is only good for the lifetime of the called CBase derived object.
|
sl@0
|
36 |
* @pre caller has already checked that the implementation is initialised using RepeatableConstruct
|
sl@0
|
37 |
* @param aInterfaceId uniqueid or well known id of interface
|
sl@0
|
38 |
* @return pointer to interface object matching this ID or NULL if no match.
|
sl@0
|
39 |
**/
|
sl@0
|
40 |
void* CWsScreenDevice::CScrDevExtension::GetInterface(TUint aInterfaceId)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
__ASSERT_DEBUG(this!=NULL,Panic(EW32PanicBadClientInterface));
|
sl@0
|
43 |
__ASSERT_DEBUG(iBuffer,Panic(EW32PanicBadClientInterface));
|
sl@0
|
44 |
__ASSERT_DEBUG(iWsHandle!=NULL,Panic(EW32PanicBadClientInterface));
|
sl@0
|
45 |
|
sl@0
|
46 |
switch (aInterfaceId)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
case MTestScreenCapture::ETypeId:
|
sl@0
|
49 |
{
|
sl@0
|
50 |
return static_cast<MTestScreenCapture*>(this);
|
sl@0
|
51 |
}
|
sl@0
|
52 |
default:
|
sl@0
|
53 |
break;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
return NULL;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
//Accessor to typeface store instance
|
sl@0
|
58 |
CFbsTypefaceStore* CWsScreenDevice::CScrDevExtension::TypefaceStore()
|
sl@0
|
59 |
{
|
sl@0
|
60 |
return iTypefaceStore;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
//Accessor to typeface store instance
|
sl@0
|
63 |
void CWsScreenDevice::CScrDevExtension::SetTypefaceStore(CFbsTypefaceStore* aTypeFaceStore)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
iTypefaceStore=aTypeFaceStore;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
|
sl@0
|
69 |
TInt CWsScreenDevice::CScrDevExtension::TranslateExtent(const TRect& aInitial, TRect& aTarget) const
|
sl@0
|
70 |
{
|
sl@0
|
71 |
// Current screen mode scale
|
sl@0
|
72 |
TPckgBuf<TSize> pntPkg;
|
sl@0
|
73 |
TInt err = WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScale);
|
sl@0
|
74 |
TSize scale = pntPkg();
|
sl@0
|
75 |
|
sl@0
|
76 |
// Current screen mode offset
|
sl@0
|
77 |
TPckgBuf<TPoint> soPkg;
|
sl@0
|
78 |
err = WriteReplyP(&soPkg,EWsSdOpGetCurrentScreenModeScaledOrigin);
|
sl@0
|
79 |
TPoint offset = soPkg();
|
sl@0
|
80 |
|
sl@0
|
81 |
// Calculate the top left point taking into account scale and offset
|
sl@0
|
82 |
TInt startingPointWidth = (scale.iWidth * aInitial.iTl.iX) + offset.iX;
|
sl@0
|
83 |
TInt startingPointHeight = (scale.iHeight * aInitial.iTl.iY) + offset.iY;
|
sl@0
|
84 |
TPoint targetXY(startingPointWidth,startingPointHeight);
|
sl@0
|
85 |
|
sl@0
|
86 |
// Calculate the extent size taking into account scale
|
sl@0
|
87 |
TInt targetWidth = (scale.iWidth * aInitial.Width());
|
sl@0
|
88 |
TInt targetHeight = (scale.iHeight * aInitial.Height());
|
sl@0
|
89 |
TSize targetSize(targetWidth,targetHeight);
|
sl@0
|
90 |
|
sl@0
|
91 |
aTarget.SetRect(targetXY,targetSize);
|
sl@0
|
92 |
return err;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
|
sl@0
|
96 |
/** Gets the size of the screen device area in pixels.
|
sl@0
|
97 |
|
sl@0
|
98 |
This function always causes a flush of the window server buffer.
|
sl@0
|
99 |
|
sl@0
|
100 |
@return The x and y dimensions of the screen device area, in pixels.
|
sl@0
|
101 |
@see CGraphicsDevice::SizeInPixels() */
|
sl@0
|
102 |
TInt CWsScreenDevice::CScrDevExtension::GetCompositedSize(TSize& aSize) const
|
sl@0
|
103 |
{
|
sl@0
|
104 |
TPckgBuf<TSize> sizePkg;
|
sl@0
|
105 |
TInt err = WriteReplyP(&sizePkg,EWsSdOpPixelSize);
|
sl@0
|
106 |
aSize = sizePkg();
|
sl@0
|
107 |
return err;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
/** Saves the entire screen to a bitmap.
|
sl@0
|
113 |
|
sl@0
|
114 |
This function always causes a flush of the window server buffer.
|
sl@0
|
115 |
|
sl@0
|
116 |
@param aBitmap Bitmap to be filled with the screen image.
|
sl@0
|
117 |
@return KErrNone if successful, otherwise one of the system-wide error codes. */
|
sl@0
|
118 |
TInt CWsScreenDevice::CScrDevExtension::ComposeScreen(const CFbsBitmap& aBitmap) const
|
sl@0
|
119 |
{
|
sl@0
|
120 |
TInt bitmapHandle = aBitmap.Handle();
|
sl@0
|
121 |
AddToBitmapArray(bitmapHandle);
|
sl@0
|
122 |
TWsSdCmdCopyScreenToBitmap rectCompare(bitmapHandle);
|
sl@0
|
123 |
return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap));
|
sl@0
|
124 |
}
|