sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* TestPicture.cpp test picture.
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "TestPicture.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
CTestPicture::CTestPicture()
|
sl@0
|
23 |
{
|
sl@0
|
24 |
iLineBreaksAllowed[0] = ETrue;
|
sl@0
|
25 |
iLineBreaksAllowed[1] = ETrue;
|
sl@0
|
26 |
iLineBreaksAllowed[2] = ETrue;
|
sl@0
|
27 |
iLineBreaksAllowed[3] = ETrue;
|
sl@0
|
28 |
iSizeInTwips.iWidth = 100;
|
sl@0
|
29 |
iSizeInTwips.iHeight = 100;
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
//draw a red square
|
sl@0
|
33 |
void CTestPicture::Draw(CGraphicsContext& aGc, const TPoint& aTopLeft,
|
sl@0
|
34 |
const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
|
sl@0
|
35 |
{
|
sl@0
|
36 |
aGc.Reset();
|
sl@0
|
37 |
aGc.SetClippingRect(aClipRect);
|
sl@0
|
38 |
TSize size;
|
sl@0
|
39 |
GetSizeInPixels(aMap,size);
|
sl@0
|
40 |
TRect box;
|
sl@0
|
41 |
box.iTl=aTopLeft;
|
sl@0
|
42 |
box.iBr.iX=aTopLeft.iX+size.iWidth;
|
sl@0
|
43 |
box.iBr.iY=aTopLeft.iY+size.iHeight;
|
sl@0
|
44 |
TRgb red(255,0,0);
|
sl@0
|
45 |
aGc.SetBrushColor(red);
|
sl@0
|
46 |
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
47 |
aGc.DrawRect(box);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
Does nothing.
|
sl@0
|
52 |
@param aStream No effect.
|
sl@0
|
53 |
@internalComponent
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
void CTestPicture::ExternalizeL(RWriteStream& /*aStream*/) const
|
sl@0
|
56 |
{
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
Returns size of picture.
|
sl@0
|
61 |
@param aSize
|
sl@0
|
62 |
Returns size of picture.
|
sl@0
|
63 |
@internalComponent
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
void CTestPicture::GetOriginalSizeInTwips(TSize& aSize) const
|
sl@0
|
66 |
{
|
sl@0
|
67 |
aSize = iSizeInTwips;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Returns information supplied by SetLineBreaksAllowed.
|
sl@0
|
72 |
@param aClass
|
sl@0
|
73 |
Not used.
|
sl@0
|
74 |
@param aBeforePicture As CPicture.
|
sl@0
|
75 |
@param aHaveSpaces As CPicture.
|
sl@0
|
76 |
@return TBool if line breaks are allowed.
|
sl@0
|
77 |
@internalComponent
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
TBool CTestPicture::LineBreakPossible(TUint /*aClass*/,
|
sl@0
|
80 |
TBool aBeforePicture, TBool aHaveSpaces) const
|
sl@0
|
81 |
{
|
sl@0
|
82 |
TInt index = aBeforePicture? 0 : 2;
|
sl@0
|
83 |
index += aHaveSpaces? 1 : 0;
|
sl@0
|
84 |
return iLineBreaksAllowed[index];
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
Set whether LineBreakPossible should return ETrue.
|
sl@0
|
89 |
@param aBeforeWithoutSpaces
|
sl@0
|
90 |
Sets the result of LineBreakPossible(*, ETrue, EFalse);
|
sl@0
|
91 |
@param aBeforeWithSpaces
|
sl@0
|
92 |
Sets the result of LineBreakPossible(*, ETrue, ETrue);
|
sl@0
|
93 |
@param aAfterWithoutSpaces
|
sl@0
|
94 |
Sets the result of LineBreakPossible(*, EFalse, EFalse);
|
sl@0
|
95 |
@param aAfterWithSpaces
|
sl@0
|
96 |
Sets the result of LineBreakPossible(*, EFalse, ETrue);
|
sl@0
|
97 |
@internalComponent
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
void CTestPicture::SetLineBreaksAllowed(
|
sl@0
|
100 |
TBool aBeforeWithoutSpaces,
|
sl@0
|
101 |
TBool aBeforeWithSpaces,
|
sl@0
|
102 |
TBool aAfterWithoutSpaces,
|
sl@0
|
103 |
TBool aAfterWithSpaces)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
iLineBreaksAllowed[0] = aBeforeWithoutSpaces;
|
sl@0
|
106 |
iLineBreaksAllowed[1] = aBeforeWithSpaces;
|
sl@0
|
107 |
iLineBreaksAllowed[2] = aAfterWithoutSpaces;
|
sl@0
|
108 |
iLineBreaksAllowed[3] = aAfterWithSpaces;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
Sets the picture size.
|
sl@0
|
113 |
@param aSize
|
sl@0
|
114 |
The size to set.
|
sl@0
|
115 |
@internalComponent
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
void CTestPicture::SetSizeInTwips(TSize aSize)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
iSizeInTwips = aSize;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
Sets the picture size so that the graphics device map aMap will convert to
|
sl@0
|
124 |
the size specified.
|
sl@0
|
125 |
@param aSize The size to set.
|
sl@0
|
126 |
@param aMap The graphics device in which aSize should be the size in pixels.
|
sl@0
|
127 |
@internalComponent
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
void CTestPicture::SetSizeInPixels(TSize aSize, const MGraphicsDeviceMap& aMap)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
iSizeInTwips.iWidth = aMap.HorizontalTwipsToPixels(aSize.iWidth);
|
sl@0
|
132 |
iSizeInTwips.iHeight = aMap.VerticalTwipsToPixels(aSize.iHeight);
|
sl@0
|
133 |
}
|