First public contribution.
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".
9 // Initial Contributors:
10 // Nokia Corporation - initial contribution.
22 @internalComponent - Internal Symbian test code
25 #ifndef __TALPHACHANNEL_H__
26 #define __TALPHACHANNEL_H__
29 #include "../tlib/testbase.h"
30 #include "TGraphicsHarness.h"
35 Introduces a base class for transparent windows (both background and foreground)
37 class CTWinAlpha : public CTWin
40 void Draw(); //we have to overridden it to avoid panic in a based class
45 enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha};
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
52 class CTWinAlphaForeground : public CTWin
55 static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize,
56 CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha);
57 ~CTWinAlphaForeground();
60 CTWinAlphaForeground(CTAlphaChannel& aTest);
64 void SetBackgroundColor(TRgb aColor);
65 void SetDisplayMode(TDisplayMode aDisplayMode);
66 void StartAnimationL();
67 void CreateBackedWindowL();
68 inline void SetDrawOpaque(TBool aDrawOpaque = ETrue)
70 iDrawOpaque = aDrawOpaque;
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();
86 TInt iCol; // width of the first column
87 CFbsBitmap* iBitmapBackground;
88 CFbsBitmapDevice* iBitmapDeviceBackground;
89 CBitmapContext* iBitmapContextBackground;
90 TRgb iBackgroundColor;
91 CArrayFix<TPoint>* iPolygon;
94 TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel
97 CTAlphaChannel& iTest;
100 /** Test base class, which exersices drawing graphics operations with alpha channel */
101 class CTAlphaChannel : public CTWsGraphicsBase
103 friend class CTWinAlphaForeground;
105 CTAlphaChannel(CTestStep* aStep);
108 void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse);
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;
120 void SetDisplayModeConfiguration(TInt aConfig);
121 void SetPositionConfiguration(TInt aConfig);
122 void SetColourConfiguration(TInt aConfig);
125 void DoInvisibility();
127 void TestMovingOverlapping();
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();
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);
153 CGraphicsContext::TBrushStyle iBrushStyle;
154 CGraphicsContext::TPenStyle iPenStyle;
155 TSize iSizeForegroundWindow;
157 CTWinAlpha* iBackgroundWindow;
158 CTWinAlphaForeground* iForegroundWindowBottom;
159 CTWinAlphaForeground* iForegroundWindowOpaque;
160 CTWinAlphaForeground* iForegroundWindowSemiTrans;
161 CTWinAlphaForeground* iForegroundWindowTrans;
162 CTWinAlphaForeground* iForegroundWindowTop;
164 CArrayPtrFlat<CTWinAlphaForeground> iArrWindow;
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;
176 CFbsBitmapDevice* iBitmapDevice64K_1;
177 CFbsBitmapDevice* iBitmapDevice16MA_1;
178 CFbsBitmapDevice* iBitmapDevice64K_2;
179 CFbsBitmapDevice* iBitmapDevice16MA_2;
180 CFbsBitmapDevice* iBitmapDevice64K_3;
181 CFbsBitmapDevice* iBitmapDevice16MA_3;
183 CGraphicsContext* iBitmapContext64K_1;
184 CGraphicsContext* iBitmapContext16MA_1;
185 CGraphicsContext* iBitmapContext64K_2;
186 CGraphicsContext* iBitmapContext16MA_2;
187 CGraphicsContext* iBitmapContext64K_3;
188 CGraphicsContext* iBitmapContext16MA_3;
191 CFont* iFont; // for true type font, needs to exercise anti-aliasing
192 CFont* iFont1; // title font
195 TSize iRectangleSize;
197 TSize iTriangleSize ;
198 TInt iFirstCellWidth ;
199 TInt iFirstCellHeight;
200 TBool iDrawText; // if true output text, graphics primitives otherwise
206 class CTAlphaChannelStep : public CTGraphicsStep
209 CTAlphaChannelStep();
211 //from CTGraphicsStep
212 virtual CTGraphicsBase* CreateTestL();
215 _LIT(KTAlphaChannelStep,"TAlphaChannel");