1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tman/TMPNTCUR.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,677 @@
1.4 +// Copyright (c) 1999-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 +// Tests for various pointer cursors on different windows
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <hal.h>
1.23 +#include "W32STD.H"
1.24 +#include "../tlib/testbase.h"
1.25 +#include "TMAN.H"
1.26 +
1.27 +class CPointerCursorWindow : public CTWin
1.28 + {
1.29 +public:
1.30 + ~CPointerCursorWindow();
1.31 + void SetChild(CPointerCursorWindow* aChild);
1.32 + inline CPointerCursorWindow* Child() {return iChild;}
1.33 + inline void SetBitmap(CFbsBitmap* aBitmap,TBool aTop=ETrue) {iBitmap=aBitmap;iTop=aTop;}
1.34 + void SetPointerCursor(CTPointerCursor* aCursor);
1.35 + //Virtual function from CTBaseWin
1.36 + void SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc);
1.37 + void Draw();
1.38 + void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
1.39 +private:
1.40 + CPointerCursorWindow* iChild;
1.41 + CFbsBitmap* iBitmap;
1.42 + TBool iTop;
1.43 + };
1.44 +
1.45 +class CPointerCursorWindowGroup : public CTWindowGroup
1.46 + {
1.47 +public:
1.48 + CPointerCursorWindowGroup(CTClient *aClient);
1.49 + void SetPointerCursor(CTPointerCursor* aCursor);
1.50 + void ConstructL();
1.51 + };
1.52 +
1.53 +class CStatusWindow : public CTTitledWindow
1.54 + {
1.55 +public:
1.56 + ~CStatusWindow();
1.57 + void Construct(CTestBase* aTest);
1.58 + void DoDraw();
1.59 + //virtual functions from CTWinBase overridden by CTBaseWin
1.60 + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
1.61 + //virtual functions from CTBaseWin
1.62 + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
1.63 + void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
1.64 + //virtual function from CTBaseWin overridden by CTTitledWindow
1.65 + void Draw();
1.66 +private:
1.67 + void UpdateString1();
1.68 + void UpdateString2();
1.69 + void UpdateString3();
1.70 + void ChangeXyInputType();
1.71 + void ChangePointerCursorMode();
1.72 +private:
1.73 + CTestBase* iTest;
1.74 + TBuf<16> iString1;
1.75 + TBuf<16> iString2;
1.76 + TBuf<16> iString3;
1.77 + TBuf<32> iString4;
1.78 + TRect iRect1;
1.79 + TRect iRect2;
1.80 + TRect iRect3;
1.81 + TRect iRect4;
1.82 + TXYInputType iXyInputType;
1.83 + TXYInputType iOriginalXyInputType;
1.84 + TPointerCursorMode iMode;
1.85 + TPointerCursorMode iOriginalMode;
1.86 + TBool iSimulatedPenDown;
1.87 + TBool iUpdateNeeded;
1.88 + TBool iExit;
1.89 + };
1.90 +
1.91 +class CPointerCursorTest : public CTestBase
1.92 + {
1.93 + enum {eWindowGap=3,eChildWindowGap=2};
1.94 + enum {eNumPointerCursors=7};
1.95 +public:
1.96 + CPointerCursorTest();
1.97 + ~CPointerCursorTest();
1.98 + TestState DoTestL();
1.99 + void ConstructL();
1.100 +private:
1.101 + CPointerCursorWindow *CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup);
1.102 + void CreatePointerCursorsL();
1.103 + void CreateWindowsL(TSize aArea);
1.104 +private:
1.105 + TSize iWinSize;
1.106 + TInt iState;
1.107 + CStatusWindow *iInfoWindow;
1.108 + CPointerCursorWindowGroup *iGroup1;
1.109 + CPointerCursorWindowGroup *iGroup2;
1.110 + CPointerCursorWindow *iWindows[6];
1.111 + CTPointerCursor *iCursors[eNumPointerCursors];
1.112 + CFbsBitmap *iBitmaps[eNumPointerCursors];
1.113 + };
1.114 +
1.115 +
1.116 +/*CPointerCursorWindow*/
1.117 +
1.118 +CPointerCursorWindow::~CPointerCursorWindow()
1.119 + {
1.120 + delete iChild;
1.121 + }
1.122 +
1.123 +void CPointerCursorWindow::SetChild(CPointerCursorWindow* aChild)
1.124 + {
1.125 + iChild=aChild;
1.126 + iWin.SetShadowDisabled(ETrue);
1.127 + }
1.128 +
1.129 +void CPointerCursorWindow::SetPointerCursor(CTPointerCursor* aCursor)
1.130 + {
1.131 + iWin.SetCustomPointerCursor(aCursor->PointerCursor());
1.132 + }
1.133 +
1.134 +void CPointerCursorWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc)
1.135 + {
1.136 + CTWin::SetUpL(aPos,aSize,aParent,aGc);
1.137 + iWin.SetShadowDisabled(ETrue);
1.138 + iWin.SetPointerGrab(EFalse);
1.139 + }
1.140 +
1.141 +void CPointerCursorWindow::Draw()
1.142 + {
1.143 + iGc->Reset();
1.144 + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.145 + iGc->DrawRect(Size());
1.146 + if (iBitmap)
1.147 + {
1.148 + TPoint point(3,3);
1.149 + if (!iTop)
1.150 + point.iY=Size().iHeight-iBitmap->SizeInPixels().iHeight-3;
1.151 + iGc->BitBlt(point,iBitmap);
1.152 + }
1.153 + }
1.154 +
1.155 +void CPointerCursorWindow::PointerL(const TPointerEvent&,const TTime&)
1.156 + {
1.157 + }
1.158 +
1.159 +
1.160 +/*CPointerCursorWindowGroup*/
1.161 +
1.162 +CPointerCursorWindowGroup::CPointerCursorWindowGroup(CTClient *aClient)
1.163 + :CTWindowGroup(aClient)
1.164 + {}
1.165 +
1.166 +void CPointerCursorWindowGroup::ConstructL()
1.167 + {
1.168 + CTWindowGroup::ConstructL();
1.169 + iGroupWin.EnableReceiptOfFocus(EFalse);
1.170 + }
1.171 +
1.172 +void CPointerCursorWindowGroup::SetPointerCursor(CTPointerCursor* aCursor)
1.173 + {
1.174 + iGroupWin.SetCustomPointerCursor(aCursor->PointerCursor());
1.175 + }
1.176 +
1.177 +
1.178 +/*CStatusWindow*/
1.179 +
1.180 +CStatusWindow::~CStatusWindow()
1.181 + {
1.182 + Client()->iWs.SetPointerCursorMode(iOriginalMode);
1.183 +#if defined(__WINS__)
1.184 + Client()->iWs.SimulateXyInputType(iOriginalXyInputType);
1.185 +#endif
1.186 + }
1.187 +
1.188 +void CStatusWindow::Construct(CTestBase* aTest)
1.189 + {
1.190 + _LIT(Title,"StatusWindow");
1.191 + _LIT(String4,"Click here to finish");
1.192 + iTest=aTest;
1.193 + TWindowTitle title(Title);
1.194 + SetTitle(title);
1.195 + TInt yy=iTitleHeight+iFont->HeightInPixels()+7;
1.196 + iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy);
1.197 + TInt yy1=yy+iFont->HeightInPixels()+2;
1.198 + iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1);
1.199 + TInt yy2=yy1+iFont->HeightInPixels()+2;
1.200 + iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2);
1.201 + iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2);
1.202 + TMachineInfoV1Buf machineInfo;
1.203 + UserHal::MachineInfo(machineInfo);
1.204 + iXyInputType=machineInfo().iXYInputType;
1.205 + iOriginalXyInputType=iXyInputType;
1.206 + iSimulatedPenDown=EFalse;
1.207 + //
1.208 + iString3.Copy(KNullDesC);
1.209 + if (iXyInputType==EXYInputDeltaMouse)
1.210 + {
1.211 + if (HAL::Get(HALData::EMouseState,iSimulatedPenDown)==KErrNone)
1.212 + UpdateString3();
1.213 + }
1.214 + UpdateString1();
1.215 + iMode=Client()->iWs.PointerCursorMode();
1.216 + iOriginalMode=iMode;
1.217 + UpdateString2();
1.218 + iUpdateNeeded=EFalse;
1.219 + iString4.Copy(String4);
1.220 + iExit=EFalse;
1.221 + }
1.222 +
1.223 +void CStatusWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc)
1.224 + {
1.225 + CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc);
1.226 + }
1.227 +
1.228 +void CStatusWindow::WinKeyL(const TKeyEvent &aKey,const TTime&)
1.229 + {
1.230 + switch(aKey.iCode)
1.231 + {
1.232 + case EKeyEscape:
1.233 + iTest->Request();
1.234 + break;
1.235 + case 'M':
1.236 + case 'm':
1.237 + if (iXyInputType==EXYInputDeltaMouse)
1.238 + {
1.239 + if (HAL::Set(HALData::EMouseState,!iSimulatedPenDown)==KErrNone)
1.240 + {
1.241 + iSimulatedPenDown=!iSimulatedPenDown;
1.242 + UpdateString3();
1.243 + DoDraw();
1.244 + }
1.245 + }
1.246 + break;
1.247 + #if defined(__WINS__)
1.248 + case 'I':
1.249 + case 'i':
1.250 + case '1':
1.251 + ChangeXyInputType();
1.252 + Client()->iWs.SimulateXyInputType(iXyInputType);
1.253 + break;
1.254 + #endif
1.255 + case 'C':
1.256 + case 'c':
1.257 + case '2':
1.258 + ChangePointerCursorMode();
1.259 + Client()->iWs.SetPointerCursorMode(iMode);
1.260 + break;
1.261 + default:;
1.262 + }
1.263 + }
1.264 +
1.265 +void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime)
1.266 + {
1.267 +#if defined(__WINS__)
1.268 + if (iRect1.Contains(aPointer.iPosition))
1.269 + {
1.270 + if (aPointer.iType==TPointerEvent::EButton1Down)
1.271 + ChangeXyInputType();
1.272 + }
1.273 + else
1.274 +#endif
1.275 + if (iRect2.Contains(aPointer.iPosition))
1.276 + {
1.277 + if (aPointer.iType==TPointerEvent::EButton1Down)
1.278 + ChangePointerCursorMode();
1.279 + }
1.280 + else if (iRect4.Contains(aPointer.iPosition))
1.281 + iExit=ETrue;
1.282 + else
1.283 + CTTitledWindow::PointerL(aPointer,aTime);
1.284 + if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up)
1.285 + {
1.286 + if (iExit)
1.287 + iTest->Request();
1.288 + else
1.289 + {
1.290 + Client()->iWs.SetPointerCursorMode(iMode);
1.291 + #if defined(__WINS__)
1.292 + Client()->iWs.SimulateXyInputType(iXyInputType);
1.293 + #endif
1.294 + Client()->iWs.Flush();
1.295 + iUpdateNeeded=EFalse;
1.296 + }
1.297 + }
1.298 + }
1.299 +
1.300 +void CStatusWindow::Draw()
1.301 + {
1.302 + CTTitledWindow::Draw();
1.303 + TInt ascent=iFont->AscentInPixels()+1;
1.304 + iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft);
1.305 + iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft);
1.306 + iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft);
1.307 + iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft);
1.308 + }
1.309 +
1.310 +void CStatusWindow::DoDraw()
1.311 + {
1.312 + iGc->Activate(iWin);
1.313 + iGc->UseFont((CFont *)iFont);
1.314 + Draw();
1.315 + iGc->Deactivate();
1.316 + }
1.317 +
1.318 +void CStatusWindow::UpdateString1()
1.319 + {
1.320 + _LIT(Text0,"No Pointer");
1.321 + _LIT(Text1,"Pen");
1.322 + _LIT(Text2,"Mouse");
1.323 + _LIT(Text3,"Relative Mouse");
1.324 + switch (iXyInputType)
1.325 + {
1.326 + case EXYInputNone:
1.327 + iString1.Copy(Text0);
1.328 + break;
1.329 + case EXYInputPointer:
1.330 + iString1.Copy(Text1);
1.331 + break;
1.332 + case EXYInputMouse:
1.333 + iString1.Copy(Text2);
1.334 + break;
1.335 + case EXYInputDeltaMouse:
1.336 + iString1.Copy(Text3);
1.337 + break;
1.338 + }
1.339 + }
1.340 +
1.341 +void CStatusWindow::UpdateString2()
1.342 + {
1.343 + _LIT(Text0,"None");
1.344 + _LIT(Text1,"Fixed");
1.345 + _LIT(Text2,"Normal");
1.346 + _LIT(Text3,"Window");
1.347 + switch (iMode)
1.348 + {
1.349 + case EPointerCursorNone:
1.350 + iString2.Copy(Text0);
1.351 + break;
1.352 + case EPointerCursorFixed:
1.353 + iString2.Copy(Text1);
1.354 + break;
1.355 + case EPointerCursorNormal:
1.356 + iString2.Copy(Text2);
1.357 + break;
1.358 + case EPointerCursorWindow:
1.359 + iString2.Copy(Text3);
1.360 + break;
1.361 + }
1.362 + }
1.363 +
1.364 +void CStatusWindow::UpdateString3()
1.365 + {
1.366 + if (iSimulatedPenDown)
1.367 + {
1.368 + _LIT(TextD,"Sim Pen Down");
1.369 + iString3.Copy(TextD);
1.370 + }
1.371 + else
1.372 + {
1.373 + _LIT(TextU,"Sim Pen Up");
1.374 + iString3.Copy(TextU);
1.375 + }
1.376 + }
1.377 +
1.378 +void CStatusWindow::ChangeXyInputType()
1.379 + {
1.380 + if (iXyInputType==EXYInputMouse)
1.381 + iXyInputType=EXYInputPointer;
1.382 + else if (iXyInputType==EXYInputPointer)
1.383 + iXyInputType=EXYInputMouse;
1.384 + UpdateString1();
1.385 + DoDraw();
1.386 + iUpdateNeeded=ETrue;
1.387 + }
1.388 +
1.389 +void CStatusWindow::ChangePointerCursorMode()
1.390 + {
1.391 + TInt mode=(iMode+1)%(EPointerCursorLastMode+1);
1.392 + iMode=STATIC_CAST(TPointerCursorMode,mode);
1.393 + UpdateString2();
1.394 + DoDraw();
1.395 + iUpdateNeeded=ETrue;
1.396 + }
1.397 +
1.398 +
1.399 +/*Sprite Drawing Functions*/
1.400 +
1.401 +#if defined(__WINS__)
1.402 + #define DRAW_COLOR 1
1.403 +#else
1.404 + #define DRAW_COLOR 0
1.405 +#endif
1.406 +
1.407 +void DrawCross(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
1.408 + {
1.409 + TInt halfLineWidth=(*STATIC_CAST(TInt*,aLineWidth)+1)/2;
1.410 + TInt lineWidth=2*halfLineWidth+1; //Must be odd
1.411 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.412 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.413 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.414 + aGc->DrawRect(TRect(aSize));
1.415 + aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1.416 + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
1.417 + aGc->SetPenSize(TSize(lineWidth,lineWidth));
1.418 + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-lineWidth,aSize.iHeight-lineWidth));
1.419 + aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-lineWidth),TPoint(aSize.iWidth-lineWidth,halfLineWidth));
1.420 + }
1.421 +
1.422 +void DrawArrow(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
1.423 + {
1.424 + TInt lineWidth=*STATIC_CAST(TInt*,aLineWidth);
1.425 + TInt halfLineWidth=(lineWidth-1)/2;
1.426 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.427 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.428 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.429 + aGc->DrawRect(TRect(aSize));
1.430 + aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1.431 + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
1.432 + aGc->SetPenSize(TSize(1,1));
1.433 + aGc->DrawLine(TPoint(0,0),TPoint(lineWidth,0));
1.434 + aGc->DrawLine(TPoint(0,0),TPoint(0,lineWidth));
1.435 + aGc->SetPenSize(TSize(lineWidth,lineWidth));
1.436 + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-halfLineWidth-1,aSize.iHeight-halfLineWidth-1));
1.437 + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/2,halfLineWidth));
1.438 + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(halfLineWidth,aSize.iHeight/2));
1.439 + }
1.440 +
1.441 +void DrawSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
1.442 + {
1.443 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.444 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.445 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.446 + aGc->DrawRect(TRect(aSize));
1.447 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
1.448 + aGc->DrawRect(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1));
1.449 + }
1.450 +
1.451 +void DrawCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
1.452 + {
1.453 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.454 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.455 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.456 + aGc->DrawRect(TRect(aSize));
1.457 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
1.458 + aGc->DrawEllipse(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1));
1.459 + }
1.460 +
1.461 +void DrawTriangle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
1.462 + {
1.463 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.464 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.465 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.466 + aGc->DrawRect(TRect(aSize));
1.467 + aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1.468 + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
1.469 + aGc->SetPenSize(TSize(1,1));
1.470 + for(TInt y=0;y<aSize.iHeight;y++)
1.471 + {
1.472 + TInt xfact=aSize.iWidth*y/aSize.iHeight;
1.473 + aGc->DrawLine(TPoint(aSize.iWidth-xfact-1,y),TPoint(aSize.iWidth-1,y));
1.474 + }
1.475 + }
1.476 +
1.477 +void DrawOpenSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
1.478 + {
1.479 + TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2;
1.480 + TInt lineWidth=2*halfLineWidth+1; //Must be odd
1.481 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.482 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.483 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.484 + aGc->DrawRect(TRect(aSize));
1.485 + aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
1.486 + aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1.487 + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
1.488 + aGc->SetPenSize(TSize(lineWidth,lineWidth));
1.489 + TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1);
1.490 + aGc->DrawRect(TRect(aSize.iWidth/4,aSize.iHeight/4,botRig.iX+1,botRig.iY+1));
1.491 + aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,aSize.iHeight/4-halfLineWidth));
1.492 + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,halfLineWidth),TPoint(botRig.iX+halfLineWidth,aSize.iHeight/4-halfLineWidth));
1.493 + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(botRig.iX+halfLineWidth,botRig.iY+halfLineWidth));
1.494 + aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,botRig.iY+halfLineWidth));
1.495 + }
1.496 +
1.497 +void DrawOpenCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth)
1.498 + {
1.499 + TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2;
1.500 + TInt lineWidth=2*halfLineWidth+1; //Must be odd
1.501 + aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3));
1.502 + aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.503 + aGc->SetPenStyle(CGraphicsContext::ENullPen);
1.504 + aGc->DrawRect(TRect(aSize));
1.505 + aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
1.506 + aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1.507 + aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR));
1.508 + aGc->SetPenSize(TSize(lineWidth,lineWidth));
1.509 + TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1);
1.510 + aGc->DrawEllipse(TRect(aSize.iWidth/4+1,aSize.iHeight/4+1,botRig.iX+1,botRig.iY+1));
1.511 + aGc->DrawLine(TPoint(aSize.iWidth/2,1+halfLineWidth),TPoint(aSize.iWidth/2,aSize.iHeight/4+1-halfLineWidth));
1.512 + aGc->DrawLine(TPoint(aSize.iWidth/2,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/2,botRig.iY+halfLineWidth));
1.513 + aGc->DrawLine(TPoint(1+halfLineWidth,aSize.iWidth/2),TPoint(aSize.iWidth/4+1-halfLineWidth,aSize.iHeight/2));
1.514 + aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight/2),TPoint(botRig.iX+halfLineWidth,aSize.iWidth/2));
1.515 + }
1.516 +
1.517 +
1.518 +/*CPointerCursorTest*/
1.519 +
1.520 +GLDEF_C CTestBase *CreatePointerCursorTest()
1.521 + {
1.522 + return(new(ELeave) CPointerCursorTest());
1.523 + }
1.524 +
1.525 +CPointerCursorTest::CPointerCursorTest() : CTestBase(_L("PointerCursor"))
1.526 + {}
1.527 +
1.528 +CPointerCursorTest::~CPointerCursorTest()
1.529 + {
1.530 + TInt ii;
1.531 + Client()->iGroup->SetCurrentWindow(NULL);
1.532 + delete iInfoWindow;
1.533 + for(ii=0;ii<6;++ii)
1.534 + {
1.535 + delete iWindows[ii];
1.536 + }
1.537 + for(ii=0;ii<eNumPointerCursors;++ii)
1.538 + {
1.539 + delete iCursors[ii];
1.540 + delete iBitmaps[ii];
1.541 + }
1.542 + delete iGroup1;
1.543 + delete iGroup2;
1.544 + }
1.545 +
1.546 +void CPointerCursorTest::ConstructL()
1.547 + {
1.548 + TSize size=Client()->iScreen->SizeInPixels();
1.549 + TInt infoWidth=Min(210,5*size.iWidth/12);
1.550 + size.iWidth=Max(Min(415,size.iWidth-infoWidth),85);
1.551 + iInfoWindow=new(ELeave) CStatusWindow();
1.552 + iInfoWindow->SetUpL(TPoint(size.iWidth,50),TSize(infoWidth,180),Client()->iGroup,*Client()->iGc);
1.553 + Client()->iGroup->SetCurrentWindow(iInfoWindow);
1.554 + iInfoWindow->Construct(this);
1.555 + iGroup1=new(ELeave) CPointerCursorWindowGroup(Client());
1.556 + iGroup1->ConstructL();
1.557 + iGroup2=new(ELeave) CPointerCursorWindowGroup(Client());
1.558 + iGroup2->ConstructL();
1.559 + size.iWidth-=5;
1.560 + CreateWindowsL(size);
1.561 + CreatePointerCursorsL();
1.562 + iGroup1->SetPointerCursor(iCursors[0]);
1.563 + iWindows[1]->SetBitmap(iBitmaps[0],EFalse);
1.564 + iWindows[0]->SetPointerCursor(iCursors[1]);
1.565 + iWindows[0]->SetBitmap(iBitmaps[1]);
1.566 + iWindows[0]->Child()->SetPointerCursor(iCursors[2]);
1.567 + iWindows[0]->Child()->SetBitmap(iBitmaps[2]);
1.568 + iWindows[2]->SetPointerCursor(iCursors[3]);
1.569 + iWindows[2]->SetBitmap(iBitmaps[3]);
1.570 + iWindows[2]->Child()->Child()->SetPointerCursor(iCursors[4]);
1.571 + iWindows[2]->Child()->Child()->SetBitmap(iBitmaps[4]);
1.572 + iWindows[3]->Child()->SetPointerCursor(iCursors[5]);
1.573 + iWindows[3]->Child()->SetBitmap(iBitmaps[5]);
1.574 + iWindows[4]->SetPointerCursor(iCursors[6]);
1.575 + iWindows[4]->SetBitmap(iBitmaps[6]);
1.576 + }
1.577 +
1.578 +void CPointerCursorTest::CreateWindowsL(TSize aArea)
1.579 + {
1.580 + //TSize screenSize=Client()->iScreen->SizeInPixels();
1.581 + TInt height=eWindowGap+(aArea.iHeight-5*eWindowGap)/4;
1.582 + TInt halfWidth=aArea.iWidth/2;
1.583 + TRect rect(5,eWindowGap,halfWidth,height);
1.584 + iWindows[0]=CreateWindowL(2,rect,iGroup1);
1.585 + rect.Move(halfWidth,0);
1.586 + iWindows[1]=CreateWindowL(2,rect,iGroup1);
1.587 + rect.Move(-halfWidth,height);
1.588 + rect.iBr.iX=aArea.iWidth;
1.589 + iWindows[2]=CreateWindowL(4,rect,iGroup2);
1.590 + rect.Move(0,height);
1.591 + rect.iBr.iX=aArea.iWidth-11;
1.592 + iWindows[3]=CreateWindowL(3,rect,iGroup2);
1.593 + rect.Move(0,height);
1.594 + rect.iBr.iX=halfWidth;
1.595 + iWindows[4]=CreateWindowL(2,rect,iGroup2);
1.596 + rect.Move(halfWidth,0);
1.597 + iWindows[5]=CreateWindowL(2,rect,iGroup2);
1.598 + }
1.599 +
1.600 +CPointerCursorWindow* CPointerCursorTest::CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup)
1.601 + {
1.602 + CPointerCursorWindow* firstWin=NULL;
1.603 + CPointerCursorWindow* parent=NULL;
1.604 + CPointerCursorWindow* win;
1.605 + TInt xInc=aLocation.Width()/aNum-eChildWindowGap;
1.606 + TInt ii;
1.607 + for (ii=aNum;ii>0;ii--)
1.608 + {
1.609 + win=new(ELeave) CPointerCursorWindow();
1.610 + CleanupStack::PushL(win);
1.611 + win->SetUpL(aLocation.iTl,aLocation.Size(),aGroup,*Client()->iGc);
1.612 + if (!parent)
1.613 + firstWin=win;
1.614 + else
1.615 + {
1.616 + parent->SetChild(win);
1.617 + CleanupStack::Pop();
1.618 + }
1.619 + aLocation.iBr=TPoint(-eChildWindowGap,-eChildWindowGap)+aLocation.Size();
1.620 + aLocation.iTl.iX=xInc;
1.621 + aLocation.iTl.iY=eChildWindowGap;
1.622 + aGroup=win;
1.623 + parent=win;
1.624 + }
1.625 + CleanupStack::Pop();
1.626 + return firstWin;
1.627 + }
1.628 +
1.629 +void CPointerCursorTest::CreatePointerCursorsL()
1.630 + {
1.631 + const TSize size(32,32);
1.632 + TSpriteCreateParams params(size,TPoint(-16,-16),DrawSquare);
1.633 + TSpriteCreateParams paramarray[eNumPointerCursors];
1.634 + TInt lineWidth1=3;
1.635 + TInt lineWidth2=5;
1.636 + paramarray[2]=params;
1.637 + params.iDrawFunc=DrawCircle;
1.638 + paramarray[3]=params;
1.639 + params.iDrawFunc=DrawOpenSquare;
1.640 + params.iDrawFuncParam=&lineWidth1;
1.641 + paramarray[5]=params;
1.642 + params.iDrawFunc=DrawOpenCircle;
1.643 + paramarray[6]=params;
1.644 + params.iOffset=TPoint(0,0);
1.645 + params.iDrawFunc=DrawArrow;
1.646 + params.iDrawFuncParam=&lineWidth2;
1.647 + paramarray[1]=params;
1.648 + params.iOffset.iX=-31;
1.649 + params.iDrawFunc=DrawTriangle;
1.650 + paramarray[4]=params;
1.651 + params.iOffset=TPoint(-15,-15);
1.652 + params.iDrawFunc=DrawCross;
1.653 + paramarray[0]=params;
1.654 + CFbsBitmap *bitmap;
1.655 + TInt ii,jj;
1.656 + TDisplayMode mode=Client()->iWs.GetDefModeMaxNumColors(ii,jj);
1.657 + for (ii=0;ii<eNumPointerCursors;++ii)
1.658 + {
1.659 + bitmap=NULL;
1.660 + iBitmaps[ii]=new(ELeave) CFbsBitmap();
1.661 + User::LeaveIfError(iBitmaps[ii]->Create(size,mode));
1.662 + iCursors[ii]=new(ELeave) CTPointerCursor(Client()->iWs);
1.663 + iCursors[ii]->ConstructL(1,¶marray[ii],0,iBitmaps[ii],bitmap);
1.664 + delete bitmap;
1.665 + }
1.666 + }
1.667 +
1.668 +TestState CPointerCursorTest::DoTestL()
1.669 + {
1.670 + switch(iState)
1.671 + {
1.672 + case 0:
1.673 + LogSubTest(_L("Pointer Cursor"),1);
1.674 + TestL(ETrue);
1.675 + iState++;
1.676 + return(EContinue);
1.677 + default:
1.678 + return(EFinished);
1.679 + }
1.680 + }