windowing/windowserver/tman/TMPNTCUR.CPP
changeset 110 7f25ef56562d
parent 98 bf7481649c98
child 111 29ddb8a72f0e
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Tests for various pointer cursors on different windows
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <hal.h>
       
    20 #include "W32STD.H"
       
    21 #include "../tlib/testbase.h"
       
    22 #include "TMAN.H"
       
    23 
       
    24 class CPointerCursorWindow : public CTWin
       
    25 	{
       
    26 public:
       
    27 	~CPointerCursorWindow();
       
    28 	void SetChild(CPointerCursorWindow* aChild);
       
    29 	inline CPointerCursorWindow* Child() {return iChild;}
       
    30 	inline void SetBitmap(CFbsBitmap* aBitmap,TBool aTop=ETrue) {iBitmap=aBitmap;iTop=aTop;}
       
    31 	void SetPointerCursor(CTPointerCursor* aCursor);
       
    32 	//Virtual function from CTBaseWin
       
    33 	void SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc);
       
    34 	void Draw();
       
    35 	void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
       
    36 private:
       
    37 	CPointerCursorWindow* iChild;
       
    38 	CFbsBitmap* iBitmap;
       
    39 	TBool iTop;
       
    40 	};
       
    41 
       
    42 class CPointerCursorWindowGroup : public CTWindowGroup
       
    43 	{
       
    44 public:
       
    45 	CPointerCursorWindowGroup(CTClient *aClient);
       
    46 	void SetPointerCursor(CTPointerCursor* aCursor);
       
    47 	void ConstructL();
       
    48 	};
       
    49 
       
    50 class CStatusWindow : public CTTitledWindow
       
    51 	{
       
    52 public:
       
    53 	~CStatusWindow();
       
    54 	void Construct(CTestBase* aTest);
       
    55 	void DoDraw();
       
    56 	//virtual functions from CTWinBase overridden by CTBaseWin
       
    57 	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
       
    58 	//virtual functions from CTBaseWin
       
    59 	void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
       
    60 	void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
       
    61 	//virtual function from CTBaseWin overridden by CTTitledWindow
       
    62 	void Draw();
       
    63 private:
       
    64 	void UpdateString1();
       
    65 	void UpdateString2();
       
    66 	void UpdateString3();
       
    67 	void ChangeXyInputType();
       
    68 	void ChangePointerCursorMode();
       
    69 private:
       
    70 	CTestBase* iTest;
       
    71 	TBuf<16> iString1;
       
    72 	TBuf<16> iString2;
       
    73 	TBuf<16> iString3;
       
    74 	TBuf<32> iString4;
       
    75 	TRect iRect1;
       
    76 	TRect iRect2;
       
    77 	TRect iRect3;
       
    78 	TRect iRect4;
       
    79 	TXYInputType iXyInputType;
       
    80 	TXYInputType iOriginalXyInputType;
       
    81 	TPointerCursorMode iMode;
       
    82 	TPointerCursorMode iOriginalMode;
       
    83 	TBool iSimulatedPenDown;
       
    84 	TBool iUpdateNeeded;
       
    85 	TBool iExit;
       
    86 	};
       
    87 
       
    88 class CPointerCursorTest : public CTestBase
       
    89 	{
       
    90 	enum {eWindowGap=3,eChildWindowGap=2};
       
    91 	enum {eNumPointerCursors=7};
       
    92 public:
       
    93 	CPointerCursorTest();
       
    94 	~CPointerCursorTest();
       
    95 	TestState DoTestL();
       
    96 	void ConstructL();
       
    97 private:
       
    98 	CPointerCursorWindow *CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup);
       
    99 	void CreatePointerCursorsL();
       
   100 	void CreateWindowsL(TSize aArea);
       
   101 private:
       
   102 	TSize iWinSize;
       
   103 	TInt iState;
       
   104 	CStatusWindow *iInfoWindow;
       
   105 	CPointerCursorWindowGroup *iGroup1;
       
   106 	CPointerCursorWindowGroup *iGroup2;
       
   107 	CPointerCursorWindow *iWindows[6];
       
   108 	CTPointerCursor *iCursors[eNumPointerCursors];
       
   109 	CFbsBitmap *iBitmaps[eNumPointerCursors];
       
   110 	};
       
   111 
       
   112 
       
   113 /*CPointerCursorWindow*/
       
   114 
       
   115 CPointerCursorWindow::~CPointerCursorWindow()
       
   116 	{
       
   117 	delete iChild;
       
   118 	}
       
   119 
       
   120 void CPointerCursorWindow::SetChild(CPointerCursorWindow* aChild)
       
   121 	{
       
   122 	iChild=aChild;
       
   123 	iWin.SetShadowDisabled(ETrue);
       
   124 	}
       
   125 
       
   126 void CPointerCursorWindow::SetPointerCursor(CTPointerCursor* aCursor)
       
   127 	{
       
   128 	iWin.SetCustomPointerCursor(aCursor->PointerCursor());
       
   129 	}
       
   130 
       
   131 void CPointerCursorWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc)
       
   132 	{
       
   133 	CTWin::SetUpL(aPos,aSize,aParent,aGc);
       
   134 	iWin.SetShadowDisabled(ETrue);
       
   135 	iWin.SetPointerGrab(EFalse);
       
   136 	}
       
   137 
       
   138 void CPointerCursorWindow::Draw()
       
   139 	{
       
   140 	iGc->Reset();
       
   141 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   142 	iGc->DrawRect(Size());
       
   143 	if (iBitmap)
       
   144 		{
       
   145 		TPoint point(3,3);
       
   146 		if (!iTop)
       
   147 			point.iY=Size().iHeight-iBitmap->SizeInPixels().iHeight-3;
       
   148 		iGc->BitBlt(point,iBitmap);
       
   149 		}
       
   150 	}
       
   151 
       
   152 void CPointerCursorWindow::PointerL(const TPointerEvent&,const TTime&)
       
   153 	{
       
   154 	}
       
   155 
       
   156 
       
   157 /*CPointerCursorWindowGroup*/
       
   158 
       
   159 CPointerCursorWindowGroup::CPointerCursorWindowGroup(CTClient *aClient)
       
   160 	:CTWindowGroup(aClient)
       
   161 	{}
       
   162 
       
   163 void CPointerCursorWindowGroup::ConstructL()
       
   164 	{
       
   165 	CTWindowGroup::ConstructL();
       
   166 	iGroupWin.EnableReceiptOfFocus(EFalse);
       
   167 	}
       
   168 
       
   169 void CPointerCursorWindowGroup::SetPointerCursor(CTPointerCursor* aCursor)
       
   170 	{
       
   171 	iGroupWin.SetCustomPointerCursor(aCursor->PointerCursor());
       
   172 	}
       
   173 
       
   174 
       
   175 /*CStatusWindow*/
       
   176 
       
   177 CStatusWindow::~CStatusWindow()
       
   178 	{
       
   179 	Client()->iWs.SetPointerCursorMode(iOriginalMode);
       
   180 #if defined(__WINS__)
       
   181 	Client()->iWs.SimulateXyInputType(iOriginalXyInputType);
       
   182 #endif
       
   183 	}
       
   184 
       
   185 void CStatusWindow::Construct(CTestBase* aTest)
       
   186 	{
       
   187 	_LIT(Title,"StatusWindow");
       
   188 	_LIT(String4,"Click here to finish");
       
   189 	iTest=aTest;
       
   190 	TWindowTitle title(Title);
       
   191 	SetTitle(title);
       
   192 	TInt yy=iTitleHeight+iFont->HeightInPixels()+7;
       
   193 	iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy);
       
   194 	TInt yy1=yy+iFont->HeightInPixels()+2;
       
   195 	iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1);
       
   196 	TInt yy2=yy1+iFont->HeightInPixels()+2;
       
   197 	iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2);
       
   198 	iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2);
       
   199 	TMachineInfoV1Buf machineInfo;
       
   200 	UserHal::MachineInfo(machineInfo);
       
   201 	iXyInputType=machineInfo().iXYInputType;
       
   202 	iOriginalXyInputType=iXyInputType;
       
   203 	iSimulatedPenDown=EFalse;
       
   204 	//
       
   205 	iString3.Copy(KNullDesC);
       
   206 	if (iXyInputType==EXYInputDeltaMouse)
       
   207 		{
       
   208 		if (HAL::Get(HALData::EMouseState,iSimulatedPenDown)==KErrNone)
       
   209 			UpdateString3();
       
   210 		}
       
   211 	UpdateString1();
       
   212 	iMode=Client()->iWs.PointerCursorMode();
       
   213 	iOriginalMode=iMode;
       
   214 	UpdateString2();
       
   215 	iUpdateNeeded=EFalse;
       
   216 	iString4.Copy(String4);
       
   217 	iExit=EFalse;
       
   218 	}
       
   219 
       
   220 void CStatusWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc)
       
   221 	{
       
   222 	CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc);
       
   223 	}
       
   224 
       
   225 void CStatusWindow::WinKeyL(const TKeyEvent &aKey,const TTime&)
       
   226 	{
       
   227 	switch(aKey.iCode)
       
   228 		{
       
   229 		case EKeyEscape:
       
   230 			iTest->Request();
       
   231 			break;
       
   232 		case 'M':
       
   233 		case 'm':
       
   234 			if (iXyInputType==EXYInputDeltaMouse)
       
   235 				{
       
   236 				if (HAL::Set(HALData::EMouseState,!iSimulatedPenDown)==KErrNone)
       
   237 					{
       
   238 					iSimulatedPenDown=!iSimulatedPenDown;
       
   239 					UpdateString3();
       
   240 					DoDraw();
       
   241 					}
       
   242 				}
       
   243 			break;
       
   244 	#if defined(__WINS__)
       
   245 		case 'I':
       
   246 		case 'i':
       
   247 		case '1':
       
   248 			ChangeXyInputType();
       
   249 			Client()->iWs.SimulateXyInputType(iXyInputType);
       
   250 			break;
       
   251 	#endif
       
   252 		case 'C':
       
   253 		case 'c':
       
   254 		case '2':
       
   255 			ChangePointerCursorMode();
       
   256 			Client()->iWs.SetPointerCursorMode(iMode);
       
   257 			break;
       
   258 		default:;
       
   259 		}
       
   260 	}
       
   261 
       
   262 void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime)
       
   263 	{
       
   264 #if defined(__WINS__)
       
   265 	if (iRect1.Contains(aPointer.iPosition))
       
   266 		{
       
   267 		if (aPointer.iType==TPointerEvent::EButton1Down)
       
   268 			ChangeXyInputType();
       
   269 		}
       
   270 	else
       
   271 #endif
       
   272         if (iRect2.Contains(aPointer.iPosition))
       
   273 		{
       
   274 		if (aPointer.iType==TPointerEvent::EButton1Down)
       
   275 			ChangePointerCursorMode();
       
   276 		}
       
   277 	else if (iRect4.Contains(aPointer.iPosition))
       
   278 		iExit=ETrue;
       
   279 	else
       
   280 		CTTitledWindow::PointerL(aPointer,aTime);
       
   281 	if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up)
       
   282 		{
       
   283 		if (iExit)
       
   284 			iTest->Request();
       
   285 		else
       
   286 			{
       
   287 			Client()->iWs.SetPointerCursorMode(iMode);
       
   288 		#if defined(__WINS__)
       
   289 			Client()->iWs.SimulateXyInputType(iXyInputType);
       
   290 		#endif
       
   291 			Client()->iWs.Flush();
       
   292 			iUpdateNeeded=EFalse;
       
   293 			}
       
   294 		}
       
   295 	}
       
   296 
       
   297 void CStatusWindow::Draw()
       
   298 	{
       
   299 	CTTitledWindow::Draw();
       
   300 	TInt ascent=iFont->AscentInPixels()+1;
       
   301 	iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft);
       
   302 	iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft);
       
   303 	iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft);
       
   304 	iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft);
       
   305 	}
       
   306 
       
   307 void CStatusWindow::DoDraw()
       
   308 	{
       
   309 	iGc->Activate(iWin);
       
   310 	iGc->UseFont((CFont *)iFont);
       
   311 	Draw();
       
   312 	iGc->Deactivate();
       
   313 	}
       
   314 
       
   315 void CStatusWindow::UpdateString1()
       
   316 	{
       
   317 	_LIT(Text0,"No Pointer");
       
   318 	_LIT(Text1,"Pen");
       
   319 	_LIT(Text2,"Mouse");
       
   320 	_LIT(Text3,"Relative Mouse");
       
   321 	switch (iXyInputType)
       
   322 		{
       
   323 	case EXYInputNone:
       
   324 		iString1.Copy(Text0);
       
   325 		break;
       
   326 	case EXYInputPointer:
       
   327 		iString1.Copy(Text1);
       
   328 		break;
       
   329 	case EXYInputMouse:
       
   330 		iString1.Copy(Text2);
       
   331 		break;
       
   332 	case EXYInputDeltaMouse:
       
   333 		iString1.Copy(Text3);
       
   334 		break;
       
   335 		}
       
   336 	}
       
   337 
       
   338 void CStatusWindow::UpdateString2()
       
   339 	{
       
   340 	_LIT(Text0,"None");
       
   341 	_LIT(Text1,"Fixed");
       
   342 	_LIT(Text2,"Normal");
       
   343 	_LIT(Text3,"Window");
       
   344 	switch (iMode)
       
   345 		{
       
   346 	case EPointerCursorNone:
       
   347 		iString2.Copy(Text0);
       
   348 		break;
       
   349 	case EPointerCursorFixed:
       
   350 		iString2.Copy(Text1);
       
   351 		break;
       
   352 	case EPointerCursorNormal:
       
   353 		iString2.Copy(Text2);
       
   354 		break;
       
   355 	case EPointerCursorWindow:
       
   356 		iString2.Copy(Text3);
       
   357 		break;
       
   358 		}
       
   359 	}
       
   360 
       
   361 void CStatusWindow::UpdateString3()
       
   362 	{
       
   363 	if (iSimulatedPenDown)
       
   364 		{
       
   365 		_LIT(TextD,"Sim Pen Down");
       
   366 		iString3.Copy(TextD);
       
   367 		}
       
   368 	else
       
   369 		{
       
   370 		_LIT(TextU,"Sim Pen Up");
       
   371 		iString3.Copy(TextU);
       
   372 		}
       
   373 	}
       
   374 
       
   375 void CStatusWindow::ChangeXyInputType()
       
   376 	{
       
   377 	if (iXyInputType==EXYInputMouse)
       
   378 		iXyInputType=EXYInputPointer;
       
   379 	else if (iXyInputType==EXYInputPointer)
       
   380 		iXyInputType=EXYInputMouse;
       
   381 	UpdateString1();
       
   382 	DoDraw();
       
   383 	iUpdateNeeded=ETrue;
       
   384 	}
       
   385 
       
   386 void CStatusWindow::ChangePointerCursorMode()
       
   387 	{
       
   388 	TInt mode=(iMode+1)%(EPointerCursorLastMode+1);
       
   389 	iMode=STATIC_CAST(TPointerCursorMode,mode);
       
   390 	UpdateString2();
       
   391 	DoDraw();
       
   392 	iUpdateNeeded=ETrue;
       
   393 	}
       
   394 
       
   395 
       
   396 /*Sprite Drawing Functions*/
       
   397 
       
   398 #if defined(__WINS__)
       
   399 	#define DRAW_COLOR 1
       
   400 #else
       
   401 	#define DRAW_COLOR 0
       
   402 #endif
       
   403 
       
   404 void DrawCross(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
       
   405 	{
       
   406 	TInt halfLineWidth=(*STATIC_CAST(TInt*,aLineWidth)+1)/2;
       
   407 	TInt lineWidth=2*halfLineWidth+1;		//Must be odd
       
   408 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   409 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   410 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   411 	aGc->DrawRect(TRect(aSize));
       
   412 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   413 	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
       
   414 	aGc->SetPenSize(TSize(lineWidth,lineWidth));
       
   415 	aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-lineWidth,aSize.iHeight-lineWidth));
       
   416 	aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-lineWidth),TPoint(aSize.iWidth-lineWidth,halfLineWidth));
       
   417 	}
       
   418 
       
   419 void DrawArrow(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
       
   420 	{
       
   421 	TInt lineWidth=*STATIC_CAST(TInt*,aLineWidth);
       
   422 	TInt halfLineWidth=(lineWidth-1)/2;
       
   423 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   424 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   425 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   426 	aGc->DrawRect(TRect(aSize));
       
   427 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   428 	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
       
   429 	aGc->SetPenSize(TSize(1,1));
       
   430 	aGc->DrawLine(TPoint(0,0),TPoint(lineWidth,0));
       
   431 	aGc->DrawLine(TPoint(0,0),TPoint(0,lineWidth));
       
   432 	aGc->SetPenSize(TSize(lineWidth,lineWidth));
       
   433 	aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-halfLineWidth-1,aSize.iHeight-halfLineWidth-1));
       
   434 	aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/2,halfLineWidth));
       
   435 	aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(halfLineWidth,aSize.iHeight/2));
       
   436 	}
       
   437 
       
   438 void DrawSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
       
   439 	{
       
   440 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   441 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   442 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   443 	aGc->DrawRect(TRect(aSize));
       
   444 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
       
   445 	aGc->DrawRect(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1));
       
   446 	}
       
   447 
       
   448 void DrawCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
       
   449 	{
       
   450 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   451 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   452 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   453 	aGc->DrawRect(TRect(aSize));
       
   454 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
       
   455 	aGc->DrawEllipse(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1));
       
   456 	}
       
   457 
       
   458 void DrawTriangle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
       
   459 	{
       
   460 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   461 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   462 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   463 	aGc->DrawRect(TRect(aSize));
       
   464 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   465 	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
       
   466 	aGc->SetPenSize(TSize(1,1));
       
   467 	for(TInt y=0;y<aSize.iHeight;y++)
       
   468 		{
       
   469 		TInt xfact=aSize.iWidth*y/aSize.iHeight;
       
   470 		aGc->DrawLine(TPoint(aSize.iWidth-xfact-1,y),TPoint(aSize.iWidth-1,y));
       
   471 		}
       
   472 	}
       
   473 
       
   474 void DrawOpenSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
       
   475 	{
       
   476 	TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2;
       
   477 	TInt lineWidth=2*halfLineWidth+1;		//Must be odd
       
   478 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   479 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   480 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   481 	aGc->DrawRect(TRect(aSize));
       
   482 	aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   483 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   484 	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
       
   485 	aGc->SetPenSize(TSize(lineWidth,lineWidth));
       
   486 	TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1);
       
   487 	aGc->DrawRect(TRect(aSize.iWidth/4,aSize.iHeight/4,botRig.iX+1,botRig.iY+1));
       
   488 	aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,aSize.iHeight/4-halfLineWidth));
       
   489 	aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,halfLineWidth),TPoint(botRig.iX+halfLineWidth,aSize.iHeight/4-halfLineWidth));
       
   490 	aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(botRig.iX+halfLineWidth,botRig.iY+halfLineWidth));
       
   491 	aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,botRig.iY+halfLineWidth));
       
   492 	}
       
   493 
       
   494 void DrawOpenCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
       
   495 	{
       
   496 	TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2;
       
   497 	TInt lineWidth=2*halfLineWidth+1;		//Must be odd
       
   498 	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
       
   499 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   500 	aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   501 	aGc->DrawRect(TRect(aSize));
       
   502 	aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   503 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   504 	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
       
   505 	aGc->SetPenSize(TSize(lineWidth,lineWidth));
       
   506 	TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1);
       
   507 	aGc->DrawEllipse(TRect(aSize.iWidth/4+1,aSize.iHeight/4+1,botRig.iX+1,botRig.iY+1));
       
   508 	aGc->DrawLine(TPoint(aSize.iWidth/2,1+halfLineWidth),TPoint(aSize.iWidth/2,aSize.iHeight/4+1-halfLineWidth));
       
   509 	aGc->DrawLine(TPoint(aSize.iWidth/2,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/2,botRig.iY+halfLineWidth));
       
   510 	aGc->DrawLine(TPoint(1+halfLineWidth,aSize.iWidth/2),TPoint(aSize.iWidth/4+1-halfLineWidth,aSize.iHeight/2));
       
   511 	aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight/2),TPoint(botRig.iX+halfLineWidth,aSize.iWidth/2));
       
   512 	}
       
   513 
       
   514 
       
   515 /*CPointerCursorTest*/
       
   516 
       
   517 GLDEF_C CTestBase *CreatePointerCursorTest()
       
   518 	{
       
   519 	return(new(ELeave) CPointerCursorTest());
       
   520 	}
       
   521 
       
   522 CPointerCursorTest::CPointerCursorTest() : CTestBase(_L("PointerCursor"))
       
   523 	{}
       
   524 
       
   525 CPointerCursorTest::~CPointerCursorTest()
       
   526 	{
       
   527 	TInt ii;
       
   528 	Client()->iGroup->SetCurrentWindow(NULL);
       
   529 	delete iInfoWindow;
       
   530 	for(ii=0;ii<6;++ii)
       
   531 		{
       
   532 		delete iWindows[ii];
       
   533 		}
       
   534 	for(ii=0;ii<eNumPointerCursors;++ii)
       
   535 		{
       
   536 		delete iCursors[ii];
       
   537 		delete iBitmaps[ii];
       
   538 		}
       
   539 	delete iGroup1;
       
   540 	delete iGroup2;
       
   541 	}
       
   542 
       
   543 void CPointerCursorTest::ConstructL()
       
   544 	{
       
   545 	TSize size=Client()->iScreen->SizeInPixels();
       
   546 	TInt infoWidth=Min(210,5*size.iWidth/12);
       
   547 	size.iWidth=Max(Min(415,size.iWidth-infoWidth),85);
       
   548 	iInfoWindow=new(ELeave) CStatusWindow();
       
   549 	iInfoWindow->SetUpL(TPoint(size.iWidth,50),TSize(infoWidth,180),Client()->iGroup,*Client()->iGc);
       
   550 	Client()->iGroup->SetCurrentWindow(iInfoWindow);
       
   551 	iInfoWindow->Construct(this);
       
   552 	iGroup1=new(ELeave) CPointerCursorWindowGroup(Client());
       
   553 	iGroup1->ConstructL();
       
   554 	iGroup2=new(ELeave) CPointerCursorWindowGroup(Client());
       
   555 	iGroup2->ConstructL();
       
   556 	size.iWidth-=5;
       
   557 	CreateWindowsL(size);
       
   558 	CreatePointerCursorsL();
       
   559 	iGroup1->SetPointerCursor(iCursors[0]);
       
   560 	iWindows[1]->SetBitmap(iBitmaps[0],EFalse);
       
   561 	iWindows[0]->SetPointerCursor(iCursors[1]);
       
   562 	iWindows[0]->SetBitmap(iBitmaps[1]);
       
   563 	iWindows[0]->Child()->SetPointerCursor(iCursors[2]);
       
   564 	iWindows[0]->Child()->SetBitmap(iBitmaps[2]);
       
   565 	iWindows[2]->SetPointerCursor(iCursors[3]);
       
   566 	iWindows[2]->SetBitmap(iBitmaps[3]);
       
   567 	iWindows[2]->Child()->Child()->SetPointerCursor(iCursors[4]);
       
   568 	iWindows[2]->Child()->Child()->SetBitmap(iBitmaps[4]);
       
   569 	iWindows[3]->Child()->SetPointerCursor(iCursors[5]);
       
   570 	iWindows[3]->Child()->SetBitmap(iBitmaps[5]);
       
   571 	iWindows[4]->SetPointerCursor(iCursors[6]);
       
   572 	iWindows[4]->SetBitmap(iBitmaps[6]);
       
   573 	}
       
   574 
       
   575 void CPointerCursorTest::CreateWindowsL(TSize aArea)
       
   576 	{
       
   577 	//TSize screenSize=Client()->iScreen->SizeInPixels();
       
   578 	TInt height=eWindowGap+(aArea.iHeight-5*eWindowGap)/4;
       
   579 	TInt halfWidth=aArea.iWidth/2;
       
   580 	TRect rect(5,eWindowGap,halfWidth,height);
       
   581 	iWindows[0]=CreateWindowL(2,rect,iGroup1);
       
   582 	rect.Move(halfWidth,0);
       
   583 	iWindows[1]=CreateWindowL(2,rect,iGroup1);
       
   584 	rect.Move(-halfWidth,height);
       
   585 	rect.iBr.iX=aArea.iWidth;
       
   586 	iWindows[2]=CreateWindowL(4,rect,iGroup2);
       
   587 	rect.Move(0,height);
       
   588 	rect.iBr.iX=aArea.iWidth-11;
       
   589 	iWindows[3]=CreateWindowL(3,rect,iGroup2);
       
   590 	rect.Move(0,height);
       
   591 	rect.iBr.iX=halfWidth;
       
   592 	iWindows[4]=CreateWindowL(2,rect,iGroup2);
       
   593 	rect.Move(halfWidth,0);
       
   594 	iWindows[5]=CreateWindowL(2,rect,iGroup2);
       
   595 	}
       
   596 
       
   597 CPointerCursorWindow* CPointerCursorTest::CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup)
       
   598 	{
       
   599 	CPointerCursorWindow* firstWin=NULL;
       
   600 	CPointerCursorWindow* parent=NULL;
       
   601 	CPointerCursorWindow* win;
       
   602 	TInt xInc=aLocation.Width()/aNum-eChildWindowGap;
       
   603 	TInt ii;
       
   604 	for (ii=aNum;ii>0;ii--)
       
   605 		{
       
   606 		win=new(ELeave) CPointerCursorWindow();
       
   607 		CleanupStack::PushL(win);
       
   608 		win->SetUpL(aLocation.iTl,aLocation.Size(),aGroup,*Client()->iGc);
       
   609 		if (!parent)
       
   610 			firstWin=win;
       
   611 		else
       
   612 			{
       
   613 			parent->SetChild(win);
       
   614 			CleanupStack::Pop();
       
   615 			}
       
   616 		aLocation.iBr=TPoint(-eChildWindowGap,-eChildWindowGap)+aLocation.Size();
       
   617 		aLocation.iTl.iX=xInc;
       
   618 		aLocation.iTl.iY=eChildWindowGap;
       
   619 		aGroup=win;
       
   620 		parent=win;
       
   621 		}
       
   622 	CleanupStack::Pop();
       
   623 	return firstWin;
       
   624 	}
       
   625 
       
   626 void CPointerCursorTest::CreatePointerCursorsL()
       
   627 	{
       
   628 	const TSize size(32,32);
       
   629 	TSpriteCreateParams params(size,TPoint(-16,-16),DrawSquare);
       
   630 	TSpriteCreateParams paramarray[eNumPointerCursors];
       
   631 	TInt lineWidth1=3;
       
   632 	TInt lineWidth2=5;
       
   633 	paramarray[2]=params;
       
   634 	params.iDrawFunc=DrawCircle;
       
   635 	paramarray[3]=params;
       
   636 	params.iDrawFunc=DrawOpenSquare;
       
   637 	params.iDrawFuncParam=&lineWidth1;
       
   638 	paramarray[5]=params;
       
   639 	params.iDrawFunc=DrawOpenCircle;
       
   640 	paramarray[6]=params;
       
   641 	params.iOffset=TPoint(0,0);
       
   642 	params.iDrawFunc=DrawArrow;
       
   643 	params.iDrawFuncParam=&lineWidth2;
       
   644 	paramarray[1]=params;
       
   645 	params.iOffset.iX=-31;
       
   646 	params.iDrawFunc=DrawTriangle;
       
   647 	paramarray[4]=params;
       
   648 	params.iOffset=TPoint(-15,-15);
       
   649 	params.iDrawFunc=DrawCross;
       
   650 	paramarray[0]=params;
       
   651 	CFbsBitmap *bitmap;
       
   652 	TInt ii,jj;
       
   653 	TDisplayMode mode=Client()->iWs.GetDefModeMaxNumColors(ii,jj);
       
   654 	for (ii=0;ii<eNumPointerCursors;++ii)
       
   655 		{
       
   656 		bitmap=NULL;
       
   657 		iBitmaps[ii]=new(ELeave) CFbsBitmap();
       
   658 		User::LeaveIfError(iBitmaps[ii]->Create(size,mode));
       
   659 		iCursors[ii]=new(ELeave) CTPointerCursor(Client()->iWs);
       
   660 		iCursors[ii]->ConstructL(1,&paramarray[ii],0,iBitmaps[ii],bitmap);
       
   661 		delete bitmap;
       
   662 		}
       
   663 	}
       
   664 
       
   665 TestState CPointerCursorTest::DoTestL()
       
   666 	{
       
   667 	switch(iState)
       
   668 		{
       
   669 		case 0:
       
   670 			LogSubTest(_L("Pointer Cursor"),1);
       
   671 			TestL(ETrue);
       
   672 			iState++;
       
   673 			return(EContinue);
       
   674 		default:
       
   675 			return(EFinished);
       
   676 		}
       
   677 	}