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