sl@0: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Tests for various pointer cursors on different windows sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "W32STD.H" sl@0: #include "../tlib/testbase.h" sl@0: #include "TMAN.H" sl@0: sl@0: class CPointerCursorWindow : public CTWin sl@0: { sl@0: public: sl@0: ~CPointerCursorWindow(); sl@0: void SetChild(CPointerCursorWindow* aChild); sl@0: inline CPointerCursorWindow* Child() {return iChild;} sl@0: inline void SetBitmap(CFbsBitmap* aBitmap,TBool aTop=ETrue) {iBitmap=aBitmap;iTop=aTop;} sl@0: void SetPointerCursor(CTPointerCursor* aCursor); sl@0: //Virtual function from CTBaseWin sl@0: void SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc); sl@0: void Draw(); sl@0: void PointerL(const TPointerEvent &aPointer,const TTime &aTime); sl@0: private: sl@0: CPointerCursorWindow* iChild; sl@0: CFbsBitmap* iBitmap; sl@0: TBool iTop; sl@0: }; sl@0: sl@0: class CPointerCursorWindowGroup : public CTWindowGroup sl@0: { sl@0: public: sl@0: CPointerCursorWindowGroup(CTClient *aClient); sl@0: void SetPointerCursor(CTPointerCursor* aCursor); sl@0: void ConstructL(); sl@0: }; sl@0: sl@0: class CStatusWindow : public CTTitledWindow sl@0: { sl@0: public: sl@0: ~CStatusWindow(); sl@0: void Construct(CTestBase* aTest); sl@0: void DoDraw(); sl@0: //virtual functions from CTWinBase overridden by CTBaseWin sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: //virtual functions from CTBaseWin sl@0: void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); sl@0: void PointerL(const TPointerEvent &aPointer,const TTime &aTime); sl@0: //virtual function from CTBaseWin overridden by CTTitledWindow sl@0: void Draw(); sl@0: private: sl@0: void UpdateString1(); sl@0: void UpdateString2(); sl@0: void UpdateString3(); sl@0: void ChangeXyInputType(); sl@0: void ChangePointerCursorMode(); sl@0: private: sl@0: CTestBase* iTest; sl@0: TBuf<16> iString1; sl@0: TBuf<16> iString2; sl@0: TBuf<16> iString3; sl@0: TBuf<32> iString4; sl@0: TRect iRect1; sl@0: TRect iRect2; sl@0: TRect iRect3; sl@0: TRect iRect4; sl@0: TXYInputType iXyInputType; sl@0: TXYInputType iOriginalXyInputType; sl@0: TPointerCursorMode iMode; sl@0: TPointerCursorMode iOriginalMode; sl@0: TBool iSimulatedPenDown; sl@0: TBool iUpdateNeeded; sl@0: TBool iExit; sl@0: }; sl@0: sl@0: class CPointerCursorTest : public CTestBase sl@0: { sl@0: enum {eWindowGap=3,eChildWindowGap=2}; sl@0: enum {eNumPointerCursors=7}; sl@0: public: sl@0: CPointerCursorTest(); sl@0: ~CPointerCursorTest(); sl@0: TestState DoTestL(); sl@0: void ConstructL(); sl@0: private: sl@0: CPointerCursorWindow *CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup); sl@0: void CreatePointerCursorsL(); sl@0: void CreateWindowsL(TSize aArea); sl@0: private: sl@0: TSize iWinSize; sl@0: TInt iState; sl@0: CStatusWindow *iInfoWindow; sl@0: CPointerCursorWindowGroup *iGroup1; sl@0: CPointerCursorWindowGroup *iGroup2; sl@0: CPointerCursorWindow *iWindows[6]; sl@0: CTPointerCursor *iCursors[eNumPointerCursors]; sl@0: CFbsBitmap *iBitmaps[eNumPointerCursors]; sl@0: }; sl@0: sl@0: sl@0: /*CPointerCursorWindow*/ sl@0: sl@0: CPointerCursorWindow::~CPointerCursorWindow() sl@0: { sl@0: delete iChild; sl@0: } sl@0: sl@0: void CPointerCursorWindow::SetChild(CPointerCursorWindow* aChild) sl@0: { sl@0: iChild=aChild; sl@0: iWin.SetShadowDisabled(ETrue); sl@0: } sl@0: sl@0: void CPointerCursorWindow::SetPointerCursor(CTPointerCursor* aCursor) sl@0: { sl@0: iWin.SetCustomPointerCursor(aCursor->PointerCursor()); sl@0: } sl@0: sl@0: void CPointerCursorWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) sl@0: { sl@0: CTWin::SetUpL(aPos,aSize,aParent,aGc); sl@0: iWin.SetShadowDisabled(ETrue); sl@0: iWin.SetPointerGrab(EFalse); sl@0: } sl@0: sl@0: void CPointerCursorWindow::Draw() sl@0: { sl@0: iGc->Reset(); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->DrawRect(Size()); sl@0: if (iBitmap) sl@0: { sl@0: TPoint point(3,3); sl@0: if (!iTop) sl@0: point.iY=Size().iHeight-iBitmap->SizeInPixels().iHeight-3; sl@0: iGc->BitBlt(point,iBitmap); sl@0: } sl@0: } sl@0: sl@0: void CPointerCursorWindow::PointerL(const TPointerEvent&,const TTime&) sl@0: { sl@0: } sl@0: sl@0: sl@0: /*CPointerCursorWindowGroup*/ sl@0: sl@0: CPointerCursorWindowGroup::CPointerCursorWindowGroup(CTClient *aClient) sl@0: :CTWindowGroup(aClient) sl@0: {} sl@0: sl@0: void CPointerCursorWindowGroup::ConstructL() sl@0: { sl@0: CTWindowGroup::ConstructL(); sl@0: iGroupWin.EnableReceiptOfFocus(EFalse); sl@0: } sl@0: sl@0: void CPointerCursorWindowGroup::SetPointerCursor(CTPointerCursor* aCursor) sl@0: { sl@0: iGroupWin.SetCustomPointerCursor(aCursor->PointerCursor()); sl@0: } sl@0: sl@0: sl@0: /*CStatusWindow*/ sl@0: sl@0: CStatusWindow::~CStatusWindow() sl@0: { sl@0: Client()->iWs.SetPointerCursorMode(iOriginalMode); sl@0: #if defined(__WINS__) sl@0: Client()->iWs.SimulateXyInputType(iOriginalXyInputType); sl@0: #endif sl@0: } sl@0: sl@0: void CStatusWindow::Construct(CTestBase* aTest) sl@0: { sl@0: _LIT(Title,"StatusWindow"); sl@0: _LIT(String4,"Click here to finish"); sl@0: iTest=aTest; sl@0: TWindowTitle title(Title); sl@0: SetTitle(title); sl@0: TInt yy=iTitleHeight+iFont->HeightInPixels()+7; sl@0: iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); sl@0: TInt yy1=yy+iFont->HeightInPixels()+2; sl@0: iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); sl@0: TInt yy2=yy1+iFont->HeightInPixels()+2; sl@0: iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); sl@0: iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); sl@0: TMachineInfoV1Buf machineInfo; sl@0: UserHal::MachineInfo(machineInfo); sl@0: iXyInputType=machineInfo().iXYInputType; sl@0: iOriginalXyInputType=iXyInputType; sl@0: iSimulatedPenDown=EFalse; sl@0: // sl@0: iString3.Copy(KNullDesC); sl@0: if (iXyInputType==EXYInputDeltaMouse) sl@0: { sl@0: if (HAL::Get(HALData::EMouseState,iSimulatedPenDown)==KErrNone) sl@0: UpdateString3(); sl@0: } sl@0: UpdateString1(); sl@0: iMode=Client()->iWs.PointerCursorMode(); sl@0: iOriginalMode=iMode; sl@0: UpdateString2(); sl@0: iUpdateNeeded=EFalse; sl@0: iString4.Copy(String4); sl@0: iExit=EFalse; sl@0: } sl@0: sl@0: void CStatusWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) sl@0: { sl@0: CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); sl@0: } sl@0: sl@0: void CStatusWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case EKeyEscape: sl@0: iTest->Request(); sl@0: break; sl@0: case 'M': sl@0: case 'm': sl@0: if (iXyInputType==EXYInputDeltaMouse) sl@0: { sl@0: if (HAL::Set(HALData::EMouseState,!iSimulatedPenDown)==KErrNone) sl@0: { sl@0: iSimulatedPenDown=!iSimulatedPenDown; sl@0: UpdateString3(); sl@0: DoDraw(); sl@0: } sl@0: } sl@0: break; sl@0: #if defined(__WINS__) sl@0: case 'I': sl@0: case 'i': sl@0: case '1': sl@0: ChangeXyInputType(); sl@0: Client()->iWs.SimulateXyInputType(iXyInputType); sl@0: break; sl@0: #endif sl@0: case 'C': sl@0: case 'c': sl@0: case '2': sl@0: ChangePointerCursorMode(); sl@0: Client()->iWs.SetPointerCursorMode(iMode); sl@0: break; sl@0: default:; sl@0: } sl@0: } sl@0: sl@0: void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) sl@0: { sl@0: #if defined(__WINS__) sl@0: if (iRect1.Contains(aPointer.iPosition)) sl@0: { sl@0: if (aPointer.iType==TPointerEvent::EButton1Down) sl@0: ChangeXyInputType(); sl@0: } sl@0: else sl@0: #endif sl@0: if (iRect2.Contains(aPointer.iPosition)) sl@0: { sl@0: if (aPointer.iType==TPointerEvent::EButton1Down) sl@0: ChangePointerCursorMode(); sl@0: } sl@0: else if (iRect4.Contains(aPointer.iPosition)) sl@0: iExit=ETrue; sl@0: else sl@0: CTTitledWindow::PointerL(aPointer,aTime); sl@0: if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up) sl@0: { sl@0: if (iExit) sl@0: iTest->Request(); sl@0: else sl@0: { sl@0: Client()->iWs.SetPointerCursorMode(iMode); sl@0: #if defined(__WINS__) sl@0: Client()->iWs.SimulateXyInputType(iXyInputType); sl@0: #endif sl@0: Client()->iWs.Flush(); sl@0: iUpdateNeeded=EFalse; sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CStatusWindow::Draw() sl@0: { sl@0: CTTitledWindow::Draw(); sl@0: TInt ascent=iFont->AscentInPixels()+1; sl@0: iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); sl@0: iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); sl@0: iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); sl@0: iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); sl@0: } sl@0: sl@0: void CStatusWindow::DoDraw() sl@0: { sl@0: iGc->Activate(iWin); sl@0: iGc->UseFont((CFont *)iFont); sl@0: Draw(); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: void CStatusWindow::UpdateString1() sl@0: { sl@0: _LIT(Text0,"No Pointer"); sl@0: _LIT(Text1,"Pen"); sl@0: _LIT(Text2,"Mouse"); sl@0: _LIT(Text3,"Relative Mouse"); sl@0: switch (iXyInputType) sl@0: { sl@0: case EXYInputNone: sl@0: iString1.Copy(Text0); sl@0: break; sl@0: case EXYInputPointer: sl@0: iString1.Copy(Text1); sl@0: break; sl@0: case EXYInputMouse: sl@0: iString1.Copy(Text2); sl@0: break; sl@0: case EXYInputDeltaMouse: sl@0: iString1.Copy(Text3); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CStatusWindow::UpdateString2() sl@0: { sl@0: _LIT(Text0,"None"); sl@0: _LIT(Text1,"Fixed"); sl@0: _LIT(Text2,"Normal"); sl@0: _LIT(Text3,"Window"); sl@0: switch (iMode) sl@0: { sl@0: case EPointerCursorNone: sl@0: iString2.Copy(Text0); sl@0: break; sl@0: case EPointerCursorFixed: sl@0: iString2.Copy(Text1); sl@0: break; sl@0: case EPointerCursorNormal: sl@0: iString2.Copy(Text2); sl@0: break; sl@0: case EPointerCursorWindow: sl@0: iString2.Copy(Text3); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CStatusWindow::UpdateString3() sl@0: { sl@0: if (iSimulatedPenDown) sl@0: { sl@0: _LIT(TextD,"Sim Pen Down"); sl@0: iString3.Copy(TextD); sl@0: } sl@0: else sl@0: { sl@0: _LIT(TextU,"Sim Pen Up"); sl@0: iString3.Copy(TextU); sl@0: } sl@0: } sl@0: sl@0: void CStatusWindow::ChangeXyInputType() sl@0: { sl@0: if (iXyInputType==EXYInputMouse) sl@0: iXyInputType=EXYInputPointer; sl@0: else if (iXyInputType==EXYInputPointer) sl@0: iXyInputType=EXYInputMouse; sl@0: UpdateString1(); sl@0: DoDraw(); sl@0: iUpdateNeeded=ETrue; sl@0: } sl@0: sl@0: void CStatusWindow::ChangePointerCursorMode() sl@0: { sl@0: TInt mode=(iMode+1)%(EPointerCursorLastMode+1); sl@0: iMode=STATIC_CAST(TPointerCursorMode,mode); sl@0: UpdateString2(); sl@0: DoDraw(); sl@0: iUpdateNeeded=ETrue; sl@0: } sl@0: sl@0: sl@0: /*Sprite Drawing Functions*/ sl@0: sl@0: #if defined(__WINS__) sl@0: #define DRAW_COLOR 1 sl@0: #else sl@0: #define DRAW_COLOR 0 sl@0: #endif sl@0: sl@0: void DrawCross(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) sl@0: { sl@0: TInt halfLineWidth=(*STATIC_CAST(TInt*,aLineWidth)+1)/2; sl@0: TInt lineWidth=2*halfLineWidth+1; //Must be odd sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); sl@0: aGc->SetPenSize(TSize(lineWidth,lineWidth)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-lineWidth,aSize.iHeight-lineWidth)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-lineWidth),TPoint(aSize.iWidth-lineWidth,halfLineWidth)); sl@0: } sl@0: sl@0: void DrawArrow(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) sl@0: { sl@0: TInt lineWidth=*STATIC_CAST(TInt*,aLineWidth); sl@0: TInt halfLineWidth=(lineWidth-1)/2; sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0)); sl@0: aGc->SetPenSize(TSize(1,1)); sl@0: aGc->DrawLine(TPoint(0,0),TPoint(lineWidth,0)); sl@0: aGc->DrawLine(TPoint(0,0),TPoint(0,lineWidth)); sl@0: aGc->SetPenSize(TSize(lineWidth,lineWidth)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth-halfLineWidth-1,aSize.iHeight-halfLineWidth-1)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/2,halfLineWidth)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(halfLineWidth,aSize.iHeight/2)); sl@0: } sl@0: sl@0: void DrawSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) sl@0: { sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); sl@0: aGc->DrawRect(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); sl@0: } sl@0: sl@0: void DrawCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) sl@0: { sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); sl@0: aGc->DrawEllipse(TRect(1,1,aSize.iWidth-1,aSize.iHeight-1)); sl@0: } sl@0: sl@0: void DrawTriangle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) sl@0: { sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); sl@0: aGc->SetPenSize(TSize(1,1)); sl@0: for(TInt y=0;yDrawLine(TPoint(aSize.iWidth-xfact-1,y),TPoint(aSize.iWidth-1,y)); sl@0: } sl@0: } sl@0: sl@0: void DrawOpenSquare(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) sl@0: { sl@0: TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; sl@0: TInt lineWidth=2*halfLineWidth+1; //Must be odd sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); sl@0: aGc->SetPenSize(TSize(lineWidth,lineWidth)); sl@0: TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); sl@0: aGc->DrawRect(TRect(aSize.iWidth/4,aSize.iHeight/4,botRig.iX+1,botRig.iY+1)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,aSize.iHeight/4-halfLineWidth)); sl@0: aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,halfLineWidth),TPoint(botRig.iX+halfLineWidth,aSize.iHeight/4-halfLineWidth)); sl@0: aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(botRig.iX+halfLineWidth,botRig.iY+halfLineWidth)); sl@0: aGc->DrawLine(TPoint(halfLineWidth,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/4-halfLineWidth,botRig.iY+halfLineWidth)); sl@0: } sl@0: sl@0: void DrawOpenCircle(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aLineWidth) sl@0: { sl@0: TInt halfLineWidth=*STATIC_CAST(TInt*,aLineWidth)/2; sl@0: TInt lineWidth=2*halfLineWidth+1; //Must be odd sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 3)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : DRAW_COLOR)); sl@0: aGc->SetPenSize(TSize(lineWidth,lineWidth)); sl@0: TPoint botRig(aSize.iWidth-aSize.iWidth/4-1,aSize.iHeight-aSize.iHeight/4-1); sl@0: aGc->DrawEllipse(TRect(aSize.iWidth/4+1,aSize.iHeight/4+1,botRig.iX+1,botRig.iY+1)); sl@0: aGc->DrawLine(TPoint(aSize.iWidth/2,1+halfLineWidth),TPoint(aSize.iWidth/2,aSize.iHeight/4+1-halfLineWidth)); sl@0: aGc->DrawLine(TPoint(aSize.iWidth/2,aSize.iHeight-1-halfLineWidth),TPoint(aSize.iWidth/2,botRig.iY+halfLineWidth)); sl@0: aGc->DrawLine(TPoint(1+halfLineWidth,aSize.iWidth/2),TPoint(aSize.iWidth/4+1-halfLineWidth,aSize.iHeight/2)); sl@0: aGc->DrawLine(TPoint(aSize.iWidth-1-halfLineWidth,aSize.iHeight/2),TPoint(botRig.iX+halfLineWidth,aSize.iWidth/2)); sl@0: } sl@0: sl@0: sl@0: /*CPointerCursorTest*/ sl@0: sl@0: GLDEF_C CTestBase *CreatePointerCursorTest() sl@0: { sl@0: return(new(ELeave) CPointerCursorTest()); sl@0: } sl@0: sl@0: CPointerCursorTest::CPointerCursorTest() : CTestBase(_L("PointerCursor")) sl@0: {} sl@0: sl@0: CPointerCursorTest::~CPointerCursorTest() sl@0: { sl@0: TInt ii; sl@0: Client()->iGroup->SetCurrentWindow(NULL); sl@0: delete iInfoWindow; sl@0: for(ii=0;ii<6;++ii) sl@0: { sl@0: delete iWindows[ii]; sl@0: } sl@0: for(ii=0;iiiScreen->SizeInPixels(); sl@0: TInt infoWidth=Min(210,5*size.iWidth/12); sl@0: size.iWidth=Max(Min(415,size.iWidth-infoWidth),85); sl@0: iInfoWindow=new(ELeave) CStatusWindow(); sl@0: iInfoWindow->SetUpL(TPoint(size.iWidth,50),TSize(infoWidth,180),Client()->iGroup,*Client()->iGc); sl@0: Client()->iGroup->SetCurrentWindow(iInfoWindow); sl@0: iInfoWindow->Construct(this); sl@0: iGroup1=new(ELeave) CPointerCursorWindowGroup(Client()); sl@0: iGroup1->ConstructL(); sl@0: iGroup2=new(ELeave) CPointerCursorWindowGroup(Client()); sl@0: iGroup2->ConstructL(); sl@0: size.iWidth-=5; sl@0: CreateWindowsL(size); sl@0: CreatePointerCursorsL(); sl@0: iGroup1->SetPointerCursor(iCursors[0]); sl@0: iWindows[1]->SetBitmap(iBitmaps[0],EFalse); sl@0: iWindows[0]->SetPointerCursor(iCursors[1]); sl@0: iWindows[0]->SetBitmap(iBitmaps[1]); sl@0: iWindows[0]->Child()->SetPointerCursor(iCursors[2]); sl@0: iWindows[0]->Child()->SetBitmap(iBitmaps[2]); sl@0: iWindows[2]->SetPointerCursor(iCursors[3]); sl@0: iWindows[2]->SetBitmap(iBitmaps[3]); sl@0: iWindows[2]->Child()->Child()->SetPointerCursor(iCursors[4]); sl@0: iWindows[2]->Child()->Child()->SetBitmap(iBitmaps[4]); sl@0: iWindows[3]->Child()->SetPointerCursor(iCursors[5]); sl@0: iWindows[3]->Child()->SetBitmap(iBitmaps[5]); sl@0: iWindows[4]->SetPointerCursor(iCursors[6]); sl@0: iWindows[4]->SetBitmap(iBitmaps[6]); sl@0: } sl@0: sl@0: void CPointerCursorTest::CreateWindowsL(TSize aArea) sl@0: { sl@0: //TSize screenSize=Client()->iScreen->SizeInPixels(); sl@0: TInt height=eWindowGap+(aArea.iHeight-5*eWindowGap)/4; sl@0: TInt halfWidth=aArea.iWidth/2; sl@0: TRect rect(5,eWindowGap,halfWidth,height); sl@0: iWindows[0]=CreateWindowL(2,rect,iGroup1); sl@0: rect.Move(halfWidth,0); sl@0: iWindows[1]=CreateWindowL(2,rect,iGroup1); sl@0: rect.Move(-halfWidth,height); sl@0: rect.iBr.iX=aArea.iWidth; sl@0: iWindows[2]=CreateWindowL(4,rect,iGroup2); sl@0: rect.Move(0,height); sl@0: rect.iBr.iX=aArea.iWidth-11; sl@0: iWindows[3]=CreateWindowL(3,rect,iGroup2); sl@0: rect.Move(0,height); sl@0: rect.iBr.iX=halfWidth; sl@0: iWindows[4]=CreateWindowL(2,rect,iGroup2); sl@0: rect.Move(halfWidth,0); sl@0: iWindows[5]=CreateWindowL(2,rect,iGroup2); sl@0: } sl@0: sl@0: CPointerCursorWindow* CPointerCursorTest::CreateWindowL(TInt aNum,TRect aLocation,CTWinBase *aGroup) sl@0: { sl@0: CPointerCursorWindow* firstWin=NULL; sl@0: CPointerCursorWindow* parent=NULL; sl@0: CPointerCursorWindow* win; sl@0: TInt xInc=aLocation.Width()/aNum-eChildWindowGap; sl@0: TInt ii; sl@0: for (ii=aNum;ii>0;ii--) sl@0: { sl@0: win=new(ELeave) CPointerCursorWindow(); sl@0: CleanupStack::PushL(win); sl@0: win->SetUpL(aLocation.iTl,aLocation.Size(),aGroup,*Client()->iGc); sl@0: if (!parent) sl@0: firstWin=win; sl@0: else sl@0: { sl@0: parent->SetChild(win); sl@0: CleanupStack::Pop(); sl@0: } sl@0: aLocation.iBr=TPoint(-eChildWindowGap,-eChildWindowGap)+aLocation.Size(); sl@0: aLocation.iTl.iX=xInc; sl@0: aLocation.iTl.iY=eChildWindowGap; sl@0: aGroup=win; sl@0: parent=win; sl@0: } sl@0: CleanupStack::Pop(); sl@0: return firstWin; sl@0: } sl@0: sl@0: void CPointerCursorTest::CreatePointerCursorsL() sl@0: { sl@0: const TSize size(32,32); sl@0: TSpriteCreateParams params(size,TPoint(-16,-16),DrawSquare); sl@0: TSpriteCreateParams paramarray[eNumPointerCursors]; sl@0: TInt lineWidth1=3; sl@0: TInt lineWidth2=5; sl@0: paramarray[2]=params; sl@0: params.iDrawFunc=DrawCircle; sl@0: paramarray[3]=params; sl@0: params.iDrawFunc=DrawOpenSquare; sl@0: params.iDrawFuncParam=&lineWidth1; sl@0: paramarray[5]=params; sl@0: params.iDrawFunc=DrawOpenCircle; sl@0: paramarray[6]=params; sl@0: params.iOffset=TPoint(0,0); sl@0: params.iDrawFunc=DrawArrow; sl@0: params.iDrawFuncParam=&lineWidth2; sl@0: paramarray[1]=params; sl@0: params.iOffset.iX=-31; sl@0: params.iDrawFunc=DrawTriangle; sl@0: paramarray[4]=params; sl@0: params.iOffset=TPoint(-15,-15); sl@0: params.iDrawFunc=DrawCross; sl@0: paramarray[0]=params; sl@0: CFbsBitmap *bitmap; sl@0: TInt ii,jj; sl@0: TDisplayMode mode=Client()->iWs.GetDefModeMaxNumColors(ii,jj); sl@0: for (ii=0;iiCreate(size,mode)); sl@0: iCursors[ii]=new(ELeave) CTPointerCursor(Client()->iWs); sl@0: iCursors[ii]->ConstructL(1,¶marray[ii],0,iBitmaps[ii],bitmap); sl@0: delete bitmap; sl@0: } sl@0: } sl@0: sl@0: TestState CPointerCursorTest::DoTestL() sl@0: { sl@0: switch(iState) sl@0: { sl@0: case 0: sl@0: LogSubTest(_L("Pointer Cursor"),1); sl@0: TestL(ETrue); sl@0: iState++; sl@0: return(EContinue); sl@0: default: sl@0: return(EFinished); sl@0: } sl@0: }