|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * WORDTESTPICTURE.CPP |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "WPTESTPICTURE.H" |
|
21 #include "WPPANIC.H" |
|
22 |
|
23 const TInt KWordTestPictureDimensions = 500; //width & height in twips |
|
24 |
|
25 EXPORT_C void TWordTestPictureFactory::NewPictureL( |
|
26 TPictureHeader& aHeader, const CStreamStore& aDeferredPictureStore) const |
|
27 { |
|
28 if (aHeader.iPictureType==KUidWordTestPictureType) |
|
29 { |
|
30 aHeader.iPicture=CWordTestPicture::NewL(aDeferredPictureStore,aHeader.iPicture.AsId()); |
|
31 } |
|
32 else |
|
33 { |
|
34 Panic(EPictureTypeNotSupported); |
|
35 } |
|
36 } |
|
37 |
|
38 EXPORT_C CWordTestPicture* CWordTestPicture::NewLC() |
|
39 { |
|
40 CWordTestPicture* p = new(ELeave) CWordTestPicture(); |
|
41 CleanupStack::PushL(p); |
|
42 return p; |
|
43 } |
|
44 |
|
45 EXPORT_C CWordTestPicture* CWordTestPicture::NewL(const CStreamStore& aStore,TStreamId aId) |
|
46 { |
|
47 CWordTestPicture* self=new(ELeave) CWordTestPicture(); |
|
48 CleanupStack::PushL(self); |
|
49 self->RestoreL(aStore,aId); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 EXPORT_C CWordTestPicture::CWordTestPicture() |
|
55 :iOriginalSizeInTwips(KWordTestPictureDimensions,KWordTestPictureDimensions) |
|
56 { |
|
57 ResetToOriginal(); |
|
58 } |
|
59 |
|
60 EXPORT_C CWordTestPicture::~CWordTestPicture() |
|
61 { |
|
62 } |
|
63 |
|
64 EXPORT_C void CWordTestPicture::ExternalizeL(RWriteStream& aStream)const |
|
65 { |
|
66 aStream.WriteUint32L(iLabel); |
|
67 } |
|
68 |
|
69 |
|
70 EXPORT_C void CWordTestPicture::InternalizeL(RReadStream& aStream) |
|
71 { |
|
72 iLabel=(TChar)aStream.ReadUint32L(); |
|
73 } |
|
74 |
|
75 EXPORT_C void CWordTestPicture::RestoreL(const CStreamStore& aStore,TStreamId aStreamId) |
|
76 { |
|
77 RStoreReadStream stream; |
|
78 stream.OpenLC(aStore,aStreamId); |
|
79 stream>> *this; |
|
80 CleanupStack::PopAndDestroy(); |
|
81 } |
|
82 |
|
83 |
|
84 EXPORT_C void CWordTestPicture::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const |
|
85 //draw a red square |
|
86 { |
|
87 aGc.Reset(); |
|
88 aGc.SetClippingRect(aClipRect); |
|
89 TSize size; |
|
90 GetSizeInPixels(aMap,size); |
|
91 TRect box; |
|
92 box.iTl=aTopLeft; |
|
93 box.iBr.iX=aTopLeft.iX+size.iWidth; |
|
94 box.iBr.iY=aTopLeft.iY+size.iHeight; |
|
95 TRgb red(255,0,0); |
|
96 aGc.SetBrushColor(red); |
|
97 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
98 aGc.DrawRect(box); |
|
99 } |
|
100 |
|
101 EXPORT_C void CWordTestPicture::GetOriginalSizeInTwips(TSize& aSize)const |
|
102 // |
|
103 { |
|
104 aSize=iOriginalSizeInTwips; |
|
105 } |