os/graphics/windowing/windowserver/test/tauto/TAlphaChannel.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TAlphaChannel.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1936 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// An alpha channel test case. 
    1.18 +// Output different graphics primitives in each window using three graphics modes
    1.19 +// for pen and brush : semi-transparent,transparent, opaque
    1.20 +// Test also exercises anti-aliasing and fading for 16MA display mode
    1.21 +// Moves sprite on the window. Tests a sprite functionality.
    1.22 +// Creates RBackedUpWindow window and moves it over transparent window,
    1.23 +// hides and shows it.
    1.24 +// Moves windows on the screen, overlaps them
    1.25 +// Actions:
    1.26 +// Create a background window, and five foreground windows:
    1.27 +// -transparent and semi-transparent 
    1.28 +// -transparent with transparency factor
    1.29 +// -not transparent
    1.30 +// 
    1.31 +//
    1.32 +
    1.33 +#include "TAlphaChannel.H"
    1.34 +
    1.35 +const TInt KWindowIndention = 2;
    1.36 +const TInt KSizeKoeff = 15;
    1.37 +
    1.38 +
    1.39 +LOCAL_D TPtrC ColumnName[]={
    1.40 +	_L("Opaque"),
    1.41 +	_L("Semi-transparent"),
    1.42 +	_L("Transparent"),
    1.43 +	_L(""),
    1.44 +	_L(""),
    1.45 +	_L(""),
    1.46 +	};
    1.47 +
    1.48 +LOCAL_D TPtrC RowName[]={
    1.49 +	_L("n"),
    1.50 +	_L("and"),
    1.51 +	_L("or"),
    1.52 +	_L("xor"),
    1.53 +	_L(""),
    1.54 +	_L(""),
    1.55 +	};
    1.56 +
    1.57 +
    1.58 +//
    1.59 +//
    1.60 +CTAlphaChannel::CTAlphaChannel(CTestStep* aStep):
    1.61 +	CTWsGraphicsBase(aStep), iArrWindow(8)
    1.62 +	{
    1.63 +	}
    1.64 +
    1.65 +CTAlphaChannel::~CTAlphaChannel()
    1.66 +	{
    1.67 +	delete iBitmap64K_1;
    1.68 +	delete iBitmap16MA_1;
    1.69 +	delete iBitmap64K_2;
    1.70 +	delete iBitmap16MA_2;
    1.71 +	delete iBitmap64K_3;
    1.72 +	delete iBitmap16MA_3;
    1.73 +
    1.74 +	delete iBitmapMask;
    1.75 +	delete iBitmapGray256Mask;
    1.76 +	
    1.77 +	delete iBitmapContext64K_1;
    1.78 +	delete iBitmapContext16MA_1;
    1.79 +	delete iBitmapContext64K_2;
    1.80 +	delete iBitmapContext16MA_2;
    1.81 +	delete iBitmapContext64K_3;
    1.82 +	delete iBitmapContext16MA_3;
    1.83 +
    1.84 +	delete iBitmapDevice64K_1;
    1.85 +	delete iBitmapDevice16MA_1;
    1.86 +	delete iBitmapDevice64K_2;
    1.87 +	delete iBitmapDevice16MA_2;
    1.88 +	delete iBitmapDevice64K_3;
    1.89 +	delete iBitmapDevice16MA_3;
    1.90 +
    1.91 +	delete iBackgroundWindow;
    1.92 +	
    1.93 +	
    1.94 +	iArrWindow.ResetAndDestroy();
    1.95 +	
    1.96 +	if(iFont)
    1.97 +		TheClient->iScreen->ReleaseFont(iFont);
    1.98 +	if(iFont1)
    1.99 +		TheClient->iScreen->ReleaseFont(iFont1);
   1.100 +	
   1.101 +	BaseWin->SetVisible(ETrue);
   1.102 +	TestWin->SetVisible(ETrue);
   1.103 +	}
   1.104 +
   1.105 +void CTAlphaChannel::ConstructL()
   1.106 +	{
   1.107 +	const TInt KIndent = 10;
   1.108 +	BaseWin->SetVisible(EFalse);
   1.109 +	TestWin->SetVisible(EFalse);
   1.110 +
   1.111 +	iText = _L("This is a text");
   1.112 +	iBrushStyle = CGraphicsContext::ESolidBrush;
   1.113 +	iPenTable = KRgbBlack;
   1.114 +
   1.115 +	TSize screenSize=TheClient->iGroup->Size();
   1.116 +	TInt winWidth=(screenSize.iWidth)-KIndent;
   1.117 +	TInt winHeight=screenSize.iHeight-KIndent;
   1.118 +	TDisplayMode dispMode = EColor64K;
   1.119 +	
   1.120 +	//background opaque window
   1.121 +	iBackgroundWindow = new (ELeave) CTWinAlpha();
   1.122 +	iBackgroundWindow->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc, &dispMode);
   1.123 +	RWindow *theWin = (RWindow*) (iBackgroundWindow->DrawableWin());
   1.124 +	theWin->SetBackgroundColor(TRgb(255, 0, 0));
   1.125 +	iBackgroundWindow->DrawNow();
   1.126 +
   1.127 +	iSizeForegroundWindow.iWidth = (winWidth - KWindowIndention * 4) / 5 ;
   1.128 +	iSizeForegroundWindow.iHeight = winHeight;
   1.129 +	
   1.130 +	CalculateSizePrimitives(iSizeForegroundWindow);
   1.131 +
   1.132 +	//-------------create bitmaps
   1.133 +	//create 64K bitmap
   1.134 +	iBitmap64K_1 = new (ELeave) CFbsBitmap ;
   1.135 +	iBitmap64K_1->Create(iBitmapSize,EColor64K);
   1.136 +	iBitmap64K_2 = new (ELeave) CFbsBitmap ;
   1.137 +	iBitmap64K_2->Create(iBitmapSize,EColor64K);
   1.138 +	iBitmap64K_3 = new (ELeave) CFbsBitmap ;
   1.139 +	iBitmap64K_3->Create(iBitmapSize,EColor64K);
   1.140 +	iBitmapDevice64K_1 = CFbsBitmapDevice::NewL(iBitmap64K_1);
   1.141 +	iBitmapDevice64K_1->CreateContext(iBitmapContext64K_1);
   1.142 +	iBitmapDevice64K_2 = CFbsBitmapDevice::NewL(iBitmap64K_2);
   1.143 +	iBitmapDevice64K_2->CreateContext(iBitmapContext64K_2);
   1.144 +	iBitmapDevice64K_3 = CFbsBitmapDevice::NewL(iBitmap64K_3);
   1.145 +	iBitmapDevice64K_3->CreateContext(iBitmapContext64K_3);
   1.146 +	
   1.147 +	//create 16MA bitmap
   1.148 +	iBitmap16MA_1 = new (ELeave) CFbsBitmap ;
   1.149 +	iBitmap16MA_1->Create(iBitmapSize, EColor16MA);
   1.150 +	iBitmap16MA_2 = new (ELeave) CFbsBitmap ;
   1.151 +	iBitmap16MA_2->Create(iBitmapSize, EColor16MA);
   1.152 +	iBitmap16MA_3 = new (ELeave) CFbsBitmap ;
   1.153 +	iBitmap16MA_3->Create(iBitmapSize, EColor16MA);
   1.154 +
   1.155 +	iBitmapDevice16MA_1 = CFbsBitmapDevice::NewL(iBitmap16MA_1);
   1.156 +	iBitmapDevice16MA_1->CreateContext(iBitmapContext16MA_1);
   1.157 +	iBitmapDevice16MA_2 = CFbsBitmapDevice::NewL(iBitmap16MA_2);
   1.158 +	iBitmapDevice16MA_2->CreateContext(iBitmapContext16MA_2);
   1.159 +	iBitmapDevice16MA_3 = CFbsBitmapDevice::NewL(iBitmap16MA_3);
   1.160 +	iBitmapDevice16MA_3->CreateContext(iBitmapContext16MA_3);
   1.161 +
   1.162 +	//create mask bitmap
   1.163 +	iBitmapMask = new (ELeave) CFbsBitmap ;
   1.164 +	iBitmapMask->Create(iBitmapSize, EGray2);
   1.165 +	
   1.166 +	CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapMask);
   1.167 +	CGraphicsContext*  theBitmapContext = NULL;
   1.168 +	theBitmapDevice->CreateContext(theBitmapContext);
   1.169 +	TRect rect = TRect(iBitmapMask->SizeInPixels());
   1.170 +	theBitmapContext->SetBrushColor(KRgbWhite);
   1.171 +   	theBitmapContext->SetPenColor(KRgbWhite);
   1.172 +   	theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.173 +	theBitmapContext->DrawRect(rect);
   1.174 +
   1.175 +	rect.Shrink(4, 4);
   1.176 +	theBitmapContext->SetBrushColor(KRgbBlack);
   1.177 +	theBitmapContext->SetPenColor(KRgbBlack);
   1.178 +	theBitmapContext->DrawEllipse(rect);
   1.179 +	delete theBitmapContext;
   1.180 +	delete theBitmapDevice;
   1.181 +	
   1.182 +	//create 256gray bitmap mask
   1.183 +	iBitmapGray256Mask = new (ELeave) CFbsBitmap;
   1.184 +	iBitmapGray256Mask->Create(iBitmapSize, EGray256);
   1.185 +	theBitmapDevice = CFbsBitmapDevice::NewL(iBitmapGray256Mask);
   1.186 +	theBitmapDevice->CreateContext(theBitmapContext);
   1.187 +	
   1.188 +	if(iBitmapSize != TSize(0, 0))
   1.189 +		{
   1.190 +	//fill bitmap with 256 gradation of gray
   1.191 +		TInt theStep = 256 / iBitmapGray256Mask->SizeInPixels().iWidth;
   1.192 +	
   1.193 +		for(TInt ii = 0; ii < iBitmapGray256Mask->SizeInPixels().iWidth; ii++)
   1.194 +			{
   1.195 +			TInt theSingleCol = theStep * ii; 
   1.196 +			TRgb theCol(theSingleCol, theSingleCol, theSingleCol);
   1.197 +			theBitmapContext->SetBrushColor(theCol);
   1.198 +			theBitmapContext->SetPenColor(theCol);
   1.199 +			TPoint ptFrom(ii, 0);
   1.200 +			TPoint ptTo(ii, iBitmapGray256Mask->SizeInPixels().iHeight);
   1.201 +			theBitmapContext->DrawLine(ptFrom, ptTo);
   1.202 +			}
   1.203 +		}
   1.204 +	delete theBitmapContext;
   1.205 +	delete theBitmapDevice;
   1.206 +	//--------------
   1.207 +	TFontSpec fontSpec(KTestFontTypefaceName,600);
   1.208 +
   1.209 +	fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.210 +	fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   1.211 +	
   1.212 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont, fontSpec));
   1.213 +	
   1.214 +	TFontSpec fontSpec1(KTestFontTypefaceName,100);
   1.215 +	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(iFont1, fontSpec1));
   1.216 +	}
   1.217 +
   1.218 +void CTAlphaChannel::CalculateSizePrimitives(const TSize& aSize)
   1.219 +	{
   1.220 +	TInt theLen = aSize.iWidth / KSizeKoeff;
   1.221 +	
   1.222 +	iBitmapSize = TSize(2 * theLen, 2 * theLen);
   1.223 +	iRectangleSize = TSize(2 * theLen, 2 * theLen);
   1.224 +	iEllipseSize = TSize(4 * theLen, 2 * theLen);
   1.225 +	iTriangleSize = TSize(3 * theLen, 2 * theLen);
   1.226 +	iFirstCellWidth = static_cast <TInt> (1.2 * theLen);
   1.227 +	iFirstCellHeight = static_cast <TInt> (1.5 * theLen);
   1.228 +	}
   1.229 +
   1.230 +void CTAlphaChannel::DrawOffscreenBitmapsL(const TRgb& /*aPen*/, const TRgb& aBrush,
   1.231 +										CGraphicsContext* aBitmapContext64K, CGraphicsContext* aBitmapContext16MA, 
   1.232 +										CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA)
   1.233 +	{
   1.234 +
   1.235 +	if(aBitmapContext64K && aBitmap64K)
   1.236 +		{
   1.237 +		SEpocBitmapHeader header = aBitmap64K->Header();
   1.238 +		TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ;
   1.239 +		TUint8* buffer = new(ELeave) TUint8[source_buffer_size];
   1.240 +		TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size);
   1.241 +		
   1.242 +		TUint16* bufferCur = reinterpret_cast<TUint16*> (buffer);
   1.243 +		TInt ii;
   1.244 +		for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii)
   1.245 +			{
   1.246 +			*bufferCur = aBrush._Color64K();
   1.247 +			bufferCur ++;
   1.248 +			}
   1.249 +	
   1.250 +		for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii)
   1.251 +			{
   1.252 +			aBitmap64K -> SetScanLine(source_ptr, ii);
   1.253 +			}
   1.254 +		
   1.255 +		delete [] buffer;
   1.256 +		}
   1.257 +		
   1.258 +	if(aBitmapContext16MA && aBitmap16MA)
   1.259 +		{
   1.260 +		SEpocBitmapHeader header = aBitmap16MA -> Header();
   1.261 +		TInt source_buffer_size = header.iBitmapSize / header.iSizeInPixels.iHeight * header.iBitsPerPixel ;
   1.262 +		TUint8* buffer = new(ELeave) TUint8[source_buffer_size];
   1.263 +		TPtr8 source_ptr(buffer, source_buffer_size, source_buffer_size);
   1.264 +		
   1.265 +		TUint32* bufferCur = reinterpret_cast<TUint32*> (buffer);
   1.266 +		TInt ii;
   1.267 +		for(ii = 0; ii < header.iSizeInPixels.iWidth; ++ii)
   1.268 +			{
   1.269 +			*bufferCur = aBrush._Color16MA();
   1.270 +			bufferCur ++;
   1.271 +			}
   1.272 +	
   1.273 +		for(ii = 0; ii < header.iSizeInPixels.iHeight; ++ii)
   1.274 +			{
   1.275 +			aBitmap16MA -> SetScanLine(source_ptr, ii);
   1.276 +			}
   1.277 +		
   1.278 +		delete [] buffer;
   1.279 +		}
   1.280 +	
   1.281 +	}
   1.282 +
   1.283 +enum {EOpaque, ESemiTrans, ETrans};
   1.284 +
   1.285 +TRgb CTAlphaChannel::GetBrush(TInt aIndex) const
   1.286 +	{
   1.287 +	switch(aIndex)
   1.288 +		{
   1.289 +			case EOpaque:
   1.290 +			return TRgb(0, 0, 255, 255);
   1.291 +			case ESemiTrans:
   1.292 +			return TRgb(0, 0, 255, 128);
   1.293 +			case ETrans:
   1.294 +			return TRgb(0, 0, 255, 0);
   1.295 +			default : break;
   1.296 +		}
   1.297 +		
   1.298 +	return 	TRgb(0, 0, 255, 255);
   1.299 +	}
   1.300 +
   1.301 +TRgb CTAlphaChannel::GetPen(TInt aIndex) const
   1.302 +	{
   1.303 +	switch(aIndex)
   1.304 +		{
   1.305 +			case EOpaque:
   1.306 +			return TRgb(0, 0, 255, 255);
   1.307 +			case ESemiTrans:
   1.308 +			return TRgb(0, 0, 255, 128);
   1.309 +			case ETrans:
   1.310 +			return TRgb(0, 0, 255, 0);
   1.311 +			default : break;
   1.312 +		}
   1.313 +		
   1.314 +	return 	TRgb(0, 0, 255, 255);
   1.315 +	}
   1.316 +   
   1.317 +CGraphicsContext::TDrawMode CTAlphaChannel::GetDrawMode(TInt /*aIndex*/) const
   1.318 +	{
   1.319 +	return CGraphicsContext::EDrawModePEN;
   1.320 +	}
   1.321 +
   1.322 +enum {EAll64K, EAll16MA, EAllDifferent};// later may add EAll16M
   1.323 +void CTAlphaChannel::SetDisplayModeConfiguration(TInt aConfig)
   1.324 +	{
   1.325 +	switch (aConfig)
   1.326 +		{
   1.327 +	case EAll64K:
   1.328 +		if(iForegroundWindowOpaque)
   1.329 +			iForegroundWindowOpaque->SetDisplayMode(EColor64K);
   1.330 +		if(iForegroundWindowSemiTrans)
   1.331 +			iForegroundWindowSemiTrans->SetDisplayMode(EColor64K);
   1.332 +		if(iForegroundWindowTrans)
   1.333 +			iForegroundWindowTrans->SetDisplayMode(EColor64K);
   1.334 +		break;
   1.335 +	case EAll16MA:
   1.336 +		if(iForegroundWindowOpaque)
   1.337 +			iForegroundWindowOpaque->SetDisplayMode(EColor16MA);
   1.338 +		if(iForegroundWindowSemiTrans)
   1.339 +			iForegroundWindowSemiTrans->SetDisplayMode(EColor16MA);
   1.340 +		if(iForegroundWindowTrans)
   1.341 +			iForegroundWindowTrans->SetDisplayMode(EColor16MA);
   1.342 +		break;
   1.343 +	case EAllDifferent:
   1.344 +		if(iForegroundWindowOpaque)
   1.345 +			iForegroundWindowOpaque->SetDisplayMode(EColor256);
   1.346 +		if(iForegroundWindowSemiTrans)
   1.347 +			iForegroundWindowSemiTrans->SetDisplayMode(EColor64K);
   1.348 +		if(iForegroundWindowTrans)
   1.349 +			iForegroundWindowTrans->SetDisplayMode(EColor16MA);
   1.350 +		break;
   1.351 +		}
   1.352 +	}
   1.353 +
   1.354 +enum {ETiled, EOverlapping};
   1.355 +
   1.356 +void CTAlphaChannel::SetPositionConfiguration(TInt aConfig)
   1.357 +	{
   1.358 +	TSize screenSize=TheClient->iGroup->Size();
   1.359 +	TInt winWidth=(screenSize.iWidth)-10;
   1.360 +	TInt winHeight=screenSize.iHeight-10;
   1.361 +	if (aConfig==ETiled)
   1.362 +		{
   1.363 +		if(iForegroundWindowOpaque)
   1.364 +			iForegroundWindowOpaque->SetPos(TPoint(winWidth/5, 0));
   1.365 +		if(iForegroundWindowSemiTrans)
   1.366 +			iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, 0));
   1.367 +		if(iForegroundWindowTrans)
   1.368 +			iForegroundWindowTrans->SetPos(TPoint(3*winWidth/5, 0));
   1.369 +		}
   1.370 +	else
   1.371 +		{
   1.372 +		if(iForegroundWindowOpaque)
   1.373 +			iForegroundWindowOpaque->SetPos(TPoint(winWidth/3, -winHeight/3));
   1.374 +		if(iForegroundWindowSemiTrans)
   1.375 +			iForegroundWindowSemiTrans->SetPos(TPoint(2*winWidth/5, winHeight/3));
   1.376 +		if(iForegroundWindowTrans)
   1.377 +			iForegroundWindowTrans->SetPos(TPoint(winWidth/2, -winHeight/3));
   1.378 +		}
   1.379 +	if (iForegroundWindowBottom)
   1.380 +		iForegroundWindowBottom->SetPos(TPoint(0, 0));
   1.381 +	if (iForegroundWindowTop)
   1.382 +		iForegroundWindowTop->SetPos(TPoint(4*winWidth/5, 0));
   1.383 +	}
   1.384 +
   1.385 +enum {EVaryingTransparency, EVaryingColour};
   1.386 +
   1.387 +void CTAlphaChannel::SetColourConfiguration(TInt aConfig)
   1.388 +	{
   1.389 +	RWindow* win;
   1.390 +	if (aConfig==EVaryingTransparency)
   1.391 +		{
   1.392 +		// red background, green foregrounds of varying transparency
   1.393 +		win = (RWindow*)(iBackgroundWindow->DrawableWin());
   1.394 +		win->SetBackgroundColor(TRgb(255,0,0,255));
   1.395 +
   1.396 +		if(iForegroundWindowOpaque)
   1.397 +			iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255));
   1.398 +		if(iForegroundWindowSemiTrans)
   1.399 +			iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128));
   1.400 +		if(iForegroundWindowTrans)
   1.401 +			iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,0));
   1.402 +		}
   1.403 +	else
   1.404 +		{
   1.405 +		// white background, semi-transparent foregrounds in primary colours
   1.406 +		win = (RWindow*)(iBackgroundWindow->DrawableWin());
   1.407 +		win->SetBackgroundColor(TRgb(255,255,255,255));
   1.408 +
   1.409 +		if(iForegroundWindowOpaque)
   1.410 +			iForegroundWindowOpaque->SetBackgroundColor(TRgb(255,0,0,128));
   1.411 +		if(iForegroundWindowSemiTrans)
   1.412 +			iForegroundWindowSemiTrans->SetBackgroundColor(TRgb(0,255,0,128));
   1.413 +		if(iForegroundWindowTrans)
   1.414 +			iForegroundWindowTrans->SetBackgroundColor(TRgb(0,0,255,128));
   1.415 +		}
   1.416 +	}
   1.417 +
   1.418 +void CTAlphaChannel::DoMoving()
   1.419 +	{
   1.420 +	TPoint pos;
   1.421 +	for (TInt i = 0; i<20; i++)
   1.422 +		{
   1.423 +		if (iForegroundWindowBottom)
   1.424 +			{
   1.425 +			pos = iForegroundWindowBottom->Position();
   1.426 +			pos += TPoint(1,5);
   1.427 +			iForegroundWindowBottom->SetPos(pos);
   1.428 +			}
   1.429 +
   1.430 +		if (iForegroundWindowOpaque)
   1.431 +			{
   1.432 +			pos = iForegroundWindowOpaque->Position();
   1.433 +			pos += TPoint(1,5);
   1.434 +			iForegroundWindowOpaque->SetPos(pos);
   1.435 +			}
   1.436 +
   1.437 +		if (iForegroundWindowSemiTrans)
   1.438 +			{
   1.439 +			pos = iForegroundWindowSemiTrans->Position();
   1.440 +			pos += TPoint(1,5);
   1.441 +			iForegroundWindowSemiTrans->SetPos(pos);
   1.442 +			}
   1.443 +
   1.444 +		if (iForegroundWindowTrans)
   1.445 +			{
   1.446 +			pos = iForegroundWindowTrans->Position();
   1.447 +			pos += TPoint(1,5);
   1.448 +			iForegroundWindowTrans->SetPos(pos);
   1.449 +			}
   1.450 +
   1.451 +		if (iForegroundWindowTop)
   1.452 +			{
   1.453 +			pos = iForegroundWindowTop->Position();
   1.454 +			pos += TPoint(1,5);
   1.455 +			iForegroundWindowTop->SetPos(pos);
   1.456 +			}
   1.457 +
   1.458 +		TheClient->iWs.Flush();	
   1.459 +		User::After(TTimeIntervalMicroSeconds32(50000));
   1.460 +		}
   1.461 +
   1.462 +	}
   1.463 +
   1.464 +void CTAlphaChannel::DoMoveBehind()
   1.465 +	{
   1.466 +	TPoint pos = iBackgroundWindow->Position();
   1.467 +	for (TInt i = 0; i<20; i++)
   1.468 +		{
   1.469 +		pos += TPoint(0,5);
   1.470 +		iBackgroundWindow->SetPos(pos);
   1.471 +
   1.472 +		TheClient->iWs.Flush();	
   1.473 +		User::After(TTimeIntervalMicroSeconds32(50000));
   1.474 +		}
   1.475 +	iBackgroundWindow->SetPos(TPoint(5,5));
   1.476 +	}
   1.477 +
   1.478 +void CTAlphaChannel::DoInvisibility()
   1.479 +	{
   1.480 +	RWindow* win;
   1.481 +	if (iForegroundWindowBottom)
   1.482 +		{
   1.483 +		win = (RWindow*)(iForegroundWindowBottom->DrawableWin());
   1.484 +		win->SetVisible(EFalse);
   1.485 +		TheClient->iWs.Flush();	
   1.486 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.487 +
   1.488 +		win->SetVisible(ETrue);
   1.489 +		TheClient->iWs.Flush();	
   1.490 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.491 +		}
   1.492 +	if (iForegroundWindowOpaque)
   1.493 +		{
   1.494 +		win = (RWindow*)(iForegroundWindowOpaque->DrawableWin());
   1.495 +		win->SetVisible(EFalse);
   1.496 +		TheClient->iWs.Flush();	
   1.497 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.498 +
   1.499 +		win->SetVisible(ETrue);
   1.500 +		TheClient->iWs.Flush();	
   1.501 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.502 +		}
   1.503 +	if (iForegroundWindowSemiTrans)
   1.504 +		{
   1.505 +		win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin());
   1.506 +		win->SetVisible(EFalse);
   1.507 +		TheClient->iWs.Flush();	
   1.508 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.509 +
   1.510 +		win->SetVisible(ETrue);
   1.511 +		TheClient->iWs.Flush();	
   1.512 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.513 +		}
   1.514 +	if (iForegroundWindowTrans)
   1.515 +		{
   1.516 +		win = (RWindow*)(iForegroundWindowTrans->DrawableWin());
   1.517 +		win->SetVisible(EFalse);
   1.518 +		TheClient->iWs.Flush();	
   1.519 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.520 +
   1.521 +		win->SetVisible(ETrue);
   1.522 +		TheClient->iWs.Flush();	
   1.523 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.524 +		}
   1.525 +	if (iForegroundWindowTop)
   1.526 +		{
   1.527 +		win = (RWindow*)(iForegroundWindowTop->DrawableWin());
   1.528 +		win->SetVisible(EFalse);
   1.529 +		TheClient->iWs.Flush();	
   1.530 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.531 +
   1.532 +		win->SetVisible(ETrue);
   1.533 +		TheClient->iWs.Flush();	
   1.534 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.535 +		}
   1.536 +	}
   1.537 +
   1.538 +/** 
   1.539 +	@SYMTestCaseID	GRAPHICS-WSERV-0328
   1.540 +  	
   1.541 +  	@SYMTestCaseDesc			Testing a Fading.
   1.542 +  	
   1.543 +  	@SYMTestPriority			High
   1.544 +  	
   1.545 +  	@SYMTestStatus      		Implemented
   1.546 +  	
   1.547 +  	@SYMTestActions		
   1.548 +		 Set fading parameters. Draw all graphics primitives and bitmaps with 
   1.549 +		 various transparency				.
   1.550 + 
   1.551 +  	@SYMTestExpectedResults
   1.552 + 				All windows should be drawn according their fading values. 
   1.553 + */
   1.554 +
   1.555 +void CTAlphaChannel::TestFading()
   1.556 +	{
   1.557 +	iIsFading = ETrue;
   1.558 +	iBlackFading = 0;
   1.559 +	iWhiteFading = 128;
   1.560 +	iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading);
   1.561 +	INFO_PRINTF1(iText);
   1.562 +	DrawTestWindowsNow();
   1.563 +
   1.564 +	User::After(TTimeIntervalMicroSeconds32(1000000 * 1));
   1.565 +	iIsFading = EFalse;
   1.566 +	DrawTestWindowsNow();
   1.567 +	iIsFading = ETrue;
   1.568 +	iBlackFading = 128;
   1.569 +	iWhiteFading = 255;
   1.570 +	iText.Format(_L("Fading. %dX%d"), iBlackFading, iWhiteFading);
   1.571 +	INFO_PRINTF1(iText);
   1.572 +	DrawTestWindowsNow();
   1.573 +
   1.574 +	iIsFading = EFalse;
   1.575 +	}
   1.576 +	
   1.577 +/** 
   1.578 +	@SYMTestCaseID	GRAPHICS-WSERV-0329
   1.579 +  	
   1.580 +  	@SYMTestCaseDesc			Tests moving of foreground windows.
   1.581 +  	
   1.582 +  	@SYMTestPriority			High
   1.583 +  	
   1.584 +  	@SYMTestStatus      		Implemented
   1.585 +  	
   1.586 +  	@SYMTestActions		
   1.587 +		 Set fading parameters. Set position of foreground windows as tile				.
   1.588 + 
   1.589 +  	@SYMTestExpectedResults
   1.590 + 			Foreground window has to be redrawn properly.
   1.591 + */
   1.592 +
   1.593 +void CTAlphaChannel::TestMoving()
   1.594 +	{
   1.595 +	SetPositionConfiguration(ETiled);
   1.596 +	DoMoving();
   1.597 +	SetPositionConfiguration(ETiled);
   1.598 +	}
   1.599 +
   1.600 +/** 
   1.601 +	@SYMTestCaseID	GRAPHICS-WSERV-0330
   1.602 +  	
   1.603 +  	@SYMTestCaseDesc			Tests moving of foreground windows.
   1.604 +  	
   1.605 +  	@SYMTestPriority			High
   1.606 +  	
   1.607 +  	@SYMTestStatus      		Implemented
   1.608 +  	
   1.609 +  	@SYMTestActions		
   1.610 +		 Set fading parameters. Moves foreground windows over the screen			.
   1.611 + 
   1.612 +  	@SYMTestExpectedResults
   1.613 + 			Foreground window has to be redrawn properly.
   1.614 + */
   1.615 +
   1.616 +
   1.617 +void CTAlphaChannel::TestMovingOverlapping()
   1.618 +	{
   1.619 +	TPoint pos;
   1.620 +
   1.621 +	for (TInt i = 0; i < 20; i++)
   1.622 +		{
   1.623 +		if (iForegroundWindowOpaque)
   1.624 +			{
   1.625 +			pos = iForegroundWindowOpaque->Position();
   1.626 +			pos += TPoint(3,0);
   1.627 +			iForegroundWindowOpaque->SetPos(pos);
   1.628 +			}
   1.629 +		if (iForegroundWindowTrans)
   1.630 +			{
   1.631 +			pos = iForegroundWindowTrans->Position();
   1.632 +			pos -= TPoint(3,0);
   1.633 +			iForegroundWindowTrans->SetPos(pos);
   1.634 +			}
   1.635 +		TheClient->iWs.Flush();	
   1.636 +		User::After(TTimeIntervalMicroSeconds32(50000));
   1.637 +		}
   1.638 +	}
   1.639 +
   1.640 +/** 
   1.641 +	@SYMTestCaseID	GRAPHICS-WSERV-0331
   1.642 +  	
   1.643 +  	@SYMTestCaseDesc			Testing transparency factor for windows with alpha channel.
   1.644 +  	
   1.645 +  	@SYMTestPriority			High
   1.646 +  	
   1.647 +  	@SYMTestStatus      		Implemented
   1.648 +  	
   1.649 +  	@SYMTestActions		
   1.650 +		 Sets background colour with various level of transparency			.
   1.651 + 
   1.652 +  	@SYMTestExpectedResults
   1.653 + 			Foreground window must be redrawn properly.
   1.654 + */
   1.655 +void CTAlphaChannel::TestChangingTransparencyFactor()
   1.656 +	{
   1.657 +	TInt i = 0;
   1.658 +	while (i <= 255)
   1.659 +		{
   1.660 +		iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,255-i));
   1.661 +		iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,i));
   1.662 +		iForegroundWindowOpaque->DrawNow();
   1.663 +		iForegroundWindowTrans->DrawNow();
   1.664 +		i+=15;
   1.665 +		}
   1.666 +	i=0;
   1.667 +	while (i <= 255)
   1.668 +		{
   1.669 +		iForegroundWindowOpaque->SetBackgroundColor(TRgb(0,255,0,i));
   1.670 +		iForegroundWindowTrans->SetBackgroundColor(TRgb(0,255,0,255-i));
   1.671 +		iForegroundWindowOpaque->DrawNow();
   1.672 +		iForegroundWindowTrans->DrawNow();
   1.673 +		User::After(TTimeIntervalMicroSeconds32(50000));// 20 frames per second
   1.674 +		i+=15;
   1.675 +		}
   1.676 +	}
   1.677 +
   1.678 +/** 
   1.679 +	@SYMTestCaseID	GRAPHICS-WSERV-0332
   1.680 +  	
   1.681 +  	@SYMTestCaseDesc			Testing redrawing of foreground windows while their positions and 
   1.682 +  				invisibility have been changed.
   1.683 +  	
   1.684 +  	@SYMTestPriority			High
   1.685 +  	
   1.686 +  	@SYMTestStatus      		Implemented
   1.687 +  	
   1.688 +  	@SYMTestActions		
   1.689 +		 Sets position of the foreground windows as overlapping, tiled.
   1.690 +		Change visability of semi transparent foreground window.		.
   1.691 + 
   1.692 +  	@SYMTestExpectedResults
   1.693 + 		Foreground window must be redrawn properly.
   1.694 + */
   1.695 +
   1.696 +void CTAlphaChannel::TestInvisibility()
   1.697 +	{
   1.698 +	RWindow* win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin());
   1.699 +	SetPositionConfiguration(EOverlapping);
   1.700 +	TheClient->iWs.Flush();	
   1.701 +	User::After(TTimeIntervalMicroSeconds32(1000000));
   1.702 +
   1.703 +	win->SetVisible(EFalse);
   1.704 +	TheClient->iWs.Flush();	
   1.705 +	User::After(TTimeIntervalMicroSeconds32(1000000));
   1.706 +
   1.707 +	win->SetVisible(ETrue);
   1.708 +	TheClient->iWs.Flush();	
   1.709 +	User::After(TTimeIntervalMicroSeconds32(1000000));
   1.710 +
   1.711 +	SetPositionConfiguration(ETiled);
   1.712 +
   1.713 +	}
   1.714 +
   1.715 +/** 
   1.716 +	@SYMTestCaseID	GRAPHICS-WSERV-0333
   1.717 +  	
   1.718 +  	@SYMTestCaseDesc			Testing redrawing of foreground windows after a 
   1.719 +  				background window has been moved.
   1.720 +  	
   1.721 +  	@SYMTestPriority			High
   1.722 +  	
   1.723 +  	@SYMTestStatus      		Implemented
   1.724 +  	
   1.725 +  	@SYMTestActions		
   1.726 +		 Sets position of the foreground windows as tiled.
   1.727 +		Moves background window.
   1.728 + 
   1.729 +  	@SYMTestExpectedResults
   1.730 + 		Foreground windows must be redrawn properly.
   1.731 + */
   1.732 +void CTAlphaChannel::TestMoveUnderneath()
   1.733 +	{
   1.734 +	SetPositionConfiguration(ETiled);
   1.735 +	DoMoveBehind();
   1.736 +	}
   1.737 +/** 
   1.738 +	@SYMTestCaseID	GRAPHICS-WSERV-0334
   1.739 +  	
   1.740 +  	@SYMTestCaseDesc			Testing redrawing of foreground windows after a 
   1.741 +  				background window has been moved.
   1.742 +  	
   1.743 +  	@SYMTestPriority			High
   1.744 +  	
   1.745 +  	@SYMTestStatus      		Implemented
   1.746 +  	
   1.747 +  	@SYMTestActions		
   1.748 +		 Sets different position of the foreground windows: tiled, overlapping.
   1.749 +		Moves background window.
   1.750 + 
   1.751 +  	@SYMTestExpectedResults
   1.752 + 		Foreground windows has to be redrawn properly.
   1.753 + */
   1.754 +
   1.755 +void CTAlphaChannel::TestMoveBehindInvisible()
   1.756 +	{
   1.757 +	SetPositionConfiguration(ETiled);
   1.758 +	RWindow* win;
   1.759 +	win = (RWindow*)(iForegroundWindowOpaque->DrawableWin());
   1.760 +	win->SetVisible(EFalse);
   1.761 +	win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin());
   1.762 +	win->SetVisible(EFalse);
   1.763 +	win = (RWindow*)(iForegroundWindowTrans->DrawableWin());
   1.764 +	win->SetVisible(EFalse);
   1.765 +	TheClient->iWs.Flush();
   1.766 +
   1.767 +	DoMoveBehind();
   1.768 +
   1.769 +	SetPositionConfiguration(EOverlapping);
   1.770 +	DoMoveBehind();
   1.771 +
   1.772 +	win = (RWindow*)(iForegroundWindowOpaque->DrawableWin());
   1.773 +	win->SetVisible(ETrue);
   1.774 +	win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin());
   1.775 +	win->SetVisible(ETrue);
   1.776 +	win = (RWindow*)(iForegroundWindowTrans->DrawableWin());
   1.777 +	win->SetVisible(ETrue);
   1.778 +	TheClient->iWs.Flush();
   1.779 +	}
   1.780 +/** 
   1.781 +	@SYMTestCaseID	GRAPHICS-WSERV-0335
   1.782 +  	
   1.783 +  	@SYMTestCaseDesc			Testing redrawing of foreground windows.
   1.784 +  	
   1.785 +  	@SYMTestPriority			High
   1.786 +  	
   1.787 +  	@SYMTestStatus      		Implemented
   1.788 +  	
   1.789 +  	@SYMTestActions		
   1.790 +		 Redraws background window
   1.791 + 
   1.792 +  	@SYMTestExpectedResults
   1.793 + 		Foreground windows should be redrawn properly, if background window 
   1.794 +  		 has been redrawn.
   1.795 + */
   1.796 +void CTAlphaChannel::TestRedrawBehind()
   1.797 +	{
   1.798 +	TheClient->iWs.Flush();	
   1.799 +	iBackgroundWindow->iState += 1;
   1.800 +	iBackgroundWindow->DrawNow();
   1.801 +	TheClient->iWs.Flush();	
   1.802 +	User::After(TTimeIntervalMicroSeconds32(1000000));
   1.803 +	}
   1.804 +/** 
   1.805 +	@SYMTestCaseID	GRAPHICS-WSERV-0336
   1.806 +  	
   1.807 +  	@SYMTestCaseDesc			Testing transparency with RWsSprite class.
   1.808 +  	
   1.809 +  	@SYMTestPriority			High
   1.810 +  	
   1.811 +  	@SYMTestStatus      		Implemented
   1.812 +  	
   1.813 +  	@SYMTestActions		
   1.814 +		 Creates RBackedUpWindow window and moves it over transparent window
   1.815 +		appears and dissapears set up window as transparent
   1.816 + 
   1.817 +  	@SYMTestExpectedResults
   1.818 + 			Must work with transparent windows. 
   1.819 + */
   1.820 +
   1.821 +void CTAlphaChannel::TestAnimationL()
   1.822 +	{
   1.823 +	for(TInt ii = 0; ii < iArrWindow.Count(); ii++)
   1.824 +		{
   1.825 +		iArrWindow[ii]->StartAnimationL();
   1.826 +		}
   1.827 +	}
   1.828 +/** 
   1.829 +	@SYMTestCaseID	GRAPHICS-WSERV-0337
   1.830 +  	
   1.831 +  	@SYMTestCaseDesc			Testing transparency with RBackedUpWindow window class.
   1.832 +  	
   1.833 +  	@SYMTestPriority			High
   1.834 +  	
   1.835 +  	@SYMTestStatus      		Implemented
   1.836 +  	
   1.837 +  	@SYMTestActions		
   1.838 +		 Creates RBackedUpWindow window and moves it over transparent window
   1.839 +		appears and dissapears set up transparent window as transparent
   1.840 + 
   1.841 +  	@SYMTestExpectedResults
   1.842 + 				Do not expect correct work of alpha channel with 
   1.843 + 				RBackedUpWindow window class. 
   1.844 +*/
   1.845 +void CTAlphaChannel::TestBackedWindowL()
   1.846 +	{
   1.847 +	for(TInt ii = 0; ii < iArrWindow.Count(); ii++)
   1.848 +		{
   1.849 +		iArrWindow[ii]->CreateBackedWindowL();
   1.850 +		}
   1.851 +	}
   1.852 +
   1.853 +/** 
   1.854 +	@SYMTestCaseID	GRAPHICS-WSERV-0338
   1.855 +  	
   1.856 +  	@SYMTestCaseDesc			Implication of setting SetDrawOpaque on drawing with alpha channel.
   1.857 +  	
   1.858 +  	@SYMTestPriority			High
   1.859 +  	
   1.860 +  	@SYMTestStatus      		Implemented
   1.861 +  	
   1.862 +  	@SYMTestActions		
   1.863 +		 Change graphic context to opaque and none opaque and rewdraw all test windows
   1.864 + 
   1.865 +  	@SYMTestExpectedResults
   1.866 + 				must not impact on output with alpha channel 
   1.867 + */
   1.868 +
   1.869 +void CTAlphaChannel::TestEffectSetOpaque()
   1.870 +	{
   1.871 +	for(TInt ii = 0; ii < 3; ii++)
   1.872 +		{
   1.873 +		
   1.874 +		for(TInt ii = 0; ii < iArrWindow.Count(); ii++)
   1.875 +			{
   1.876 +			iArrWindow[ii]->SetDrawOpaque(EFalse);
   1.877 +			}
   1.878 +	
   1.879 +		DrawTestWindowsNow();
   1.880 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.881 +
   1.882 +		for(TInt jj = 0; jj < iArrWindow.Count(); jj++)
   1.883 +			{
   1.884 +			iArrWindow[jj]->SetDrawOpaque(ETrue);
   1.885 +			}
   1.886 +
   1.887 +		DrawTestWindowsNow();
   1.888 +		User::After(TTimeIntervalMicroSeconds32(1000000));
   1.889 +		}
   1.890 +	}
   1.891 +
   1.892 +/** 
   1.893 +	@SYMTestCaseID	GRAPHICS-WSERV-0339
   1.894 +  	
   1.895 +  	@SYMTestCaseDesc			Redrawing of child windows with transparency.
   1.896 +  	
   1.897 +  	@SYMTestPriority			High
   1.898 +  	
   1.899 +  	@SYMTestStatus      		Implemented
   1.900 +  	
   1.901 +  	@SYMTestActions		
   1.902 +		 	Creates a few child windows with various levels of transparency.
   1.903 +		Moves parent window over the screen.
   1.904 +  	@SYMTestExpectedResults
   1.905 + 				Child and parent windows must be redrawn properly 
   1.906 + */
   1.907 +
   1.908 +void CTAlphaChannel::TestChildWindowL()
   1.909 +	{
   1.910 +	SetPositionConfiguration(ETiled);
   1.911 +	SetColourConfiguration(EVaryingColour);
   1.912 +	DrawTestWindowsNow(ETrue);
   1.913 +	TDisplayMode mode = EColor64K;
   1.914 +	CTWinAlphaForeground* childWin[] = {NULL, NULL, NULL, NULL, NULL};
   1.915 +	if (iForegroundWindowBottom)
   1.916 +		{
   1.917 +		childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
   1.918 +		childWin[0]->DrawNow();
   1.919 +		}
   1.920 +	if (iForegroundWindowOpaque)
   1.921 +		{
   1.922 +		childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyFactor);
   1.923 +		childWin[1]->DrawNow();
   1.924 +		}
   1.925 +	if (iForegroundWindowSemiTrans)
   1.926 +		{
   1.927 +		childWin[2] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowSemiTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ETransparencyAlpha);
   1.928 +		childWin[2]->DrawNow();
   1.929 +		}
   1.930 +	if (iForegroundWindowTrans)
   1.931 +		{
   1.932 +		childWin[3] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTrans,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
   1.933 +		childWin[3]->DrawNow();
   1.934 +		}
   1.935 +	if (iForegroundWindowTop)
   1.936 +		{
   1.937 +		childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowTop,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
   1.938 +		childWin[4]->DrawNow();
   1.939 +		}
   1.940 +	TheClient->iWs.Flush();	
   1.941 +
   1.942 +	User::After(TTimeIntervalMicroSeconds32(1000000));
   1.943 +	DoMoving();
   1.944 +
   1.945 +	delete childWin[0];
   1.946 +	delete childWin[1];
   1.947 +	delete childWin[2];
   1.948 +	delete childWin[3];
   1.949 +	delete childWin[4];
   1.950 +	}
   1.951 +/** 
   1.952 +	@SYMTestCaseID	GRAPHICS-WSERV-0340
   1.953 +  	
   1.954 +  	@SYMTestCaseDesc			Redrawing of multiple child windows with transparency.
   1.955 +  	
   1.956 +  	@SYMTestPriority			High
   1.957 +  	
   1.958 +  	@SYMTestStatus      		Implemented
   1.959 +  	
   1.960 +  	@SYMTestActions		
   1.961 +		 	Creates multiple child windows with various levels of transparency.
   1.962 +		Moves parent windows over the screen.
   1.963 +  	@SYMTestExpectedResults
   1.964 + 				Child and parent windows must be redrawn properly 
   1.965 + */
   1.966 +
   1.967 +void CTAlphaChannel::TestMultipleChildrenL()
   1.968 +	{
   1.969 +	SetPositionConfiguration(ETiled);
   1.970 +	SetColourConfiguration(EVaryingColour);
   1.971 +	TDisplayMode mode = EColor64K;
   1.972 +	CTWinAlphaForeground* childWin[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
   1.973 +	if (iForegroundWindowBottom)
   1.974 +		{
   1.975 +		childWin[0] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(50,50),iForegroundWindowBottom,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyFactor);
   1.976 +		childWin[1] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[0],*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha);
   1.977 +		childWin[0]->DrawNow();
   1.978 +		childWin[1]->DrawNow();
   1.979 +		}
   1.980 +	if (iForegroundWindowOpaque)
   1.981 +		{
   1.982 +		childWin[4] = CTWinAlphaForeground::NewL(*this, TPoint(0,0),TSize(100,100),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ETransparencyAlpha);
   1.983 +		childWin[5] = CTWinAlphaForeground::NewL(*this, TPoint(20,80),TSize(50,50),iForegroundWindowOpaque,*TheClient->iGc, &mode, TRgb(255, 255, 255,128), ENonTransparentAlpha);
   1.984 +		childWin[6] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(60,60),childWin[4],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
   1.985 +		childWin[7] = CTWinAlphaForeground::NewL(*this, TPoint(20,20),TSize(50,50),childWin[6],*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
   1.986 +		childWin[4]->DrawNow();
   1.987 +		childWin[5]->DrawNow();
   1.988 +		childWin[6]->DrawNow();
   1.989 +		childWin[7]->DrawNow();
   1.990 +		}
   1.991 +	DrawTestWindowsNow(ETrue);
   1.992 +
   1.993 +	TestMoving();
   1.994 +
   1.995 +	delete childWin[0];
   1.996 +	delete childWin[1];
   1.997 +	delete childWin[2];
   1.998 +	delete childWin[3];
   1.999 +	delete childWin[4];
  1.1000 +	delete childWin[5];
  1.1001 +	delete childWin[6];
  1.1002 +	delete childWin[7];
  1.1003 +	}
  1.1004 +
  1.1005 +/** 
  1.1006 +	@SYMTestCaseID	GRAPHICS-WSERV-0341
  1.1007 +  	
  1.1008 +  	@SYMTestCaseDesc			Test transparent window which positioned under opaque.
  1.1009 +  	
  1.1010 +  	@SYMTestPriority			High
  1.1011 +  	
  1.1012 +  	@SYMTestStatus      		Implemented
  1.1013 +  	
  1.1014 +  	@SYMTestActions		
  1.1015 +		 	Creates an opaque window on the topt of transparent windows.
  1.1016 +		Moves transparent windows over the screen.
  1.1017 +  	@SYMTestExpectedResults
  1.1018 + 				Transparent windows must be redrawn properly 
  1.1019 + */
  1.1020 +
  1.1021 +void CTAlphaChannel::TestTransparentMovingUnderOpaqueL()
  1.1022 +	{
  1.1023 +	SetColourConfiguration(EVaryingColour);
  1.1024 +	TDisplayMode mode = EColor64K;
  1.1025 +	CTWinAlphaForeground* win = CTWinAlphaForeground::NewL(*this, TPoint(0,100),TSize(600,40),TheClient->iGroup,*TheClient->iGc, &mode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
  1.1026 +	win->DrawNow();
  1.1027 +
  1.1028 +	TestMoving();
  1.1029 +
  1.1030 +	delete win;
  1.1031 +	}
  1.1032 +/** 
  1.1033 +	@SYMTestCaseID	GRAPHICS-WSERV-0342
  1.1034 +  	
  1.1035 +  	@SYMTestCaseDesc			Changing orinary position of the foreground windows.
  1.1036 +  	
  1.1037 +  	@SYMTestPriority			High
  1.1038 +  	
  1.1039 +  	@SYMTestStatus      		Implemented
  1.1040 +  	
  1.1041 +  	@SYMTestActions		
  1.1042 +		 	Set ordinal position of foreground windows.
  1.1043 +  	@SYMTestExpectedResults
  1.1044 + 				Foreground windows must be redrawn properly 
  1.1045 + */
  1.1046 +
  1.1047 +void CTAlphaChannel::TestSetOrdinalPosition()
  1.1048 +	{
  1.1049 +	SetColourConfiguration(EVaryingColour);
  1.1050 +	SetPositionConfiguration(EOverlapping);
  1.1051 +	DrawTestWindowsNow(ETrue);
  1.1052 +	TheClient->iWs.Flush();	
  1.1053 +	User::After(TTimeIntervalMicroSeconds32(1000000));
  1.1054 +	RWindow* win;
  1.1055 +	for (TInt i=0; i<3; i++)
  1.1056 +		{
  1.1057 +		if (iForegroundWindowOpaque)
  1.1058 +			{
  1.1059 +			win = (RWindow*)(iForegroundWindowOpaque->DrawableWin());
  1.1060 +			win->SetOrdinalPosition(0);
  1.1061 +			TheClient->iWs.Flush();	
  1.1062 +			User::After(TTimeIntervalMicroSeconds32(1000000));
  1.1063 +			}
  1.1064 +		if (iForegroundWindowSemiTrans)
  1.1065 +			{
  1.1066 +			win = (RWindow*)(iForegroundWindowSemiTrans->DrawableWin());
  1.1067 +			win->SetOrdinalPosition(0);
  1.1068 +			TheClient->iWs.Flush();	
  1.1069 +			User::After(TTimeIntervalMicroSeconds32(1000000));
  1.1070 +			}
  1.1071 +		if (iForegroundWindowTrans)
  1.1072 +			{
  1.1073 +			win = (RWindow*)(iForegroundWindowTrans->DrawableWin());
  1.1074 +			win->SetOrdinalPosition(0);
  1.1075 +			TheClient->iWs.Flush();	
  1.1076 +			User::After(TTimeIntervalMicroSeconds32(1000000));
  1.1077 +			}
  1.1078 +		}
  1.1079 +	}
  1.1080 +
  1.1081 +void CTAlphaChannel::RunTestCaseL(TInt aCurTestCase)
  1.1082 +	{
  1.1083 +	User::After(TTimeIntervalMicroSeconds32(1000000 * 2));
  1.1084 +	
  1.1085 +	((CTAlphaChannelStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1086 +	switch (aCurTestCase)
  1.1087 +		{
  1.1088 +		case 1:
  1.1089 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1090 +			CreateForegroundWindowsL(iSizeForegroundWindow, EColor16MU);
  1.1091 +			break;
  1.1092 +		case 2:
  1.1093 +			{
  1.1094 +			CreateForegroundWindowsL(iSizeForegroundWindow, EColor64K);
  1.1095 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0339"));
  1.1096 +			TestChildWindowL();
  1.1097 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1098 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0340"));
  1.1099 +			TestMultipleChildrenL();
  1.1100 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1101 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0342"));
  1.1102 +			TestSetOrdinalPosition();
  1.1103 +			}
  1.1104 +			break;
  1.1105 +		case 3: 
  1.1106 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336"));
  1.1107 +			TestAnimationL();
  1.1108 +		case 4: 
  1.1109 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337"));
  1.1110 +			TestBackedWindowL();
  1.1111 +			break;
  1.1112 +		case 5: 
  1.1113 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338"));
  1.1114 +			TestEffectSetOpaque();
  1.1115 +			break;
  1.1116 +		case 6:
  1.1117 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1118 +			iIsFading = EFalse;
  1.1119 +			DrawTestWindowsNow();
  1.1120 +			INFO_PRINTF1(_L("Anti-aliasing"));
  1.1121 +			iIsFading = EFalse;
  1.1122 +			iDrawText = ETrue;
  1.1123 +			DrawTestWindowsNow();
  1.1124 +			break;
  1.1125 +		case 7:	
  1.1126 +			SetColourConfiguration(EVaryingColour);
  1.1127 +			SetPositionConfiguration(EOverlapping);
  1.1128 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335"));
  1.1129 +			TestRedrawBehind();		
  1.1130 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1131 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329"));
  1.1132 +			TestMoving();
  1.1133 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1134 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0330"));
  1.1135 +			TestMovingOverlapping();		
  1.1136 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1137 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0341"));
  1.1138 +			TestMoveBehindInvisible();
  1.1139 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1140 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0334"));
  1.1141 +			TestTransparentMovingUnderOpaqueL();
  1.1142 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1143 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331"));
  1.1144 +			TestInvisibility();
  1.1145 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1146 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332"));
  1.1147 +			TestChangingTransparencyFactor();
  1.1148 +			break;
  1.1149 +		case 8:
  1.1150 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328"));
  1.1151 +			TestFading();
  1.1152 +			break;
  1.1153 +		case 9:
  1.1154 +			{
  1.1155 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1156 +			iDrawText = EFalse;
  1.1157 +			SetDisplayModeConfiguration(EAll16MA);
  1.1158 +			}
  1.1159 +			break;
  1.1160 +		case 10:
  1.1161 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1162 +			iIsFading = EFalse;
  1.1163 +			DrawTestWindowsNow();
  1.1164 +			INFO_PRINTF1(_L("Anti-aliasing"));
  1.1165 +			iIsFading = EFalse;
  1.1166 +			iDrawText = ETrue;
  1.1167 +			DrawTestWindowsNow();
  1.1168 +			break;
  1.1169 +		case 11:
  1.1170 +			SetColourConfiguration(EVaryingColour);
  1.1171 +			SetPositionConfiguration(EOverlapping);
  1.1172 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333"));
  1.1173 +			TestMoveUnderneath();
  1.1174 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1175 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335"));
  1.1176 +			TestRedrawBehind();
  1.1177 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1178 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329"));
  1.1179 +			TestMoving();
  1.1180 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1181 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332"));
  1.1182 +			TestInvisibility();
  1.1183 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1184 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0331"));
  1.1185 +			TestChangingTransparencyFactor();
  1.1186 +			break;
  1.1187 +		case 12:
  1.1188 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0328"));
  1.1189 +			TestFading();
  1.1190 +			break;
  1.1191 +		case 13:
  1.1192 +			SetDisplayModeConfiguration(EAllDifferent);
  1.1193 +			SetColourConfiguration(EVaryingColour);
  1.1194 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0333"));
  1.1195 +			TestMoveUnderneath();
  1.1196 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1197 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0335"));
  1.1198 +			TestRedrawBehind();
  1.1199 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1200 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0332"));
  1.1201 +			TestInvisibility();
  1.1202 +			((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1203 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0329"));
  1.1204 +			TestMoving();
  1.1205 +			break;
  1.1206 +		case 14:
  1.1207 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0336"));
  1.1208 +			TestAnimationL();
  1.1209 +			break;
  1.1210 +		case 15:
  1.1211 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0337"));
  1.1212 +			TestBackedWindowL();
  1.1213 +			break;
  1.1214 +		case 16:
  1.1215 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0338"));
  1.1216 +			TestEffectSetOpaque();
  1.1217 +			break;
  1.1218 +		case 17:
  1.1219 +			((CTAlphaChannelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1220 +			((CTAlphaChannelStep*)iStep)->CloseTMSGraphicsStep();
  1.1221 +			TestComplete();
  1.1222 +			break;
  1.1223 +		}
  1.1224 +	((CTAlphaChannelStep*)iStep)->RecordTestResultL();
  1.1225 +	}
  1.1226 +	
  1.1227 +/** Calculate foreground windows margin and create them*/
  1.1228 +void CTAlphaChannel::CreateForegroundWindowsL(const TSize& aSize, TDisplayMode aMode)
  1.1229 +	{
  1.1230 +	TPoint pt = TPoint(5, 5);
  1.1231 +	
  1.1232 +	//creating foreground windows
  1.1233 +	//bottom window
  1.1234 +	TDisplayMode dispMode = aMode;
  1.1235 +	iForegroundWindowBottom = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ETransparencyFactor);
  1.1236 +	iArrWindow.AppendL( iForegroundWindowBottom);
  1.1237 +
  1.1238 +	//dispMode = EColor16MA;
  1.1239 +	pt.iX += aSize.iWidth + KWindowIndention;
  1.1240 +	//opaque window
  1.1241 +	iForegroundWindowOpaque = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 255), ETransparencyAlpha);
  1.1242 +	iArrWindow.AppendL( iForegroundWindowOpaque);
  1.1243 +
  1.1244 +	pt.iX += aSize.iWidth + KWindowIndention;
  1.1245 +	//semi-transparent window
  1.1246 +	iForegroundWindowSemiTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 128), ETransparencyAlpha);
  1.1247 +	iArrWindow.AppendL( iForegroundWindowSemiTrans);
  1.1248 +
  1.1249 +	//transparent window
  1.1250 +	pt.iX += aSize.iWidth + KWindowIndention;
  1.1251 +	iForegroundWindowTrans = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0, 0), ETransparencyAlpha);
  1.1252 +	iArrWindow.AppendL( iForegroundWindowTrans);
  1.1253 +
  1.1254 +	// top window
  1.1255 +	pt.iX += aSize.iWidth + KWindowIndention;
  1.1256 +	iForegroundWindowTop = CTWinAlphaForeground::NewL(*this, pt,aSize,TheClient->iGroup,*TheClient->iGc, &dispMode, TRgb(0, 255, 0,128), ENonTransparentAlpha);
  1.1257 +	iArrWindow.AppendL( iForegroundWindowTop);
  1.1258 +	}
  1.1259 +
  1.1260 +void CTAlphaChannel::DestroyForegroundWindows()
  1.1261 +	{
  1.1262 +	iArrWindow.ResetAndDestroy();
  1.1263 +	iForegroundWindowBottom = NULL;
  1.1264 +	iForegroundWindowOpaque = NULL;
  1.1265 +	iForegroundWindowSemiTrans = NULL;
  1.1266 +	iForegroundWindowTrans = NULL;
  1.1267 +	iForegroundWindowTop = NULL;
  1.1268 +	}
  1.1269 +
  1.1270 +/** Draw all foreground windows */
  1.1271 +void CTAlphaChannel::DrawTestWindowsNow(TBool aDrawBackgroundWin)
  1.1272 +	{
  1.1273 +	if(iBackgroundWindow && aDrawBackgroundWin)
  1.1274 +		{
  1.1275 +		iBackgroundWindow->DrawNow();
  1.1276 +		}
  1.1277 +
  1.1278 +	for(TInt ii = 0; ii < iArrWindow.Count(); ii++)
  1.1279 +		{
  1.1280 +		iArrWindow[ii]->DrawNow();
  1.1281 +		}
  1.1282 +	}
  1.1283 +	
  1.1284 +//-------------
  1.1285 +
  1.1286 +CTWinAlphaForeground* CTWinAlphaForeground::NewL(CTAlphaChannel& aTest, TPoint aPos, TSize aSize, CTWinBase *aParent, CWindowGc &aGc, TDisplayMode *aMode, TRgb aCol, TInt aTransparencyType)
  1.1287 +	{
  1.1288 +	CTWinAlphaForeground* theWin = new(ELeave) CTWinAlphaForeground(aTest);
  1.1289 +	
  1.1290 +	theWin->ConstructL(*aParent);
  1.1291 +	if (aMode)
  1.1292 +		theWin->SetDisplayMode(*aMode);
  1.1293 +	theWin->SetExtL(aPos, aSize);
  1.1294 +	theWin->AssignGC(aGc);
  1.1295 +	theWin->PrepareForDrawingL();	
  1.1296 +
  1.1297 +	// for hardware testing	only we create an additional bitmap
  1.1298 +#ifndef __WINS__
  1.1299 +	theWin->CreateBackgroundBitmapL(*aMode);
  1.1300 +#endif
  1.1301 +		
  1.1302 +	RWindow* win = (RWindow*) (theWin->DrawableWin());
  1.1303 +	win->SetShadowHeight(0);
  1.1304 +	win->SetShadowDisabled(ETrue);
  1.1305 +	switch (aTransparencyType)
  1.1306 +		{
  1.1307 +	case ETransparencyFactor:
  1.1308 +		{
  1.1309 +		win->SetTransparencyFactor(aCol);
  1.1310 +		theWin->SetBackgroundColor(aCol);
  1.1311 +		}
  1.1312 +		break;
  1.1313 +	case ETransparencyAlpha:
  1.1314 +		win->SetTransparencyAlphaChannel();
  1.1315 +		// fall through into next case
  1.1316 +	case ENonTransparentAlpha:
  1.1317 +	default:
  1.1318 +		theWin->SetBackgroundColor(aCol);
  1.1319 +		break;
  1.1320 +		}
  1.1321 +	
  1.1322 +	theWin->Activate();
  1.1323 +
  1.1324 +	return theWin;
  1.1325 +	}
  1.1326 +
  1.1327 +CTWinAlphaForeground::~CTWinAlphaForeground()
  1.1328 +	{
  1.1329 +	if(iPolygon)
  1.1330 +		{
  1.1331 +		iPolygon->Reset();
  1.1332 +		delete iPolygon;
  1.1333 +		}
  1.1334 +	delete iBitmapBackground;
  1.1335 +	delete iBitmapDeviceBackground;
  1.1336 +	delete iBitmapContextBackground;
  1.1337 +	}
  1.1338 +	
  1.1339 +CTWinAlphaForeground::CTWinAlphaForeground(CTAlphaChannel& aTest)
  1.1340 +	: iTest(aTest)
  1.1341 +	{	
  1.1342 +	}
  1.1343 +
  1.1344 +
  1.1345 +void CTWinAlphaForeground::SetDisplayMode(TDisplayMode aDisplayMode)
  1.1346 +	{
  1.1347 +	BaseWin()->SetRequiredDisplayMode(aDisplayMode);
  1.1348 +	switch (aDisplayMode)
  1.1349 +		{
  1.1350 +	case EColor256:
  1.1351 +		iTitle1 = _L("256");
  1.1352 +		break;
  1.1353 +	case EColor64K:
  1.1354 +		iTitle1 = _L("64K");
  1.1355 +		break;
  1.1356 +	case EColor16MU:
  1.1357 +		iTitle1 = _L("16MU");
  1.1358 +		break;
  1.1359 +	case EColor16MA:
  1.1360 +		iTitle1 = _L("16MA");
  1.1361 +		break;
  1.1362 +	case EColor16MAP:
  1.1363 +		iTitle1 = _L("16MAP");
  1.1364 +		break;
  1.1365 +	default:
  1.1366 +		iTitle1 = _L("");
  1.1367 +		break;
  1.1368 +		}
  1.1369 +	}
  1.1370 +
  1.1371 +void CTWinAlphaForeground::SetBackgroundColor(TRgb aRgb)
  1.1372 +	{
  1.1373 +	switch (aRgb.Alpha())
  1.1374 +		{
  1.1375 +		case 0:
  1.1376 +		iTitle2 = _L(" trans ");		
  1.1377 +		break;
  1.1378 +		case 255:
  1.1379 +		iTitle2 = _L(" opaque ");		
  1.1380 +		break;
  1.1381 +		case 128:
  1.1382 +		default:
  1.1383 +		iTitle2 = _L(" s-trans ");		
  1.1384 +		break;
  1.1385 +		}
  1.1386 +	if (aRgb.Red())
  1.1387 +		iTitle2 += _L("R");
  1.1388 +	if (aRgb.Green())
  1.1389 +		iTitle2 += _L("G");
  1.1390 +	if (aRgb.Blue())
  1.1391 +		iTitle2 += _L("B");
  1.1392 +
  1.1393 +	iBackgroundColor = aRgb;
  1.1394 +	((RWindow*) DrawableWin())->SetBackgroundColor(aRgb);
  1.1395 +	}
  1.1396 +
  1.1397 +void CTWinAlphaForeground::Draw()
  1.1398 +	{
  1.1399 +	CBitmapContext* theGc = TheClient->iGc;
  1.1400 +	((CWindowGc*)theGc)->SetOpaque(iDrawOpaque);
  1.1401 +	
  1.1402 +	if(iBitmapContextBackground)
  1.1403 +		{
  1.1404 +		//CGraphicsContext
  1.1405 +		theGc = iBitmapContextBackground;
  1.1406 +		CleanBackgroundBitmap();
  1.1407 +		}
  1.1408 +	if(iTest.iFont1)
  1.1409 +		theGc->UseFont(iTest.iFont1);
  1.1410 +	
  1.1411 +	
  1.1412 +	theGc->SetFaded(EFalse);
  1.1413 +	DrawTable(*theGc);
  1.1414 +
  1.1415 +	TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ;
  1.1416 +
  1.1417 +	theGc->SetBrushStyle(iTest.iBrushStyle);
  1.1418 +	if(iTest.iFont && iTest.iDrawText)
  1.1419 +		{
  1.1420 +		theGc->DiscardFont();
  1.1421 +		theGc->UseFont(iTest.iFont);
  1.1422 +		}
  1.1423 +	
  1.1424 +	theGc->SetFaded(iTest.iIsFading);
  1.1425 +	
  1.1426 +	// the factor and offset are calculated as follows: 
  1.1427 +	// iFadeMapFactor = iWhiteFading - iBlackFading;
  1.1428 +	// iFadeMapOffset = iBlackFading;
  1.1429 +
  1.1430 +	theGc->SetFadingParameters(iTest.iBlackFading, iTest.iWhiteFading); //black and white
  1.1431 +		
  1.1432 +	for(TInt ii = 0; ii < numRows - 1; ii++)
  1.1433 +		{
  1.1434 +		theGc -> SetBrushStyle(iTest.iBrushStyle);
  1.1435 +
  1.1436 +		TRect theRect = TRect(iCol, iRows[ii], Size().iWidth, iRows[ii + 1]);
  1.1437 +				
  1.1438 +   		TRgb theBrush = iTest.GetBrush(ii);
  1.1439 +   		TRgb thePen = iTest.GetPen(ii);
  1.1440 +
  1.1441 +   		CGraphicsContext::TDrawMode theDrawMode = iTest.GetDrawMode(ii);
  1.1442 +    		
  1.1443 +   		theGc->SetBrushColor(theBrush);
  1.1444 +		theGc->SetPenColor(thePen);
  1.1445 +   		theGc->SetDrawMode(theDrawMode);
  1.1446 +		
  1.1447 +		CGraphicsContext* theBitmapContext64K;
  1.1448 +		CGraphicsContext* theBitmapContext16MA;
  1.1449 +		CFbsBitmap* theBitmap64K;
  1.1450 +		CFbsBitmap* theBitmap16MA;
  1.1451 +
  1.1452 +		switch(ii)
  1.1453 +			{
  1.1454 +			case 0:
  1.1455 +				{
  1.1456 +				theBitmapContext64K = iTest.iBitmapContext64K_1;
  1.1457 +				theBitmapContext16MA = iTest.iBitmapContext16MA_1;
  1.1458 +				theBitmap64K = iTest.iBitmap64K_1;
  1.1459 +				theBitmap16MA = iTest.iBitmap16MA_1;
  1.1460 +				break;
  1.1461 +				}
  1.1462 +			case 1:
  1.1463 +				{
  1.1464 +				theBitmapContext64K = iTest.iBitmapContext64K_2;
  1.1465 +				theBitmapContext16MA = iTest.iBitmapContext16MA_2;
  1.1466 +				theBitmap64K = iTest.iBitmap64K_2;
  1.1467 +				theBitmap16MA = iTest.iBitmap16MA_2;
  1.1468 +				break;
  1.1469 +				}
  1.1470 +			default:
  1.1471 +				{
  1.1472 +				theBitmapContext64K = iTest.iBitmapContext64K_3;
  1.1473 +				theBitmapContext16MA = iTest.iBitmapContext16MA_3;
  1.1474 +				theBitmap64K = iTest.iBitmap64K_3;
  1.1475 +				theBitmap16MA = iTest.iBitmap16MA_3;
  1.1476 +				break;
  1.1477 +				}
  1.1478 +			}
  1.1479 +			if(iTest.iDrawText)
  1.1480 +				{
  1.1481 +				DrawTextInCell(*theGc, theRect);
  1.1482 +				}
  1.1483 +			else
  1.1484 +				{
  1.1485 +				TRAP_IGNORE(iTest.DrawOffscreenBitmapsL(thePen, theBrush, theBitmapContext64K, 
  1.1486 +					theBitmapContext16MA, theBitmap64K, theBitmap16MA));
  1.1487 +				DrawPrimitivesInCell(*theGc, theRect, theBitmap64K, theBitmap16MA);
  1.1488 +				}
  1.1489 +		TheClient->iWs.Flush();	
  1.1490 +		}
  1.1491 +
  1.1492 +	theGc->DiscardFont();
  1.1493 +
  1.1494 +	if(iBitmapContextBackground)
  1.1495 +		{
  1.1496 +		theGc = TheClient->iGc;
  1.1497 +		theGc->BitBlt(TPoint(0, 0), iBitmapBackground);
  1.1498 +		}
  1.1499 +	}
  1.1500 +
  1.1501 +void CTWinAlphaForeground::SetPoligonLocation(const TPoint &ptOffset)
  1.1502 +	{
  1.1503 +	TRect rect = TRect(iTest.iTriangleSize);
  1.1504 +	(*iPolygon)[0] = rect.iTl + ptOffset;
  1.1505 +	(*iPolygon)[1] = TPoint(rect.iTl.iX, rect.iBr.iY) + ptOffset;
  1.1506 +	(*iPolygon)[2] = rect.iBr + ptOffset;
  1.1507 +	}
  1.1508 +	
  1.1509 +/** Define boundary of the table*/
  1.1510 +void CTWinAlphaForeground::CalculateTableMargin()
  1.1511 +	{
  1.1512 +	TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ;
  1.1513 +	iRows[0] = iTest.iFirstCellHeight;
  1.1514 +	TInt theRowHeight = (Size().iHeight - iTest.iFirstCellHeight) / 3;
  1.1515 +	for(TInt ii = 1; ii < numRows; ii++)
  1.1516 +		{
  1.1517 +		iRows[ii] = iRows[ii-1] + theRowHeight;
  1.1518 +		}
  1.1519 +	}
  1.1520 +	
  1.1521 +/** Draw a table which comprises 3 rows: for transparent, semi-transparent 
  1.1522 +	and opaque output
  1.1523 +
  1.1524 +*/	
  1.1525 +void CTWinAlphaForeground::DrawTable(CBitmapContext& aGc) const
  1.1526 +	{
  1.1527 +	TInt numRows = sizeof(iRows) / sizeof(iRows[0]) ;
  1.1528 +	
  1.1529 +	aGc.SetPenColor(iTest.iPenTable);
  1.1530 +	
  1.1531 +	for (TInt ii = 0; ii < numRows - 1; ii++)
  1.1532 +		{
  1.1533 +		TBuf<4> iBuf;
  1.1534 +		TPoint pt1 = TPoint(0, iRows[ii]);
  1.1535 +		TPoint pt2 = TPoint(Size().iWidth, iRows[ii]);
  1.1536 +
  1.1537 +		aGc.DrawLine(pt1, pt2);
  1.1538 +		
  1.1539 +		if(iCol)
  1.1540 +			{
  1.1541 +			TPoint pt3 = TPoint(0, iRows[ii]) + TPoint(2,(iRows[1] - iRows[0]) / 2); 
  1.1542 +			switch(ii)
  1.1543 +				{
  1.1544 +					case 0: iBuf = _L("o"); break;
  1.1545 +					case 1: iBuf = _L("s"); break;
  1.1546 +					case 2: iBuf = _L("t"); break;
  1.1547 +					default : iBuf = _L(""); break;
  1.1548 +				}
  1.1549 +			aGc.DrawText(iBuf, pt3); 
  1.1550 +			}
  1.1551 +		}
  1.1552 +	if(iCol)
  1.1553 +		{
  1.1554 +		TPoint pt3 = TPoint(iCol, iRows[0]) + TPoint(1,-2); 
  1.1555 +		TBuf<32> text = iTitle1;
  1.1556 +		text += iTitle2;
  1.1557 +		aGc.DrawText(text, pt3); 
  1.1558 +	
  1.1559 +		TPoint pt1 = TPoint(iCol, 0);
  1.1560 +		TPoint pt2 = TPoint(iCol, Size().iHeight);
  1.1561 +		aGc.DrawLine(pt1, pt2);
  1.1562 +		}
  1.1563 +		
  1.1564 +	}
  1.1565 +
  1.1566 +/** Draw truetype font to check anti-aliasing*/
  1.1567 +void CTWinAlphaForeground::DrawTextInCell(CBitmapContext& aGc, const TRect& aRect)
  1.1568 +	{
  1.1569 +    TPoint pt(aRect.iTl.iX, aRect.iBr.iY);
  1.1570 +    pt += TPoint(2, -10);
  1.1571 +    
  1.1572 +    aGc.DrawText(_L("ABCD"), pt);
  1.1573 +	}
  1.1574 +
  1.1575 +/** Draw graphics primitive in a cell:
  1.1576 +	rectangle, ellipse, triangle, a few lines, bitmaps
  1.1577 +
  1.1578 + */	
  1.1579 +void CTWinAlphaForeground::DrawPrimitivesInCell(CBitmapContext& aGc, const TRect& aRect, 
  1.1580 +								CFbsBitmap* aBitmap64K, CFbsBitmap* aBitmap16MA)
  1.1581 +	{
  1.1582 +	TRect theCellRect = aRect;
  1.1583 +	theCellRect.Shrink(1, 1);
  1.1584 +	
  1.1585 +	//rectangle
  1.1586 +	TRect rect = TRect(iTest.iRectangleSize);
  1.1587 +	rect.Move(theCellRect.iTl);
  1.1588 +    aGc.DrawRect(rect);
  1.1589 +    
  1.1590 +    //ellipse
  1.1591 +    rect = TRect(iTest.iEllipseSize);
  1.1592 +	rect.Move(theCellRect.iTl + TPoint(iTest.iRectangleSize.iWidth + 5, 0));
  1.1593 +    aGc.DrawEllipse(rect);
  1.1594 +
  1.1595 +	//triangle
  1.1596 +	TPoint pt = TPoint(rect.iBr.iX, rect.iTl.iY) + TPoint(5, 0);
  1.1597 +	SetPoligonLocation(pt);
  1.1598 +   	aGc.DrawPolygon(iPolygon);
  1.1599 +    
  1.1600 +    //DrawLine
  1.1601 +    pt = pt + TPoint (((*iPolygon)[2]).iX - ((*iPolygon)[0]).iX, 0) + TPoint(5, 2);
  1.1602 +    rect = TRect(iTest.iTriangleSize);
  1.1603 +    rect.Move(pt);
  1.1604 +    aGc.DrawLine(rect.iTl, TPoint(rect.iTl.iX, rect.iBr.iY));
  1.1605 +    aGc.DrawLine(TPoint(rect.iTl.iX, rect.iBr.iY), rect.iBr);
  1.1606 +    aGc.DrawLine(rect.iBr, TPoint(rect.iBr.iX, rect.iTl.iY));
  1.1607 +    aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), rect.iTl);
  1.1608 +    aGc.DrawLine(rect.iTl, rect.iBr);
  1.1609 +    aGc.DrawLine(TPoint(rect.iBr.iX, rect.iTl.iY), TPoint(rect.iTl.iX, rect.iBr.iY));
  1.1610 +
  1.1611 +    //64K bitmap
  1.1612 +    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1613 +    pt = TPoint(theCellRect.iTl.iX, rect.iBr.iY) + TPoint(0, 5);
  1.1614 +    if(aBitmap64K)
  1.1615 +    	{
  1.1616 +    	aGc.BitBlt(pt, aBitmap64K);
  1.1617 +    	pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0);
  1.1618 +
  1.1619 +    	aGc.BitBltMasked(pt, 
  1.1620 +    		aBitmap64K, TRect(aBitmap64K->SizeInPixels()),
  1.1621 +	    	iTest.iBitmapGray256Mask, EFalse);
  1.1622 +    	pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0);
  1.1623 +
  1.1624 +    	aGc.BitBltMasked(pt, 
  1.1625 +	    	aBitmap64K, TRect(aBitmap64K->SizeInPixels()),
  1.1626 +    		iTest.iBitmapMask, EFalse);
  1.1627 +
  1.1628 +    	pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0);
  1.1629 +	   	}
  1.1630 +    
  1.1631 +    if(aBitmap16MA)
  1.1632 +    	{
  1.1633 +    	aGc.BitBlt(pt, aBitmap16MA);
  1.1634 +
  1.1635 +    	pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2, 0);
  1.1636 +
  1.1637 +    	aGc.BitBltMasked(pt, 
  1.1638 +	    	aBitmap16MA, TRect(aBitmap16MA->SizeInPixels()),
  1.1639 +    		iTest.iBitmapGray256Mask, EFalse);
  1.1640 +
  1.1641 +    	pt = pt + TPoint( aBitmap16MA->SizeInPixels().iWidth, 0) + TPoint(2,0);
  1.1642 +
  1.1643 +    	pt = pt + TPoint( 0, aBitmap16MA->SizeInPixels().iHeight);
  1.1644 +    	}
  1.1645 +    
  1.1646 +	pt.iX = aRect.iTl.iX + 2;
  1.1647 +	pt.iY = pt.iY + 18;
  1.1648 +	
  1.1649 +    if(aBitmap64K)
  1.1650 +    	{
  1.1651 +		TSize size = aBitmap64K->SizeInPixels();
  1.1652 +		TRect srcRect(TPoint(0,0),size);
  1.1653 +		size += TSize(5,5);
  1.1654 +		TRect destRect(pt - TPoint(0, 8), size);
  1.1655 +    	aGc.DrawBitmap(destRect, aBitmap64K, srcRect);
  1.1656 +    	pt = pt + TPoint( size.iWidth, 0) + TPoint(2, 0);
  1.1657 +
  1.1658 +#ifdef __WINS__
  1.1659 +    	destRect.Move(TPoint(aBitmap64K->SizeInPixels().iWidth + 8, 0));
  1.1660 +    	((CWindowGc&) aGc).DrawBitmapMasked(destRect, 
  1.1661 +    		aBitmap64K, srcRect,
  1.1662 +	    	iTest.iBitmapGray256Mask, EFalse);
  1.1663 +    	pt = pt + TPoint( aBitmap64K->SizeInPixels().iWidth, 0) + TPoint(2, 0);
  1.1664 +#endif
  1.1665 +	   	}
  1.1666 +    
  1.1667 +    aGc.DrawText(iTest.iText, pt);
  1.1668 +    
  1.1669 +#ifdef __WINS__
  1.1670 +    ((CWindowGc&) aGc).DrawTextVertical(iTest.iText, pt, ETrue);
  1.1671 +#endif
  1.1672 +	}
  1.1673 +	
  1.1674 +/** calculate table's size and size of graphics primitieves */
  1.1675 +void CTWinAlphaForeground::PrepareForDrawingL()
  1.1676 +	{
  1.1677 +	iCol = iTest.iFirstCellWidth;
  1.1678 +
  1.1679 +	CalculateTableMargin();
  1.1680 +
  1.1681 +	//create triangle
  1.1682 +	iPolygon = new (ELeave) CArrayFixFlat<TPoint> (3);
  1.1683 +	TRect rect = TRect(iTest.iTriangleSize);
  1.1684 +	iPolygon->AppendL(rect.iTl);
  1.1685 +	iPolygon->AppendL(TPoint(rect.iTl.iX, rect.iBr.iY));
  1.1686 +	iPolygon->AppendL(rect.iBr);
  1.1687 +	}
  1.1688 +
  1.1689 +/** Bitmap is intended to use on target only*/	
  1.1690 +void CTWinAlphaForeground::CreateBackgroundBitmapL(const TDisplayMode& aDispMode)
  1.1691 +	{
  1.1692 +	ASSERT(!iBitmapBackground);
  1.1693 +	
  1.1694 +	TSize size = Size(); 
  1.1695 +		
  1.1696 +	iBitmapBackground = new (ELeave) CFbsBitmap ;
  1.1697 +	iBitmapBackground->Create(size,aDispMode);
  1.1698 +	
  1.1699 +	iBitmapDeviceBackground = CFbsBitmapDevice::NewL(iBitmapBackground);
  1.1700 +	CGraphicsContext *&theGc = (CGraphicsContext*&)iBitmapContextBackground;
  1.1701 +	iBitmapDeviceBackground->CreateContext(theGc);
  1.1702 +	}
  1.1703 +	
  1.1704 +void CTWinAlphaForeground::CleanBackgroundBitmap()
  1.1705 +	{
  1.1706 +	ASSERT(iBitmapBackground);
  1.1707 +	
  1.1708 +	TRect rect = TRect(iBitmapBackground->SizeInPixels());
  1.1709 +	iBitmapContextBackground->SetBrushColor(iBackgroundColor);
  1.1710 +   	iBitmapContextBackground->SetPenColor(iBackgroundColor);
  1.1711 +   	iBitmapContextBackground->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1712 +	iBitmapContextBackground->DrawRect(rect);
  1.1713 +	}
  1.1714 +
  1.1715 +void CTWinAlphaForeground::StartAnimationL()
  1.1716 +	{
  1.1717 +	__UHEAP_MARK;
  1.1718 +	RWsSprite theSprite;
  1.1719 +	
  1.1720 +	RDrawableWindow *theWin = DrawableWin();
  1.1721 +
  1.1722 +	theSprite=RWsSprite(TheClient->iWs);
  1.1723 +	TPoint theSpritePos = TPoint(10, 10); 
  1.1724 +	TInt theFlags = 0;
  1.1725 +	theSprite.Construct(*theWin, theSpritePos, theFlags);
  1.1726 +	TDisplayMode dispMode = EColor256;
  1.1727 +	//create a ball bitmap for animation
  1.1728 +	CFbsBitmap* theBitmapBall= new (ELeave) CFbsBitmap;
  1.1729 +	theBitmapBall->Create(TSize(32, 32), dispMode);
  1.1730 +	CFbsBitmapDevice* theBitmapDeviceBall = CFbsBitmapDevice::NewL(theBitmapBall);
  1.1731 +	CGraphicsContext* theBitmapContextBall = NULL;
  1.1732 +	theBitmapDeviceBall->CreateContext(theBitmapContextBall);
  1.1733 +	//draw a background
  1.1734 +	theBitmapContextBall->SetBrushColor(TRgb(128, 0, 255));
  1.1735 +   	theBitmapContextBall->SetPenColor(TRgb(128, 0, 255));
  1.1736 +   	theBitmapContextBall->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1737 +	theBitmapContextBall->DrawRect(theBitmapBall->SizeInPixels());
  1.1738 +	
  1.1739 +	//create a ball's mask
  1.1740 +	CFbsBitmap* theBitmapMask= new (ELeave) CFbsBitmap;
  1.1741 +	theBitmapMask->Create(TSize(32, 32), dispMode);
  1.1742 +	CFbsBitmapDevice* theBitmapDeviceMask = CFbsBitmapDevice::NewL(theBitmapMask);
  1.1743 +	CGraphicsContext* theBitmapContextMask = NULL;
  1.1744 +	theBitmapDeviceMask->CreateContext(theBitmapContextMask);
  1.1745 +	//draw a mask
  1.1746 +	theBitmapContextMask->SetBrushColor(TRgb(0, 0, 0));
  1.1747 +   	theBitmapContextMask->SetPenColor(TRgb(0, 0, 0));
  1.1748 +   	theBitmapContextMask->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1749 +	theBitmapContextMask->DrawRect(theBitmapMask->SizeInPixels());
  1.1750 +
  1.1751 +	theBitmapContextMask->SetBrushColor(TRgb(255, 255, 255));
  1.1752 +   	theBitmapContextMask->SetPenColor(TRgb(255, 255, 255));
  1.1753 +   	TRect rect = TRect(theBitmapMask->SizeInPixels());
  1.1754 +	theBitmapContextMask->SetPenSize(TSize(6,6));
  1.1755 +	theBitmapContextMask->DrawLine(rect.iTl, rect.iBr);
  1.1756 +	theBitmapContextMask->DrawLine(TPoint(0, rect.iBr.iY), TPoint(rect.iBr.iX, 0));
  1.1757 +
  1.1758 +	//create a second ball's mask
  1.1759 +	CFbsBitmap* theBitmapMask1= new (ELeave) CFbsBitmap;
  1.1760 +	theBitmapMask1->Create(TSize(32, 32), dispMode);
  1.1761 +	CFbsBitmapDevice* theBitmapDeviceMask1 = CFbsBitmapDevice::NewL(theBitmapMask1);
  1.1762 +	CGraphicsContext* theBitmapContextMask1 = NULL;
  1.1763 +	theBitmapDeviceMask1->CreateContext(theBitmapContextMask1);
  1.1764 +	//draw a mask
  1.1765 +	theBitmapContextMask1->SetBrushColor(TRgb(0, 0, 0));
  1.1766 +   	theBitmapContextMask1->SetPenColor(TRgb(0, 0, 0));
  1.1767 +   	theBitmapContextMask1->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1768 +	theBitmapContextMask1->DrawRect(theBitmapMask1->SizeInPixels());
  1.1769 +
  1.1770 +	theBitmapContextMask1->SetBrushColor(TRgb(255, 255, 255));
  1.1771 +   	theBitmapContextMask1->SetPenColor(TRgb(255, 255, 255));
  1.1772 +   	rect = TRect(theBitmapMask1->SizeInPixels());
  1.1773 +	theBitmapContextMask1->SetPenSize(TSize(6,6));
  1.1774 +	theBitmapContextMask1->DrawLine(TPoint(rect.iBr.iX/2, 0), TPoint(rect.iBr.iX/2, rect.iBr.iY));
  1.1775 +	theBitmapContextMask1->DrawLine(TPoint(0, rect.iBr.iY/2), TPoint(rect.iBr.iX, rect.iBr.iY/2));
  1.1776 +
  1.1777 +
  1.1778 +	TSpriteMember theSpriteList;
  1.1779 +	theSpriteList.iBitmap = theBitmapBall;
  1.1780 +	theSpriteList.iMaskBitmap = theBitmapMask;
  1.1781 +	theSpriteList.iInvertMask = EFalse;
  1.1782 +	theSpriteList.iDrawMode = CGraphicsContext::EDrawModePEN;
  1.1783 +	theSpriteList.iOffset = TPoint(0, 0);
  1.1784 +	theSpriteList.iInterval = TTimeIntervalMicroSeconds32(100000);
  1.1785 +	theSprite.AppendMember(theSpriteList);
  1.1786 +
  1.1787 +	TSpriteMember theSpriteList1;
  1.1788 +	theSpriteList1.iBitmap = theBitmapBall;
  1.1789 +	theSpriteList1.iMaskBitmap = theBitmapMask1;
  1.1790 +	theSpriteList1.iInvertMask = EFalse;
  1.1791 +	theSpriteList1.iDrawMode = CGraphicsContext::EDrawModePEN;
  1.1792 +	theSpriteList1.iOffset = TPoint(0, 0);
  1.1793 +	theSpriteList1.iInterval = TTimeIntervalMicroSeconds32(100000);
  1.1794 +	
  1.1795 +	theSprite.AppendMember(theSpriteList1);
  1.1796 +	
  1.1797 +	theSprite.Activate();
  1.1798 +	
  1.1799 +	for(TInt ii = 0; ii < 20; ii++)
  1.1800 +		{
  1.1801 +		theSpritePos += TPoint(3, 8);
  1.1802 +		theSprite.SetPosition(theSpritePos);
  1.1803 +		TheClient->iWs.Flush();	
  1.1804 +		User::After(TTimeIntervalMicroSeconds32(50000));		
  1.1805 +		}
  1.1806 +
  1.1807 +	for(TInt jj = 0; jj < 20; jj++)
  1.1808 +		{
  1.1809 +		theSpritePos -= TPoint(0, 8);
  1.1810 +		theSprite.SetPosition(theSpritePos);
  1.1811 +		TheClient->iWs.Flush();	
  1.1812 +		User::After(TTimeIntervalMicroSeconds32(50000));
  1.1813 +		}
  1.1814 +	
  1.1815 +	theSprite.Close();
  1.1816 +	
  1.1817 +	delete theBitmapContextBall;
  1.1818 +	delete theBitmapDeviceBall;
  1.1819 +	
  1.1820 +	delete theBitmapBall;
  1.1821 +	
  1.1822 +	delete theBitmapMask;
  1.1823 +	delete theBitmapContextMask;
  1.1824 +	delete theBitmapDeviceMask;
  1.1825 +	
  1.1826 +	delete theBitmapMask1;
  1.1827 +	delete theBitmapContextMask1;
  1.1828 +	delete theBitmapDeviceMask1;
  1.1829 +
  1.1830 +	__UHEAP_MARKEND;
  1.1831 +	}
  1.1832 +
  1.1833 +void CTWinAlphaForeground::CreateBackedWindowL()
  1.1834 +	{
  1.1835 +	RBackedUpWindow theBackedWindow(TheClient->iWs); 
  1.1836 +	CleanupClosePushL(theBackedWindow);
  1.1837 +	
  1.1838 +	TDisplayMode theDisplayMode = EColor16MA;
  1.1839 +	
  1.1840 +	RWindow* theWin = (RWindow*) DrawableWin();
  1.1841 +
  1.1842 +	theBackedWindow.Construct(*theWin,theDisplayMode, ENullWsHandle);
  1.1843 +	
  1.1844 +	TPoint pos =TPoint(10, 10);
  1.1845 +	TSize size = theWin->Size();
  1.1846 +	size.SetSize(size.iWidth / 5, size.iHeight/10);
  1.1847 +	
  1.1848 +	theBackedWindow.SetExtentErr(pos, size);
  1.1849 +	theBackedWindow.SetOrdinalPosition(0);
  1.1850 +
  1.1851 +	
  1.1852 +	//draw to backed window	
  1.1853 +	TRgb color = TRgb(255, 0, 128);
  1.1854 +	TInt bitmapHandle = theBackedWindow.BitmapHandle();
  1.1855 +	CFbsBitmap bitmapWin;
  1.1856 +	bitmapWin.Duplicate(bitmapHandle);
  1.1857 +	//Leave poss here - theBackedWindow could leak
  1.1858 +	CFbsBitmapDevice* theBitmapDevice = CFbsBitmapDevice::NewL(&bitmapWin);
  1.1859 +	CGraphicsContext* theBitmapContext = NULL;
  1.1860 +	theBitmapDevice->CreateContext(theBitmapContext);
  1.1861 +	theBitmapContext->SetBrushColor(color);
  1.1862 +   	theBitmapContext->SetPenColor(color);
  1.1863 +   	theBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1864 +	theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels()));
  1.1865 +
  1.1866 +	color = TRgb(0, 0, 0);
  1.1867 +   	theBitmapContext->SetPenColor(color);
  1.1868 +	for(TInt kk = 0; kk < bitmapWin.SizeInPixels().iWidth; kk += 8)
  1.1869 +		{
  1.1870 +		theBitmapContext->DrawLine(TPoint(kk, 0), TPoint(kk, bitmapWin.SizeInPixels().iHeight));
  1.1871 +		}
  1.1872 +	
  1.1873 +	
  1.1874 +	theBackedWindow.Activate();
  1.1875 +	TheClient->iWs.Flush();
  1.1876 +	User::After(TTimeIntervalMicroSeconds32(500000));
  1.1877 +	
  1.1878 +	//hide the window
  1.1879 +	theBackedWindow.SetVisible(EFalse);
  1.1880 +	TheClient->iWs.Flush();
  1.1881 +	User::After(TTimeIntervalMicroSeconds32(500000));
  1.1882 +	theBackedWindow.SetVisible(ETrue);
  1.1883 +	TheClient->iWs.Flush();
  1.1884 +	
  1.1885 +	for(TInt ii = 0; ii < 7; ii++)
  1.1886 +		{
  1.1887 +		User::After(TTimeIntervalMicroSeconds32(100000));
  1.1888 +		pos.iX += 5;
  1.1889 +		pos.iY += 15;
  1.1890 +		 
  1.1891 +		theBackedWindow.SetExtentErr(pos, size);
  1.1892 +		TheClient->iWs.Flush();
  1.1893 +		}
  1.1894 +
  1.1895 +	User::After(TTimeIntervalMicroSeconds32(500000));
  1.1896 +	
  1.1897 +	//transparent color. don't expect it to work
  1.1898 +	pos.iX -= 5;
  1.1899 +	pos.iY -= 15;
  1.1900 +
  1.1901 +	theBackedWindow.SetExtentErr(pos, size);
  1.1902 +	color = TRgb(255, 255, 128, 128);
  1.1903 +	theBitmapContext->SetBrushColor(color);
  1.1904 +   	theBitmapContext->SetPenColor(color);
  1.1905 +	theBitmapContext->DrawRect(TRect(bitmapWin.SizeInPixels()));
  1.1906 +	TheClient->iWs.Flush();
  1.1907 +	User::After(TTimeIntervalMicroSeconds32(500000));
  1.1908 +
  1.1909 +	//semi-transparent color
  1.1910 +	pos.iX -= 5;
  1.1911 +	pos.iY -= 15;
  1.1912 +	theBackedWindow.SetExtentErr(pos, size);
  1.1913 +	color = TRgb(255, 255, 128, 255);
  1.1914 +	theBitmapContext->SetBrushColor(color);
  1.1915 +   	theBitmapContext->SetPenColor(color);
  1.1916 +	TheClient->iWs.Flush();
  1.1917 +	User::After(TTimeIntervalMicroSeconds32(500000));
  1.1918 +
  1.1919 +	
  1.1920 +	CleanupStack::PopAndDestroy();	 //bitmapWin
  1.1921 +	delete theBitmapContext;
  1.1922 +	delete theBitmapDevice;
  1.1923 +	
  1.1924 +	}
  1.1925 +
  1.1926 +	
  1.1927 +//-------------------
  1.1928 +void CTWinAlpha::Draw()
  1.1929 +	{
  1.1930 +	CBitmapContext* theGc = TheClient->iGc;
  1.1931 +	TSize size = Size();
  1.1932 +	
  1.1933 +	for(TInt ii = 0; ii < size.iHeight; ii += (20+iState))
  1.1934 +		{
  1.1935 +		theGc->DrawLine(TPoint(0, ii), TPoint(size.iWidth, ii));
  1.1936 +		}
  1.1937 +	}
  1.1938 +	
  1.1939 +__WS_CONSTRUCT_STEP__(AlphaChannel)