sl@0: sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // TBITMAP.H sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #ifndef __TALPHACHANNEL_H__ sl@0: #define __TALPHACHANNEL_H__ sl@0: sl@0: #include "AUTO.H" sl@0: #include "../tlib/testbase.h" sl@0: #include "TGraphicsHarness.h" sl@0: sl@0: class CTAlphaChannel; sl@0: sl@0: /** sl@0: Introduces a base class for transparent windows (both background and foreground) sl@0: */ sl@0: class CTWinAlpha : public CTWin sl@0: { sl@0: public: sl@0: void Draw(); //we have to overridden it to avoid panic in a based class sl@0: public: sl@0: TInt iState; sl@0: }; sl@0: sl@0: enum {ETransparencyFactor, ETransparencyAlpha, ENonTransparentAlpha}; sl@0: sl@0: /** sl@0: Introduces a foreground transparent windows. sl@0: In order to set any instance of class as transparent it has to be created with sl@0: ETransparencyAlpha parameter sl@0: */ sl@0: class CTWinAlphaForeground : public CTWin sl@0: { sl@0: public: sl@0: static CTWinAlphaForeground* NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, sl@0: CTWinBase* aParent, CWindowGc& aGc, TDisplayMode* aMode, TRgb aCol, TInt aTransparencyType = ENonTransparentAlpha); sl@0: ~CTWinAlphaForeground(); sl@0: sl@0: private: sl@0: CTWinAlphaForeground(CTAlphaChannel& aTest); sl@0: sl@0: public: sl@0: void Draw(); sl@0: void SetBackgroundColor(TRgb aColor); sl@0: void SetDisplayMode(TDisplayMode aDisplayMode); sl@0: void StartAnimationL(); sl@0: void CreateBackedWindowL(); sl@0: inline void SetDrawOpaque(TBool aDrawOpaque = ETrue) sl@0: { sl@0: iDrawOpaque = aDrawOpaque; sl@0: } sl@0: sl@0: protected: sl@0: void DrawTable(CBitmapContext& aGc) const; sl@0: void DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, sl@0: CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); sl@0: void DrawTextInCell(CBitmapContext& aGc, const TRect& aRect); sl@0: void PrepareForDrawingL(); sl@0: void CalculateTableMargin(); sl@0: void SetPoligonLocation(const TPoint &ptOffset); sl@0: void CreateBackgroundBitmapL(const TDisplayMode& aDispMode); sl@0: void CleanBackgroundBitmap(); sl@0: sl@0: protected: sl@0: TInt iRows[4]; sl@0: TInt iCol; // width of the first column sl@0: CFbsBitmap* iBitmapBackground; sl@0: CFbsBitmapDevice* iBitmapDeviceBackground; sl@0: CBitmapContext* iBitmapContextBackground; sl@0: TRgb iBackgroundColor; sl@0: CArrayFix* iPolygon; sl@0: TBuf<16> iTitle1; sl@0: TBuf<16> iTitle2; sl@0: TBool iDrawOpaque; // this value will set to CWindowGc before drawing, should have any effect on drawing with alpha channel sl@0: sl@0: private: sl@0: CTAlphaChannel& iTest; sl@0: }; sl@0: sl@0: /** Test base class, which exersices drawing graphics operations with alpha channel */ sl@0: class CTAlphaChannel : public CTWsGraphicsBase sl@0: { sl@0: friend class CTWinAlphaForeground; sl@0: public: sl@0: CTAlphaChannel(CTestStep* aStep); sl@0: ~CTAlphaChannel(); sl@0: void ConstructL(); sl@0: void DrawTestWindowsNow(TBool aDrawBackgroundWin = EFalse); sl@0: sl@0: void SetWindow64K(); sl@0: void SetOpaqueWindow16MA(); sl@0: void SetTransparentWindow16MA(); sl@0: TInt SetWindow16MAWithMask(); sl@0: TInt SetWindow64KWithMask(); sl@0: CGraphicsContext::TDrawMode GetDrawMode(TInt aIndex) const; sl@0: TRgb GetBrush(TInt aIndex) const; sl@0: TRgb GetPen(TInt aIndex) const; sl@0: sl@0: // test functions sl@0: void SetDisplayModeConfiguration(TInt aConfig); sl@0: void SetPositionConfiguration(TInt aConfig); sl@0: void SetColourConfiguration(TInt aConfig); sl@0: void DoMoving(); sl@0: void DoMoveBehind(); sl@0: void DoInvisibility(); sl@0: void TestMoving(); sl@0: void TestMovingOverlapping(); sl@0: void TestFading(); sl@0: void TestChangingTransparencyFactor(); sl@0: void TestInvisibility(); sl@0: void TestMoveUnderneath(); sl@0: void TestMoveBehindInvisible(); sl@0: void TestRedrawBehind(); sl@0: void TestAnimationL(); sl@0: void TestBackedWindowL(); sl@0: void TestEffectSetOpaque(); sl@0: void TestChildWindowL(); sl@0: void TestMultipleChildrenL(); sl@0: void TestTransparentMovingUnderOpaqueL(); sl@0: void TestSetOrdinalPosition(); sl@0: sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: void CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode); sl@0: void DestroyForegroundWindows(); sl@0: void DrawOffscreenBitmapsL(const TRgb& aPen, const TRgb& aBrush, sl@0: CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, sl@0: CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA); sl@0: void CalculateSizePrimitives(const TSize& aSize); sl@0: protected: sl@0: TRgb iPenTable; sl@0: CGraphicsContext::TBrushStyle iBrushStyle; sl@0: CGraphicsContext::TPenStyle iPenStyle; sl@0: TSize iSizeForegroundWindow; sl@0: private: sl@0: CTWinAlpha* iBackgroundWindow; sl@0: CTWinAlphaForeground* iForegroundWindowBottom; sl@0: CTWinAlphaForeground* iForegroundWindowOpaque; sl@0: CTWinAlphaForeground* iForegroundWindowSemiTrans; sl@0: CTWinAlphaForeground* iForegroundWindowTrans; sl@0: CTWinAlphaForeground* iForegroundWindowTop; sl@0: sl@0: CArrayPtrFlat iArrWindow; sl@0: sl@0: sl@0: CFbsBitmap* iBitmap64K_1; sl@0: CFbsBitmap* iBitmap16MA_1; sl@0: CFbsBitmap* iBitmap64K_2; sl@0: CFbsBitmap* iBitmap16MA_2; sl@0: CFbsBitmap* iBitmap64K_3; sl@0: CFbsBitmap* iBitmap16MA_3; sl@0: CFbsBitmap* iBitmapMask; sl@0: CFbsBitmap* iBitmapGray256Mask; sl@0: sl@0: CFbsBitmapDevice* iBitmapDevice64K_1; sl@0: CFbsBitmapDevice* iBitmapDevice16MA_1; sl@0: CFbsBitmapDevice* iBitmapDevice64K_2; sl@0: CFbsBitmapDevice* iBitmapDevice16MA_2; sl@0: CFbsBitmapDevice* iBitmapDevice64K_3; sl@0: CFbsBitmapDevice* iBitmapDevice16MA_3; sl@0: sl@0: CGraphicsContext* iBitmapContext64K_1; sl@0: CGraphicsContext* iBitmapContext16MA_1; sl@0: CGraphicsContext* iBitmapContext64K_2; sl@0: CGraphicsContext* iBitmapContext16MA_2; sl@0: CGraphicsContext* iBitmapContext64K_3; sl@0: CGraphicsContext* iBitmapContext16MA_3; sl@0: sl@0: TBuf<256> iText; sl@0: CFont* iFont; // for true type font, needs to exercise anti-aliasing sl@0: CFont* iFont1; // title font sl@0: sl@0: TSize iBitmapSize; sl@0: TSize iRectangleSize; sl@0: TSize iEllipseSize ; sl@0: TSize iTriangleSize ; sl@0: TInt iFirstCellWidth ; sl@0: TInt iFirstCellHeight; sl@0: TBool iDrawText; // if true output text, graphics primitives otherwise sl@0: TBool iIsFading; sl@0: TUint8 iBlackFading; sl@0: TUint8 iWhiteFading; sl@0: }; sl@0: sl@0: class CTAlphaChannelStep : public CTGraphicsStep sl@0: { sl@0: public: sl@0: CTAlphaChannelStep(); sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual CTGraphicsBase* CreateTestL(); sl@0: }; sl@0: sl@0: _LIT(KTAlphaChannelStep,"TAlphaChannel"); sl@0: sl@0: sl@0: #endif