os/graphics/windowing/windowserver/test/CONNECT.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Very simple test program to connect to the window server
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include "W32STD.H"
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include "../SERVER/w32cmd.h"
sl@0
    22
#include "../test/tlib/testbase.h"
sl@0
    23
#include "ANIMWIN.H"
sl@0
    24
#include "HNDLODR.H"
sl@0
    25
sl@0
    26
#define TEST_BITMAP_NAME _L("Z:\\WSTEST\\TEST.MBM")
sl@0
    27
_LIT(KTestFontTypefaceName,"DejaVu Sans Condensed");
sl@0
    28
sl@0
    29
//
sl@0
    30
// TestWindow class
sl@0
    31
//
sl@0
    32
sl@0
    33
class TestClient;	// Forward reference
sl@0
    34
sl@0
    35
class TestWindow1 : public CTWin
sl@0
    36
	{
sl@0
    37
public:
sl@0
    38
	TestWindow1();
sl@0
    39
	void Resized(const TSize &aNewSize);
sl@0
    40
	void Draw();
sl@0
    41
	void WinKeyL(const TKeyEvent &aKey,const TTime &);
sl@0
    42
private:
sl@0
    43
	TBool iDrawPolygon;
sl@0
    44
	};
sl@0
    45
sl@0
    46
class TestWindow2 : public CTWin
sl@0
    47
	{
sl@0
    48
	enum EPointerState
sl@0
    49
		{
sl@0
    50
		EPointerIn,
sl@0
    51
		EPointerOut,
sl@0
    52
		EPointerUndefined,
sl@0
    53
		};
sl@0
    54
public:
sl@0
    55
	TestWindow2();
sl@0
    56
	~TestWindow2();
sl@0
    57
	void InitWinL();
sl@0
    58
	void Draw();
sl@0
    59
	void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
sl@0
    60
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
    61
	void NewText(TPoint &pos,TInt &width,TDes &des);
sl@0
    62
	void PointerState(EPointerState aState);
sl@0
    63
	void PointerEnter(const TTime &aTime);
sl@0
    64
	void PointerExit(const TTime &aTime);
sl@0
    65
	void SetBufBits();
sl@0
    66
	void RequestPointerRepeat();
sl@0
    67
private:
sl@0
    68
	void SwitchOn(const TTime &aTime);
sl@0
    69
private:
sl@0
    70
	TBuf<0x40> iBuf;
sl@0
    71
	TBuf<0x40> iBufBits;
sl@0
    72
	TBuf<0x40> iBufMem;
sl@0
    73
	TPoint iPos;
sl@0
    74
	TPoint iPosBits;
sl@0
    75
	TPoint iPosMem;
sl@0
    76
	TInt iWid;
sl@0
    77
	TInt iWidBits;
sl@0
    78
	TInt iWidMem;
sl@0
    79
	TInt iFontHeight;
sl@0
    80
	EPointerState iPointerState;
sl@0
    81
	TUint32 iFilter;
sl@0
    82
	TBool iCapture;
sl@0
    83
	TBool iGrab;
sl@0
    84
	TRgb iBackColor;
sl@0
    85
	TInt iRepeatCount;
sl@0
    86
	TRect iRepeatRect;
sl@0
    87
	};
sl@0
    88
sl@0
    89
class TestWindow3 : public CTWin
sl@0
    90
	{
sl@0
    91
public:
sl@0
    92
	TestWindow3();
sl@0
    93
	~TestWindow3();
sl@0
    94
	void Draw();
sl@0
    95
	void InitWinL();
sl@0
    96
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
    97
	void Resized(const TSize &aNewSize);
sl@0
    98
	void SetShape(TInt aShapeNum);
sl@0
    99
	void ScreenDeviceChangedL();
sl@0
   100
private:
sl@0
   101
	CWsBitmap *iBitmap;
sl@0
   102
	TInt iShapeNum;
sl@0
   103
	TInt iCornerFlags;
sl@0
   104
	TCornerType iCornerType;
sl@0
   105
	};
sl@0
   106
sl@0
   107
class TestWindow4 : public CTWin
sl@0
   108
	{
sl@0
   109
public:
sl@0
   110
	TestWindow4();
sl@0
   111
	void InitWin();
sl@0
   112
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   113
	void Resized(const TSize &aSize);
sl@0
   114
	void Draw();
sl@0
   115
	void Draw(TBool aSetCursor);
sl@0
   116
private:
sl@0
   117
	void SetSwappedSize();
sl@0
   118
	void SetCursor(const TPoint &aPos);
sl@0
   119
private:
sl@0
   120
	TBuf<300> TxtBuf;
sl@0
   121
	TPoint iBasePos;
sl@0
   122
	TBool iVertical;
sl@0
   123
	TSize iSwappedSize;
sl@0
   124
	//TInt iTemp;
sl@0
   125
	};
sl@0
   126
sl@0
   127
class TestWindow5 : public CTBackedUpWin
sl@0
   128
	{
sl@0
   129
public:
sl@0
   130
	TestWindow5(TBool aGrey2);
sl@0
   131
	void Draw();
sl@0
   132
	void InitWinL();
sl@0
   133
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   134
	void Resized(const TSize &aNewSize);
sl@0
   135
private:
sl@0
   136
	CFbsBitmap iBrushBit;
sl@0
   137
	TInt iOrdPri;
sl@0
   138
	};
sl@0
   139
sl@0
   140
class TestWindow6 : public CTBackedUpWin
sl@0
   141
	{
sl@0
   142
public:
sl@0
   143
	enum {KPointerMoveBufferSize=32};
sl@0
   144
public:
sl@0
   145
	TestWindow6(TBool aGrey2);
sl@0
   146
	~TestWindow6();
sl@0
   147
	void Draw();
sl@0
   148
	void InitWinL();
sl@0
   149
	void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
sl@0
   150
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   151
	virtual void AssignGC(CWindowGc &aGc);
sl@0
   152
	void Resized(const TSize &aNewSize);
sl@0
   153
	void PointerBufferReady(const TTime &aTime);
sl@0
   154
private:
sl@0
   155
	TSize iOldSize;	// Needed as part of resizing after old size has been lost
sl@0
   156
	TBool iDragging;
sl@0
   157
	TInt iGray;
sl@0
   158
	CWindowGc *iGc2;
sl@0
   159
	CWindowGc *iCurGc;
sl@0
   160
	};
sl@0
   161
sl@0
   162
class TestWindow7 : public CTBackedUpWin
sl@0
   163
	{
sl@0
   164
private:
sl@0
   165
	enum {EPointerModes=3};
sl@0
   166
public:
sl@0
   167
	TestWindow7(TBool aGrey2);
sl@0
   168
	~TestWindow7();
sl@0
   169
	void InitWinL();
sl@0
   170
	void Draw();
sl@0
   171
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   172
	void Resized(const TSize &aNewSize);
sl@0
   173
/*private:
sl@0
   174
	void createBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask);
sl@0
   175
	void createBitmap2L(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask);
sl@0
   176
	void InitPointerCursorL(RWsPointerCursor &aSprite, const TSize &aSize, TInt aFlags);
sl@0
   177
	void InitSpriteL(RWsSprite &aSprite, const TPoint &aPos, const TSize &aSize, TTimeIntervalMicroSeconds32 aOnTime, TTimeIntervalMicroSeconds32 aOffTime, TInt aFlags);*/
sl@0
   178
private:
sl@0
   179
	CTSprite *iSprite1;
sl@0
   180
	CTSprite *iSprite2;
sl@0
   181
	CTSprite *iSprite3;
sl@0
   182
	CTSprite *iSprite4;
sl@0
   183
	CTSprite *iSprite5;
sl@0
   184
	CTPointerCursor *iPointerCursor;
sl@0
   185
	CFbsBitmap *iSpriteBitmap;
sl@0
   186
	CFbsBitmap *iSpriteMaskBitmap;
sl@0
   187
	TInt iPointerMode;
sl@0
   188
	TPoint iPos1;
sl@0
   189
	TPoint iPos2;
sl@0
   190
	TPoint iPos3;
sl@0
   191
	TPoint iPos4;
sl@0
   192
	TPoint iPos5;
sl@0
   193
	TPoint *iCurPos;
sl@0
   194
	CTSprite *iCurSprite;
sl@0
   195
	};
sl@0
   196
sl@0
   197
class TestWindow8 : public CTBlankWindow
sl@0
   198
	{
sl@0
   199
public:
sl@0
   200
	TestWindow8();
sl@0
   201
	void Draw();
sl@0
   202
	void InitWin();
sl@0
   203
	};
sl@0
   204
sl@0
   205
class TestWindow9 : public CTWin
sl@0
   206
	{
sl@0
   207
public:
sl@0
   208
	TestWindow9();
sl@0
   209
	void Draw();
sl@0
   210
	void WinKeyL(const TKeyEvent &aKey,const TTime &);
sl@0
   211
	void InitWinL();
sl@0
   212
	void Play();
sl@0
   213
private:
sl@0
   214
	CFbsBitmap iBitmap;
sl@0
   215
	TSize iVideoSize;
sl@0
   216
	};
sl@0
   217
sl@0
   218
class TestWindow10 : public CTWin
sl@0
   219
	{
sl@0
   220
public:
sl@0
   221
	TestWindow10();
sl@0
   222
	void Draw();
sl@0
   223
	void InitWin();
sl@0
   224
	void WinKeyL(const TKeyEvent &aKey,const TTime &);
sl@0
   225
	};
sl@0
   226
sl@0
   227
class TestWindow12 : public CTWin
sl@0
   228
	{
sl@0
   229
public:
sl@0
   230
	TestWindow12();
sl@0
   231
	void Draw();
sl@0
   232
	void InitWin();
sl@0
   233
	void WinKeyL(const TKeyEvent &aKey,const TTime &);
sl@0
   234
	};
sl@0
   235
sl@0
   236
class TestWindowGroup : public CTWindowGroup
sl@0
   237
	{
sl@0
   238
public:
sl@0
   239
	TestWindowGroup(CTClient *aClient);
sl@0
   240
	virtual void ConstructL();
sl@0
   241
	virtual void KeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   242
	void ScreenDeviceChanged();
sl@0
   243
	void RunLaunchAndShootTestL();
sl@0
   244
	void MillionsOfSessions();
sl@0
   245
	inline void SetHandWriting(CHandWriting* aHand) {iHand=aHand;}
sl@0
   246
private:
sl@0
   247
	CHandWriting* iHand;
sl@0
   248
	TBool iIncludeChildren;
sl@0
   249
	};
sl@0
   250
sl@0
   251
class TestClient : public CTClient
sl@0
   252
	{
sl@0
   253
public:
sl@0
   254
	TestClient();
sl@0
   255
	~TestClient();
sl@0
   256
	void ConstructL();
sl@0
   257
	TInt EventLoop();
sl@0
   258
	void Exit();
sl@0
   259
	void SetCurrentWindow(CTWinBase *aWindow);
sl@0
   260
	CTBaseWin *CreateTestWindowL(TInt type,TPoint pos,TSize size,CTWinBase *parent,CWindowGc &gc,TBool aAlternate=EFalse);
sl@0
   261
	void AdjustLightSource(TInt aX,TInt aY);
sl@0
   262
private:
sl@0
   263
	inline TestWindowGroup* TestWindow() {return STATIC_CAST(TestWindowGroup*,iGroup);}
sl@0
   264
private:
sl@0
   265
	CHandWriting *iHandWriting;
sl@0
   266
	TPoint ShadowOffset;
sl@0
   267
	};
sl@0
   268
sl@0
   269
//const TInt Xmove=8;
sl@0
   270
//const TInt Ymove=6;
sl@0
   271
const TInt Xmove=1;
sl@0
   272
const TInt Ymove=1;
sl@0
   273
sl@0
   274
LOCAL_D const TUint KTestThreadHeapSize=0x10000;
sl@0
   275
sl@0
   276
enum TConnectPanic
sl@0
   277
	{
sl@0
   278
	EConnectPanicRedrawToBackedUpWindow,
sl@0
   279
	EConnectPanicRequiredDisplayMode,
sl@0
   280
	EConnectPanicDragEvent,
sl@0
   281
	};
sl@0
   282
sl@0
   283
TInt RunLaunchAndShootTest(TAny *);
sl@0
   284
sl@0
   285
void Panic(TInt aPanic)
sl@0
   286
	{
sl@0
   287
	User::Panic(_L("CONNECT"),aPanic);
sl@0
   288
	}
sl@0
   289
sl@0
   290
//
sl@0
   291
// Individual window sub-classes
sl@0
   292
//
sl@0
   293
sl@0
   294
TestWindow1::TestWindow1() : CTWin()
sl@0
   295
	{
sl@0
   296
	__DECLARE_NAME(_S("TestWindow1"));
sl@0
   297
	}
sl@0
   298
sl@0
   299
void TestWindow1::Draw()
sl@0
   300
//This function is virtual and so cannot have an 'L' at the end of it's name
sl@0
   301
	{
sl@0
   302
	TInt i;
sl@0
   303
sl@0
   304
	iGc->SetBrushColor(TRgb::Gray16(14));
sl@0
   305
	iGc->Clear();
sl@0
   306
	iGc->SetPenColor(TRgb::Gray16(8));
sl@0
   307
	iGc->SetBrushColor(TRgb::Gray16(0));
sl@0
   308
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   309
	CArrayFixFlat<TPoint> *pnts;
sl@0
   310
	pnts=new(ELeave) CArrayFixFlat<TPoint>(20);
sl@0
   311
	TPoint mid(iSize.iWidth>>1,iSize.iHeight>>1);
sl@0
   312
	for(i=0;i<mid.iX;i+=4)
sl@0
   313
		{
sl@0
   314
		pnts->AppendL(TPoint(mid.iX-i,mid.iY-i));
sl@0
   315
		pnts->AppendL(TPoint(mid.iX+i+1,mid.iY-i-1));
sl@0
   316
		pnts->AppendL(TPoint(mid.iX+i+2,mid.iY+i+2));
sl@0
   317
		pnts->AppendL(TPoint(mid.iX-i-3,mid.iY+i+3));
sl@0
   318
		}
sl@0
   319
	if (iDrawPolygon)
sl@0
   320
		iGc->DrawPolygon(pnts,CGraphicsContext::EAlternate);
sl@0
   321
	else
sl@0
   322
		iGc->DrawPolyLine(pnts);
sl@0
   323
	delete pnts;
sl@0
   324
//
sl@0
   325
	TPoint polygon[8];
sl@0
   326
	polygon[0]=TPoint(mid.iX-8,mid.iY-16);
sl@0
   327
	polygon[1]=TPoint(mid.iX+8,mid.iY-16);
sl@0
   328
	polygon[2]=TPoint(mid.iX+16,mid.iY-8);
sl@0
   329
	polygon[3]=TPoint(mid.iX+16,mid.iY+8);
sl@0
   330
	polygon[4]=TPoint(mid.iX+8,mid.iY+16);
sl@0
   331
	polygon[5]=TPoint(mid.iX-8,mid.iY+16);
sl@0
   332
	polygon[6]=TPoint(mid.iX-16,mid.iY+8);
sl@0
   333
	polygon[7]=TPoint(mid.iX-16,mid.iY-8);
sl@0
   334
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   335
	iGc->DrawPolygon(&polygon[0],sizeof(polygon)/sizeof(polygon[0]));
sl@0
   336
	}
sl@0
   337
sl@0
   338
void TestWindow1::Resized(const TSize &aNewSize)
sl@0
   339
	{
sl@0
   340
	iWin.Invalidate();
sl@0
   341
	CTBaseWin::Resized(aNewSize);
sl@0
   342
	}
sl@0
   343
sl@0
   344
/*void AFunction(TDesC& des)
sl@0
   345
	{
sl@0
   346
	TDesC *abc=&des;
sl@0
   347
	TInt a=3+4;
sl@0
   348
	}
sl@0
   349
sl@0
   350
void AFunction2(TDes& des)
sl@0
   351
	{
sl@0
   352
	TDes *abc=&des;
sl@0
   353
	TInt a=3+4;
sl@0
   354
	}*/
sl@0
   355
sl@0
   356
void TestWindow1::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   357
	{
sl@0
   358
	if (aKey.iCode=='p')
sl@0
   359
		{
sl@0
   360
		RWindow win1(Client()->iWs);
sl@0
   361
		win1.Construct(iWin,1);
sl@0
   362
		RWindow win2(Client()->iWs);
sl@0
   363
		win2.Construct(win1,1);
sl@0
   364
		win1.Close();
sl@0
   365
		win2.SetExtent(TPoint(1,2),TSize(3,4));
sl@0
   366
		Client()->iWs.Flush();
sl@0
   367
		}
sl@0
   368
	else if (aKey.iCode=='q' || aKey.iCode=='Q')
sl@0
   369
		{
sl@0
   370
		RWindowGroup group1(Client()->iWs);
sl@0
   371
		RWindowGroup group2(Client()->iWs);
sl@0
   372
		group1.Construct(1);
sl@0
   373
		group2.Construct(2);
sl@0
   374
		group1.DefaultOwningWindow();
sl@0
   375
		group2.DefaultOwningWindow();
sl@0
   376
		group1.DefaultOwningWindow();
sl@0
   377
		group1.Close();
sl@0
   378
		group2.Close();
sl@0
   379
		Client()->iWs.Flush();
sl@0
   380
		}
sl@0
   381
	else if (aKey.iCode=='w' || aKey.iCode=='W')
sl@0
   382
		{
sl@0
   383
		RWindowGroup group1(Client()->iWs);
sl@0
   384
		RWindowGroup group2(Client()->iWs);
sl@0
   385
		group1.Construct(1);
sl@0
   386
		group2.Construct(2);
sl@0
   387
		group1.DefaultOwningWindow();
sl@0
   388
		group2.DefaultOwningWindow();
sl@0
   389
		group1.DefaultOwningWindow();
sl@0
   390
		group2.Close();
sl@0
   391
		group1.Close();
sl@0
   392
		Client()->iWs.Flush();
sl@0
   393
		}
sl@0
   394
	else if (aKey.iCode=='A' || aKey.iCode=='a')
sl@0
   395
		{
sl@0
   396
		/*RWindowGroup group(Client()->iWs);
sl@0
   397
		group.Construct(1);*/
sl@0
   398
		RDrawableWindow* win=new(ELeave) RBackedUpWindow(Client()->iWs);
sl@0
   399
		User::LeaveIfError(((RBackedUpWindow*)win)->Construct(*Client()->iGroup->GroupWin(),EGray2,(TUint32)this));   
sl@0
   400
		User::LeaveIfError(win->SetExtentErr(TPoint(20,20),TSize(600,200)));
sl@0
   401
		win->Activate();
sl@0
   402
		}
sl@0
   403
	else if (aKey.iCode=='B' || aKey.iCode=='b')
sl@0
   404
		{
sl@0
   405
		RWindowGroup group(Client()->iWs);
sl@0
   406
		group.Construct(344);
sl@0
   407
		//group.EnableReceiptOfFocus(EFalse);
sl@0
   408
		RBlankWindow blank(Client()->iWs);
sl@0
   409
		blank.Construct(group,345);
sl@0
   410
		blank.SetOrdinalPosition(0,1000);
sl@0
   411
		//blank.SetShadowHeight(0);
sl@0
   412
		//blank.SetShadowDisabled(ETrue);
sl@0
   413
		blank.Activate();
sl@0
   414
		RWindow window(Client()->iWs);
sl@0
   415
		window.Construct(group,346);
sl@0
   416
		}
sl@0
   417
	/*else if (aKey.iCode=='Z' || aKey.iCode=='z')		//TDes8 TPtr8 TPtrC8 TBufCBase8 TBuf8
sl@0
   418
		{
sl@0
   419
		TBuf<4> buf2(_L("1234"));
sl@0
   420
		TBuf<4> buf(_L("abcd"));
sl@0
   421
		TBufC<4> bufC(_L("WXYZ"));
sl@0
   422
		HBufC *hbuf=HBufC::NewL(4);
sl@0
   423
		TPtr pHBuf=hbuf->Des();
sl@0
   424
		pHBuf=buf2;
sl@0
   425
		TPtr ptr(hbuf->Des());
sl@0
   426
		//AFunction(ptr);
sl@0
   427
		TPtrC ptrC1(buf);
sl@0
   428
		//AFunction(ptrC1);
sl@0
   429
		TPtrC ptrC2(bufC);
sl@0
   430
		//AFunction(ptrC2);
sl@0
   431
		TPtrC ptrC3(hbuf->Des());
sl@0
   432
		AFunction(ptrC3);
sl@0
   433
		AFunction(buf);
sl@0
   434
		AFunction(bufC);
sl@0
   435
		AFunction(*hbuf);
sl@0
   436
		AFunction2(ptr);
sl@0
   437
		AFunction2(buf);
sl@0
   438
		}*/
sl@0
   439
	if (aKey.iCode==' ')
sl@0
   440
		{
sl@0
   441
		iDrawPolygon=!iDrawPolygon;
sl@0
   442
		iWin.Invalidate();
sl@0
   443
		}
sl@0
   444
	}
sl@0
   445
sl@0
   446
TestWindow2::TestWindow2() : CTWin(),
sl@0
   447
		iWid(0), iFontHeight(16), iPointerState(EPointerOut), iFilter(0), iCapture(EFalse), iGrab(EFalse)
sl@0
   448
	{
sl@0
   449
	__DECLARE_NAME(_S("TestWindow2"));
sl@0
   450
	}
sl@0
   451
sl@0
   452
TestWindow2::~TestWindow2()
sl@0
   453
	{
sl@0
   454
	}
sl@0
   455
sl@0
   456
void TestWindow2::InitWinL()
sl@0
   457
	{
sl@0
   458
	iPos.SetXY(40,iFont->AscentInPixels()+10);
sl@0
   459
	TPoint next(0,iFont->HeightInPixels()+10);
sl@0
   460
	iPosBits=iPos+next;
sl@0
   461
	iPosMem=iPosBits+next;
sl@0
   462
	iWin.PointerFilter(0xFFFFFFFF,iFilter);
sl@0
   463
	User::LeaveIfError(iWin.EnableOnEvents());
sl@0
   464
	iWin.ClaimPointerGrab();
sl@0
   465
	}
sl@0
   466
sl@0
   467
void TestWindow2::Draw()
sl@0
   468
	{
sl@0
   469
	TInt pen=0;
sl@0
   470
	switch(iPointerState)
sl@0
   471
		{
sl@0
   472
		case EPointerIn:
sl@0
   473
			pen=0;
sl@0
   474
			break;
sl@0
   475
		case EPointerOut:
sl@0
   476
			pen=5;
sl@0
   477
			break;
sl@0
   478
		case EPointerUndefined:
sl@0
   479
			pen=15;
sl@0
   480
			break;
sl@0
   481
		}
sl@0
   482
	iGc->SetPenColor(TRgb::Gray16(pen));
sl@0
   483
	iGc->SetBrushColor(iBackColor);
sl@0
   484
	DrawBorder();
sl@0
   485
	iGc->DrawText(iBuf,iPos);
sl@0
   486
	iGc->DrawText(iBufBits,iPosBits);
sl@0
   487
	iGc->DrawText(iBufMem,iPosMem);
sl@0
   488
	}
sl@0
   489
sl@0
   490
void TestWindow2::NewText(TPoint &pos,TInt &width,TDes &des)
sl@0
   491
	{
sl@0
   492
	TInt newWid=iFont->TextWidthInPixels(des);
sl@0
   493
	Invalidate(TRect(pos-TSize(0,iFont->AscentInPixels()),pos+TSize(Max(width,newWid),iFont->DescentInPixels())));
sl@0
   494
	width=newWid;
sl@0
   495
	}
sl@0
   496
sl@0
   497
void TestWindow2::PointerState(EPointerState aState)
sl@0
   498
	{
sl@0
   499
	switch(aState)
sl@0
   500
		{
sl@0
   501
		case EPointerIn:
sl@0
   502
			iBackColor=TRgb::Gray16(15);
sl@0
   503
			break;
sl@0
   504
		case EPointerOut:
sl@0
   505
			iBackColor=TRgb::Gray16(12);
sl@0
   506
			break;
sl@0
   507
		case EPointerUndefined:
sl@0
   508
			iBackColor=TRgb::Gray16(4);
sl@0
   509
			break;
sl@0
   510
		}
sl@0
   511
	iWin.SetBackgroundColor(iBackColor);
sl@0
   512
	Invalidate();
sl@0
   513
	iPointerState=aState;
sl@0
   514
	}
sl@0
   515
sl@0
   516
void TestWindow2::SwitchOn(const TTime &)
sl@0
   517
	{
sl@0
   518
	iWin.SetBackgroundColor(TRgb(0,0,0));
sl@0
   519
	Client()->iWs.Flush();
sl@0
   520
	User::After(TTimeIntervalMicroSeconds32(500000));
sl@0
   521
	PointerState(iPointerState);
sl@0
   522
	}
sl@0
   523
sl@0
   524
void TestWindow2::PointerEnter(const TTime &)
sl@0
   525
	{
sl@0
   526
	PointerState(EPointerIn);
sl@0
   527
	}
sl@0
   528
sl@0
   529
void TestWindow2::PointerExit(const TTime &)
sl@0
   530
	{
sl@0
   531
	PointerState(EPointerOut);
sl@0
   532
	}
sl@0
   533
sl@0
   534
void TestWindow2::RequestPointerRepeat()
sl@0
   535
	{
sl@0
   536
	iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(200000),iRepeatRect);
sl@0
   537
	}
sl@0
   538
sl@0
   539
void TestWindow2::PointerL(const TPointerEvent &pointer,const TTime &aTime)
sl@0
   540
	{
sl@0
   541
	if (pointer.iType==TPointerEvent::EButtonRepeat)
sl@0
   542
		{
sl@0
   543
		iRepeatCount++;
sl@0
   544
		SetBufBits();
sl@0
   545
		RequestPointerRepeat();
sl@0
   546
		}
sl@0
   547
	else
sl@0
   548
		{
sl@0
   549
		iRepeatCount=0;
sl@0
   550
		CTWin::PointerL(pointer,aTime);
sl@0
   551
		iBuf.Format(TRefByValue<const TDesC>(_L("Pos(%d,%d)(%d,%d), 0x%x")),pointer.iPosition.iX,pointer.iPosition.iY,pointer.iParentPosition.iX,pointer.iParentPosition.iY,pointer.iModifiers);
sl@0
   552
		NewText(iPos,iWid,iBuf);
sl@0
   553
		if (pointer.iType==TPointerEvent::EButton1Down)
sl@0
   554
			{
sl@0
   555
			iRepeatRect=TRect(pointer.iPosition-TPoint(5,5),pointer.iPosition+TPoint(5,5));
sl@0
   556
			RequestPointerRepeat();
sl@0
   557
			}
sl@0
   558
		SetBufBits();
sl@0
   559
		}
sl@0
   560
	}
sl@0
   561
sl@0
   562
void TestWindow2::SetBufBits()
sl@0
   563
	{
sl@0
   564
	iBufBits.Format(TRefByValue<const TDesC>(_L("Filter=0x%x, Capture[%s], Grab[%s], Repeat[%d]")),iFilter,
sl@0
   565
									 iCapture ? _S("On") : _S("Off"),
sl@0
   566
									 iGrab ? _S("On") : _S("Off"),
sl@0
   567
									 iRepeatCount);
sl@0
   568
	NewText(iPosBits,iWidBits,iBufBits);
sl@0
   569
	Invalidate();
sl@0
   570
	}
sl@0
   571
sl@0
   572
void TestWindow2::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   573
	{
sl@0
   574
	switch(aKey.iCode)
sl@0
   575
		{
sl@0
   576
		case ',':	// Unshifted <
sl@0
   577
		case '.':	// Unshifted >
sl@0
   578
			{
sl@0
   579
			if (aKey.iCode==',')
sl@0
   580
				{
sl@0
   581
				if (iFontHeight>1)
sl@0
   582
					iFontHeight-=1;
sl@0
   583
				}
sl@0
   584
			else
sl@0
   585
				iFontHeight+=1;
sl@0
   586
			CFbsFont *newFont;
sl@0
   587
			TFontSpec fspec(KTestFontTypefaceName,iFontHeight*KTwipsPerPoint);
sl@0
   588
			User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)newFont, fspec));
sl@0
   589
sl@0
   590
			Client()->iScreen->ReleaseFont(iFont);
sl@0
   591
			iFont=newFont;
sl@0
   592
			iWid=iFont->TextWidthInPixels(iBuf);
sl@0
   593
			Invalidate();
sl@0
   594
			}
sl@0
   595
			break;
sl@0
   596
		case '?':
sl@0
   597
			iBufMem.Format(TRefByValue<const TDesC>(_L("Count=%d")),Client()->iWs.HeapCount());
sl@0
   598
			NewText(iPosMem,iWidMem,iBufMem);
sl@0
   599
			break;
sl@0
   600
		case 'c':
sl@0
   601
			iCapture=(TBool)!iCapture;
sl@0
   602
			iWin.SetPointerCapture(iCapture);
sl@0
   603
			SetBufBits();
sl@0
   604
			break;
sl@0
   605
		case 'g':
sl@0
   606
			iGrab=(TBool)!iGrab;
sl@0
   607
			iWin.SetPointerGrab(iGrab);
sl@0
   608
			SetBufBits();
sl@0
   609
			break;
sl@0
   610
		case ' ':
sl@0
   611
			{
sl@0
   612
			iFilter=(iFilter+1)%8;
sl@0
   613
			iWin.PointerFilter(0xFFFFFFFF,iFilter);
sl@0
   614
			SetBufBits();
sl@0
   615
			if (iFilter&EPointerFilterEnterExit)
sl@0
   616
				PointerState(EPointerUndefined);
sl@0
   617
			else
sl@0
   618
				PointerState(EPointerOut);
sl@0
   619
			}
sl@0
   620
		case 's':
sl@0
   621
		case 'S':
sl@0
   622
			{
sl@0
   623
			CWsBitmap* bitmap=new(ELeave) CWsBitmap(Client()->iWs);
sl@0
   624
			CleanupStack::PushL(bitmap);
sl@0
   625
			User::LeaveIfError(bitmap->Create(Client()->iScreen->SizeInPixels(),EGray4));
sl@0
   626
			User::LeaveIfError(Client()->iScreen->CopyScreenToBitmap(bitmap));
sl@0
   627
			CleanupStack::Pop();
sl@0
   628
			}
sl@0
   629
			break;
sl@0
   630
		default:
sl@0
   631
			iBufMem.Format(TRefByValue<const TDesC>(_L("Key=%d")),aKey.iCode);
sl@0
   632
			NewText(iPosMem,iWidMem,iBufMem);
sl@0
   633
			break;
sl@0
   634
		}
sl@0
   635
	}
sl@0
   636
sl@0
   637
TestWindow3::TestWindow3() : CTWin()
sl@0
   638
	{
sl@0
   639
	__DECLARE_NAME(_S("TestWindow3"));
sl@0
   640
	}
sl@0
   641
sl@0
   642
TestWindow3::~TestWindow3()
sl@0
   643
	{
sl@0
   644
	delete iBitmap;
sl@0
   645
	}
sl@0
   646
sl@0
   647
void TestWindow3::Resized(const TSize &aNewSize)
sl@0
   648
	{
sl@0
   649
	CTBaseWin::Resized(aNewSize);
sl@0
   650
	SetShape(iShapeNum);
sl@0
   651
	DrawNow();
sl@0
   652
	}
sl@0
   653
sl@0
   654
void TestWindow3::InitWinL()
sl@0
   655
	{
sl@0
   656
	iCornerType=EWindowCorner3;
sl@0
   657
	iWin.PointerFilter(EPointerFilterDrag,0);	// Clear drag filter
sl@0
   658
	iWin.SetPointerGrab(ETrue);
sl@0
   659
	iWin.SetBackgroundColor(TRgb::Gray256(230));
sl@0
   660
	iWin.SetCornerType(iCornerType);
sl@0
   661
	iBitmap=new(ELeave) CWsBitmap(Client()->iWs);
sl@0
   662
	User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME,0));
sl@0
   663
	iSize=iBitmap->SizeInPixels();
sl@0
   664
	}
sl@0
   665
sl@0
   666
void TestWindow3::Draw()
sl@0
   667
	{
sl@0
   668
	iGc->BitBlt(TPoint(0,0),iBitmap);
sl@0
   669
	TSize bitSize(iBitmap->SizeInPixels());
sl@0
   670
	TSize winSize(Size());
sl@0
   671
	iGc->Clear(TRect(bitSize.iWidth,0,winSize.iWidth,bitSize.iHeight));
sl@0
   672
	iGc->Clear(TRect(0,bitSize.iHeight,winSize.iWidth,winSize.iHeight));
sl@0
   673
	}
sl@0
   674
sl@0
   675
void TestWindow3::SetShape(TInt aShapeNum)
sl@0
   676
	{
sl@0
   677
	iShapeNum=aShapeNum;
sl@0
   678
	TSize size=Size();
sl@0
   679
	switch(iShapeNum)
sl@0
   680
		{
sl@0
   681
		case 0:
sl@0
   682
			{
sl@0
   683
			TRegionFix<4> shape;
sl@0
   684
			shape.AddRect(TRect(0,0,size.iWidth,size.iHeight>>2));
sl@0
   685
			shape.AddRect(TRect(0,size.iHeight>>2,size.iWidth>>2,size.iHeight-(size.iHeight>>2)));
sl@0
   686
			shape.AddRect(TRect(size.iWidth-(size.iWidth>>2),size.iHeight>>2,size.iWidth,size.iHeight-(size.iHeight>>2)));
sl@0
   687
			shape.AddRect(TRect(0,size.iHeight-(size.iHeight>>2),size.iWidth,size.iHeight));
sl@0
   688
			iWin.SetShape(shape);
sl@0
   689
			}
sl@0
   690
			break;
sl@0
   691
		case 1:
sl@0
   692
			{
sl@0
   693
			TRegionFix<3> shape;
sl@0
   694
			shape.AddRect(TRect(size.iWidth>>2,0,size.iWidth-(size.iWidth>>2),size.iHeight>>2));
sl@0
   695
			shape.AddRect(TRect(0,size.iHeight>>2,size.iWidth,size.iHeight-(size.iHeight>>2)));
sl@0
   696
			shape.AddRect(TRect(size.iWidth>>2,size.iHeight-(size.iHeight>>2),size.iWidth-(size.iWidth>>2),size.iHeight));
sl@0
   697
			iWin.SetShape(shape);
sl@0
   698
			}
sl@0
   699
			break;
sl@0
   700
		case 2:
sl@0
   701
			{
sl@0
   702
			RRegion shape;
sl@0
   703
			for(TInt index=0;index<(size.iHeight-1);index++)
sl@0
   704
				{
sl@0
   705
				TInt xFactor=(size.iWidth>>1)*index/size.iHeight;
sl@0
   706
				shape.AddRect(TRect((size.iWidth>>1)-xFactor,index,(size.iWidth>>1)+xFactor,index+1));
sl@0
   707
				}
sl@0
   708
			iWin.SetShape(shape);
sl@0
   709
			shape.Close();
sl@0
   710
			}
sl@0
   711
			break;
sl@0
   712
		}
sl@0
   713
	}
sl@0
   714
sl@0
   715
void TestWindow3::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   716
	{
sl@0
   717
	if (aKey.iCode=='f')
sl@0
   718
		{
sl@0
   719
		TSize scrSize(Client()->iScreen->SizeInPixels());
sl@0
   720
		if (scrSize==iWin.Size())
sl@0
   721
			{
sl@0
   722
			scrSize.iWidth/=2;
sl@0
   723
			scrSize.iHeight/=2;
sl@0
   724
			}
sl@0
   725
		SetExtL(TPoint(),scrSize);
sl@0
   726
		}
sl@0
   727
	else if (aKey.iCode>='0' && aKey.iCode<='5')
sl@0
   728
		{
sl@0
   729
		switch(aKey.iCode)
sl@0
   730
			{
sl@0
   731
			case '0':
sl@0
   732
				iCornerType=EWindowCornerSquare;
sl@0
   733
				break;
sl@0
   734
			case '1':
sl@0
   735
				iCornerType=EWindowCorner1;
sl@0
   736
				break;
sl@0
   737
			case '2':
sl@0
   738
				iCornerType=EWindowCorner2;
sl@0
   739
				break;
sl@0
   740
			case '3':
sl@0
   741
				iCornerType=EWindowCorner3;
sl@0
   742
				break;
sl@0
   743
			case '5':
sl@0
   744
				iCornerType=EWindowCorner5;
sl@0
   745
				break;
sl@0
   746
			}
sl@0
   747
		iWin.SetCornerType(iCornerType,iCornerFlags);
sl@0
   748
		}
sl@0
   749
	else switch(User::LowerCase(aKey.iCode))
sl@0
   750
		{
sl@0
   751
		case '6':
sl@0
   752
			SetShape(0);
sl@0
   753
			break;
sl@0
   754
		case '7':
sl@0
   755
			SetShape(1);
sl@0
   756
			break;
sl@0
   757
		case '8':
sl@0
   758
			SetShape(2);
sl@0
   759
			break;
sl@0
   760
		case 'a':
sl@0
   761
			iCornerFlags^=EWindowCornerNotTL;
sl@0
   762
			goto setcorner;
sl@0
   763
		case 'b':
sl@0
   764
			iCornerFlags^=EWindowCornerNotTR;
sl@0
   765
			goto setcorner;
sl@0
   766
		case 'c':
sl@0
   767
			iCornerFlags^=EWindowCornerNotBL;
sl@0
   768
			goto setcorner;
sl@0
   769
		case 'd':
sl@0
   770
			iCornerFlags^=EWindowCornerNotBR;
sl@0
   771
setcorner:	iWin.SetCornerType(iCornerType,iCornerFlags);
sl@0
   772
			break;
sl@0
   773
		}
sl@0
   774
	}
sl@0
   775
sl@0
   776
void TestWindow3::ScreenDeviceChangedL()
sl@0
   777
	{
sl@0
   778
	TSize scrSize(Client()->iScreen->SizeInPixels());
sl@0
   779
	if (scrSize==iWin.Size())
sl@0
   780
		{
sl@0
   781
		scrSize.iWidth/=2;
sl@0
   782
		scrSize.iHeight/=2;
sl@0
   783
		}
sl@0
   784
	SetExtL(TPoint(),scrSize);
sl@0
   785
	}
sl@0
   786
sl@0
   787
TestWindow4::TestWindow4() : CTWin()
sl@0
   788
	{
sl@0
   789
	__DECLARE_NAME(_S("TestWindow4"));
sl@0
   790
	}
sl@0
   791
sl@0
   792
void TestWindow4::SetSwappedSize()
sl@0
   793
	{
sl@0
   794
	if (iVertical)
sl@0
   795
		{
sl@0
   796
		iSwappedSize.iHeight=iSize.iWidth;
sl@0
   797
		iSwappedSize.iWidth=iSize.iHeight;
sl@0
   798
		}
sl@0
   799
	else
sl@0
   800
		iSwappedSize=iSize;
sl@0
   801
	}
sl@0
   802
sl@0
   803
void TestWindow4::InitWin()
sl@0
   804
	{
sl@0
   805
	iBasePos.SetXY(10,20);
sl@0
   806
	iWin.SetBackgroundColor();
sl@0
   807
	SetSwappedSize();
sl@0
   808
	//iTemp=1;
sl@0
   809
	}
sl@0
   810
sl@0
   811
void TestWindow4::Resized(const TSize &aSize)
sl@0
   812
	{
sl@0
   813
	CTBaseWin::Resized(aSize);
sl@0
   814
	SetSwappedSize();
sl@0
   815
	Invalidate();
sl@0
   816
	iWin.BeginRedraw();
sl@0
   817
	iGc->Activate(iWin);
sl@0
   818
	iGc->UseFont((CFont *)iFont);
sl@0
   819
	Draw(ETrue);
sl@0
   820
	iGc->Deactivate();
sl@0
   821
	iWin.EndRedraw();
sl@0
   822
	}
sl@0
   823
sl@0
   824
void TestWindow4::Draw()
sl@0
   825
	{
sl@0
   826
	Draw(EFalse);
sl@0
   827
	}
sl@0
   828
sl@0
   829
void TestWindow4::Draw(TBool aSetCursor)
sl@0
   830
	{
sl@0
   831
	TPoint tl(iBasePos.iX,iBasePos.iY-iFont->AscentInPixels());
sl@0
   832
	TRect rect(1,1,iSize.iWidth-1,iSize.iHeight);
sl@0
   833
//
sl@0
   834
	/*switch (iTemp)
sl@0
   835
		{
sl@0
   836
	case 1:
sl@0
   837
		iGc->SetBrushColor(TRgb::Gray4(2));
sl@0
   838
		break;
sl@0
   839
	case 2:*/
sl@0
   840
		iGc->SetBrushColor(TRgb::Gray16(13));
sl@0
   841
		/*break;
sl@0
   842
	case 3:
sl@0
   843
		iGc->SetBrushColor(TRgb::Gray16(12));
sl@0
   844
		break;
sl@0
   845
	case 4:
sl@0
   846
		iGc->SetBrushColor(TRgb::Gray16(11));
sl@0
   847
	default:
sl@0
   848
		break;
sl@0
   849
		}*/
sl@0
   850
	iGc->Clear(rect);
sl@0
   851
//
sl@0
   852
	TPoint pos(iBasePos);
sl@0
   853
	iGc->SetPenColor(TRgb::Gray16(0));
sl@0
   854
	iGc->DrawRect(TRect(iSize));
sl@0
   855
	TInt index=0;
sl@0
   856
	TInt ToGo=TxtBuf.Length();
sl@0
   857
	TInt lineHeight=iFont->HeightInPixels()+2;
sl@0
   858
	rect.iTl.iY=rect.iBr.iY=tl.iY;
sl@0
   859
	while((pos.iY+iFont->DescentInPixels())<(iSwappedSize.iHeight-1))
sl@0
   860
		{
sl@0
   861
		rect.iBr.iY+=lineHeight;
sl@0
   862
		iGc->Clear(rect);
sl@0
   863
		if (ToGo>0)
sl@0
   864
			{
sl@0
   865
			TInt len=iFont->TextCount(TxtBuf.Right(ToGo),iSwappedSize.iWidth-2*pos.iX);
sl@0
   866
			if (len==0)
sl@0
   867
				len=1;
sl@0
   868
			if (iVertical)
sl@0
   869
				iGc->DrawTextVertical(TxtBuf.Mid(index,len),TPoint(pos.iY,iSize.iHeight-pos.iX),ETrue);
sl@0
   870
			else
sl@0
   871
				iGc->DrawText(TxtBuf.Mid(index,len),pos);
sl@0
   872
			ToGo-=len;
sl@0
   873
			if (ToGo==0 && aSetCursor)
sl@0
   874
				{
sl@0
   875
				TPoint cursorPos;
sl@0
   876
				if (iVertical)
sl@0
   877
					cursorPos=TPoint(pos.iY-iFont->AscentInPixels(),iSize.iHeight-pos.iX)+TPoint(0,iFont->TextWidthInPixels(TxtBuf.Mid(index,len)));
sl@0
   878
				else
sl@0
   879
					cursorPos=pos+TPoint(iFont->TextWidthInPixels(TxtBuf.Mid(index,len)),0);
sl@0
   880
				SetCursor(cursorPos);
sl@0
   881
				}
sl@0
   882
			index+=len;
sl@0
   883
			}
sl@0
   884
		pos.iY+=lineHeight;
sl@0
   885
		rect.iTl.iY=rect.iBr.iY;
sl@0
   886
		}
sl@0
   887
	rect.iBr.iY=iSwappedSize.iHeight-1;
sl@0
   888
	iGc->Clear(rect);
sl@0
   889
	}
sl@0
   890
sl@0
   891
void TestWindow4::SetCursor(const TPoint &aPos)
sl@0
   892
	{
sl@0
   893
	TTextCursor cursor;
sl@0
   894
	cursor.iType=TTextCursor::ETypeRectangle;
sl@0
   895
	if (iVertical)
sl@0
   896
		{
sl@0
   897
		cursor.iAscent=2;
sl@0
   898
		cursor.iHeight=2;
sl@0
   899
		cursor.iWidth=iFont->HeightInPixels();
sl@0
   900
		}
sl@0
   901
	else
sl@0
   902
		{
sl@0
   903
		cursor.iAscent=iFont->AscentInPixels();
sl@0
   904
		cursor.iHeight=iFont->HeightInPixels();
sl@0
   905
		cursor.iWidth=20;
sl@0
   906
		}
sl@0
   907
	cursor.iFlags=0;
sl@0
   908
//	cursor.iColor=TRgb(255,255,255);
sl@0
   909
	cursor.iColor=TRgb(128,128,128);
sl@0
   910
	Client()->iGroup->GroupWin()->SetTextCursor(iWin, aPos, cursor);
sl@0
   911
	}
sl@0
   912
sl@0
   913
void TestWindow4::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   914
	{
sl@0
   915
	TChar chr=aKey.iCode;
sl@0
   916
sl@0
   917
	if (aKey.iCode==32 && aKey.iModifiers&EModifierFunc)
sl@0
   918
		{
sl@0
   919
		iWin.Invalidate();
sl@0
   920
		iVertical=!iVertical;
sl@0
   921
		SetSwappedSize();
sl@0
   922
		}
sl@0
   923
	else if (aKey.iCode>=32 && aKey.iCode<4000)
sl@0
   924
		{
sl@0
   925
		TBool invalidate=EFalse;
sl@0
   926
		if (TxtBuf.Length()==TxtBuf.MaxLength())
sl@0
   927
			{
sl@0
   928
			TxtBuf=TxtBuf.Right(TxtBuf.Length()-1);
sl@0
   929
			invalidate=ETrue;
sl@0
   930
			}
sl@0
   931
		TxtBuf.Append(chr);
sl@0
   932
		
sl@0
   933
		TPoint pos(iBasePos);
sl@0
   934
		TInt index=0;
sl@0
   935
		TInt ToGo=TxtBuf.Length();
sl@0
   936
		while(ToGo>0)
sl@0
   937
			{
sl@0
   938
			TInt len=iFont->TextCount(TxtBuf.Right(ToGo),iSwappedSize.iWidth-2*pos.iX);
sl@0
   939
			if (len==0)
sl@0
   940
				len=1;
sl@0
   941
			if (len==ToGo)
sl@0
   942
				break;
sl@0
   943
			index+=len;
sl@0
   944
			ToGo-=len;
sl@0
   945
			pos.iY+=iFont->HeightInPixels()+2;
sl@0
   946
			}
sl@0
   947
		pos.iX+=iFont->TextWidthInPixels(TxtBuf.Mid(index,ToGo-1));
sl@0
   948
		if (invalidate)
sl@0
   949
			iWin.Invalidate(TRect(iBasePos.iX,iBasePos.iY-iFont->AscentInPixels(),iSize.iWidth-iBasePos.iX,iSize.iHeight));
sl@0
   950
		else
sl@0
   951
			{
sl@0
   952
			iGc->Activate(iWin);
sl@0
   953
			iGc->UseFont(iFont);
sl@0
   954
			if (iVertical)
sl@0
   955
				iGc->DrawTextVertical(TxtBuf.Mid(index+ToGo-1,1),TPoint(pos.iY,iSize.iHeight-pos.iX),ETrue);
sl@0
   956
			else
sl@0
   957
				iGc->DrawText(TxtBuf.Mid(index+ToGo-1,1),pos);
sl@0
   958
			iGc->Deactivate();
sl@0
   959
			}
sl@0
   960
		pos.iX+=iFont->TextWidthInPixels(TxtBuf.Mid(index+ToGo-1));
sl@0
   961
		SetCursor(iVertical ? TPoint(pos.iY-iFont->AscentInPixels(),iSize.iHeight-pos.iX) : pos);
sl@0
   962
		}
sl@0
   963
	}
sl@0
   964
sl@0
   965
TestWindow5::TestWindow5(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray4)
sl@0
   966
	{
sl@0
   967
	__DECLARE_NAME(_S("TestWindow5"));
sl@0
   968
	}
sl@0
   969
sl@0
   970
void TestWindow5::Resized(const TSize &aNewSize)
sl@0
   971
	{
sl@0
   972
	CTBaseWin::Resized(aNewSize);
sl@0
   973
	iGc->Activate(*DrawableWin());
sl@0
   974
	iGc->SetBrushColor(TRgb::Gray256(128));
sl@0
   975
	iGc->Clear(TRect(aNewSize));
sl@0
   976
	iGc->UseBrushPattern(&iBrushBit);
sl@0
   977
	iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
sl@0
   978
	iGc->DrawEllipse(TRect(aNewSize));
sl@0
   979
	iGc->Deactivate();
sl@0
   980
	}
sl@0
   981
sl@0
   982
void TestWindow5::InitWinL()
sl@0
   983
	{
sl@0
   984
	iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit);
sl@0
   985
	iWin.SetPointerGrab(ETrue);
sl@0
   986
	iOrdPri=-1;
sl@0
   987
	iWin.SetOrdinalPosition(0,iOrdPri);
sl@0
   988
	User::LeaveIfError(iBrushBit.Load(TEST_BITMAP_NAME,0));
sl@0
   989
	}
sl@0
   990
sl@0
   991
void TestWindow5::Draw()
sl@0
   992
	{
sl@0
   993
	Panic(EConnectPanicRedrawToBackedUpWindow);
sl@0
   994
	}
sl@0
   995
sl@0
   996
void TestWindow5::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   997
	{
sl@0
   998
	switch(aKey.iCode)
sl@0
   999
		{
sl@0
  1000
		case ' ':
sl@0
  1001
			iOrdPri=(iOrdPri<0)?1:-1;
sl@0
  1002
			iWin.SetOrdinalPosition(0,iOrdPri);
sl@0
  1003
			break;
sl@0
  1004
		case 'z':
sl@0
  1005
			SetPos(iPos-TPoint(2,1));
sl@0
  1006
			SetPos(iPos-TPoint(-1,-1));
sl@0
  1007
			SetPos(iPos-TPoint(2,3));
sl@0
  1008
			SetPos(iPos-TPoint(-2,-1));
sl@0
  1009
			SetPos(iPos-TPoint(-2,-3));
sl@0
  1010
			SetPos(iPos-TPoint(1,1));
sl@0
  1011
			break;
sl@0
  1012
		}
sl@0
  1013
	}
sl@0
  1014
sl@0
  1015
TestWindow6::TestWindow6(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray16), iGray(0)
sl@0
  1016
	{
sl@0
  1017
	__DECLARE_NAME(_S("TestWindow6"));
sl@0
  1018
	}
sl@0
  1019
sl@0
  1020
TestWindow6::~TestWindow6()
sl@0
  1021
	{
sl@0
  1022
	delete iGc;
sl@0
  1023
	delete iGc2;
sl@0
  1024
	}
sl@0
  1025
sl@0
  1026
void TestWindow6::Resized(const TSize &aNewSize)
sl@0
  1027
	{
sl@0
  1028
	CTBaseWin::Resized(aNewSize);
sl@0
  1029
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1030
	iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1031
	if (iOldSize.iWidth<aNewSize.iWidth)
sl@0
  1032
		iGc->DrawRect(TRect(iOldSize.iWidth,0,aNewSize.iWidth,iOldSize.iHeight));
sl@0
  1033
	if (iOldSize.iHeight<aNewSize.iHeight)
sl@0
  1034
		iGc->DrawRect(TRect(0,iOldSize.iHeight,aNewSize.iWidth,aNewSize.iHeight));
sl@0
  1035
	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
  1036
	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1037
	iOldSize=aNewSize;
sl@0
  1038
	TPoint pos;
sl@0
  1039
	for(TInt index=0;index<3;index++)
sl@0
  1040
		{
sl@0
  1041
		pos.iY=index*aNewSize.iHeight/3;
sl@0
  1042
		for(pos.iX=0;pos.iX<aNewSize.iWidth;pos.iX++)
sl@0
  1043
			{
sl@0
  1044
			TInt val=pos.iX*255/aNewSize.iWidth;
sl@0
  1045
			TRgb rgb(index==0?val:0,index==1?val:0,index==2?val:0);
sl@0
  1046
			iGc->SetPenColor(rgb);
sl@0
  1047
			iGc->DrawLine(pos,pos+TSize(0,aNewSize.iHeight/3));
sl@0
  1048
			}
sl@0
  1049
		}
sl@0
  1050
	iGc->SetPenColor(TRgb(255,255,255));
sl@0
  1051
	}
sl@0
  1052
sl@0
  1053
void TestWindow6::InitWinL()
sl@0
  1054
	{
sl@0
  1055
	iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit);
sl@0
  1056
	User::LeaveIfError(iWin.AllocPointerMoveBuffer(KPointerMoveBufferSize,0));
sl@0
  1057
	iWin.DisablePointerMoveBuffer();
sl@0
  1058
	iWin.SetPointerGrab(ETrue);
sl@0
  1059
	iGc=new(ELeave) CWindowGc(Client()->iScreen);
sl@0
  1060
	User::LeaveIfError(iGc->Construct());
sl@0
  1061
	iGc2=new(ELeave) CWindowGc(Client()->iScreen);
sl@0
  1062
	User::LeaveIfError(iGc2->Construct());
sl@0
  1063
	iWin.SetCornerType(EWindowCorner1);
sl@0
  1064
	iGc->Activate(iWin);
sl@0
  1065
	iGc->SetBrushColor(TRgb::Gray256(230));
sl@0
  1066
	iGc2->Activate(iWin);
sl@0
  1067
	iGc2->SetBrushColor(TRgb::Gray256(230));	
sl@0
  1068
	iCurGc=iGc;
sl@0
  1069
	}
sl@0
  1070
sl@0
  1071
void TestWindow6::Draw()
sl@0
  1072
	{
sl@0
  1073
	Panic(EConnectPanicRedrawToBackedUpWindow);
sl@0
  1074
	}
sl@0
  1075
sl@0
  1076
void TestWindow6::PointerBufferReady(const TTime &)
sl@0
  1077
	{
sl@0
  1078
	TPoint pnts[KPointerMoveBufferSize];
sl@0
  1079
	TPtr8 ptr((TUint8 *)&pnts,sizeof(pnts));
sl@0
  1080
	TInt numPnts=iWin.RetrievePointerMoveBuffer(ptr);
sl@0
  1081
	for(TInt index=0;index<numPnts;index++)
sl@0
  1082
		iCurGc->DrawLineTo(pnts[index]);
sl@0
  1083
	}
sl@0
  1084
sl@0
  1085
void TestWindow6::PointerL(const TPointerEvent &pointer,const TTime &aTime)
sl@0
  1086
	{
sl@0
  1087
	switch(pointer.iType)
sl@0
  1088
		{
sl@0
  1089
		case TPointerEvent::EButton1Down:
sl@0
  1090
			if (pointer.iModifiers&(EModifierCtrl|EModifierShift))
sl@0
  1091
				{
sl@0
  1092
				iDragging=ETrue;
sl@0
  1093
				iWin.EnablePointerMoveBuffer();
sl@0
  1094
				if (pointer.iModifiers&EModifierCtrl)
sl@0
  1095
					iCurGc=iGc;
sl@0
  1096
				else if (pointer.iModifiers&EModifierShift)
sl@0
  1097
					iCurGc=iGc2;
sl@0
  1098
				iCurGc->MoveTo(pointer.iPosition);
sl@0
  1099
				return;
sl@0
  1100
				}
sl@0
  1101
			break;
sl@0
  1102
		case TPointerEvent::EButton1Up:
sl@0
  1103
			if (iDragging)
sl@0
  1104
				{
sl@0
  1105
				iDragging=EFalse;
sl@0
  1106
				iWin.DisablePointerMoveBuffer();
sl@0
  1107
				return;
sl@0
  1108
				}
sl@0
  1109
		default:;
sl@0
  1110
		}
sl@0
  1111
	CTBackedUpWin::PointerL(pointer,aTime);
sl@0
  1112
	}
sl@0
  1113
sl@0
  1114
void TestWindow6::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
  1115
	{
sl@0
  1116
	if (TChar(aKey.iCode).IsDigit())
sl@0
  1117
		{
sl@0
  1118
		TInt wid=1;
sl@0
  1119
		for(TUint i=0;i<(aKey.iCode-'0');i++)
sl@0
  1120
			wid+=i;
sl@0
  1121
		iCurGc->SetPenSize(TSize(wid,wid));
sl@0
  1122
		}
sl@0
  1123
	else switch(aKey.iCode)
sl@0
  1124
		{
sl@0
  1125
		case ',':	// Unshifted <
sl@0
  1126
		case '.':	// Unshifted >
sl@0
  1127
			{
sl@0
  1128
			if (aKey.iCode==',')
sl@0
  1129
				{
sl@0
  1130
				if (iGray>0)
sl@0
  1131
					iGray-=1;
sl@0
  1132
				}
sl@0
  1133
			else if (iGray<15)
sl@0
  1134
				iGray+=1;
sl@0
  1135
			iCurGc->SetPenColor(TRgb::Gray16(iGray));
sl@0
  1136
			}
sl@0
  1137
			break;
sl@0
  1138
		}
sl@0
  1139
	}
sl@0
  1140
sl@0
  1141
void TestWindow6::AssignGC(CWindowGc &)
sl@0
  1142
	{
sl@0
  1143
	}
sl@0
  1144
sl@0
  1145
TestWindow7::TestWindow7(TBool aGrey2) : CTBackedUpWin(aGrey2?EGray2:EGray4)
sl@0
  1146
	{
sl@0
  1147
	__DECLARE_NAME(_S("TestWindow1"));
sl@0
  1148
	}
sl@0
  1149
sl@0
  1150
TestWindow7::~TestWindow7()
sl@0
  1151
	{
sl@0
  1152
	delete iSpriteBitmap;
sl@0
  1153
	delete iSpriteMaskBitmap;
sl@0
  1154
	delete iPointerCursor;
sl@0
  1155
	delete iSprite4;
sl@0
  1156
	delete iSprite5;
sl@0
  1157
	delete iSprite2;
sl@0
  1158
	delete iSprite3;
sl@0
  1159
	delete iSprite1;
sl@0
  1160
	}
sl@0
  1161
sl@0
  1162
void DrawPointerCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aMode)
sl@0
  1163
	{
sl@0
  1164
	TInt mode=*(TInt *)aMode;
sl@0
  1165
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
sl@0
  1166
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1167
	aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1168
	aGc->DrawRect(TRect(aSize));
sl@0
  1169
	TInt size=mode+1;
sl@0
  1170
	TRect rect1(0,aSize.iHeight/2-size,aSize.iWidth,aSize.iHeight/2+size);
sl@0
  1171
	TRect rect2(aSize.iWidth/2-size,0,aSize.iWidth/2+size,aSize.iHeight);
sl@0
  1172
//
sl@0
  1173
	if (!aDoMask)
sl@0
  1174
		{
sl@0
  1175
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1176
		aGc->SetPenColor(TRgb::Gray4(0));
sl@0
  1177
		aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
  1178
		aGc->DrawRect(rect1);
sl@0
  1179
		aGc->DrawRect(rect2);
sl@0
  1180
		rect1.Shrink(1,1);
sl@0
  1181
		rect2.Shrink(1,1);
sl@0
  1182
		}
sl@0
  1183
//
sl@0
  1184
	aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1185
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
sl@0
  1186
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1187
	aGc->DrawRect(rect1);
sl@0
  1188
	aGc->DrawRect(rect2);
sl@0
  1189
	}
sl@0
  1190
sl@0
  1191
void DrawSprite(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
sl@0
  1192
	{
sl@0
  1193
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
sl@0
  1194
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1195
	aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1196
	aGc->DrawRect(TRect(aSize));
sl@0
  1197
	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1198
	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
sl@0
  1199
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
sl@0
  1200
	aGc->DrawEllipse(TRect(aSize));
sl@0
  1201
	}
sl@0
  1202
sl@0
  1203
void TestWindow7::InitWinL()
sl@0
  1204
	{
sl@0
  1205
	iPos1.SetXY(30,10);
sl@0
  1206
	iPos2.SetXY(50,40);
sl@0
  1207
	iPos3.SetXY(10,50);
sl@0
  1208
	iPos4.SetXY(10,10);
sl@0
  1209
	iPos5.SetXY(50,10);
sl@0
  1210
//
sl@0
  1211
	TSpriteCreateParams params(TSize(30,70),TPoint(0,0),DrawSprite);
sl@0
  1212
	TSpriteCreateParams paramarray[10];
sl@0
  1213
	params.iInterval=TTimeIntervalMicroSeconds32(200000);
sl@0
  1214
sl@0
  1215
	paramarray[0]=params;
sl@0
  1216
	paramarray[1]=params;
sl@0
  1217
	paramarray[2]=params;
sl@0
  1218
	paramarray[1].iSize=TSize(20,30);
sl@0
  1219
	paramarray[2].iSize=TSize(100,10);
sl@0
  1220
	paramarray[2].iInterval=TTimeIntervalMicroSeconds32(200000);
sl@0
  1221
	iSprite1=new(ELeave) CTSprite(Client()->iWs);
sl@0
  1222
	iSprite1->ConstructL(iWin,iPos1,3,&paramarray[0],ESpriteNoChildClip);
sl@0
  1223
//
sl@0
  1224
	params.iSize=TSize(20,30);
sl@0
  1225
	for(TInt index=0;index<10;index++)
sl@0
  1226
		{
sl@0
  1227
		paramarray[index]=params;
sl@0
  1228
		paramarray[index].iOffset=TPoint(index*20,index*4);
sl@0
  1229
		}
sl@0
  1230
	iSprite2=new(ELeave) CTSprite(Client()->iWs);
sl@0
  1231
	iSprite2->ConstructL(iWin,iPos2,10,&paramarray[0],0);
sl@0
  1232
//
sl@0
  1233
	params.iSize=TSize(100,10);
sl@0
  1234
	iSprite3=new(ELeave) CTSprite(Client()->iWs);
sl@0
  1235
	iSprite3->ConstructL(iWin,iPos3,1,&params,ESpriteFlash);
sl@0
  1236
//
sl@0
  1237
	params.iSize=TSize(32,32);
sl@0
  1238
	iSprite4=new(ELeave) CTSprite(Client()->iWs);
sl@0
  1239
	iSprite4->ConstructL(*Client()->iGroup->GroupWin(),iPos4,1,&params,0);
sl@0
  1240
//
sl@0
  1241
	params.iSize=TSize(16,64);
sl@0
  1242
	iSprite5=new(ELeave) CTSprite(Client()->iWs);
sl@0
  1243
	iSprite5->ConstructL(*Client()->iGroup->GroupWin(),iPos5,1,&params,ESpriteNoChildClip);
sl@0
  1244
//
sl@0
  1245
	iCurPos= &iPos1;
sl@0
  1246
	iCurSprite= iSprite1;
sl@0
  1247
//	iWin.SetBackgroundColor(TRgb::Gray256(170));
sl@0
  1248
	TSpriteCreateParams pcursor(TSize(24,48),TPoint(-12,-24),DrawPointerCursor,&iPointerMode);
sl@0
  1249
	iPointerCursor=new(ELeave) CTPointerCursor(Client()->iWs);
sl@0
  1250
	iPointerCursor->ConstructL(1,&pcursor,0,iSpriteBitmap,iSpriteMaskBitmap);
sl@0
  1251
	iWin.SetCustomPointerCursor(iPointerCursor->PointerCursor());
sl@0
  1252
	Client()->iGroup->GroupWin()->SetCustomPointerCursor(iPointerCursor->PointerCursor());
sl@0
  1253
	}
sl@0
  1254
sl@0
  1255
	
sl@0
  1256
void TestWindow7::Resized(const TSize &aNewSize)
sl@0
  1257
	{
sl@0
  1258
	CTBaseWin::Resized(aNewSize);
sl@0
  1259
	iGc->Activate(*DrawableWin());
sl@0
  1260
	Draw();
sl@0
  1261
	iGc->Deactivate();
sl@0
  1262
	}
sl@0
  1263
sl@0
  1264
void TestWindow7::Draw()
sl@0
  1265
	{
sl@0
  1266
	iGc->SetBrushColor(TRgb::Gray256(170));
sl@0
  1267
	iGc->Clear();
sl@0
  1268
	for(TInt xPos=0;xPos<iSize.iWidth;xPos+=50)
sl@0
  1269
		iGc->DrawLine(TPoint(xPos,0),TPoint(xPos,iSize.iHeight));
sl@0
  1270
	for(TInt yPos=0;yPos<iSize.iHeight;yPos+=50)
sl@0
  1271
		iGc->DrawLine(TPoint(0,yPos),TPoint(iSize.iWidth,yPos));
sl@0
  1272
	}
sl@0
  1273
sl@0
  1274
void TestWindow7::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
  1275
	{
sl@0
  1276
	switch(aKey.iCode)
sl@0
  1277
		{
sl@0
  1278
		case 'c':
sl@0
  1279
		case 'C':
sl@0
  1280
			{
sl@0
  1281
			iPointerMode=(iPointerMode+1)&EPointerModes;
sl@0
  1282
			TSpriteCreateParams params(iSpriteBitmap->SizeInPixels(),TPoint(0,0),DrawPointerCursor,&iPointerMode);
sl@0
  1283
			iPointerCursor->RedrawL(iSpriteBitmap,iSpriteMaskBitmap,&params);
sl@0
  1284
			break;
sl@0
  1285
			}
sl@0
  1286
		case ' ':
sl@0
  1287
			if (iCurSprite==iSprite1)
sl@0
  1288
				{
sl@0
  1289
				iCurPos= &iPos2;
sl@0
  1290
				iCurSprite= iSprite2;
sl@0
  1291
				}
sl@0
  1292
			else if (iCurSprite==iSprite2)
sl@0
  1293
				{
sl@0
  1294
				iCurPos= &iPos3;
sl@0
  1295
				iCurSprite= iSprite3;
sl@0
  1296
				}
sl@0
  1297
			else if (iCurSprite==iSprite3)
sl@0
  1298
				{
sl@0
  1299
				iCurPos= &iPos4;
sl@0
  1300
				iCurSprite= iSprite4;
sl@0
  1301
				}
sl@0
  1302
			else if (iCurSprite==iSprite4)
sl@0
  1303
				{
sl@0
  1304
				iCurPos= &iPos5;
sl@0
  1305
				iCurSprite= iSprite5;
sl@0
  1306
				}
sl@0
  1307
			else if (iCurSprite==iSprite5)
sl@0
  1308
				{
sl@0
  1309
				iCurPos= &iPos1;
sl@0
  1310
				iCurSprite= iSprite1;
sl@0
  1311
				}
sl@0
  1312
			break;
sl@0
  1313
		case '1':
sl@0
  1314
			iCurPos->iX-=5;
sl@0
  1315
			iCurSprite->Sprite().SetPosition(*iCurPos);
sl@0
  1316
			break;
sl@0
  1317
		case '2':
sl@0
  1318
			iCurPos->iX+=5;
sl@0
  1319
			iCurSprite->Sprite().SetPosition(*iCurPos);
sl@0
  1320
			break;
sl@0
  1321
		case '3':
sl@0
  1322
			iCurPos->iY-=5;
sl@0
  1323
			iCurSprite->Sprite().SetPosition(*iCurPos);
sl@0
  1324
			break;
sl@0
  1325
		case '4':
sl@0
  1326
			iCurPos->iY+=5;
sl@0
  1327
			iCurSprite->Sprite().SetPosition(*iCurPos);
sl@0
  1328
			break;
sl@0
  1329
		default:;
sl@0
  1330
		}
sl@0
  1331
	}
sl@0
  1332
sl@0
  1333
TestWindow8::TestWindow8() : CTBlankWindow()
sl@0
  1334
	{
sl@0
  1335
	__DECLARE_NAME(_S("TestWindow8"));
sl@0
  1336
	}
sl@0
  1337
sl@0
  1338
void TestWindow8::InitWin()
sl@0
  1339
	{
sl@0
  1340
	iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit);
sl@0
  1341
	iWin.SetPointerGrab(ETrue);
sl@0
  1342
	iWin.SetColor(TRgb::Gray256(170));
sl@0
  1343
	}
sl@0
  1344
sl@0
  1345
void TestWindow8::Draw()
sl@0
  1346
	{
sl@0
  1347
	Panic(EConnectPanicRedrawToBackedUpWindow);
sl@0
  1348
	}
sl@0
  1349
sl@0
  1350
TestWindow9::TestWindow9() : CTWin()
sl@0
  1351
	{
sl@0
  1352
	__DECLARE_NAME(_S("TestWindow9"));
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
void TestWindow9::InitWinL()
sl@0
  1356
	{
sl@0
  1357
	iWin.SetRequiredDisplayMode(EGray16);
sl@0
  1358
	User::LeaveIfError(iBitmap.Load(VIDEO_MBM_NAME,0));
sl@0
  1359
	iVideoSize=iBitmap.SizeInPixels();
sl@0
  1360
	}
sl@0
  1361
sl@0
  1362
void TestWindow9::Draw()
sl@0
  1363
	{
sl@0
  1364
	iGc->BitBlt(TPoint(),&iBitmap);
sl@0
  1365
	}
sl@0
  1366
sl@0
  1367
void TestWindow9::Play()
sl@0
  1368
	{
sl@0
  1369
	iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize);
sl@0
  1370
	iWin.BeginRedraw();
sl@0
  1371
	iWin.EndRedraw();
sl@0
  1372
	iGc->Activate(iWin);
sl@0
  1373
	TInt index=1;
sl@0
  1374
	while(iBitmap.Load(VIDEO_MBM_NAME,index++)==KErrNone)
sl@0
  1375
		{
sl@0
  1376
		iGc->BitBlt(TPoint(),&iBitmap);
sl@0
  1377
		Client()->iWs.Flush();
sl@0
  1378
		}
sl@0
  1379
	iBitmap.Load(VIDEO_MBM_NAME,0);
sl@0
  1380
	iGc->BitBlt(TPoint(),&iBitmap);
sl@0
  1381
	iGc->Deactivate();
sl@0
  1382
	}
sl@0
  1383
sl@0
  1384
void TestWindow9::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
  1385
	{
sl@0
  1386
	if (aKey.iCode=='p' || aKey.iCode=='P')
sl@0
  1387
		Play();
sl@0
  1388
	}
sl@0
  1389
sl@0
  1390
TestWindow10::TestWindow10() : CTWin()
sl@0
  1391
	{
sl@0
  1392
	__DECLARE_NAME(_S("TestWindow10"));
sl@0
  1393
	}
sl@0
  1394
sl@0
  1395
void TestWindow10::InitWin()
sl@0
  1396
	{
sl@0
  1397
	//iWin.PointerFilter(EPointerFilterMove|EPointerFilterEnterExit,EPointerFilterMove|EPointerFilterEnterExit);
sl@0
  1398
	//iWin.SetPointerGrab(ETrue);
sl@0
  1399
	iWin.SetRequiredDisplayMode(EColor256);
sl@0
  1400
	}
sl@0
  1401
sl@0
  1402
void TestWindow10::Draw()
sl@0
  1403
	{
sl@0
  1404
	TSize size=Size();
sl@0
  1405
	TRect rect(size);
sl@0
  1406
	TInt ii;
sl@0
  1407
sl@0
  1408
	iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1409
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1410
	rect.iBr.iX=0;
sl@0
  1411
	for(ii=0;ii<256;ii++)
sl@0
  1412
		{
sl@0
  1413
		rect.iTl.iX=rect.iBr.iX;
sl@0
  1414
		rect.iBr.iX=((ii+1)*size.iWidth)/256;
sl@0
  1415
		iGc->SetBrushColor(TRgb::Color256(ii));
sl@0
  1416
		iGc->DrawRect(rect);
sl@0
  1417
		}
sl@0
  1418
	}
sl@0
  1419
sl@0
  1420
void TestWindow10::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
  1421
	{
sl@0
  1422
	switch(aKey.iCode)
sl@0
  1423
		{
sl@0
  1424
		case '0':
sl@0
  1425
			iWin.SetRequiredDisplayMode(EGray2);
sl@0
  1426
			break;
sl@0
  1427
		case '1':
sl@0
  1428
			iWin.SetRequiredDisplayMode(EGray4);
sl@0
  1429
			break;
sl@0
  1430
		case '2':
sl@0
  1431
			iWin.SetRequiredDisplayMode(EGray16);
sl@0
  1432
			break;
sl@0
  1433
		case '3':
sl@0
  1434
			iWin.SetRequiredDisplayMode(EGray256);
sl@0
  1435
			break;
sl@0
  1436
		case '4':
sl@0
  1437
			iWin.SetRequiredDisplayMode(EColor16);
sl@0
  1438
			break;
sl@0
  1439
		case '5':
sl@0
  1440
			iWin.SetRequiredDisplayMode(EColor256);
sl@0
  1441
			break;
sl@0
  1442
		case '6':
sl@0
  1443
			iWin.SetRequiredDisplayMode(EColor64K);
sl@0
  1444
			break;
sl@0
  1445
		}
sl@0
  1446
	}
sl@0
  1447
sl@0
  1448
TestWindow12::TestWindow12() : CTWin()
sl@0
  1449
	{}
sl@0
  1450
sl@0
  1451
void TestWindow12::InitWin()
sl@0
  1452
	{
sl@0
  1453
	iWin.SetRequiredDisplayMode(EColor16);
sl@0
  1454
	}
sl@0
  1455
sl@0
  1456
void TestWindow12::Draw()
sl@0
  1457
	{
sl@0
  1458
	TRect rect(Size());
sl@0
  1459
sl@0
  1460
	iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1461
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1462
	iGc->SetBrushColor(TRgb(0,255,0));
sl@0
  1463
	iGc->DrawRect(rect);
sl@0
  1464
	rect.iTl.iX=rect.iBr.iX/2;
sl@0
  1465
	iGc->SetBrushColor(TRgb(0,0,255));
sl@0
  1466
	iGc->DrawRect(rect);
sl@0
  1467
	}
sl@0
  1468
sl@0
  1469
void TestWindow12::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
  1470
	{
sl@0
  1471
	TSize screen(Client()->iScreen->SizeInPixels());
sl@0
  1472
	TSize size(Size());
sl@0
  1473
	TPoint pos(Position());
sl@0
  1474
	TPoint dest1(screen.iWidth-size.iWidth,screen.iHeight-size.iHeight);
sl@0
  1475
	TPoint dest;
sl@0
  1476
	iGc->Activate(iWin);
sl@0
  1477
	switch(aKey.iCode)
sl@0
  1478
		{
sl@0
  1479
	//case '1':
sl@0
  1480
		//break;
sl@0
  1481
	case '2':
sl@0
  1482
		dest.iX=dest1.iX/2;
sl@0
  1483
		break;
sl@0
  1484
	case '3':
sl@0
  1485
		dest.iX=dest1.iX;
sl@0
  1486
		break;
sl@0
  1487
	case '4':
sl@0
  1488
		dest.iY=dest1.iY/2;
sl@0
  1489
		break;
sl@0
  1490
	case '5':
sl@0
  1491
		dest.iX=dest1.iX/2;
sl@0
  1492
		dest.iY=dest1.iY/2;
sl@0
  1493
		break;
sl@0
  1494
	case '6':
sl@0
  1495
		dest.iX=dest1.iX;
sl@0
  1496
		dest.iY=dest1.iY/2;
sl@0
  1497
		break;
sl@0
  1498
	case '7':
sl@0
  1499
		dest.iY=dest1.iY;
sl@0
  1500
		break;
sl@0
  1501
	case '8':
sl@0
  1502
		dest.iX=dest1.iX/2;
sl@0
  1503
		dest.iY=dest1.iY;
sl@0
  1504
		break;
sl@0
  1505
	case '9':
sl@0
  1506
		dest.iX=dest1.iX;
sl@0
  1507
		dest.iY=dest1.iY;
sl@0
  1508
		break;
sl@0
  1509
		}
sl@0
  1510
	TRect rect(screen);
sl@0
  1511
	rect.Move(-pos);
sl@0
  1512
	iGc->CopyRect(pos-dest,rect);
sl@0
  1513
	iGc->Deactivate();
sl@0
  1514
	}
sl@0
  1515
sl@0
  1516
//
sl@0
  1517
sl@0
  1518
TestWindowGroup::TestWindowGroup(CTClient *aClient) : CTWindowGroup(aClient), iIncludeChildren(EFalse)
sl@0
  1519
	{
sl@0
  1520
	}
sl@0
  1521
sl@0
  1522
void TestWindowGroup::ConstructL()
sl@0
  1523
	{
sl@0
  1524
	CTWindowGroup::ConstructL();
sl@0
  1525
	iGroupWin.EnableScreenChangeEvents();
sl@0
  1526
	}
sl@0
  1527
sl@0
  1528
void TestWindowGroup::ScreenDeviceChanged()
sl@0
  1529
	{
sl@0
  1530
	TPixelsTwipsAndRotation sizeAndRotation;
sl@0
  1531
	Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
sl@0
  1532
	Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation);
sl@0
  1533
	}
sl@0
  1534
sl@0
  1535
void TestWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &aTime)
sl@0
  1536
	{
sl@0
  1537
	if (aKey.iModifiers&EModifierCtrl && !(aKey.iModifiers&EModifierFunc))
sl@0
  1538
		{
sl@0
  1539
		TInt type=0;
sl@0
  1540
		if (aKey.iCode<=14)
sl@0
  1541
			type=aKey.iCode;
sl@0
  1542
		if (type!=0)
sl@0
  1543
			{
sl@0
  1544
			TPoint pos;
sl@0
  1545
			TSize size;
sl@0
  1546
			CTWinBase *win=this;
sl@0
  1547
			if ((aKey.iModifiers&EModifierLeftShift) && iCurWin)
sl@0
  1548
				win=iCurWin;
sl@0
  1549
			pos.iX=win->Size().iWidth>>2;
sl@0
  1550
			pos.iY=win->Size().iHeight>>2;
sl@0
  1551
			size.iWidth=win->Size().iWidth>>1;
sl@0
  1552
			size.iHeight=win->Size().iHeight>>1;
sl@0
  1553
			iCurWin=((TestClient *)Client())->CreateTestWindowL(type,pos,size,win,*Client()->iGc,aKey.iModifiers&EModifierRightShift);
sl@0
  1554
			return;
sl@0
  1555
			}
sl@0
  1556
		}
sl@0
  1557
	if (aKey.iModifiers&EModifierFunc)
sl@0
  1558
		{
sl@0
  1559
		switch(aKey.iCode)
sl@0
  1560
			{
sl@0
  1561
			case 'a':
sl@0
  1562
				{
sl@0
  1563
				for(TInt loop=0;loop<100;loop++)
sl@0
  1564
					{
sl@0
  1565
					((TestClient *)Client())->iWs.HeapSetFail(RHeap::EDeterministic,loop);
sl@0
  1566
					CTBaseWin *win=NULL;
sl@0
  1567
					TRAP_IGNORE(win=((TestClient *)Client())->CreateTestWindowL(1,TPoint(15,20),TSize(150,110),Client()->iGroup,*Client()->iGc));
sl@0
  1568
					if (win)
sl@0
  1569
						{
sl@0
  1570
						((CTWin *)win)->Redraw(TRect());
sl@0
  1571
						delete win;
sl@0
  1572
						}
sl@0
  1573
					}
sl@0
  1574
				((TestClient *)Client())->iWs.HeapSetFail(RHeap::ENone,0);
sl@0
  1575
				}
sl@0
  1576
				break;
sl@0
  1577
			case '0':
sl@0
  1578
				{
sl@0
  1579
				TUint *aNullPtr=NULL;
sl@0
  1580
				*aNullPtr=0;
sl@0
  1581
				}
sl@0
  1582
				break;
sl@0
  1583
			case 'p':
sl@0
  1584
				{
sl@0
  1585
				RThread thread;
sl@0
  1586
				thread.Panic(_L("Connect"),123);
sl@0
  1587
				}
sl@0
  1588
				break;
sl@0
  1589
			case 'x':
sl@0
  1590
				((TestClient *)Client())->Exit();
sl@0
  1591
				break;
sl@0
  1592
			case 'f':
sl@0
  1593
				if (Client()->iWs.SetAutoFlush(ETrue))
sl@0
  1594
					Client()->iWs.SetAutoFlush(EFalse);
sl@0
  1595
				break;
sl@0
  1596
			case 'b':
sl@0
  1597
				RunLaunchAndShootTestL();
sl@0
  1598
				break;
sl@0
  1599
			case 'm':
sl@0
  1600
				MillionsOfSessions();
sl@0
  1601
				break;
sl@0
  1602
			case 'o':
sl@0
  1603
				GroupWin()->SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow);
sl@0
  1604
				break;
sl@0
  1605
			case 10:
sl@0
  1606
				if (aKey.iModifiers&EModifierCtrl && aKey.iModifiers&EModifierShift)
sl@0
  1607
					iHand->ToggleStatus();
sl@0
  1608
				break;
sl@0
  1609
			case EKeyLeftArrow:
sl@0
  1610
				((TestClient *)Client())->AdjustLightSource(-1,0);
sl@0
  1611
				break;
sl@0
  1612
			case EKeyRightArrow:
sl@0
  1613
				((TestClient *)Client())->AdjustLightSource(1,0);
sl@0
  1614
				break;
sl@0
  1615
			case EKeyUpArrow:
sl@0
  1616
				((TestClient *)Client())->AdjustLightSource(0,-1);
sl@0
  1617
				break;
sl@0
  1618
			case EKeyDownArrow:
sl@0
  1619
				((TestClient *)Client())->AdjustLightSource(0,1);
sl@0
  1620
				break;
sl@0
  1621
			default:
sl@0
  1622
				goto keeptrying;
sl@0
  1623
			}
sl@0
  1624
		return;
sl@0
  1625
		}
sl@0
  1626
keeptrying:
sl@0
  1627
	if (iCurWin)
sl@0
  1628
		{
sl@0
  1629
		if (aKey.iModifiers&EModifierFunc)
sl@0
  1630
			{
sl@0
  1631
			//TBool shift=aKey.iModifiers&EModifierShift;
sl@0
  1632
			switch(aKey.iCode)
sl@0
  1633
				{
sl@0
  1634
				case 'c':
sl@0
  1635
					GroupWin()->DisableKeyClick(ETrue);
sl@0
  1636
					break;
sl@0
  1637
				case 'C':
sl@0
  1638
					GroupWin()->DisableKeyClick(EFalse);
sl@0
  1639
					break;
sl@0
  1640
				case 's':
sl@0
  1641
					iCurWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  1642
					break;
sl@0
  1643
				case 'S':
sl@0
  1644
					iCurWin->BaseWin()->SetShadowDisabled(EFalse);
sl@0
  1645
					break;
sl@0
  1646
				case 'v':
sl@0
  1647
					iCurWin->SetVisible(ETrue);
sl@0
  1648
					break;
sl@0
  1649
				case 'i':
sl@0
  1650
					iCurWin->SetVisible(EFalse);
sl@0
  1651
					break;
sl@0
  1652
				case 'd':
sl@0
  1653
					iCurWin->BaseWin()->SetFaded(ETrue
sl@0
  1654
						,(iIncludeChildren? RWindowTreeNode::EFadeIncludeChildren:RWindowTreeNode::EFadeWindowOnly));
sl@0
  1655
					break;
sl@0
  1656
				case 'D':
sl@0
  1657
					iCurWin->BaseWin()->SetFaded(EFalse
sl@0
  1658
						,(iIncludeChildren? RWindowTreeNode::EFadeIncludeChildren:RWindowTreeNode::EFadeWindowOnly));
sl@0
  1659
					break;
sl@0
  1660
				case 'w':
sl@0
  1661
				case 'W':
sl@0
  1662
					iIncludeChildren=!iIncludeChildren;
sl@0
  1663
				case 'e':
sl@0
  1664
					iCurWin->BaseWin()->SetNonFading(ETrue);
sl@0
  1665
					break;
sl@0
  1666
				case 'E':
sl@0
  1667
					iCurWin->BaseWin()->SetNonFading(EFalse);
sl@0
  1668
					break;
sl@0
  1669
				case 'r':
sl@0
  1670
					iCurWin->BaseWin()->FadeBehind(ETrue);
sl@0
  1671
					break;
sl@0
  1672
				case 'R':
sl@0
  1673
					iCurWin->BaseWin()->FadeBehind(EFalse);
sl@0
  1674
					break;
sl@0
  1675
				/*case 'b':
sl@0
  1676
					iCurWin->WinTreeNode()->SetOrdinalPosition(-1);
sl@0
  1677
					break;
sl@0
  1678
				case 'f':
sl@0
  1679
					iCurWin->WinTreeNode()->SetOrdinalPosition(0);
sl@0
  1680
					break;*/
sl@0
  1681
				case 'B':
sl@0
  1682
					{
sl@0
  1683
					RWindowTreeNode* win=iCurWin->WinTreeNode();
sl@0
  1684
					win->SetOrdinalPosition(win->OrdinalPosition()+1);
sl@0
  1685
					}
sl@0
  1686
					break;
sl@0
  1687
				case 'F':
sl@0
  1688
					{
sl@0
  1689
					RWindowTreeNode* win=iCurWin->WinTreeNode();
sl@0
  1690
					win->SetOrdinalPosition(win->OrdinalPosition()-1);
sl@0
  1691
					}
sl@0
  1692
					break;
sl@0
  1693
				default:
sl@0
  1694
					goto keeptrying2;
sl@0
  1695
				}
sl@0
  1696
			return;
sl@0
  1697
			}
sl@0
  1698
keeptrying2:
sl@0
  1699
		switch(aKey.iCode)
sl@0
  1700
			{
sl@0
  1701
			case 24:			//Ctrl-X
sl@0
  1702
				CTWin::Delete(iCurWin);
sl@0
  1703
				break;
sl@0
  1704
			case 19:			//Ctrl-S
sl@0
  1705
				if (aKey.iModifiers&EModifierShift)
sl@0
  1706
					iCurWin=iCurWin->Prev();
sl@0
  1707
				else
sl@0
  1708
					iCurWin=iCurWin->Next();
sl@0
  1709
				break;
sl@0
  1710
			case EKeyLeftArrow:
sl@0
  1711
				iCurWin->AdjustSizeL(-Xmove,0,aKey.iModifiers);
sl@0
  1712
				break;
sl@0
  1713
			case EKeyRightArrow:
sl@0
  1714
				iCurWin->AdjustSizeL(Xmove,0,aKey.iModifiers);
sl@0
  1715
				break;
sl@0
  1716
			case EKeyUpArrow:
sl@0
  1717
				iCurWin->AdjustSizeL(0,-Ymove,aKey.iModifiers);
sl@0
  1718
				break;
sl@0
  1719
			case EKeyDownArrow:
sl@0
  1720
				iCurWin->AdjustSizeL(0,Ymove,aKey.iModifiers);
sl@0
  1721
				break;
sl@0
  1722
			case '[':		// Move back 1 ordinal position
sl@0
  1723
				iCurWin->AdjustOrdinal(-1);
sl@0
  1724
				break;
sl@0
  1725
			case ']':		// Move forward 1 ordinal position
sl@0
  1726
				iCurWin->AdjustOrdinal(1);
sl@0
  1727
				break;
sl@0
  1728
			case '<':		// Decrease shadow size
sl@0
  1729
				iCurWin->AdjustShadow(-1);
sl@0
  1730
				break;
sl@0
  1731
			case '>':		// Increase shadow size
sl@0
  1732
				iCurWin->AdjustShadow(1);
sl@0
  1733
				break;
sl@0
  1734
			case 13:
sl@0
  1735
//				iCurWin->SetDefaultExtL();
sl@0
  1736
				iCurWin->SetFullScreenExtL();
sl@0
  1737
				break;
sl@0
  1738
			default:
sl@0
  1739
				iCurWin->WinKeyL(aKey,aTime);
sl@0
  1740
				break;
sl@0
  1741
			}
sl@0
  1742
		}
sl@0
  1743
	}
sl@0
  1744
sl@0
  1745
void TestWindowGroup::RunLaunchAndShootTestL()
sl@0
  1746
	{
sl@0
  1747
	RThread thread;
sl@0
  1748
	User::LeaveIfError(thread.Create(_L("Launcher"),RunLaunchAndShootTest,KDefaultStackSize,NULL,
sl@0
  1749
						NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread));
sl@0
  1750
	thread.Resume();
sl@0
  1751
	thread.Close();
sl@0
  1752
	}
sl@0
  1753
sl@0
  1754
void TestWindowGroup::MillionsOfSessions()
sl@0
  1755
	{
sl@0
  1756
	RWsSession session;
sl@0
  1757
	FOREVER
sl@0
  1758
		{
sl@0
  1759
		session=RWsSession();
sl@0
  1760
		if (session.Connect()!=KErrNone)
sl@0
  1761
			break;
sl@0
  1762
		}
sl@0
  1763
	}
sl@0
  1764
sl@0
  1765
//
sl@0
  1766
sl@0
  1767
TestClient::TestClient()
sl@0
  1768
	{
sl@0
  1769
	__DECLARE_NAME(_S("TestClient"));
sl@0
  1770
	}
sl@0
  1771
sl@0
  1772
CTBaseWin *TestClient::CreateTestWindowL(TInt type,TPoint pos,TSize size,CTWinBase *parent,CWindowGc &aGc,TBool aAlternate/*=EFalse*/)
sl@0
  1773
	{
sl@0
  1774
	CTBaseWin *win=NULL;
sl@0
  1775
	switch(type)
sl@0
  1776
		{
sl@0
  1777
		case 1:
sl@0
  1778
			win=new(ELeave) TestWindow1();
sl@0
  1779
			break;
sl@0
  1780
		case 2:
sl@0
  1781
			win=new(ELeave) TestWindow2();
sl@0
  1782
			break;
sl@0
  1783
		case 3:
sl@0
  1784
			win=new(ELeave) TestWindow3();
sl@0
  1785
			break;
sl@0
  1786
		case 4:
sl@0
  1787
			win=new(ELeave) TestWindow4();
sl@0
  1788
			break;
sl@0
  1789
		case 5:
sl@0
  1790
			win=new(ELeave) TestWindow5(aAlternate);
sl@0
  1791
			break;
sl@0
  1792
		case 6:
sl@0
  1793
			win=new(ELeave) TestWindow6(aAlternate);
sl@0
  1794
			break;
sl@0
  1795
		case 7:
sl@0
  1796
			win=new(ELeave) TestWindow7(aAlternate);
sl@0
  1797
			break;
sl@0
  1798
		case 8:
sl@0
  1799
			win=new(ELeave) TestWindow8();
sl@0
  1800
			break;
sl@0
  1801
		case 9:
sl@0
  1802
			win=new(ELeave) TestWindow9();
sl@0
  1803
			break;
sl@0
  1804
		case 10:
sl@0
  1805
			win=new(ELeave) TestWindow10();
sl@0
  1806
			break;
sl@0
  1807
		case 11:
sl@0
  1808
			win=new(ELeave) TestWindow11();
sl@0
  1809
			break;
sl@0
  1810
		case 12:
sl@0
  1811
			win=new(ELeave) TestWindow12();
sl@0
  1812
			break;
sl@0
  1813
		default:
sl@0
  1814
			User::Leave(KErrArgument);
sl@0
  1815
		}
sl@0
  1816
	TRAPD(err,win->ConstructL(*parent));
sl@0
  1817
	if (err!=KErrNone)
sl@0
  1818
		goto ctw_err;
sl@0
  1819
	win->AssignGC(aGc);
sl@0
  1820
	TRAP(err,win->SetExtL(pos,size));
sl@0
  1821
	if (err!=KErrNone)
sl@0
  1822
		{
sl@0
  1823
ctw_err:
sl@0
  1824
		delete win;
sl@0
  1825
		User::Leave(err);
sl@0
  1826
		}
sl@0
  1827
	if (type!=2)
sl@0
  1828
		win->BaseWin()->EnableBackup();
sl@0
  1829
	win->BaseWin()->SetPointerCursor(0);
sl@0
  1830
	win->Activate();
sl@0
  1831
	return(win);
sl@0
  1832
	}
sl@0
  1833
sl@0
  1834
TestClient::~TestClient()
sl@0
  1835
	{
sl@0
  1836
	delete iHandWriting;
sl@0
  1837
	}
sl@0
  1838
sl@0
  1839
//
sl@0
  1840
sl@0
  1841
// Define to include hand writing tests
sl@0
  1842
#define TEST_HWR
sl@0
  1843
void TestClient::ConstructL()
sl@0
  1844
	{
sl@0
  1845
	CTClient::ConstructL();
sl@0
  1846
	iGroup=new(ELeave) TestWindowGroup(this);
sl@0
  1847
	iGroup->ConstructL();
sl@0
  1848
//	CreateTestWindowL(1,TPoint(15,20),TSize(150,110),iGroup,*iGc);
sl@0
  1849
//	CreateTestWindowL(2,TPoint(100,100),TSize(200,90),iGroup,*iGc);
sl@0
  1850
//	CreateTestWindowL(3,TPoint(310,190),TSize(90,40),iGroup,*iGc);
sl@0
  1851
	CreateTestWindowL(4,TPoint(10,10),TSize(160,120),iGroup,*iGc);
sl@0
  1852
//	CreateTestWindowL(5,TPoint(300,14),TSize(260,140),iGroup,*iGc);
sl@0
  1853
//	CreateTestWindowL(6,TPoint(20,200),TSize(160,60),iGroup,*iGc);
sl@0
  1854
	iGroup->SetCurrentWindow(iGroup->Child());
sl@0
  1855
#if defined(TEST_HWR)
sl@0
  1856
	iHandWriting=new(ELeave) CHandWriting(iWs);
sl@0
  1857
	TRAPD(err,iHandWriting->ConstructL(iScreen->SizeInPixels(),*iGroup->GroupWin(),ETrue));   //EFalse don't use seperate Mask bitmap.
sl@0
  1858
	if (err!=KErrNone)
sl@0
  1859
		delete iHandWriting;
sl@0
  1860
	else
sl@0
  1861
		TestWindow()->SetHandWriting(iHandWriting);
sl@0
  1862
#endif
sl@0
  1863
	}
sl@0
  1864
sl@0
  1865
void TestClient::AdjustLightSource(TInt aX,TInt aY)
sl@0
  1866
	{
sl@0
  1867
	TPoint vector=iWs.ShadowVector();
sl@0
  1868
	vector.iX+=aX;
sl@0
  1869
	vector.iY+=aY;
sl@0
  1870
	iWs.SetShadowVector(vector);
sl@0
  1871
	}
sl@0
  1872
sl@0
  1873
void TestClient::Exit()
sl@0
  1874
	{
sl@0
  1875
	CActiveScheduler::Stop();
sl@0
  1876
	}
sl@0
  1877
sl@0
  1878
//
sl@0
  1879
// Special bit of test code to repeatedly launch and shoot a wserv //
sl@0
  1880
//
sl@0
  1881
sl@0
  1882
#define NT_KILLER
sl@0
  1883
sl@0
  1884
TInt LaunchAndShootTestLoop(TAny *)
sl@0
  1885
	{
sl@0
  1886
#if defined(NT_KILLER)
sl@0
  1887
	User::WaitForAnyRequest();
sl@0
  1888
#else 
sl@0
  1889
sl@0
  1890
	RWsSession ws;
sl@0
  1891
	ws.Connect();
sl@0
  1892
	TTimeIntervalMicroSeconds32 initialTime;
sl@0
  1893
	TTimeIntervalMicroSeconds32 time;
sl@0
  1894
	FOREVER
sl@0
  1895
		ws.GetKeyboardRepeatRate(initialTime, time);
sl@0
  1896
#endif
sl@0
  1897
	return(KErrNone);
sl@0
  1898
	}
sl@0
  1899
sl@0
  1900
#if defined(NT_KILLER)
sl@0
  1901
TInt RunLaunchAndShootTest(TAny *)
sl@0
  1902
	{
sl@0
  1903
	RThread().SetPriority(EPriorityRealTime);
sl@0
  1904
	RThread thread;
sl@0
  1905
	thread.Create(_L("xx1"),LaunchAndShootTestLoop,KDefaultStackSize,NULL,
sl@0
  1906
						NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread);
sl@0
  1907
	thread.Resume();
sl@0
  1908
	thread.Kill(KErrNone);
sl@0
  1909
	thread.Close();
sl@0
  1910
	RThread thread2;
sl@0
  1911
	thread2.Create(_L("xx2"),LaunchAndShootTestLoop,KDefaultStackSize,NULL,
sl@0
  1912
						NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread);
sl@0
  1913
	thread2.Resume();
sl@0
  1914
	thread2.Kill(KErrNone);
sl@0
  1915
	thread2.Close();
sl@0
  1916
	return(KErrNone);
sl@0
  1917
	}
sl@0
  1918
#else
sl@0
  1919
TInt RunLaunchAndShootTest(TAny *)
sl@0
  1920
	{
sl@0
  1921
	RThread().SetPriority(EPriorityRealTime);
sl@0
  1922
	for(TInt count=0;count<100;count++)
sl@0
  1923
		{
sl@0
  1924
		RThread thread;
sl@0
  1925
		TBuf<KMaxFileName> threadName;
sl@0
  1926
		TInt num=0;
sl@0
  1927
		TInt err=KErrNone;
sl@0
  1928
		do
sl@0
  1929
			{
sl@0
  1930
			threadName.Format(_L("%S%02d"),&_L("Looper"),num++);
sl@0
  1931
			err=thread.Create(threadName,LaunchAndShootTestLoop,KDefaultStackSize,NULL,
sl@0
  1932
							NULL,NULL,KTestThreadHeapSize,KTestThreadHeapSize,EOwnerThread);
sl@0
  1933
			} while(err==KErrAlreadyExists);
sl@0
  1934
		if (err!=KErrNone)
sl@0
  1935
			return(KErrNone);
sl@0
  1936
		thread.Resume();
sl@0
  1937
		User::After(TTimeIntervalMicroSeconds32(50000));
sl@0
  1938
		thread.Kill(KErrNone);
sl@0
  1939
		thread.Close();
sl@0
  1940
		}
sl@0
  1941
	return(KErrNone);
sl@0
  1942
	}
sl@0
  1943
#endif
sl@0
  1944
	
sl@0
  1945
//
sl@0
  1946
#define leavescan_needs_to_see_some_brackets_here	{	}
sl@0
  1947
sl@0
  1948
GLDEF_C CTClient* CreateClientL()
sl@0
  1949
	{
sl@0
  1950
	return(new(ELeave) TestClient());	   //Leavescan thinks this fn is  user::After!
sl@0
  1951
	}
sl@0
  1952
sl@0
  1953
GLDEF_C TInt E32Main()
sl@0
  1954
	{
sl@0
  1955
	return(TestLibStartUp(CreateClientL));
sl@0
  1956
	}