sl@0: // Copyright (c) 1994-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: // Very simple test program to connect to the window server sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "W32STD.H" sl@0: #include sl@0: #include "../SERVER/w32cmd.h" sl@0: #include "../test/tlib/testbase.h" sl@0: #include "ANIMWIN.H" sl@0: #include "HNDLODR.H" sl@0: sl@0: #define TEST_BITMAP_NAME _L("Z:\\WSTEST\\TEST.MBM") sl@0: _LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); sl@0: sl@0: // sl@0: // TestWindow class sl@0: // sl@0: sl@0: class TestClient; // Forward reference sl@0: sl@0: class TestWindow1 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow1(); sl@0: void Resized(const TSize &aNewSize); sl@0: void Draw(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &); sl@0: private: sl@0: TBool iDrawPolygon; sl@0: }; sl@0: sl@0: class TestWindow2 : public CTWin sl@0: { sl@0: enum EPointerState sl@0: { sl@0: EPointerIn, sl@0: EPointerOut, sl@0: EPointerUndefined, sl@0: }; sl@0: public: sl@0: TestWindow2(); sl@0: ~TestWindow2(); sl@0: void InitWinL(); sl@0: void Draw(); sl@0: void PointerL(const TPointerEvent &aPointer,const TTime &aTime); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void NewText(TPoint &pos,TInt &width,TDes &des); sl@0: void PointerState(EPointerState aState); sl@0: void PointerEnter(const TTime &aTime); sl@0: void PointerExit(const TTime &aTime); sl@0: void SetBufBits(); sl@0: void RequestPointerRepeat(); sl@0: private: sl@0: void SwitchOn(const TTime &aTime); sl@0: private: sl@0: TBuf<0x40> iBuf; sl@0: TBuf<0x40> iBufBits; sl@0: TBuf<0x40> iBufMem; sl@0: TPoint iPos; sl@0: TPoint iPosBits; sl@0: TPoint iPosMem; sl@0: TInt iWid; sl@0: TInt iWidBits; sl@0: TInt iWidMem; sl@0: TInt iFontHeight; sl@0: EPointerState iPointerState; sl@0: TUint32 iFilter; sl@0: TBool iCapture; sl@0: TBool iGrab; sl@0: TRgb iBackColor; sl@0: TInt iRepeatCount; sl@0: TRect iRepeatRect; sl@0: }; sl@0: sl@0: class TestWindow3 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow3(); sl@0: ~TestWindow3(); sl@0: void Draw(); sl@0: void InitWinL(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void Resized(const TSize &aNewSize); sl@0: void SetShape(TInt aShapeNum); sl@0: void ScreenDeviceChangedL(); sl@0: private: sl@0: CWsBitmap *iBitmap; sl@0: TInt iShapeNum; sl@0: TInt iCornerFlags; sl@0: TCornerType iCornerType; sl@0: }; sl@0: sl@0: class TestWindow4 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow4(); sl@0: void InitWin(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void Resized(const TSize &aSize); sl@0: void Draw(); sl@0: void Draw(TBool aSetCursor); sl@0: private: sl@0: void SetSwappedSize(); sl@0: void SetCursor(const TPoint &aPos); sl@0: private: sl@0: TBuf<300> TxtBuf; sl@0: TPoint iBasePos; sl@0: TBool iVertical; sl@0: TSize iSwappedSize; sl@0: //TInt iTemp; sl@0: }; sl@0: sl@0: class TestWindow5 : public CTBackedUpWin sl@0: { sl@0: public: sl@0: TestWindow5(TBool aGrey2); sl@0: void Draw(); sl@0: void InitWinL(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void Resized(const TSize &aNewSize); sl@0: private: sl@0: CFbsBitmap iBrushBit; sl@0: TInt iOrdPri; sl@0: }; sl@0: sl@0: class TestWindow6 : public CTBackedUpWin sl@0: { sl@0: public: sl@0: enum {KPointerMoveBufferSize=32}; sl@0: public: sl@0: TestWindow6(TBool aGrey2); sl@0: ~TestWindow6(); sl@0: void Draw(); sl@0: void InitWinL(); sl@0: void PointerL(const TPointerEvent &aPointer,const TTime &aTime); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: virtual void AssignGC(CWindowGc &aGc); sl@0: void Resized(const TSize &aNewSize); sl@0: void PointerBufferReady(const TTime &aTime); sl@0: private: sl@0: TSize iOldSize; // Needed as part of resizing after old size has been lost sl@0: TBool iDragging; sl@0: TInt iGray; sl@0: CWindowGc *iGc2; sl@0: CWindowGc *iCurGc; sl@0: }; sl@0: sl@0: class TestWindow7 : public CTBackedUpWin sl@0: { sl@0: private: sl@0: enum {EPointerModes=3}; sl@0: public: sl@0: TestWindow7(TBool aGrey2); sl@0: ~TestWindow7(); sl@0: void InitWinL(); sl@0: void Draw(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void Resized(const TSize &aNewSize); sl@0: /*private: sl@0: void createBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask); sl@0: void createBitmap2L(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask); sl@0: void InitPointerCursorL(RWsPointerCursor &aSprite, const TSize &aSize, TInt aFlags); sl@0: void InitSpriteL(RWsSprite &aSprite, const TPoint &aPos, const TSize &aSize, TTimeIntervalMicroSeconds32 aOnTime, TTimeIntervalMicroSeconds32 aOffTime, TInt aFlags);*/ sl@0: private: sl@0: CTSprite *iSprite1; sl@0: CTSprite *iSprite2; sl@0: CTSprite *iSprite3; sl@0: CTSprite *iSprite4; sl@0: CTSprite *iSprite5; sl@0: CTPointerCursor *iPointerCursor; sl@0: CFbsBitmap *iSpriteBitmap; sl@0: CFbsBitmap *iSpriteMaskBitmap; sl@0: TInt iPointerMode; sl@0: TPoint iPos1; sl@0: TPoint iPos2; sl@0: TPoint iPos3; sl@0: TPoint iPos4; sl@0: TPoint iPos5; sl@0: TPoint *iCurPos; sl@0: CTSprite *iCurSprite; sl@0: }; sl@0: sl@0: class TestWindow8 : public CTBlankWindow sl@0: { sl@0: public: sl@0: TestWindow8(); sl@0: void Draw(); sl@0: void InitWin(); sl@0: }; sl@0: sl@0: class TestWindow9 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow9(); sl@0: void Draw(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &); sl@0: void InitWinL(); sl@0: void Play(); sl@0: private: sl@0: CFbsBitmap iBitmap; sl@0: TSize iVideoSize; sl@0: }; sl@0: sl@0: class TestWindow10 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow10(); sl@0: void Draw(); sl@0: void InitWin(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &); sl@0: }; sl@0: sl@0: class TestWindow12 : public CTWin sl@0: { sl@0: public: sl@0: TestWindow12(); sl@0: void Draw(); sl@0: void InitWin(); sl@0: void WinKeyL(const TKeyEvent &aKey,const TTime &); sl@0: }; sl@0: sl@0: class TestWindowGroup : public CTWindowGroup sl@0: { sl@0: public: sl@0: TestWindowGroup(CTClient *aClient); sl@0: virtual void ConstructL(); sl@0: virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime); sl@0: void ScreenDeviceChanged(); sl@0: void RunLaunchAndShootTestL(); sl@0: void MillionsOfSessions(); sl@0: inline void SetHandWriting(CHandWriting* aHand) {iHand=aHand;} sl@0: private: sl@0: CHandWriting* iHand; sl@0: TBool iIncludeChildren; sl@0: }; sl@0: sl@0: class TestClient : public CTClient sl@0: { sl@0: public: sl@0: TestClient(); sl@0: ~TestClient(); sl@0: void ConstructL(); sl@0: TInt EventLoop(); sl@0: void Exit(); sl@0: void SetCurrentWindow(CTWinBase *aWindow); sl@0: CTBaseWin *CreateTestWindowL(TInt type,TPoint pos,TSize size,CTWinBase *parent,CWindowGc &gc,TBool aAlternate=EFalse); sl@0: void AdjustLightSource(TInt aX,TInt aY); sl@0: private: sl@0: inline TestWindowGroup* TestWindow() {return STATIC_CAST(TestWindowGroup*,iGroup);} sl@0: private: sl@0: CHandWriting *iHandWriting; sl@0: TPoint ShadowOffset; sl@0: }; sl@0: sl@0: //const TInt Xmove=8; sl@0: //const TInt Ymove=6; sl@0: const TInt Xmove=1; sl@0: const TInt Ymove=1; sl@0: sl@0: LOCAL_D const TUint KTestThreadHeapSize=0x10000; sl@0: sl@0: enum TConnectPanic sl@0: { sl@0: EConnectPanicRedrawToBackedUpWindow, sl@0: EConnectPanicRequiredDisplayMode, sl@0: EConnectPanicDragEvent, sl@0: }; sl@0: sl@0: TInt RunLaunchAndShootTest(TAny *); sl@0: sl@0: void Panic(TInt aPanic) sl@0: { sl@0: User::Panic(_L("CONNECT"),aPanic); sl@0: } sl@0: sl@0: // sl@0: // Individual window sub-classes sl@0: // sl@0: sl@0: TestWindow1::TestWindow1() : CTWin() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow1")); sl@0: } sl@0: sl@0: void TestWindow1::Draw() sl@0: //This function is virtual and so cannot have an 'L' at the end of it's name sl@0: { sl@0: TInt i; sl@0: sl@0: iGc->SetBrushColor(TRgb::Gray16(14)); sl@0: iGc->Clear(); sl@0: iGc->SetPenColor(TRgb::Gray16(8)); sl@0: iGc->SetBrushColor(TRgb::Gray16(0)); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: CArrayFixFlat *pnts; sl@0: pnts=new(ELeave) CArrayFixFlat(20); sl@0: TPoint mid(iSize.iWidth>>1,iSize.iHeight>>1); sl@0: for(i=0;iAppendL(TPoint(mid.iX-i,mid.iY-i)); sl@0: pnts->AppendL(TPoint(mid.iX+i+1,mid.iY-i-1)); sl@0: pnts->AppendL(TPoint(mid.iX+i+2,mid.iY+i+2)); sl@0: pnts->AppendL(TPoint(mid.iX-i-3,mid.iY+i+3)); sl@0: } sl@0: if (iDrawPolygon) sl@0: iGc->DrawPolygon(pnts,CGraphicsContext::EAlternate); sl@0: else sl@0: iGc->DrawPolyLine(pnts); sl@0: delete pnts; sl@0: // sl@0: TPoint polygon[8]; sl@0: polygon[0]=TPoint(mid.iX-8,mid.iY-16); sl@0: polygon[1]=TPoint(mid.iX+8,mid.iY-16); sl@0: polygon[2]=TPoint(mid.iX+16,mid.iY-8); sl@0: polygon[3]=TPoint(mid.iX+16,mid.iY+8); sl@0: polygon[4]=TPoint(mid.iX+8,mid.iY+16); sl@0: polygon[5]=TPoint(mid.iX-8,mid.iY+16); sl@0: polygon[6]=TPoint(mid.iX-16,mid.iY+8); sl@0: polygon[7]=TPoint(mid.iX-16,mid.iY-8); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->DrawPolygon(&polygon[0],sizeof(polygon)/sizeof(polygon[0])); sl@0: } sl@0: sl@0: void TestWindow1::Resized(const TSize &aNewSize) sl@0: { sl@0: iWin.Invalidate(); sl@0: CTBaseWin::Resized(aNewSize); sl@0: } sl@0: sl@0: /*void AFunction(TDesC& des) sl@0: { sl@0: TDesC *abc=&des; sl@0: TInt a=3+4; sl@0: } sl@0: sl@0: void AFunction2(TDes& des) sl@0: { sl@0: TDes *abc=&des; sl@0: TInt a=3+4; sl@0: }*/ sl@0: sl@0: void TestWindow1::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: if (aKey.iCode=='p') sl@0: { sl@0: RWindow win1(Client()->iWs); sl@0: win1.Construct(iWin,1); sl@0: RWindow win2(Client()->iWs); sl@0: win2.Construct(win1,1); sl@0: win1.Close(); sl@0: win2.SetExtent(TPoint(1,2),TSize(3,4)); sl@0: Client()->iWs.Flush(); sl@0: } sl@0: else if (aKey.iCode=='q' || aKey.iCode=='Q') sl@0: { sl@0: RWindowGroup group1(Client()->iWs); sl@0: RWindowGroup group2(Client()->iWs); sl@0: group1.Construct(1); sl@0: group2.Construct(2); sl@0: group1.DefaultOwningWindow(); sl@0: group2.DefaultOwningWindow(); sl@0: group1.DefaultOwningWindow(); sl@0: group1.Close(); sl@0: group2.Close(); sl@0: Client()->iWs.Flush(); sl@0: } sl@0: else if (aKey.iCode=='w' || aKey.iCode=='W') sl@0: { sl@0: RWindowGroup group1(Client()->iWs); sl@0: RWindowGroup group2(Client()->iWs); sl@0: group1.Construct(1); sl@0: group2.Construct(2); sl@0: group1.DefaultOwningWindow(); sl@0: group2.DefaultOwningWindow(); sl@0: group1.DefaultOwningWindow(); sl@0: group2.Close(); sl@0: group1.Close(); sl@0: Client()->iWs.Flush(); sl@0: } sl@0: else if (aKey.iCode=='A' || aKey.iCode=='a') sl@0: { sl@0: /*RWindowGroup group(Client()->iWs); sl@0: group.Construct(1);*/ sl@0: RDrawableWindow* win=new(ELeave) RBackedUpWindow(Client()->iWs); sl@0: User::LeaveIfError(((RBackedUpWindow*)win)->Construct(*Client()->iGroup->GroupWin(),EGray2,(TUint32)this)); sl@0: User::LeaveIfError(win->SetExtentErr(TPoint(20,20),TSize(600,200))); sl@0: win->Activate(); sl@0: } sl@0: else if (aKey.iCode=='B' || aKey.iCode=='b') sl@0: { sl@0: RWindowGroup group(Client()->iWs); sl@0: group.Construct(344); sl@0: //group.EnableReceiptOfFocus(EFalse); sl@0: RBlankWindow blank(Client()->iWs); sl@0: blank.Construct(group,345); sl@0: blank.SetOrdinalPosition(0,1000); sl@0: //blank.SetShadowHeight(0); sl@0: //blank.SetShadowDisabled(ETrue); sl@0: blank.Activate(); sl@0: RWindow window(Client()->iWs); sl@0: window.Construct(group,346); sl@0: } sl@0: /*else if (aKey.iCode=='Z' || aKey.iCode=='z') //TDes8 TPtr8 TPtrC8 TBufCBase8 TBuf8 sl@0: { sl@0: TBuf<4> buf2(_L("1234")); sl@0: TBuf<4> buf(_L("abcd")); sl@0: TBufC<4> bufC(_L("WXYZ")); sl@0: HBufC *hbuf=HBufC::NewL(4); sl@0: TPtr pHBuf=hbuf->Des(); sl@0: pHBuf=buf2; sl@0: TPtr ptr(hbuf->Des()); sl@0: //AFunction(ptr); sl@0: TPtrC ptrC1(buf); sl@0: //AFunction(ptrC1); sl@0: TPtrC ptrC2(bufC); sl@0: //AFunction(ptrC2); sl@0: TPtrC ptrC3(hbuf->Des()); sl@0: AFunction(ptrC3); sl@0: AFunction(buf); sl@0: AFunction(bufC); sl@0: AFunction(*hbuf); sl@0: AFunction2(ptr); sl@0: AFunction2(buf); sl@0: }*/ sl@0: if (aKey.iCode==' ') sl@0: { sl@0: iDrawPolygon=!iDrawPolygon; sl@0: iWin.Invalidate(); sl@0: } sl@0: } sl@0: sl@0: TestWindow2::TestWindow2() : CTWin(), sl@0: iWid(0), iFontHeight(16), iPointerState(EPointerOut), iFilter(0), iCapture(EFalse), iGrab(EFalse) sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow2")); sl@0: } sl@0: sl@0: TestWindow2::~TestWindow2() sl@0: { sl@0: } sl@0: sl@0: void TestWindow2::InitWinL() sl@0: { sl@0: iPos.SetXY(40,iFont->AscentInPixels()+10); sl@0: TPoint next(0,iFont->HeightInPixels()+10); sl@0: iPosBits=iPos+next; sl@0: iPosMem=iPosBits+next; sl@0: iWin.PointerFilter(0xFFFFFFFF,iFilter); sl@0: User::LeaveIfError(iWin.EnableOnEvents()); sl@0: iWin.ClaimPointerGrab(); sl@0: } sl@0: sl@0: void TestWindow2::Draw() sl@0: { sl@0: TInt pen=0; sl@0: switch(iPointerState) sl@0: { sl@0: case EPointerIn: sl@0: pen=0; sl@0: break; sl@0: case EPointerOut: sl@0: pen=5; sl@0: break; sl@0: case EPointerUndefined: sl@0: pen=15; sl@0: break; sl@0: } sl@0: iGc->SetPenColor(TRgb::Gray16(pen)); sl@0: iGc->SetBrushColor(iBackColor); sl@0: DrawBorder(); sl@0: iGc->DrawText(iBuf,iPos); sl@0: iGc->DrawText(iBufBits,iPosBits); sl@0: iGc->DrawText(iBufMem,iPosMem); sl@0: } sl@0: sl@0: void TestWindow2::NewText(TPoint &pos,TInt &width,TDes &des) sl@0: { sl@0: TInt newWid=iFont->TextWidthInPixels(des); sl@0: Invalidate(TRect(pos-TSize(0,iFont->AscentInPixels()),pos+TSize(Max(width,newWid),iFont->DescentInPixels()))); sl@0: width=newWid; sl@0: } sl@0: sl@0: void TestWindow2::PointerState(EPointerState aState) sl@0: { sl@0: switch(aState) sl@0: { sl@0: case EPointerIn: sl@0: iBackColor=TRgb::Gray16(15); sl@0: break; sl@0: case EPointerOut: sl@0: iBackColor=TRgb::Gray16(12); sl@0: break; sl@0: case EPointerUndefined: sl@0: iBackColor=TRgb::Gray16(4); sl@0: break; sl@0: } sl@0: iWin.SetBackgroundColor(iBackColor); sl@0: Invalidate(); sl@0: iPointerState=aState; sl@0: } sl@0: sl@0: void TestWindow2::SwitchOn(const TTime &) sl@0: { sl@0: iWin.SetBackgroundColor(TRgb(0,0,0)); sl@0: Client()->iWs.Flush(); sl@0: User::After(TTimeIntervalMicroSeconds32(500000)); sl@0: PointerState(iPointerState); sl@0: } sl@0: sl@0: void TestWindow2::PointerEnter(const TTime &) sl@0: { sl@0: PointerState(EPointerIn); sl@0: } sl@0: sl@0: void TestWindow2::PointerExit(const TTime &) sl@0: { sl@0: PointerState(EPointerOut); sl@0: } sl@0: sl@0: void TestWindow2::RequestPointerRepeat() sl@0: { sl@0: iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(200000),iRepeatRect); sl@0: } sl@0: sl@0: void TestWindow2::PointerL(const TPointerEvent &pointer,const TTime &aTime) sl@0: { sl@0: if (pointer.iType==TPointerEvent::EButtonRepeat) sl@0: { sl@0: iRepeatCount++; sl@0: SetBufBits(); sl@0: RequestPointerRepeat(); sl@0: } sl@0: else sl@0: { sl@0: iRepeatCount=0; sl@0: CTWin::PointerL(pointer,aTime); sl@0: iBuf.Format(TRefByValue(_L("Pos(%d,%d)(%d,%d), 0x%x")),pointer.iPosition.iX,pointer.iPosition.iY,pointer.iParentPosition.iX,pointer.iParentPosition.iY,pointer.iModifiers); sl@0: NewText(iPos,iWid,iBuf); sl@0: if (pointer.iType==TPointerEvent::EButton1Down) sl@0: { sl@0: iRepeatRect=TRect(pointer.iPosition-TPoint(5,5),pointer.iPosition+TPoint(5,5)); sl@0: RequestPointerRepeat(); sl@0: } sl@0: SetBufBits(); sl@0: } sl@0: } sl@0: sl@0: void TestWindow2::SetBufBits() sl@0: { sl@0: iBufBits.Format(TRefByValue(_L("Filter=0x%x, Capture[%s], Grab[%s], Repeat[%d]")),iFilter, sl@0: iCapture ? _S("On") : _S("Off"), sl@0: iGrab ? _S("On") : _S("Off"), sl@0: iRepeatCount); sl@0: NewText(iPosBits,iWidBits,iBufBits); sl@0: Invalidate(); sl@0: } sl@0: sl@0: void TestWindow2::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case ',': // Unshifted < sl@0: case '.': // Unshifted > sl@0: { sl@0: if (aKey.iCode==',') sl@0: { sl@0: if (iFontHeight>1) sl@0: iFontHeight-=1; sl@0: } sl@0: else sl@0: iFontHeight+=1; sl@0: CFbsFont *newFont; sl@0: TFontSpec fspec(KTestFontTypefaceName,iFontHeight*KTwipsPerPoint); sl@0: User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)newFont, fspec)); sl@0: sl@0: Client()->iScreen->ReleaseFont(iFont); sl@0: iFont=newFont; sl@0: iWid=iFont->TextWidthInPixels(iBuf); sl@0: Invalidate(); sl@0: } sl@0: break; sl@0: case '?': sl@0: iBufMem.Format(TRefByValue(_L("Count=%d")),Client()->iWs.HeapCount()); sl@0: NewText(iPosMem,iWidMem,iBufMem); sl@0: break; sl@0: case 'c': sl@0: iCapture=(TBool)!iCapture; sl@0: iWin.SetPointerCapture(iCapture); sl@0: SetBufBits(); sl@0: break; sl@0: case 'g': sl@0: iGrab=(TBool)!iGrab; sl@0: iWin.SetPointerGrab(iGrab); sl@0: SetBufBits(); sl@0: break; sl@0: case ' ': sl@0: { sl@0: iFilter=(iFilter+1)%8; sl@0: iWin.PointerFilter(0xFFFFFFFF,iFilter); sl@0: SetBufBits(); sl@0: if (iFilter&EPointerFilterEnterExit) sl@0: PointerState(EPointerUndefined); sl@0: else sl@0: PointerState(EPointerOut); sl@0: } sl@0: case 's': sl@0: case 'S': sl@0: { sl@0: CWsBitmap* bitmap=new(ELeave) CWsBitmap(Client()->iWs); sl@0: CleanupStack::PushL(bitmap); sl@0: User::LeaveIfError(bitmap->Create(Client()->iScreen->SizeInPixels(),EGray4)); sl@0: User::LeaveIfError(Client()->iScreen->CopyScreenToBitmap(bitmap)); sl@0: CleanupStack::Pop(); sl@0: } sl@0: break; sl@0: default: sl@0: iBufMem.Format(TRefByValue(_L("Key=%d")),aKey.iCode); sl@0: NewText(iPosMem,iWidMem,iBufMem); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TestWindow3::TestWindow3() : CTWin() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow3")); sl@0: } sl@0: sl@0: TestWindow3::~TestWindow3() sl@0: { sl@0: delete iBitmap; sl@0: } sl@0: sl@0: void TestWindow3::Resized(const TSize &aNewSize) sl@0: { sl@0: CTBaseWin::Resized(aNewSize); sl@0: SetShape(iShapeNum); sl@0: DrawNow(); sl@0: } sl@0: sl@0: void TestWindow3::InitWinL() sl@0: { sl@0: iCornerType=EWindowCorner3; sl@0: iWin.PointerFilter(EPointerFilterDrag,0); // Clear drag filter sl@0: iWin.SetPointerGrab(ETrue); sl@0: iWin.SetBackgroundColor(TRgb::Gray256(230)); sl@0: iWin.SetCornerType(iCornerType); sl@0: iBitmap=new(ELeave) CWsBitmap(Client()->iWs); sl@0: User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME,0)); sl@0: iSize=iBitmap->SizeInPixels(); sl@0: } sl@0: sl@0: void TestWindow3::Draw() sl@0: { sl@0: iGc->BitBlt(TPoint(0,0),iBitmap); sl@0: TSize bitSize(iBitmap->SizeInPixels()); sl@0: TSize winSize(Size()); sl@0: iGc->Clear(TRect(bitSize.iWidth,0,winSize.iWidth,bitSize.iHeight)); sl@0: iGc->Clear(TRect(0,bitSize.iHeight,winSize.iWidth,winSize.iHeight)); sl@0: } sl@0: sl@0: void TestWindow3::SetShape(TInt aShapeNum) sl@0: { sl@0: iShapeNum=aShapeNum; sl@0: TSize size=Size(); sl@0: switch(iShapeNum) sl@0: { sl@0: case 0: sl@0: { sl@0: TRegionFix<4> shape; sl@0: shape.AddRect(TRect(0,0,size.iWidth,size.iHeight>>2)); sl@0: shape.AddRect(TRect(0,size.iHeight>>2,size.iWidth>>2,size.iHeight-(size.iHeight>>2))); sl@0: shape.AddRect(TRect(size.iWidth-(size.iWidth>>2),size.iHeight>>2,size.iWidth,size.iHeight-(size.iHeight>>2))); sl@0: shape.AddRect(TRect(0,size.iHeight-(size.iHeight>>2),size.iWidth,size.iHeight)); sl@0: iWin.SetShape(shape); sl@0: } sl@0: break; sl@0: case 1: sl@0: { sl@0: TRegionFix<3> shape; sl@0: shape.AddRect(TRect(size.iWidth>>2,0,size.iWidth-(size.iWidth>>2),size.iHeight>>2)); sl@0: shape.AddRect(TRect(0,size.iHeight>>2,size.iWidth,size.iHeight-(size.iHeight>>2))); sl@0: shape.AddRect(TRect(size.iWidth>>2,size.iHeight-(size.iHeight>>2),size.iWidth-(size.iWidth>>2),size.iHeight)); sl@0: iWin.SetShape(shape); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: RRegion shape; sl@0: for(TInt index=0;index<(size.iHeight-1);index++) sl@0: { sl@0: TInt xFactor=(size.iWidth>>1)*index/size.iHeight; sl@0: shape.AddRect(TRect((size.iWidth>>1)-xFactor,index,(size.iWidth>>1)+xFactor,index+1)); sl@0: } sl@0: iWin.SetShape(shape); sl@0: shape.Close(); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void TestWindow3::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: if (aKey.iCode=='f') sl@0: { sl@0: TSize scrSize(Client()->iScreen->SizeInPixels()); sl@0: if (scrSize==iWin.Size()) sl@0: { sl@0: scrSize.iWidth/=2; sl@0: scrSize.iHeight/=2; sl@0: } sl@0: SetExtL(TPoint(),scrSize); sl@0: } sl@0: else if (aKey.iCode>='0' && aKey.iCode<='5') sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case '0': sl@0: iCornerType=EWindowCornerSquare; sl@0: break; sl@0: case '1': sl@0: iCornerType=EWindowCorner1; sl@0: break; sl@0: case '2': sl@0: iCornerType=EWindowCorner2; sl@0: break; sl@0: case '3': sl@0: iCornerType=EWindowCorner3; sl@0: break; sl@0: case '5': sl@0: iCornerType=EWindowCorner5; sl@0: break; sl@0: } sl@0: iWin.SetCornerType(iCornerType,iCornerFlags); sl@0: } sl@0: else switch(User::LowerCase(aKey.iCode)) sl@0: { sl@0: case '6': sl@0: SetShape(0); sl@0: break; sl@0: case '7': sl@0: SetShape(1); sl@0: break; sl@0: case '8': sl@0: SetShape(2); sl@0: break; sl@0: case 'a': sl@0: iCornerFlags^=EWindowCornerNotTL; sl@0: goto setcorner; sl@0: case 'b': sl@0: iCornerFlags^=EWindowCornerNotTR; sl@0: goto setcorner; sl@0: case 'c': sl@0: iCornerFlags^=EWindowCornerNotBL; sl@0: goto setcorner; sl@0: case 'd': sl@0: iCornerFlags^=EWindowCornerNotBR; sl@0: setcorner: iWin.SetCornerType(iCornerType,iCornerFlags); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void TestWindow3::ScreenDeviceChangedL() sl@0: { sl@0: TSize scrSize(Client()->iScreen->SizeInPixels()); sl@0: if (scrSize==iWin.Size()) sl@0: { sl@0: scrSize.iWidth/=2; sl@0: scrSize.iHeight/=2; sl@0: } sl@0: SetExtL(TPoint(),scrSize); sl@0: } sl@0: sl@0: TestWindow4::TestWindow4() : CTWin() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow4")); sl@0: } sl@0: sl@0: void TestWindow4::SetSwappedSize() sl@0: { sl@0: if (iVertical) sl@0: { sl@0: iSwappedSize.iHeight=iSize.iWidth; sl@0: iSwappedSize.iWidth=iSize.iHeight; sl@0: } sl@0: else sl@0: iSwappedSize=iSize; sl@0: } sl@0: sl@0: void TestWindow4::InitWin() sl@0: { sl@0: iBasePos.SetXY(10,20); sl@0: iWin.SetBackgroundColor(); sl@0: SetSwappedSize(); sl@0: //iTemp=1; sl@0: } sl@0: sl@0: void TestWindow4::Resized(const TSize &aSize) sl@0: { sl@0: CTBaseWin::Resized(aSize); sl@0: SetSwappedSize(); sl@0: Invalidate(); sl@0: iWin.BeginRedraw(); sl@0: iGc->Activate(iWin); sl@0: iGc->UseFont((CFont *)iFont); sl@0: Draw(ETrue); sl@0: iGc->Deactivate(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: void TestWindow4::Draw() sl@0: { sl@0: Draw(EFalse); sl@0: } sl@0: sl@0: void TestWindow4::Draw(TBool aSetCursor) sl@0: { sl@0: TPoint tl(iBasePos.iX,iBasePos.iY-iFont->AscentInPixels()); sl@0: TRect rect(1,1,iSize.iWidth-1,iSize.iHeight); sl@0: // sl@0: /*switch (iTemp) sl@0: { sl@0: case 1: sl@0: iGc->SetBrushColor(TRgb::Gray4(2)); sl@0: break; sl@0: case 2:*/ sl@0: iGc->SetBrushColor(TRgb::Gray16(13)); sl@0: /*break; sl@0: case 3: sl@0: iGc->SetBrushColor(TRgb::Gray16(12)); sl@0: break; sl@0: case 4: sl@0: iGc->SetBrushColor(TRgb::Gray16(11)); sl@0: default: sl@0: break; sl@0: }*/ sl@0: iGc->Clear(rect); sl@0: // sl@0: TPoint pos(iBasePos); sl@0: iGc->SetPenColor(TRgb::Gray16(0)); sl@0: iGc->DrawRect(TRect(iSize)); sl@0: TInt index=0; sl@0: TInt ToGo=TxtBuf.Length(); sl@0: TInt lineHeight=iFont->HeightInPixels()+2; sl@0: rect.iTl.iY=rect.iBr.iY=tl.iY; sl@0: while((pos.iY+iFont->DescentInPixels())<(iSwappedSize.iHeight-1)) sl@0: { sl@0: rect.iBr.iY+=lineHeight; sl@0: iGc->Clear(rect); sl@0: if (ToGo>0) sl@0: { sl@0: TInt len=iFont->TextCount(TxtBuf.Right(ToGo),iSwappedSize.iWidth-2*pos.iX); sl@0: if (len==0) sl@0: len=1; sl@0: if (iVertical) sl@0: iGc->DrawTextVertical(TxtBuf.Mid(index,len),TPoint(pos.iY,iSize.iHeight-pos.iX),ETrue); sl@0: else sl@0: iGc->DrawText(TxtBuf.Mid(index,len),pos); sl@0: ToGo-=len; sl@0: if (ToGo==0 && aSetCursor) sl@0: { sl@0: TPoint cursorPos; sl@0: if (iVertical) sl@0: cursorPos=TPoint(pos.iY-iFont->AscentInPixels(),iSize.iHeight-pos.iX)+TPoint(0,iFont->TextWidthInPixels(TxtBuf.Mid(index,len))); sl@0: else sl@0: cursorPos=pos+TPoint(iFont->TextWidthInPixels(TxtBuf.Mid(index,len)),0); sl@0: SetCursor(cursorPos); sl@0: } sl@0: index+=len; sl@0: } sl@0: pos.iY+=lineHeight; sl@0: rect.iTl.iY=rect.iBr.iY; sl@0: } sl@0: rect.iBr.iY=iSwappedSize.iHeight-1; sl@0: iGc->Clear(rect); sl@0: } sl@0: sl@0: void TestWindow4::SetCursor(const TPoint &aPos) sl@0: { sl@0: TTextCursor cursor; sl@0: cursor.iType=TTextCursor::ETypeRectangle; sl@0: if (iVertical) sl@0: { sl@0: cursor.iAscent=2; sl@0: cursor.iHeight=2; sl@0: cursor.iWidth=iFont->HeightInPixels(); sl@0: } sl@0: else sl@0: { sl@0: cursor.iAscent=iFont->AscentInPixels(); sl@0: cursor.iHeight=iFont->HeightInPixels(); sl@0: cursor.iWidth=20; sl@0: } sl@0: cursor.iFlags=0; sl@0: // cursor.iColor=TRgb(255,255,255); sl@0: cursor.iColor=TRgb(128,128,128); sl@0: Client()->iGroup->GroupWin()->SetTextCursor(iWin, aPos, cursor); sl@0: } sl@0: sl@0: void TestWindow4::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: TChar chr=aKey.iCode; sl@0: sl@0: if (aKey.iCode==32 && aKey.iModifiers&EModifierFunc) sl@0: { sl@0: iWin.Invalidate(); sl@0: iVertical=!iVertical; sl@0: SetSwappedSize(); sl@0: } sl@0: else if (aKey.iCode>=32 && aKey.iCode<4000) sl@0: { sl@0: TBool invalidate=EFalse; sl@0: if (TxtBuf.Length()==TxtBuf.MaxLength()) sl@0: { sl@0: TxtBuf=TxtBuf.Right(TxtBuf.Length()-1); sl@0: invalidate=ETrue; sl@0: } sl@0: TxtBuf.Append(chr); sl@0: sl@0: TPoint pos(iBasePos); sl@0: TInt index=0; sl@0: TInt ToGo=TxtBuf.Length(); sl@0: while(ToGo>0) sl@0: { sl@0: TInt len=iFont->TextCount(TxtBuf.Right(ToGo),iSwappedSize.iWidth-2*pos.iX); sl@0: if (len==0) sl@0: len=1; sl@0: if (len==ToGo) sl@0: break; sl@0: index+=len; sl@0: ToGo-=len; sl@0: pos.iY+=iFont->HeightInPixels()+2; sl@0: } sl@0: pos.iX+=iFont->TextWidthInPixels(TxtBuf.Mid(index,ToGo-1)); sl@0: if (invalidate) sl@0: iWin.Invalidate(TRect(iBasePos.iX,iBasePos.iY-iFont->AscentInPixels(),iSize.iWidth-iBasePos.iX,iSize.iHeight)); sl@0: else sl@0: { sl@0: iGc->Activate(iWin); sl@0: iGc->UseFont(iFont); sl@0: if (iVertical) sl@0: iGc->DrawTextVertical(TxtBuf.Mid(index+ToGo-1,1),TPoint(pos.iY,iSize.iHeight-pos.iX),ETrue); sl@0: else sl@0: iGc->DrawText(TxtBuf.Mid(index+ToGo-1,1),pos); sl@0: iGc->Deactivate(); sl@0: } sl@0: pos.iX+=iFont->TextWidthInPixels(TxtBuf.Mid(index+ToGo-1)); sl@0: SetCursor(iVertical ? TPoint(pos.iY-iFont->AscentInPixels(),iSize.iHeight-pos.iX) : pos); sl@0: } sl@0: } sl@0: sl@0: TestWindow5::TestWindow5(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray4) sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow5")); sl@0: } sl@0: sl@0: void TestWindow5::Resized(const TSize &aNewSize) sl@0: { sl@0: CTBaseWin::Resized(aNewSize); sl@0: iGc->Activate(*DrawableWin()); sl@0: iGc->SetBrushColor(TRgb::Gray256(128)); sl@0: iGc->Clear(TRect(aNewSize)); sl@0: iGc->UseBrushPattern(&iBrushBit); sl@0: iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); sl@0: iGc->DrawEllipse(TRect(aNewSize)); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: void TestWindow5::InitWinL() sl@0: { sl@0: iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit); sl@0: iWin.SetPointerGrab(ETrue); sl@0: iOrdPri=-1; sl@0: iWin.SetOrdinalPosition(0,iOrdPri); sl@0: User::LeaveIfError(iBrushBit.Load(TEST_BITMAP_NAME,0)); sl@0: } sl@0: sl@0: void TestWindow5::Draw() sl@0: { sl@0: Panic(EConnectPanicRedrawToBackedUpWindow); sl@0: } sl@0: sl@0: void TestWindow5::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case ' ': sl@0: iOrdPri=(iOrdPri<0)?1:-1; sl@0: iWin.SetOrdinalPosition(0,iOrdPri); sl@0: break; sl@0: case 'z': sl@0: SetPos(iPos-TPoint(2,1)); sl@0: SetPos(iPos-TPoint(-1,-1)); sl@0: SetPos(iPos-TPoint(2,3)); sl@0: SetPos(iPos-TPoint(-2,-1)); sl@0: SetPos(iPos-TPoint(-2,-3)); sl@0: SetPos(iPos-TPoint(1,1)); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TestWindow6::TestWindow6(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray16), iGray(0) sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow6")); sl@0: } sl@0: sl@0: TestWindow6::~TestWindow6() sl@0: { sl@0: delete iGc; sl@0: delete iGc2; sl@0: } sl@0: sl@0: void TestWindow6::Resized(const TSize &aNewSize) sl@0: { sl@0: CTBaseWin::Resized(aNewSize); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: if (iOldSize.iWidthDrawRect(TRect(iOldSize.iWidth,0,aNewSize.iWidth,iOldSize.iHeight)); sl@0: if (iOldSize.iHeightDrawRect(TRect(0,iOldSize.iHeight,aNewSize.iWidth,aNewSize.iHeight)); sl@0: iGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: iGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: iOldSize=aNewSize; sl@0: TPoint pos; sl@0: for(TInt index=0;index<3;index++) sl@0: { sl@0: pos.iY=index*aNewSize.iHeight/3; sl@0: for(pos.iX=0;pos.iXSetPenColor(rgb); sl@0: iGc->DrawLine(pos,pos+TSize(0,aNewSize.iHeight/3)); sl@0: } sl@0: } sl@0: iGc->SetPenColor(TRgb(255,255,255)); sl@0: } sl@0: sl@0: void TestWindow6::InitWinL() sl@0: { sl@0: iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit); sl@0: User::LeaveIfError(iWin.AllocPointerMoveBuffer(KPointerMoveBufferSize,0)); sl@0: iWin.DisablePointerMoveBuffer(); sl@0: iWin.SetPointerGrab(ETrue); sl@0: iGc=new(ELeave) CWindowGc(Client()->iScreen); sl@0: User::LeaveIfError(iGc->Construct()); sl@0: iGc2=new(ELeave) CWindowGc(Client()->iScreen); sl@0: User::LeaveIfError(iGc2->Construct()); sl@0: iWin.SetCornerType(EWindowCorner1); sl@0: iGc->Activate(iWin); sl@0: iGc->SetBrushColor(TRgb::Gray256(230)); sl@0: iGc2->Activate(iWin); sl@0: iGc2->SetBrushColor(TRgb::Gray256(230)); sl@0: iCurGc=iGc; sl@0: } sl@0: sl@0: void TestWindow6::Draw() sl@0: { sl@0: Panic(EConnectPanicRedrawToBackedUpWindow); sl@0: } sl@0: sl@0: void TestWindow6::PointerBufferReady(const TTime &) sl@0: { sl@0: TPoint pnts[KPointerMoveBufferSize]; sl@0: TPtr8 ptr((TUint8 *)&pnts,sizeof(pnts)); sl@0: TInt numPnts=iWin.RetrievePointerMoveBuffer(ptr); sl@0: for(TInt index=0;indexDrawLineTo(pnts[index]); sl@0: } sl@0: sl@0: void TestWindow6::PointerL(const TPointerEvent &pointer,const TTime &aTime) sl@0: { sl@0: switch(pointer.iType) sl@0: { sl@0: case TPointerEvent::EButton1Down: sl@0: if (pointer.iModifiers&(EModifierCtrl|EModifierShift)) sl@0: { sl@0: iDragging=ETrue; sl@0: iWin.EnablePointerMoveBuffer(); sl@0: if (pointer.iModifiers&EModifierCtrl) sl@0: iCurGc=iGc; sl@0: else if (pointer.iModifiers&EModifierShift) sl@0: iCurGc=iGc2; sl@0: iCurGc->MoveTo(pointer.iPosition); sl@0: return; sl@0: } sl@0: break; sl@0: case TPointerEvent::EButton1Up: sl@0: if (iDragging) sl@0: { sl@0: iDragging=EFalse; sl@0: iWin.DisablePointerMoveBuffer(); sl@0: return; sl@0: } sl@0: default:; sl@0: } sl@0: CTBackedUpWin::PointerL(pointer,aTime); sl@0: } sl@0: sl@0: void TestWindow6::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: if (TChar(aKey.iCode).IsDigit()) sl@0: { sl@0: TInt wid=1; sl@0: for(TUint i=0;i<(aKey.iCode-'0');i++) sl@0: wid+=i; sl@0: iCurGc->SetPenSize(TSize(wid,wid)); sl@0: } sl@0: else switch(aKey.iCode) sl@0: { sl@0: case ',': // Unshifted < sl@0: case '.': // Unshifted > sl@0: { sl@0: if (aKey.iCode==',') sl@0: { sl@0: if (iGray>0) sl@0: iGray-=1; sl@0: } sl@0: else if (iGray<15) sl@0: iGray+=1; sl@0: iCurGc->SetPenColor(TRgb::Gray16(iGray)); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void TestWindow6::AssignGC(CWindowGc &) sl@0: { sl@0: } sl@0: sl@0: TestWindow7::TestWindow7(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray4) sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow1")); sl@0: } sl@0: sl@0: TestWindow7::~TestWindow7() sl@0: { sl@0: delete iSpriteBitmap; sl@0: delete iSpriteMaskBitmap; sl@0: delete iPointerCursor; sl@0: delete iSprite4; sl@0: delete iSprite5; sl@0: delete iSprite2; sl@0: delete iSprite3; sl@0: delete iSprite1; sl@0: } sl@0: sl@0: void DrawPointerCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aMode) sl@0: { sl@0: TInt mode=*(TInt *)aMode; sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(aSize)); sl@0: TInt size=mode+1; sl@0: TRect rect1(0,aSize.iHeight/2-size,aSize.iWidth,aSize.iHeight/2+size); sl@0: TRect rect2(aSize.iWidth/2-size,0,aSize.iWidth/2+size,aSize.iHeight); sl@0: // sl@0: if (!aDoMask) sl@0: { sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb::Gray4(0)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: aGc->DrawRect(rect1); sl@0: aGc->DrawRect(rect2); sl@0: rect1.Shrink(1,1); sl@0: rect2.Shrink(1,1); sl@0: } sl@0: // sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->DrawRect(rect1); sl@0: aGc->DrawRect(rect2); sl@0: } sl@0: sl@0: void DrawSprite(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *) sl@0: { sl@0: aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2)); 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->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1)); sl@0: aGc->DrawEllipse(TRect(aSize)); sl@0: } sl@0: sl@0: void TestWindow7::InitWinL() sl@0: { sl@0: iPos1.SetXY(30,10); sl@0: iPos2.SetXY(50,40); sl@0: iPos3.SetXY(10,50); sl@0: iPos4.SetXY(10,10); sl@0: iPos5.SetXY(50,10); sl@0: // sl@0: TSpriteCreateParams params(TSize(30,70),TPoint(0,0),DrawSprite); sl@0: TSpriteCreateParams paramarray[10]; sl@0: params.iInterval=TTimeIntervalMicroSeconds32(200000); sl@0: sl@0: paramarray[0]=params; sl@0: paramarray[1]=params; sl@0: paramarray[2]=params; sl@0: paramarray[1].iSize=TSize(20,30); sl@0: paramarray[2].iSize=TSize(100,10); sl@0: paramarray[2].iInterval=TTimeIntervalMicroSeconds32(200000); sl@0: iSprite1=new(ELeave) CTSprite(Client()->iWs); sl@0: iSprite1->ConstructL(iWin,iPos1,3,¶marray[0],ESpriteNoChildClip); sl@0: // sl@0: params.iSize=TSize(20,30); sl@0: for(TInt index=0;index<10;index++) sl@0: { sl@0: paramarray[index]=params; sl@0: paramarray[index].iOffset=TPoint(index*20,index*4); sl@0: } sl@0: iSprite2=new(ELeave) CTSprite(Client()->iWs); sl@0: iSprite2->ConstructL(iWin,iPos2,10,¶marray[0],0); sl@0: // sl@0: params.iSize=TSize(100,10); sl@0: iSprite3=new(ELeave) CTSprite(Client()->iWs); sl@0: iSprite3->ConstructL(iWin,iPos3,1,¶ms,ESpriteFlash); sl@0: // sl@0: params.iSize=TSize(32,32); sl@0: iSprite4=new(ELeave) CTSprite(Client()->iWs); sl@0: iSprite4->ConstructL(*Client()->iGroup->GroupWin(),iPos4,1,¶ms,0); sl@0: // sl@0: params.iSize=TSize(16,64); sl@0: iSprite5=new(ELeave) CTSprite(Client()->iWs); sl@0: iSprite5->ConstructL(*Client()->iGroup->GroupWin(),iPos5,1,¶ms,ESpriteNoChildClip); sl@0: // sl@0: iCurPos= &iPos1; sl@0: iCurSprite= iSprite1; sl@0: // iWin.SetBackgroundColor(TRgb::Gray256(170)); sl@0: TSpriteCreateParams pcursor(TSize(24,48),TPoint(-12,-24),DrawPointerCursor,&iPointerMode); sl@0: iPointerCursor=new(ELeave) CTPointerCursor(Client()->iWs); sl@0: iPointerCursor->ConstructL(1,&pcursor,0,iSpriteBitmap,iSpriteMaskBitmap); sl@0: iWin.SetCustomPointerCursor(iPointerCursor->PointerCursor()); sl@0: Client()->iGroup->GroupWin()->SetCustomPointerCursor(iPointerCursor->PointerCursor()); sl@0: } sl@0: sl@0: sl@0: void TestWindow7::Resized(const TSize &aNewSize) sl@0: { sl@0: CTBaseWin::Resized(aNewSize); sl@0: iGc->Activate(*DrawableWin()); sl@0: Draw(); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: void TestWindow7::Draw() sl@0: { sl@0: iGc->SetBrushColor(TRgb::Gray256(170)); sl@0: iGc->Clear(); sl@0: for(TInt xPos=0;xPosDrawLine(TPoint(xPos,0),TPoint(xPos,iSize.iHeight)); sl@0: for(TInt yPos=0;yPosDrawLine(TPoint(0,yPos),TPoint(iSize.iWidth,yPos)); sl@0: } sl@0: sl@0: void TestWindow7::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case 'c': sl@0: case 'C': sl@0: { sl@0: iPointerMode=(iPointerMode+1)&EPointerModes; sl@0: TSpriteCreateParams params(iSpriteBitmap->SizeInPixels(),TPoint(0,0),DrawPointerCursor,&iPointerMode); sl@0: iPointerCursor->RedrawL(iSpriteBitmap,iSpriteMaskBitmap,¶ms); sl@0: break; sl@0: } sl@0: case ' ': sl@0: if (iCurSprite==iSprite1) sl@0: { sl@0: iCurPos= &iPos2; sl@0: iCurSprite= iSprite2; sl@0: } sl@0: else if (iCurSprite==iSprite2) sl@0: { sl@0: iCurPos= &iPos3; sl@0: iCurSprite= iSprite3; sl@0: } sl@0: else if (iCurSprite==iSprite3) sl@0: { sl@0: iCurPos= &iPos4; sl@0: iCurSprite= iSprite4; sl@0: } sl@0: else if (iCurSprite==iSprite4) sl@0: { sl@0: iCurPos= &iPos5; sl@0: iCurSprite= iSprite5; sl@0: } sl@0: else if (iCurSprite==iSprite5) sl@0: { sl@0: iCurPos= &iPos1; sl@0: iCurSprite= iSprite1; sl@0: } sl@0: break; sl@0: case '1': sl@0: iCurPos->iX-=5; sl@0: iCurSprite->Sprite().SetPosition(*iCurPos); sl@0: break; sl@0: case '2': sl@0: iCurPos->iX+=5; sl@0: iCurSprite->Sprite().SetPosition(*iCurPos); sl@0: break; sl@0: case '3': sl@0: iCurPos->iY-=5; sl@0: iCurSprite->Sprite().SetPosition(*iCurPos); sl@0: break; sl@0: case '4': sl@0: iCurPos->iY+=5; sl@0: iCurSprite->Sprite().SetPosition(*iCurPos); sl@0: break; sl@0: default:; sl@0: } sl@0: } sl@0: sl@0: TestWindow8::TestWindow8() : CTBlankWindow() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow8")); sl@0: } sl@0: sl@0: void TestWindow8::InitWin() sl@0: { sl@0: iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit); sl@0: iWin.SetPointerGrab(ETrue); sl@0: iWin.SetColor(TRgb::Gray256(170)); sl@0: } sl@0: sl@0: void TestWindow8::Draw() sl@0: { sl@0: Panic(EConnectPanicRedrawToBackedUpWindow); sl@0: } sl@0: sl@0: TestWindow9::TestWindow9() : CTWin() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow9")); sl@0: } sl@0: sl@0: void TestWindow9::InitWinL() sl@0: { sl@0: iWin.SetRequiredDisplayMode(EGray16); sl@0: User::LeaveIfError(iBitmap.Load(VIDEO_MBM_NAME,0)); sl@0: iVideoSize=iBitmap.SizeInPixels(); sl@0: } sl@0: sl@0: void TestWindow9::Draw() sl@0: { sl@0: iGc->BitBlt(TPoint(),&iBitmap); sl@0: } sl@0: sl@0: void TestWindow9::Play() sl@0: { sl@0: iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize); sl@0: iWin.BeginRedraw(); sl@0: iWin.EndRedraw(); sl@0: iGc->Activate(iWin); sl@0: TInt index=1; sl@0: while(iBitmap.Load(VIDEO_MBM_NAME,index++)==KErrNone) sl@0: { sl@0: iGc->BitBlt(TPoint(),&iBitmap); sl@0: Client()->iWs.Flush(); sl@0: } sl@0: iBitmap.Load(VIDEO_MBM_NAME,0); sl@0: iGc->BitBlt(TPoint(),&iBitmap); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: void TestWindow9::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: if (aKey.iCode=='p' || aKey.iCode=='P') sl@0: Play(); sl@0: } sl@0: sl@0: TestWindow10::TestWindow10() : CTWin() sl@0: { sl@0: __DECLARE_NAME(_S("TestWindow10")); sl@0: } sl@0: sl@0: void TestWindow10::InitWin() sl@0: { sl@0: //iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit); sl@0: //iWin.SetPointerGrab(ETrue); sl@0: iWin.SetRequiredDisplayMode(EColor256); sl@0: } sl@0: sl@0: void TestWindow10::Draw() sl@0: { sl@0: TSize size=Size(); sl@0: TRect rect(size); sl@0: TInt ii; sl@0: sl@0: iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: rect.iBr.iX=0; sl@0: for(ii=0;ii<256;ii++) sl@0: { sl@0: rect.iTl.iX=rect.iBr.iX; sl@0: rect.iBr.iX=((ii+1)*size.iWidth)/256; sl@0: iGc->SetBrushColor(TRgb::Color256(ii)); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: } sl@0: sl@0: void TestWindow10::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case '0': sl@0: iWin.SetRequiredDisplayMode(EGray2); sl@0: break; sl@0: case '1': sl@0: iWin.SetRequiredDisplayMode(EGray4); sl@0: break; sl@0: case '2': sl@0: iWin.SetRequiredDisplayMode(EGray16); sl@0: break; sl@0: case '3': sl@0: iWin.SetRequiredDisplayMode(EGray256); sl@0: break; sl@0: case '4': sl@0: iWin.SetRequiredDisplayMode(EColor16); sl@0: break; sl@0: case '5': sl@0: iWin.SetRequiredDisplayMode(EColor256); sl@0: break; sl@0: case '6': sl@0: iWin.SetRequiredDisplayMode(EColor64K); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TestWindow12::TestWindow12() : CTWin() sl@0: {} sl@0: sl@0: void TestWindow12::InitWin() sl@0: { sl@0: iWin.SetRequiredDisplayMode(EColor16); sl@0: } sl@0: sl@0: void TestWindow12::Draw() sl@0: { sl@0: TRect rect(Size()); sl@0: sl@0: iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(TRgb(0,255,0)); sl@0: iGc->DrawRect(rect); sl@0: rect.iTl.iX=rect.iBr.iX/2; sl@0: iGc->SetBrushColor(TRgb(0,0,255)); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: sl@0: void TestWindow12::WinKeyL(const TKeyEvent &aKey,const TTime &) sl@0: { sl@0: TSize screen(Client()->iScreen->SizeInPixels()); sl@0: TSize size(Size()); sl@0: TPoint pos(Position()); sl@0: TPoint dest1(screen.iWidth-size.iWidth,screen.iHeight-size.iHeight); sl@0: TPoint dest; sl@0: iGc->Activate(iWin); sl@0: switch(aKey.iCode) sl@0: { sl@0: //case '1': sl@0: //break; sl@0: case '2': sl@0: dest.iX=dest1.iX/2; sl@0: break; sl@0: case '3': sl@0: dest.iX=dest1.iX; sl@0: break; sl@0: case '4': sl@0: dest.iY=dest1.iY/2; sl@0: break; sl@0: case '5': sl@0: dest.iX=dest1.iX/2; sl@0: dest.iY=dest1.iY/2; sl@0: break; sl@0: case '6': sl@0: dest.iX=dest1.iX; sl@0: dest.iY=dest1.iY/2; sl@0: break; sl@0: case '7': sl@0: dest.iY=dest1.iY; sl@0: break; sl@0: case '8': sl@0: dest.iX=dest1.iX/2; sl@0: dest.iY=dest1.iY; sl@0: break; sl@0: case '9': sl@0: dest.iX=dest1.iX; sl@0: dest.iY=dest1.iY; sl@0: break; sl@0: } sl@0: TRect rect(screen); sl@0: rect.Move(-pos); sl@0: iGc->CopyRect(pos-dest,rect); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: // sl@0: sl@0: TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient), iIncludeChildren(EFalse) sl@0: { sl@0: } sl@0: sl@0: void TestWindowGroup::ConstructL() sl@0: { sl@0: CTWindowGroup::ConstructL(); sl@0: iGroupWin.EnableScreenChangeEvents(); sl@0: } sl@0: sl@0: void TestWindowGroup::ScreenDeviceChanged() sl@0: { sl@0: TPixelsTwipsAndRotation sizeAndRotation; sl@0: Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); sl@0: } sl@0: sl@0: void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime) sl@0: { sl@0: if (aKey.iModifiers&EModifierCtrl && !(aKey.iModifiers&EModifierFunc)) sl@0: { sl@0: TInt type=0; sl@0: if (aKey.iCode<=14) sl@0: type=aKey.iCode; sl@0: if (type!=0) sl@0: { sl@0: TPoint pos; sl@0: TSize size; sl@0: CTWinBase *win=this; sl@0: if ((aKey.iModifiers&EModifierLeftShift) && iCurWin) sl@0: win=iCurWin; sl@0: pos.iX=win->Size().iWidth>>2; sl@0: pos.iY=win->Size().iHeight>>2; sl@0: size.iWidth=win->Size().iWidth>>1; sl@0: size.iHeight=win->Size().iHeight>>1; sl@0: iCurWin=((TestClient *)Client())->CreateTestWindowL(type,pos,size,win,*Client()->iGc,aKey.iModifiers&EModifierRightShift); sl@0: return; sl@0: } sl@0: } sl@0: if (aKey.iModifiers&EModifierFunc) sl@0: { sl@0: switch(aKey.iCode) sl@0: { sl@0: case 'a': sl@0: { sl@0: for(TInt loop=0;loop<100;loop++) sl@0: { sl@0: ((TestClient *)Client())->iWs.HeapSetFail(RHeap::EDeterministic,loop); sl@0: CTBaseWin *win=NULL; sl@0: TRAP_IGNORE(win=((TestClient *)Client())->CreateTestWindowL(1,TPoint(15,20),TSize(150,110),Client()->iGroup,*Client()->iGc)); sl@0: if (win) sl@0: { sl@0: ((CTWin *)win)->Redraw(TRect()); sl@0: delete win; sl@0: } sl@0: } sl@0: ((TestClient *)Client())->iWs.HeapSetFail(RHeap::ENone,0); sl@0: } sl@0: break; sl@0: case '0': sl@0: { sl@0: TUint *aNullPtr=NULL; sl@0: *aNullPtr=0; sl@0: } sl@0: break; sl@0: case 'p': sl@0: { sl@0: RThread thread; sl@0: thread.Panic(_L("Connect"),123); sl@0: } sl@0: break; sl@0: case 'x': sl@0: ((TestClient *)Client())->Exit(); sl@0: break; sl@0: case 'f': sl@0: if (Client()->iWs.SetAutoFlush(ETrue)) sl@0: Client()->iWs.SetAutoFlush(EFalse); sl@0: break; sl@0: case 'b': sl@0: RunLaunchAndShootTestL(); sl@0: break; sl@0: case 'm': sl@0: MillionsOfSessions(); sl@0: break; sl@0: case 'o': sl@0: GroupWin()->SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow); sl@0: break; sl@0: case 10: sl@0: if (aKey.iModifiers&EModifierCtrl && aKey.iModifiers&EModifierShift) sl@0: iHand->ToggleStatus(); sl@0: break; sl@0: case EKeyLeftArrow: sl@0: ((TestClient *)Client())->AdjustLightSource(-1,0); sl@0: break; sl@0: case EKeyRightArrow: sl@0: ((TestClient *)Client())->AdjustLightSource(1,0); sl@0: break; sl@0: case EKeyUpArrow: sl@0: ((TestClient *)Client())->AdjustLightSource(0,-1); sl@0: break; sl@0: case EKeyDownArrow: sl@0: ((TestClient *)Client())->AdjustLightSource(0,1); sl@0: break; sl@0: default: sl@0: goto keeptrying; sl@0: } sl@0: return; sl@0: } sl@0: keeptrying: sl@0: if (iCurWin) sl@0: { sl@0: if (aKey.iModifiers&EModifierFunc) sl@0: { sl@0: //TBool shift=aKey.iModifiers&EModifierShift; sl@0: switch(aKey.iCode) sl@0: { sl@0: case 'c': sl@0: GroupWin()->DisableKeyClick(ETrue); sl@0: break; sl@0: case 'C': sl@0: GroupWin()->DisableKeyClick(EFalse); sl@0: break; sl@0: case 's': sl@0: iCurWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: break; sl@0: case 'S': sl@0: iCurWin->BaseWin()->SetShadowDisabled(EFalse); sl@0: break; sl@0: case 'v': sl@0: iCurWin->SetVisible(ETrue); sl@0: break; sl@0: case 'i': sl@0: iCurWin->SetVisible(EFalse); sl@0: break; sl@0: case 'd': sl@0: iCurWin->BaseWin()->SetFaded(ETrue sl@0: ,(iIncludeChildren? RWindowTreeNode::EFadeIncludeChildren:RWindowTreeNode::EFadeWindowOnly)); sl@0: break; sl@0: case 'D': sl@0: iCurWin->BaseWin()->SetFaded(EFalse sl@0: ,(iIncludeChildren? RWindowTreeNode::EFadeIncludeChildren:RWindowTreeNode::EFadeWindowOnly)); sl@0: break; sl@0: case 'w': sl@0: case 'W': sl@0: iIncludeChildren=!iIncludeChildren; sl@0: case 'e': sl@0: iCurWin->BaseWin()->SetNonFading(ETrue); sl@0: break; sl@0: case 'E': sl@0: iCurWin->BaseWin()->SetNonFading(EFalse); sl@0: break; sl@0: case 'r': sl@0: iCurWin->BaseWin()->FadeBehind(ETrue); sl@0: break; sl@0: case 'R': sl@0: iCurWin->BaseWin()->FadeBehind(EFalse); sl@0: break; sl@0: /*case 'b': sl@0: iCurWin->WinTreeNode()->SetOrdinalPosition(-1); sl@0: break; sl@0: case 'f': sl@0: iCurWin->WinTreeNode()->SetOrdinalPosition(0); sl@0: break;*/ sl@0: case 'B': sl@0: { sl@0: RWindowTreeNode* win=iCurWin->WinTreeNode(); sl@0: win->SetOrdinalPosition(win->OrdinalPosition()+1); sl@0: } sl@0: break; sl@0: case 'F': sl@0: { sl@0: RWindowTreeNode* win=iCurWin->WinTreeNode(); sl@0: win->SetOrdinalPosition(win->OrdinalPosition()-1); sl@0: } sl@0: break; sl@0: default: sl@0: goto keeptrying2; sl@0: } sl@0: return; sl@0: } sl@0: keeptrying2: sl@0: switch(aKey.iCode) sl@0: { sl@0: case 24: //Ctrl-X sl@0: CTWin::Delete(iCurWin); sl@0: break; sl@0: case 19: //Ctrl-S sl@0: if (aKey.iModifiers&EModifierShift) sl@0: iCurWin=iCurWin->Prev(); sl@0: else sl@0: iCurWin=iCurWin->Next(); sl@0: break; sl@0: case EKeyLeftArrow: sl@0: iCurWin->AdjustSizeL(-Xmove,0,aKey.iModifiers); sl@0: break; sl@0: case EKeyRightArrow: sl@0: iCurWin->AdjustSizeL(Xmove,0,aKey.iModifiers); sl@0: break; sl@0: case EKeyUpArrow: sl@0: iCurWin->AdjustSizeL(0,-Ymove,aKey.iModifiers); sl@0: break; sl@0: case EKeyDownArrow: sl@0: iCurWin->AdjustSizeL(0,Ymove,aKey.iModifiers); sl@0: break; sl@0: case '[': // Move back 1 ordinal position sl@0: iCurWin->AdjustOrdinal(-1); sl@0: break; sl@0: case ']': // Move forward 1 ordinal position sl@0: iCurWin->AdjustOrdinal(1); sl@0: break; sl@0: case '<': // Decrease shadow size sl@0: iCurWin->AdjustShadow(-1); sl@0: break; sl@0: case '>': // Increase shadow size sl@0: iCurWin->AdjustShadow(1); sl@0: break; sl@0: case 13: sl@0: // iCurWin->SetDefaultExtL(); sl@0: iCurWin->SetFullScreenExtL(); sl@0: break; sl@0: default: sl@0: iCurWin->WinKeyL(aKey,aTime); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: void TestWindowGroup::RunLaunchAndShootTestL() sl@0: { sl@0: RThread thread; sl@0: User::LeaveIfError(thread.Create(_L("Launcher"),RunLaunchAndShootTest,KDefaultStackSize,NULL, sl@0: NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread)); sl@0: thread.Resume(); sl@0: thread.Close(); sl@0: } sl@0: sl@0: void TestWindowGroup::MillionsOfSessions() sl@0: { sl@0: RWsSession session; sl@0: FOREVER sl@0: { sl@0: session=RWsSession(); sl@0: if (session.Connect()!=KErrNone) sl@0: break; sl@0: } sl@0: } sl@0: sl@0: // sl@0: sl@0: TestClient::TestClient() sl@0: { sl@0: __DECLARE_NAME(_S("TestClient")); sl@0: } sl@0: sl@0: CTBaseWin *TestClient::CreateTestWindowL(TInt type,TPoint pos,TSize size,CTWinBase *parent,CWindowGc &aGc,TBool aAlternate/*=EFalse*/) sl@0: { sl@0: CTBaseWin *win=NULL; sl@0: switch(type) sl@0: { sl@0: case 1: sl@0: win=new(ELeave) TestWindow1(); sl@0: break; sl@0: case 2: sl@0: win=new(ELeave) TestWindow2(); sl@0: break; sl@0: case 3: sl@0: win=new(ELeave) TestWindow3(); sl@0: break; sl@0: case 4: sl@0: win=new(ELeave) TestWindow4(); sl@0: break; sl@0: case 5: sl@0: win=new(ELeave) TestWindow5(aAlternate); sl@0: break; sl@0: case 6: sl@0: win=new(ELeave) TestWindow6(aAlternate); sl@0: break; sl@0: case 7: sl@0: win=new(ELeave) TestWindow7(aAlternate); sl@0: break; sl@0: case 8: sl@0: win=new(ELeave) TestWindow8(); sl@0: break; sl@0: case 9: sl@0: win=new(ELeave) TestWindow9(); sl@0: break; sl@0: case 10: sl@0: win=new(ELeave) TestWindow10(); sl@0: break; sl@0: case 11: sl@0: win=new(ELeave) TestWindow11(); sl@0: break; sl@0: case 12: sl@0: win=new(ELeave) TestWindow12(); sl@0: break; sl@0: default: sl@0: User::Leave(KErrArgument); sl@0: } sl@0: TRAPD(err,win->ConstructL(*parent)); sl@0: if (err!=KErrNone) sl@0: goto ctw_err; sl@0: win->AssignGC(aGc); sl@0: TRAP(err,win->SetExtL(pos,size)); sl@0: if (err!=KErrNone) sl@0: { sl@0: ctw_err: sl@0: delete win; sl@0: User::Leave(err); sl@0: } sl@0: if (type!=2) sl@0: win->BaseWin()->EnableBackup(); sl@0: win->BaseWin()->SetPointerCursor(0); sl@0: win->Activate(); sl@0: return(win); sl@0: } sl@0: sl@0: TestClient::~TestClient() sl@0: { sl@0: delete iHandWriting; sl@0: } sl@0: sl@0: // sl@0: sl@0: // Define to include hand writing tests sl@0: #define TEST_HWR sl@0: void TestClient::ConstructL() sl@0: { sl@0: CTClient::ConstructL(); sl@0: iGroup=new(ELeave) TestWindowGroup(this); sl@0: iGroup->ConstructL(); sl@0: // CreateTestWindowL(1,TPoint(15,20),TSize(150,110),iGroup,*iGc); sl@0: // CreateTestWindowL(2,TPoint(100,100),TSize(200,90),iGroup,*iGc); sl@0: // CreateTestWindowL(3,TPoint(310,190),TSize(90,40),iGroup,*iGc); sl@0: CreateTestWindowL(4,TPoint(10,10),TSize(160,120),iGroup,*iGc); sl@0: // CreateTestWindowL(5,TPoint(300,14),TSize(260,140),iGroup,*iGc); sl@0: // CreateTestWindowL(6,TPoint(20,200),TSize(160,60),iGroup,*iGc); sl@0: iGroup->SetCurrentWindow(iGroup->Child()); sl@0: #if defined(TEST_HWR) sl@0: iHandWriting=new(ELeave) CHandWriting(iWs); sl@0: TRAPD(err,iHandWriting->ConstructL(iScreen->SizeInPixels(),*iGroup->GroupWin(),ETrue)); //EFalse don't use seperate Mask bitmap. sl@0: if (err!=KErrNone) sl@0: delete iHandWriting; sl@0: else sl@0: TestWindow()->SetHandWriting(iHandWriting); sl@0: #endif sl@0: } sl@0: sl@0: void TestClient::AdjustLightSource(TInt aX,TInt aY) sl@0: { sl@0: TPoint vector=iWs.ShadowVector(); sl@0: vector.iX+=aX; sl@0: vector.iY+=aY; sl@0: iWs.SetShadowVector(vector); sl@0: } sl@0: sl@0: void TestClient::Exit() sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: // sl@0: // Special bit of test code to repeatedly launch and shoot a wserv // sl@0: // sl@0: sl@0: #define NT_KILLER sl@0: sl@0: TInt LaunchAndShootTestLoop(TAny *) sl@0: { sl@0: #if defined(NT_KILLER) sl@0: User::WaitForAnyRequest(); sl@0: #else sl@0: sl@0: RWsSession ws; sl@0: ws.Connect(); sl@0: TTimeIntervalMicroSeconds32 initialTime; sl@0: TTimeIntervalMicroSeconds32 time; sl@0: FOREVER sl@0: ws.GetKeyboardRepeatRate(initialTime, time); sl@0: #endif sl@0: return(KErrNone); sl@0: } sl@0: sl@0: #if defined(NT_KILLER) sl@0: TInt RunLaunchAndShootTest(TAny *) sl@0: { sl@0: RThread().SetPriority(EPriorityRealTime); sl@0: RThread thread; sl@0: thread.Create(_L("xx1"),LaunchAndShootTestLoop,KDefaultStackSize,NULL, sl@0: NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread); sl@0: thread.Resume(); sl@0: thread.Kill(KErrNone); sl@0: thread.Close(); sl@0: RThread thread2; sl@0: thread2.Create(_L("xx2"),LaunchAndShootTestLoop,KDefaultStackSize,NULL, sl@0: NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread); sl@0: thread2.Resume(); sl@0: thread2.Kill(KErrNone); sl@0: thread2.Close(); sl@0: return(KErrNone); sl@0: } sl@0: #else sl@0: TInt RunLaunchAndShootTest(TAny *) sl@0: { sl@0: RThread().SetPriority(EPriorityRealTime); sl@0: for(TInt count=0;count<100;count++) sl@0: { sl@0: RThread thread; sl@0: TBuf threadName; sl@0: TInt num=0; sl@0: TInt err=KErrNone; sl@0: do sl@0: { sl@0: threadName.Format(_L("%S%02d"),&_L("Looper"),num++); sl@0: err=thread.Create(threadName,LaunchAndShootTestLoop,KDefaultStackSize,NULL, sl@0: NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread); sl@0: } while(err==KErrAlreadyExists); sl@0: if (err!=KErrNone) sl@0: return(KErrNone); sl@0: thread.Resume(); sl@0: User::After(TTimeIntervalMicroSeconds32(50000)); sl@0: thread.Kill(KErrNone); sl@0: thread.Close(); sl@0: } sl@0: return(KErrNone); sl@0: } sl@0: #endif sl@0: sl@0: // sl@0: #define leavescan_needs_to_see_some_brackets_here { } sl@0: sl@0: GLDEF_C CTClient* CreateClientL() sl@0: { sl@0: return(new(ELeave) TestClient()); //Leavescan thinks this fn is user::After! sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: return(TestLibStartUp(CreateClientL)); sl@0: }