103
|
1 |
|
|
2 |
// Copyright (c) 1996-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 |
// TBITMAP.H
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@test
|
|
22 |
@internalComponent - Internal Symbian test code
|
|
23 |
*/
|
|
24 |
|
|
25 |
#ifndef __TALPHACHANNEL_H__
|
|
26 |
#define __TALPHACHANNEL_H__
|
|
27 |
|
|
28 |
#include "AUTO.H"
|
|
29 |
#include "../tlib/testbase.h"
|
|
30 |
#include "TGraphicsHarness.h"
|
|
31 |
|
|
32 |
class CTAlphaChannel;
|
|
33 |
|
|
34 |
/**
|
|
35 |
Introduces a base class for transparent windows (both background and foreground)
|
|
36 |
*/
|
|
37 |
class CTWinAlpha : public CTWin
|
|
38 |
{
|
|
39 |
public:
|
|
40 |
void Draw(); //we have to overridden it to avoid panic in a based class
|
|
41 |
public:
|
|
42 |
TInt iState;
|
|
43 |
};
|
|
44 |
|
|
45 |
enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha};
|
|
46 |
|
|
47 |
/**
|
|
48 |
Introduces a foreground transparent windows.
|
|
49 |
In order to set any instance of class as transparent it has to be created with
|
|
50 |
ETransparencyAlpha parameter
|
|
51 |
*/
|
|
52 |
class CTWinAlphaForeground : public CTWin
|
|
53 |
{
|
|
54 |
public:
|
|
55 |
static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize,
|
|
56 |
CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha);
|
|
57 |
~CTWinAlphaForeground();
|
|
58 |
|
|
59 |
private:
|
|
60 |
CTWinAlphaForeground(CTAlphaChannel& aTest);
|
|
61 |
|
|
62 |
public:
|
|
63 |
void Draw();
|
|
64 |
void SetBackgroundColor(TRgb aColor);
|
|
65 |
void SetDisplayMode(TDisplayMode aDisplayMode);
|
|
66 |
void StartAnimationL();
|
|
67 |
void CreateBackedWindowL();
|
|
68 |
inline void SetDrawOpaque(TBool aDrawOpaque = ETrue)
|
|
69 |
{
|
|
70 |
iDrawOpaque = aDrawOpaque;
|
|
71 |
}
|
|
72 |
|
|
73 |
protected:
|
|
74 |
void DrawTable(CBitmapContext& aGc) const;
|
|
75 |
void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect,
|
|
76 |
CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
|
|
77 |
void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect);
|
|
78 |
void PrepareForDrawingL();
|
|
79 |
void CalculateTableMargin();
|
|
80 |
void SetPoligonLocation(const TPoint &ptOffset);
|
|
81 |
void CreateBackgroundBitmapL(const TDisplayMode& aDispMode);
|
|
82 |
void CleanBackgroundBitmap();
|
|
83 |
|
|
84 |
protected:
|
|
85 |
TInt iRows[4];
|
|
86 |
TInt iCol; // width of the first column
|
|
87 |
CFbsBitmap* iBitmapBackground;
|
|
88 |
CFbsBitmapDevice* iBitmapDeviceBackground;
|
|
89 |
CBitmapContext* iBitmapContextBackground;
|
|
90 |
TRgb iBackgroundColor;
|
|
91 |
CArrayFix<TPoint>* iPolygon;
|
|
92 |
TBuf<16> iTitle1;
|
|
93 |
TBuf<16> iTitle2;
|
|
94 |
TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel
|
|
95 |
|
|
96 |
private:
|
|
97 |
CTAlphaChannel& iTest;
|
|
98 |
};
|
|
99 |
|
|
100 |
/** Test base class, which exersices drawing graphics operations with alpha channel */
|
|
101 |
class CTAlphaChannel : public CTWsGraphicsBase
|
|
102 |
{
|
|
103 |
friend class CTWinAlphaForeground;
|
|
104 |
public:
|
|
105 |
CTAlphaChannel(CTestStep* aStep);
|
|
106 |
~CTAlphaChannel();
|
|
107 |
void ConstructL();
|
|
108 |
void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse);
|
|
109 |
|
|
110 |
void SetWindow64K();
|
|
111 |
void SetOpaqueWindow16MA();
|
|
112 |
void SetTransparentWindow16MA();
|
|
113 |
TInt SetWindow16MAWithMask();
|
|
114 |
TInt SetWindow64KWithMask();
|
|
115 |
CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const;
|
|
116 |
TRgb GetBrush(TInt aIndex) const;
|
|
117 |
TRgb GetPen(TInt aIndex) const;
|
|
118 |
|
|
119 |
// test functions
|
|
120 |
void SetDisplayModeConfiguration(TInt aConfig);
|
|
121 |
void SetPositionConfiguration(TInt aConfig);
|
|
122 |
void SetColourConfiguration(TInt aConfig);
|
|
123 |
void DoMoving();
|
|
124 |
void DoMoveBehind();
|
|
125 |
void DoInvisibility();
|
|
126 |
void TestMoving();
|
|
127 |
void TestMovingOverlapping();
|
|
128 |
void TestFading();
|
|
129 |
void TestChangingTransparencyFactor();
|
|
130 |
void TestInvisibility();
|
|
131 |
void TestMoveUnderneath();
|
|
132 |
void TestMoveBehindInvisible();
|
|
133 |
void TestRedrawBehind();
|
|
134 |
void TestAnimationL();
|
|
135 |
void TestBackedWindowL();
|
|
136 |
void TestEffectSetOpaque();
|
|
137 |
void TestChildWindowL();
|
|
138 |
void TestMultipleChildrenL();
|
|
139 |
void TestTransparentMovingUnderOpaqueL();
|
|
140 |
void TestSetOrdinalPosition();
|
|
141 |
|
|
142 |
protected:
|
|
143 |
//from CTGraphicsStep
|
|
144 |
virtual void RunTestCaseL(TInt aCurTestCase);
|
|
145 |
void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode);
|
|
146 |
void DestroyForegroundWindows();
|
|
147 |
void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush,
|
|
148 |
CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA,
|
|
149 |
CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA);
|
|
150 |
void CalculateSizePrimitives(const TSize& aSize);
|
|
151 |
protected:
|
|
152 |
TRgb iPenTable;
|
|
153 |
CGraphicsContext::TBrushStyle iBrushStyle;
|
|
154 |
CGraphicsContext::TPenStyle iPenStyle;
|
|
155 |
TSize iSizeForegroundWindow;
|
|
156 |
private:
|
|
157 |
CTWinAlpha* iBackgroundWindow;
|
|
158 |
CTWinAlphaForeground* iForegroundWindowBottom;
|
|
159 |
CTWinAlphaForeground* iForegroundWindowOpaque;
|
|
160 |
CTWinAlphaForeground* iForegroundWindowSemiTrans;
|
|
161 |
CTWinAlphaForeground* iForegroundWindowTrans;
|
|
162 |
CTWinAlphaForeground* iForegroundWindowTop;
|
|
163 |
|
|
164 |
CArrayPtrFlat<CTWinAlphaForeground> iArrWindow;
|
|
165 |
|
|
166 |
|
|
167 |
CFbsBitmap* iBitmap64K_1;
|
|
168 |
CFbsBitmap* iBitmap16MA_1;
|
|
169 |
CFbsBitmap* iBitmap64K_2;
|
|
170 |
CFbsBitmap* iBitmap16MA_2;
|
|
171 |
CFbsBitmap* iBitmap64K_3;
|
|
172 |
CFbsBitmap* iBitmap16MA_3;
|
|
173 |
CFbsBitmap* iBitmapMask;
|
|
174 |
CFbsBitmap* iBitmapGray256Mask;
|
|
175 |
|
|
176 |
CFbsBitmapDevice* iBitmapDevice64K_1;
|
|
177 |
CFbsBitmapDevice* iBitmapDevice16MA_1;
|
|
178 |
CFbsBitmapDevice* iBitmapDevice64K_2;
|
|
179 |
CFbsBitmapDevice* iBitmapDevice16MA_2;
|
|
180 |
CFbsBitmapDevice* iBitmapDevice64K_3;
|
|
181 |
CFbsBitmapDevice* iBitmapDevice16MA_3;
|
|
182 |
|
|
183 |
CGraphicsContext* iBitmapContext64K_1;
|
|
184 |
CGraphicsContext* iBitmapContext16MA_1;
|
|
185 |
CGraphicsContext* iBitmapContext64K_2;
|
|
186 |
CGraphicsContext* iBitmapContext16MA_2;
|
|
187 |
CGraphicsContext* iBitmapContext64K_3;
|
|
188 |
CGraphicsContext* iBitmapContext16MA_3;
|
|
189 |
|
|
190 |
TBuf<256> iText;
|
|
191 |
CFont* iFont; // for true type font, needs to exercise anti-aliasing
|
|
192 |
CFont* iFont1; // title font
|
|
193 |
|
|
194 |
TSize iBitmapSize;
|
|
195 |
TSize iRectangleSize;
|
|
196 |
TSize iEllipseSize ;
|
|
197 |
TSize iTriangleSize ;
|
|
198 |
TInt iFirstCellWidth ;
|
|
199 |
TInt iFirstCellHeight;
|
|
200 |
TBool iDrawText; // if true output text, graphics primitives otherwise
|
|
201 |
TBool iIsFading;
|
|
202 |
TUint8 iBlackFading;
|
|
203 |
TUint8 iWhiteFading;
|
|
204 |
};
|
|
205 |
|
|
206 |
class CTAlphaChannelStep : public CTGraphicsStep
|
|
207 |
{
|
|
208 |
public:
|
|
209 |
CTAlphaChannelStep();
|
|
210 |
protected:
|
|
211 |
//from CTGraphicsStep
|
|
212 |
virtual CTGraphicsBase* CreateTestL();
|
|
213 |
};
|
|
214 |
|
|
215 |
_LIT(KTAlphaChannelStep,"TAlphaChannel");
|
|
216 |
|
|
217 |
|
|
218 |
#endif
|