|
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 // Base classes used for building window server test code |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <w32std.h> |
|
20 #include <e32svr.h> |
|
21 #include <e32property.h> |
|
22 #include "TLIB.H" |
|
23 #include <graphics/wsgraphicdrawerinterface.h> |
|
24 |
|
25 // |
|
26 // Test code classes |
|
27 // |
|
28 // CTWinBase |
|
29 // CTBaseWin |
|
30 // CTWin |
|
31 // CTBackedUpWin |
|
32 // CTGroupWin |
|
33 // CTClient |
|
34 // |
|
35 // |
|
36 |
|
37 _LIT(KTestFontTypefaceName,"DejaVu Sans Condensed"); |
|
38 |
|
39 class CStopTheScheduler : public CAsyncOneShot |
|
40 { |
|
41 public: |
|
42 inline CStopTheScheduler(CTClient* aClient,TInt aPriority,TBool aAll) :CAsyncOneShot(aPriority), iClient(aClient), iAll(aAll) {} |
|
43 inline CStopTheScheduler(CTClient* aClient,TInt aPriority) :CAsyncOneShot(aPriority), iClient(aClient) {} |
|
44 inline CStopTheScheduler(TInt aPriority) :CAsyncOneShot(aPriority) {} |
|
45 void RunL(); |
|
46 public: |
|
47 CTClient* iClient; |
|
48 TBool iAll; |
|
49 #ifdef __WINS__ |
|
50 TInt iCStopTheSchedulerRunCount; |
|
51 #endif |
|
52 }; |
|
53 |
|
54 |
|
55 void TbPanic(TInt aPanic) |
|
56 { |
|
57 User::Panic(_L("TestBase"),aPanic); |
|
58 } |
|
59 |
|
60 EXPORT_C CTWinBase::CTWinBase(TInt aType) : iType(aType) |
|
61 { |
|
62 __DECLARE_NAME(_S("CTWinBase")); |
|
63 } |
|
64 |
|
65 EXPORT_C CTWinBase *CTWinBase::Parent() const |
|
66 { |
|
67 return((CTWinBase *)WinTreeNode()->Parent()); |
|
68 } |
|
69 |
|
70 EXPORT_C CTWinBase *CTWinBase::NextSibling() const |
|
71 { |
|
72 return((CTWinBase *)WinTreeNode()->NextSibling()); |
|
73 } |
|
74 |
|
75 EXPORT_C CTWinBase *CTWinBase::PrevSibling() const |
|
76 { |
|
77 return((CTWinBase *)WinTreeNode()->PrevSibling()); |
|
78 } |
|
79 |
|
80 EXPORT_C CTClient *CTWinBase::Client() const |
|
81 { |
|
82 return(iOwnerWin->Client()); |
|
83 } |
|
84 |
|
85 EXPORT_C CTBaseWin *CTWinBase::Child() const |
|
86 { |
|
87 return((CTBaseWin *)WinTreeNode()->Child()); |
|
88 } |
|
89 |
|
90 EXPORT_C TPoint CTWinBase::Position() const |
|
91 { |
|
92 return(TPoint(0,0)); |
|
93 } |
|
94 |
|
95 EXPORT_C void CTWinBase::PointerEnter(const TTime&) |
|
96 { |
|
97 } |
|
98 |
|
99 EXPORT_C void CTWinBase::PointerExit(const TTime&) |
|
100 { |
|
101 } |
|
102 |
|
103 EXPORT_C void CTWinBase::PointerBufferReady(const TTime&) |
|
104 { |
|
105 } |
|
106 |
|
107 EXPORT_C void CTWinBase::PointerL(const TPointerEvent&,const TTime&) |
|
108 { |
|
109 } |
|
110 |
|
111 EXPORT_C void CTWinBase::SwitchOn(const TTime &) |
|
112 { |
|
113 } |
|
114 |
|
115 EXPORT_C void CTWinBase::ModifiersChanged(const TModifiersChangedEvent &,const TTime &) |
|
116 { |
|
117 } |
|
118 |
|
119 EXPORT_C void CTWinBase::AdjustOrdinal(TInt) |
|
120 { |
|
121 } |
|
122 |
|
123 EXPORT_C void CTWinBase::AdjustShadow(TInt) |
|
124 { |
|
125 } |
|
126 |
|
127 EXPORT_C void CTWinBase::SetVisible(TBool) |
|
128 { |
|
129 } |
|
130 |
|
131 EXPORT_C TInt CTWinBase::SubType() |
|
132 { |
|
133 return(0); |
|
134 } |
|
135 |
|
136 EXPORT_C void CTWinBase::ErrorMessage(const TWsErrorMessage&, const TTime &) |
|
137 { |
|
138 } |
|
139 |
|
140 EXPORT_C void CTWinBase::__DbgTestInvariant() const |
|
141 { |
|
142 WinTreeNode()->__DbgTestInvariant(); |
|
143 } |
|
144 |
|
145 // CTBaseWin // |
|
146 |
|
147 EXPORT_C CTBaseWin::CTBaseWin(TInt aType) : CTWinBase(aType) |
|
148 { |
|
149 __DECLARE_NAME(_S("CTBaseWin")); |
|
150 } |
|
151 |
|
152 EXPORT_C CTBaseWin::~CTBaseWin() |
|
153 { |
|
154 } |
|
155 |
|
156 EXPORT_C void CTBaseWin::RelinquishFocus() |
|
157 { |
|
158 CTWinBase *parent=Parent(); |
|
159 CTWindowGroup *group=Group(); |
|
160 CTWinBase *child=group->Child(); |
|
161 if (child==this) |
|
162 child=child->NextSibling(); |
|
163 group->SetCurrentWindow((parent->iType==EWinTypeClient) ? (CTBaseWin *)parent : (CTBaseWin *)child); |
|
164 } |
|
165 |
|
166 EXPORT_C void CTBaseWin::SetVisible(TBool aState) |
|
167 { |
|
168 BaseWin()->SetVisible(aState); |
|
169 } |
|
170 |
|
171 EXPORT_C const RWindowTreeNode *CTBaseWin::WinTreeNode() const |
|
172 { |
|
173 return((const RWindowTreeNode *)BaseWin()); |
|
174 } |
|
175 |
|
176 EXPORT_C RWindowTreeNode *CTBaseWin::WinTreeNode() |
|
177 { |
|
178 return((RWindowTreeNode *)BaseWin()); |
|
179 } |
|
180 |
|
181 EXPORT_C void CTBaseWin::InitWin() |
|
182 { |
|
183 } |
|
184 |
|
185 EXPORT_C void CTBaseWin::ConstructExtLD(CTWinBase &aParent, const TPoint &aPos, const TSize &aSize) |
|
186 // |
|
187 // Call ConstructL, SetExt and either of these fail destroy this and leave |
|
188 // |
|
189 { |
|
190 TRAPD(err,ConstructL(aParent)); |
|
191 if (err!=KErrNone) |
|
192 goto celd_err; |
|
193 TRAP(err,SetExtL(aPos,aSize)); |
|
194 if (err!=KErrNone) |
|
195 { |
|
196 celd_err: |
|
197 delete this; |
|
198 User::Leave(err); |
|
199 } |
|
200 } |
|
201 |
|
202 EXPORT_C void CTBaseWin::ConstructL(CTWinBase &aParent) |
|
203 { |
|
204 TInt ret; |
|
205 __ASSERT_DEBUG(aParent.iOwnerWin!=NULL,TbPanic(ETestBasePanicNullOwnerWin)); |
|
206 iOwnerWin=aParent.iOwnerWin; |
|
207 if ((ret=ConstructWin(aParent))==KErrNone) |
|
208 { |
|
209 //TFontSpec fspec(KTestFontTypefaceName,200); |
|
210 //User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont, fspec)); |
|
211 TFontSpec fspec(KTestFontTypefaceName,17); |
|
212 User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)iFont, fspec)); |
|
213 AdjustShadow(1); |
|
214 InitWin(); |
|
215 iSize=BaseWin()->Size(); |
|
216 } |
|
217 User::LeaveIfError(ret); |
|
218 } |
|
219 |
|
220 EXPORT_C void CTBaseWin::Activate() |
|
221 { |
|
222 BaseWin()->Activate(); |
|
223 } |
|
224 |
|
225 EXPORT_C void CTBaseWin::SetFullScreenExtL() |
|
226 { |
|
227 SetExtL(TPoint(0,0), Parent()->Size()); |
|
228 } |
|
229 |
|
230 EXPORT_C void CTBaseWin::SetDefaultExtL() |
|
231 { |
|
232 TSize size=Parent()->Size(); |
|
233 size.iWidth>>=1; |
|
234 size.iHeight>>=1; |
|
235 SetExtL(TPoint(size.iWidth>>1,size.iHeight>>1), size); |
|
236 } |
|
237 |
|
238 EXPORT_C void CTBaseWin::AssignGC(CWindowGc &aGc) |
|
239 { |
|
240 iGc= &aGc; |
|
241 } |
|
242 |
|
243 EXPORT_C void CTBaseWin::SetPos(const TPoint &aPos) |
|
244 { |
|
245 BaseWin()->SetPosition(aPos); |
|
246 iPos=aPos; |
|
247 } |
|
248 |
|
249 EXPORT_C void CTBaseWin::SetInitialPos(const TPoint &aPos) |
|
250 { |
|
251 TSize screen=Client()->iScreen->SizeInPixels(); |
|
252 TPoint pos(aPos); |
|
253 TPoint botLeft=pos+iSize; |
|
254 if (botLeft.iX>screen.iWidth) |
|
255 pos.iX=Max(0,pos.iX-botLeft.iX+screen.iWidth); |
|
256 if (botLeft.iY>screen.iHeight) |
|
257 pos.iY=Max(0,pos.iY-botLeft.iY+screen.iHeight); |
|
258 SetPos(pos); |
|
259 } |
|
260 |
|
261 EXPORT_C void CTBaseWin::SetExtL(const TPoint &aPos, const TSize &aSize) |
|
262 { |
|
263 User::LeaveIfError(BaseWin()->SetExtentErr(aPos,aSize)); |
|
264 iPos=aPos; |
|
265 iSize=aSize; |
|
266 Resized(iSize); |
|
267 } |
|
268 |
|
269 EXPORT_C void CTBaseWin::AdjustSizeL(TInt xMove,TInt yMove,TInt modifiers) |
|
270 { |
|
271 if (modifiers&EModifierCtrl) // 4 times the movement |
|
272 { |
|
273 xMove<<=2; |
|
274 yMove<<=2; |
|
275 } |
|
276 if (modifiers&EModifierShift) |
|
277 { |
|
278 TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); |
|
279 |
|
280 if (size.iWidth<0) |
|
281 size.iWidth=0; |
|
282 if (size.iHeight<0) |
|
283 size.iHeight=0; |
|
284 if (modifiers&EModifierCtrl) |
|
285 { |
|
286 TPoint pos(iPos); |
|
287 pos.iX-=(xMove>>1); |
|
288 pos.iY-=(yMove>>1); |
|
289 SetExtL(pos,size); |
|
290 } |
|
291 else |
|
292 SetSizeL(size); |
|
293 } |
|
294 else |
|
295 SetPos(TPoint(iPos+TPoint(xMove,yMove))); |
|
296 } |
|
297 |
|
298 EXPORT_C void CTBaseWin::SetSizeL(const TSize &aSize) |
|
299 { |
|
300 User::LeaveIfError(BaseWin()->SetSizeErr(aSize)); |
|
301 iSize=aSize; |
|
302 Resized(iSize); |
|
303 } |
|
304 |
|
305 EXPORT_C TSize CTBaseWin::Size() const |
|
306 { |
|
307 return(iSize); |
|
308 } |
|
309 |
|
310 EXPORT_C void CTBaseWin::Resized(const TSize &aSize) |
|
311 // |
|
312 { |
|
313 SetDragRect(TRect(aSize)); |
|
314 } |
|
315 |
|
316 EXPORT_C TPoint CTBaseWin::Position() const |
|
317 { |
|
318 return(BaseWin()->Position()); |
|
319 } |
|
320 |
|
321 EXPORT_C void CTBaseWin::Delete(CTBaseWin *aWin) |
|
322 { |
|
323 RHeap& heap = User::Heap(); |
|
324 TUint8* base=heap.Base(); |
|
325 TInt size=heap.Size(); |
|
326 TUint8* cell=REINTERPRET_CAST(TUint8*,aWin); |
|
327 __ASSERT_ALWAYS(base<=cell && cell<base+size, TbPanic(ETestBasePanicInvalidHeapAddress)); |
|
328 CTWinBase *tmp=aWin; |
|
329 CTWinBase *win2; |
|
330 CTBaseWin *curwin=NULL; |
|
331 if (tmp->Group()) |
|
332 curwin=tmp->Group()->CurWin(); |
|
333 do |
|
334 { |
|
335 win2=tmp; |
|
336 while((tmp=win2->Child())!=NULL) |
|
337 win2=tmp; |
|
338 if ((tmp=win2->NextSibling())==NULL) |
|
339 tmp=win2->Parent(); |
|
340 if (curwin==win2) |
|
341 ((CTBaseWin *)win2)->RelinquishFocus(); |
|
342 delete win2; |
|
343 } while(win2!=aWin); |
|
344 } |
|
345 |
|
346 EXPORT_C void CTBaseWin::KeyUpL(const TKeyEvent &,const TTime&) |
|
347 { |
|
348 } |
|
349 |
|
350 EXPORT_C void CTBaseWin::KeyDownL(const TKeyEvent &,const TTime&) |
|
351 { |
|
352 } |
|
353 |
|
354 EXPORT_C void CTBaseWin::WinKeyL(const TKeyEvent &,const TTime&) |
|
355 { |
|
356 } |
|
357 |
|
358 EXPORT_C void CTBaseWin::PointerL(const TPointerEvent &aPointer,const TTime&) |
|
359 { |
|
360 if (iDragging) |
|
361 { |
|
362 if (aPointer.iType==TPointerEvent::EDrag) |
|
363 SetPos(aPointer.iParentPosition-iDragPos); |
|
364 else |
|
365 iDragging=EFalse; |
|
366 return; |
|
367 } |
|
368 if (aPointer.iType==TPointerEvent::EButton1Down) |
|
369 { |
|
370 if (aPointer.iModifiers&EModifierCtrl) |
|
371 { |
|
372 if (aPointer.iModifiers&EModifierShift) |
|
373 BaseWin()->SetOrdinalPosition(-1); |
|
374 else |
|
375 BaseWin()->SetOrdinalPosition(0); |
|
376 return; |
|
377 } |
|
378 #if defined(__WINS__) |
|
379 else if (aPointer.iModifiers&EModifierShift) |
|
380 __DbgTestInvariant(); |
|
381 #endif |
|
382 else |
|
383 { |
|
384 Group()->SetCurrentWindow(this); |
|
385 if (iDragRect.Contains(aPointer.iPosition)) |
|
386 { |
|
387 iDragging=ETrue; |
|
388 iDragPos=aPointer.iPosition; |
|
389 return; |
|
390 } |
|
391 } |
|
392 } |
|
393 } |
|
394 |
|
395 EXPORT_C void CTBaseWin::DragDropL(const TPointerEvent &,const TTime &) |
|
396 { |
|
397 } |
|
398 |
|
399 EXPORT_C void CTBaseWin::AdjustOrdinal(TInt aAdjust) |
|
400 { |
|
401 TInt pos=BaseWin()->OrdinalPosition()+aAdjust; |
|
402 if (pos>=0) |
|
403 BaseWin()->SetOrdinalPosition(pos); |
|
404 } |
|
405 |
|
406 EXPORT_C void CTBaseWin::AdjustShadow(TInt aAdjust) |
|
407 { |
|
408 iShadow+=aAdjust; |
|
409 if (iShadow<0) |
|
410 iShadow=0; |
|
411 BaseWin()->SetShadowHeight(iShadow); |
|
412 } |
|
413 |
|
414 EXPORT_C void CTBaseWin::DrawBorder() |
|
415 { |
|
416 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
417 iGc->DrawRect(TRect(iSize)); |
|
418 iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
419 } |
|
420 |
|
421 EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode,TBool aVisible,TInt aTransparency) |
|
422 { |
|
423 ConstructL(*parent); |
|
424 if (aMode) |
|
425 BaseWin()->SetRequiredDisplayMode(*aMode); |
|
426 SetExtL(pos,size); |
|
427 if (!aVisible) |
|
428 BaseWin()->SetVisible(aVisible); |
|
429 if (aTransparency!=ENoTransparency) |
|
430 { |
|
431 TInt err=((RWindow*)(BaseWin()))->SetTransparencyFactor(TRgb::_Gray256(aTransparency)); |
|
432 User::LeaveIfError(err); //asked for transparency when not got none! |
|
433 } |
|
434 Activate(); |
|
435 AssignGC(aGc); |
|
436 } |
|
437 |
|
438 EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc, TDisplayMode *aMode) |
|
439 { |
|
440 SetUpL(pos,size,parent,aGc,aMode,ETrue); |
|
441 } |
|
442 |
|
443 EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc,TBool aVisible) |
|
444 { |
|
445 SetUpL(pos,size,parent,aGc,NULL,aVisible); |
|
446 } |
|
447 |
|
448 EXPORT_C void CTBaseWin::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) |
|
449 { |
|
450 SetUpL(pos,size,parent,aGc,NULL,ETrue); |
|
451 } |
|
452 |
|
453 EXPORT_C void CTBaseWin::SetDragRect(const TRect &aRect) |
|
454 { |
|
455 BaseWin()->PointerFilter(EPointerFilterDrag,0); // Clear the drag filter |
|
456 BaseWin()->SetPointerGrab(ETrue); |
|
457 iDragRect=aRect; |
|
458 } |
|
459 |
|
460 EXPORT_C CTWindowGroup *CTBaseWin::Group() const |
|
461 { |
|
462 return(iOwnerWin); |
|
463 } |
|
464 |
|
465 EXPORT_C void CTBaseWin::FocusChanged(TBool ) |
|
466 { |
|
467 } |
|
468 |
|
469 EXPORT_C CTBaseWin *CTBaseWin::Next() |
|
470 { |
|
471 CTWinBase *win; |
|
472 CTWinBase *ret=Child(); |
|
473 if (ret==NULL) |
|
474 { |
|
475 win=this; |
|
476 while((ret=win->NextSibling())==NULL) |
|
477 { |
|
478 ret=win; |
|
479 win=win->Parent(); |
|
480 if (win==NULL) // Group window |
|
481 { |
|
482 ret=ret->Child(); |
|
483 break; |
|
484 } |
|
485 } |
|
486 } |
|
487 return((CTBaseWin *)ret); |
|
488 } |
|
489 |
|
490 EXPORT_C CTBaseWin *CTBaseWin::Prev() |
|
491 { |
|
492 CTWinBase *par=Parent(); |
|
493 CTWinBase *win; |
|
494 CTWinBase *child; |
|
495 if ((win=PrevSibling())==NULL) |
|
496 { |
|
497 if (par->iType==EWinTypeGroup) |
|
498 { |
|
499 CTWinBase *win2=par->Child(); |
|
500 do |
|
501 { |
|
502 win=win2; |
|
503 while((win2=win->NextSibling())!=NULL) |
|
504 win=win2; |
|
505 win2=win->Child(); |
|
506 } while(win2!=NULL); |
|
507 } |
|
508 else |
|
509 win=par; |
|
510 } |
|
511 else |
|
512 { |
|
513 child=win->Child(); |
|
514 while(child!=NULL) |
|
515 { |
|
516 win=child; |
|
517 child=child->NextSibling(); |
|
518 } |
|
519 } |
|
520 return((CTBaseWin *)win); |
|
521 } |
|
522 |
|
523 //EXPORT_C void CTBaseWin::SetDefaultExt() |
|
524 // { |
|
525 // TbPanic(ETestBasePanicUnimplementedBaseFunction); |
|
526 // } |
|
527 |
|
528 EXPORT_C void CTBaseWin::Draw() |
|
529 { |
|
530 TbPanic(ETestBasePanicUnimplementedBaseFunction); |
|
531 } |
|
532 |
|
533 EXPORT_C void CTBaseWin::__DbgTestInvariant() const |
|
534 { |
|
535 CTWinBase::__DbgTestInvariant(); |
|
536 #if defined(__WINS__) |
|
537 if (BaseWin()->Size()!=iSize) |
|
538 User::Invariant(); |
|
539 TPoint offset; |
|
540 const CTWinBase *win=this; |
|
541 const CTWinBase *win2; |
|
542 while((win2=win->Parent())!=NULL) |
|
543 { |
|
544 offset+=((CTBaseWin *)win)->BaseWin()->Position(); |
|
545 if (BaseWin()->InquireOffset(*(win2->WinTreeNode()))!=offset) |
|
546 User::Invariant(); |
|
547 win=win2; |
|
548 } |
|
549 #endif |
|
550 } |
|
551 |
|
552 //CTDrawableWin// |
|
553 // Drawable window // |
|
554 // |
|
555 |
|
556 EXPORT_C CTDrawableWin::CTDrawableWin(TInt aType) : CTBaseWin(aType) |
|
557 { |
|
558 __DECLARE_NAME(_S("CTDrawableWin")); |
|
559 } |
|
560 |
|
561 //CTWin// |
|
562 // Standard client window // |
|
563 // |
|
564 |
|
565 EXPORT_C CTWin::CTWin() : CTDrawableWin(EWinTypeClient) |
|
566 { |
|
567 __DECLARE_NAME(_S("CTWin")); |
|
568 } |
|
569 |
|
570 EXPORT_C CTWin::~CTWin() |
|
571 { |
|
572 if (iFont) |
|
573 Client()->iScreen->ReleaseFont(iFont); |
|
574 iWin.Close(); |
|
575 } |
|
576 |
|
577 EXPORT_C TInt CTWin::ConstructWin(const CTWinBase &aParent) |
|
578 { |
|
579 iWin=RWindow(aParent.Client()->iWs); |
|
580 return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); |
|
581 } |
|
582 |
|
583 EXPORT_C void CTWin::SetDefaultExt() |
|
584 { |
|
585 TSize size=Parent()->Size(); |
|
586 size.iWidth>>=1; |
|
587 size.iHeight>>=1; |
|
588 SetExt(TPoint(size.iWidth>>1,size.iHeight>>1), size); |
|
589 Invalidate(); |
|
590 } |
|
591 |
|
592 EXPORT_C void CTWin::SetExt(const TPoint &aPos, const TSize &aSize) |
|
593 { |
|
594 iWin.SetExtent(aPos,aSize); |
|
595 iPos=aPos; |
|
596 iSize=aSize; |
|
597 Resized(iSize); |
|
598 } |
|
599 |
|
600 EXPORT_C void CTWin::SetSize(const TSize &aSize) |
|
601 { |
|
602 iWin.SetSize(aSize); |
|
603 iSize=aSize; |
|
604 Resized(iSize); |
|
605 } |
|
606 |
|
607 EXPORT_C void CTWin::AdjustSize(TInt xMove,TInt yMove,TInt modifiers) |
|
608 { |
|
609 if (modifiers&EModifierCtrl) // 4 times the movement |
|
610 { |
|
611 xMove<<=2; |
|
612 yMove<<=2; |
|
613 } |
|
614 if (modifiers&EModifierShift) |
|
615 { |
|
616 TSize size(iSize.iWidth+xMove,iSize.iHeight+yMove); |
|
617 |
|
618 if (size.iWidth<0) |
|
619 size.iWidth=0; |
|
620 if (size.iHeight<0) |
|
621 size.iHeight=0; |
|
622 if (modifiers&EModifierCtrl) |
|
623 { |
|
624 TPoint pos(iPos); |
|
625 pos.iX-=(xMove>>1); |
|
626 pos.iY-=(yMove>>1); |
|
627 SetExt(pos,size); |
|
628 } |
|
629 else |
|
630 SetSize(size); |
|
631 Invalidate(); |
|
632 } |
|
633 else |
|
634 SetPos(TPoint(iPos+TPoint(xMove,yMove))); |
|
635 } |
|
636 |
|
637 EXPORT_C RWindowBase *CTWin::BaseWin() |
|
638 { |
|
639 return((RWindowBase *)&iWin); |
|
640 } |
|
641 |
|
642 EXPORT_C const RWindowBase *CTWin::BaseWin() const |
|
643 { |
|
644 return((const RWindowBase *)&iWin); |
|
645 } |
|
646 |
|
647 EXPORT_C RDrawableWindow *CTWin::DrawableWin() |
|
648 { |
|
649 return((RDrawableWindow *)&iWin); |
|
650 } |
|
651 |
|
652 EXPORT_C const RDrawableWindow *CTWin::DrawableWin() const |
|
653 { |
|
654 return((const RDrawableWindow *)&iWin); |
|
655 } |
|
656 |
|
657 |
|
658 EXPORT_C void CTWin::Invalidate() |
|
659 { |
|
660 iWin.Invalidate(); |
|
661 } |
|
662 |
|
663 EXPORT_C void CTWin::Invalidate(const TRect &rect) |
|
664 { |
|
665 iWin.Invalidate(rect); |
|
666 } |
|
667 |
|
668 EXPORT_C void CTWin::DrawNow() |
|
669 { |
|
670 iWin.Invalidate(); |
|
671 iWin.BeginRedraw(); |
|
672 iGc->Activate(iWin); |
|
673 iGc->UseFont((CFont *)iFont); |
|
674 Draw(); |
|
675 iGc->Deactivate(); |
|
676 iWin.EndRedraw(); |
|
677 } |
|
678 |
|
679 EXPORT_C void CTWin::Redraw() |
|
680 { |
|
681 iWin.BeginRedraw(); |
|
682 iGc->Activate(iWin); |
|
683 iGc->UseFont((CFont *)iFont); |
|
684 Draw(); |
|
685 iGc->Deactivate(); |
|
686 iWin.EndRedraw(); |
|
687 } |
|
688 |
|
689 EXPORT_C void CTWin::Redraw(const TRect &aRect) |
|
690 { |
|
691 iWin.BeginRedraw(aRect); |
|
692 iGc->Activate(iWin); |
|
693 iGc->UseFont((CFont *)iFont); |
|
694 Draw(); |
|
695 iGc->Deactivate(); |
|
696 iWin.EndRedraw(); |
|
697 } |
|
698 |
|
699 //CTBackedUpWin// |
|
700 // Backed up window // |
|
701 // |
|
702 |
|
703 EXPORT_C CTBackedUpWin::CTBackedUpWin(TDisplayMode aDisplayMode) : CTDrawableWin(EWinTypeClient), iDisplayMode(aDisplayMode) |
|
704 { |
|
705 __DECLARE_NAME(_S("CTBackedUpWin")); |
|
706 } |
|
707 |
|
708 EXPORT_C CTBackedUpWin::~CTBackedUpWin() |
|
709 { |
|
710 if (iFont) |
|
711 Client()->iScreen->ReleaseFont(iFont); |
|
712 iWin.Close(); |
|
713 } |
|
714 |
|
715 EXPORT_C TInt CTBackedUpWin::ConstructWin(const CTWinBase &aParent) |
|
716 { |
|
717 iWin=RBackedUpWindow(aParent.Client()->iWs); |
|
718 return(iWin.Construct(*(aParent.WinTreeNode()), iDisplayMode, (TUint32)this)); |
|
719 } |
|
720 |
|
721 EXPORT_C RWindowBase *CTBackedUpWin::BaseWin() |
|
722 { |
|
723 return((RWindowBase *)&iWin); |
|
724 } |
|
725 |
|
726 EXPORT_C const RWindowBase *CTBackedUpWin::BaseWin() const |
|
727 { |
|
728 return((const RWindowBase *)&iWin); |
|
729 } |
|
730 |
|
731 EXPORT_C RDrawableWindow *CTBackedUpWin::DrawableWin() |
|
732 { |
|
733 return((RDrawableWindow *)&iWin); |
|
734 } |
|
735 |
|
736 EXPORT_C const RDrawableWindow *CTBackedUpWin::DrawableWin() const |
|
737 { |
|
738 return((const RDrawableWindow *)&iWin); |
|
739 } |
|
740 |
|
741 EXPORT_C RBackedUpWindow *CTBackedUpWin::BackedUpWin() |
|
742 { |
|
743 return &iWin; |
|
744 } |
|
745 |
|
746 EXPORT_C const RBackedUpWindow *CTBackedUpWin::BackedUpWin() const |
|
747 { |
|
748 return &iWin; |
|
749 } |
|
750 |
|
751 //CTTitledWindow// |
|
752 |
|
753 EXPORT_C CTTitledWindow::CTTitledWindow() : CTWin(), iWinColor(TRgb(255,255,255)), iPenColor(TRgb(0,0,0)) |
|
754 { |
|
755 __DECLARE_NAME(_S("CTTitledWin")); |
|
756 } |
|
757 |
|
758 EXPORT_C CTTitledWindow::~CTTitledWindow() |
|
759 { |
|
760 } |
|
761 |
|
762 EXPORT_C void CTTitledWindow::ConstructL(CTWinBase &parent) |
|
763 { |
|
764 CTBaseWin::ConstructL(parent); |
|
765 iTitleHeight=iFont->HeightInPixels()+4; |
|
766 if (iTitle.Length()==0) |
|
767 SetTitle(*Client()->Title()); |
|
768 } |
|
769 |
|
770 EXPORT_C void CTTitledWindow::SetColor(TRgb aRgb) |
|
771 { |
|
772 iWinColor=aRgb; |
|
773 iWin.SetBackgroundColor(aRgb); |
|
774 } |
|
775 |
|
776 EXPORT_C void CTTitledWindow::Resized(const TSize &aSize) |
|
777 { |
|
778 SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight)); |
|
779 } |
|
780 |
|
781 EXPORT_C void CTTitledWindow::SetTitle(const TWindowTitle &aTitle) |
|
782 { |
|
783 iTitle=aTitle; |
|
784 } |
|
785 |
|
786 EXPORT_C void CTTitledWindow::Draw() |
|
787 { |
|
788 iGc->SetPenColor(iPenColor); |
|
789 iGc->SetBrushColor(iWinColor); |
|
790 DrawBorder(); |
|
791 iGc->DrawLine(TPoint(0,iTitleHeight),TPoint(iSize.iWidth,iTitleHeight)); |
|
792 if (Group()->HasFocus(this)) |
|
793 { |
|
794 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
795 iGc->SetPenColor(~iPenColor); |
|
796 iGc->SetBrushColor(~iWinColor); |
|
797 } |
|
798 iGc->DrawText(iTitle, TRect(1,1,iSize.iWidth-1,iTitleHeight),iFont->AscentInPixels()+1,CGraphicsContext::ECenter); |
|
799 iGc->SetPenColor(iPenColor); |
|
800 iGc->SetBrushColor(iWinColor); |
|
801 } |
|
802 |
|
803 EXPORT_C void CTTitledWindow::FocusChanged(TBool ) |
|
804 { |
|
805 iWin.Invalidate(TRect(0,0,iSize.iWidth,iTitleHeight)); |
|
806 } |
|
807 |
|
808 // CTBlankWindow // |
|
809 |
|
810 EXPORT_C CTBlankWindow::CTBlankWindow() : CTBaseWin(EWinTypeClient) |
|
811 { |
|
812 __DECLARE_NAME(_S("CTBlankWin")); |
|
813 } |
|
814 |
|
815 EXPORT_C void CTBlankWindow::ConstructL(CTWinBase &aParent) |
|
816 { |
|
817 CTBaseWin::ConstructL(aParent); |
|
818 } |
|
819 |
|
820 EXPORT_C CTBlankWindow::~CTBlankWindow() |
|
821 { |
|
822 if (iFont) |
|
823 Client()->iScreen->ReleaseFont(iFont); |
|
824 iWin.Close(); |
|
825 } |
|
826 |
|
827 EXPORT_C void CTBlankWindow::SetExt(const TPoint &aPos, const TSize &aSize) |
|
828 { |
|
829 iWin.SetExtent(aPos,aSize); |
|
830 iPos=aPos; |
|
831 iSize=aSize; |
|
832 Resized(iSize); |
|
833 } |
|
834 |
|
835 EXPORT_C void CTBlankWindow::SetSize(const TSize &aSize) |
|
836 { |
|
837 iWin.SetSize(aSize); |
|
838 iSize=aSize; |
|
839 Resized(iSize); |
|
840 } |
|
841 |
|
842 EXPORT_C void CTBlankWindow::SetColor(const TRgb &aRgb) |
|
843 { |
|
844 iWin.SetColor(aRgb); |
|
845 } |
|
846 |
|
847 EXPORT_C TInt CTBlankWindow::ConstructWin(const CTWinBase &aParent) |
|
848 { |
|
849 iWin=RBlankWindow(aParent.Client()->iWs); |
|
850 return(iWin.Construct(*(aParent.WinTreeNode()),(TUint32)this)); |
|
851 } |
|
852 |
|
853 EXPORT_C const RWindowBase *CTBlankWindow::BaseWin() const |
|
854 { |
|
855 return((const RWindowBase *)&iWin); |
|
856 } |
|
857 |
|
858 EXPORT_C RWindowBase *CTBlankWindow::BaseWin() |
|
859 { |
|
860 return((RWindowBase *)&iWin); |
|
861 } |
|
862 |
|
863 //CTWindowGroup// |
|
864 |
|
865 EXPORT_C CTWindowGroup::CTWindowGroup(CTClient *aClient) : CTWinBase(EWinTypeGroup), iGroupWin(aClient->iWs) |
|
866 { |
|
867 __DECLARE_NAME(_S("CTWindowGroup")); |
|
868 iClient=aClient; |
|
869 iOwnerWin=this; |
|
870 } |
|
871 |
|
872 EXPORT_C CTWindowGroup::~CTWindowGroup() |
|
873 { |
|
874 iGroupWin.Close(); |
|
875 } |
|
876 |
|
877 EXPORT_C const RWindowTreeNode *CTWindowGroup::WinTreeNode() const |
|
878 { |
|
879 return((const RWindowTreeNode *)&iGroupWin); |
|
880 } |
|
881 |
|
882 EXPORT_C RWindowTreeNode *CTWindowGroup::WinTreeNode() |
|
883 { |
|
884 return((RWindowTreeNode *)&iGroupWin); |
|
885 } |
|
886 |
|
887 EXPORT_C void CTWindowGroup::ConstructL() |
|
888 { |
|
889 User::LeaveIfError(iGroupWin.Construct((TUint32)this)); |
|
890 } |
|
891 |
|
892 EXPORT_C TSize CTWindowGroup::Size() const |
|
893 { |
|
894 return(iClient->iScreen->SizeInPixels()); |
|
895 } |
|
896 |
|
897 EXPORT_C void CTWindowGroup::WinKeyL(const TKeyEvent &,const TTime&) |
|
898 { |
|
899 } |
|
900 |
|
901 EXPORT_C void CTWindowGroup::KeyL(const TKeyEvent &aKey,const TTime&aTime) |
|
902 { |
|
903 if (iCurWin) |
|
904 iCurWin->WinKeyL(aKey,aTime); |
|
905 } |
|
906 |
|
907 EXPORT_C void CTWindowGroup::KeyUpL(const TKeyEvent &,const TTime&) |
|
908 { |
|
909 } |
|
910 |
|
911 EXPORT_C void CTWindowGroup::KeyDownL(const TKeyEvent &,const TTime&) |
|
912 { |
|
913 } |
|
914 |
|
915 EXPORT_C void CTWindowGroup::ClearCurrentWindow() |
|
916 { |
|
917 iCurWin=NULL; |
|
918 } |
|
919 |
|
920 EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow) |
|
921 { |
|
922 SetCurrentWindow(aWindow, EFalse); |
|
923 } |
|
924 |
|
925 EXPORT_C void CTWindowGroup::SetCurrentWindow(CTBaseWin *aWindow, TBool aLocked) |
|
926 { |
|
927 if (iCurWin!=aWindow) |
|
928 { |
|
929 if (iFocus && iCurWin) |
|
930 iCurWin->FocusChanged(EFalse); |
|
931 iCurWin=aWindow; |
|
932 if (iFocus && iCurWin) |
|
933 iCurWin->FocusChanged(ETrue); |
|
934 } |
|
935 iLocked=aLocked; |
|
936 } |
|
937 |
|
938 EXPORT_C CTBaseWin *CTWindowGroup::CurWin(void) const |
|
939 { |
|
940 return(iCurWin); |
|
941 } |
|
942 |
|
943 EXPORT_C void CTWindowGroup::FocusLost() |
|
944 { |
|
945 iFocus=EFalse; |
|
946 if (iCurWin) |
|
947 iCurWin->FocusChanged(EFalse); |
|
948 } |
|
949 |
|
950 EXPORT_C void CTWindowGroup::FocusGained() |
|
951 { |
|
952 iFocus=ETrue; |
|
953 if (iCurWin) |
|
954 iCurWin->FocusChanged(ETrue); |
|
955 } |
|
956 |
|
957 EXPORT_C TBool CTWindowGroup::HasFocus(CTBaseWin *aWin) const |
|
958 { |
|
959 return(iFocus && iCurWin==aWin); |
|
960 } |
|
961 |
|
962 EXPORT_C CTClient *CTWindowGroup::Client() const |
|
963 { |
|
964 return(iClient); |
|
965 } |
|
966 |
|
967 EXPORT_C CTWindowGroup *CTWindowGroup::Group() const |
|
968 { |
|
969 return((CTWindowGroup *)this); |
|
970 } |
|
971 |
|
972 EXPORT_C void CTWindowGroup::PasswordL(const TTime &) |
|
973 { |
|
974 TbPanic(ETestBasePanicPassword); |
|
975 } |
|
976 |
|
977 EXPORT_C void CTWindowGroup::MessageReady(const TWsEvent &) |
|
978 // |
|
979 // Dummy handler for un-exepected messages (could panic, but better not as the app sending the messages fault really not ours) |
|
980 // |
|
981 { |
|
982 } |
|
983 |
|
984 EXPORT_C void CTWindowGroup::ScreenDeviceChanged() |
|
985 { |
|
986 TPixelsAndRotation sizeAndRotation; |
|
987 Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation); |
|
988 Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation); |
|
989 } |
|
990 |
|
991 EXPORT_C void CTWindowGroup::UserEvent(TInt /*aEventType*/) |
|
992 { |
|
993 } |
|
994 |
|
995 |
|
996 // CTClient // |
|
997 |
|
998 EXPORT_C CTClient::CTClient() |
|
999 { |
|
1000 __DECLARE_NAME(_S("CTClient")); |
|
1001 } |
|
1002 |
|
1003 EXPORT_C void CTClient::DestroyWindows() |
|
1004 { |
|
1005 if (iGroup) |
|
1006 { |
|
1007 CTBaseWin *win; |
|
1008 if (iGroup->GroupWin()->WsHandle()!=0) // Check it was created okay |
|
1009 while((win=iGroup->Child())!=NULL && ((TUint)win)!=ENullWsHandle) |
|
1010 CTBaseWin::Delete(win); |
|
1011 delete iGroup; |
|
1012 iGroup=NULL; |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 EXPORT_C CTClient::~CTClient() |
|
1017 { |
|
1018 DestroyWindows(); |
|
1019 delete iGc; |
|
1020 delete iEventHandler; |
|
1021 delete iRedrawEventHandler; |
|
1022 delete iScreen; |
|
1023 TInt count=iWs.ResourceCount(); |
|
1024 __ASSERT_ALWAYS(count==0,TbPanic(ETestBasePanicResourceCount)); |
|
1025 iWs.Close(); |
|
1026 } |
|
1027 |
|
1028 EXPORT_C void CTClient::ConstructEventHandlerL() |
|
1029 { |
|
1030 iEventHandler=new(ELeave) CTEvent(&iWs); |
|
1031 iEventHandler->Construct(); |
|
1032 } |
|
1033 |
|
1034 EXPORT_C void CTClient::ConstructL() |
|
1035 { |
|
1036 User::LeaveIfError(iWs.Connect()); |
|
1037 iScreen=new(ELeave) CWsScreenDevice(iWs); |
|
1038 User::LeaveIfError(iScreen->Construct(iScreenNumber)); |
|
1039 iRedrawEventHandler=new(ELeave) CTRedraw(&iWs); |
|
1040 iRedrawEventHandler->Construct(); |
|
1041 ConstructEventHandlerL(); |
|
1042 iGc=new(ELeave) CWindowGc(iScreen); |
|
1043 User::LeaveIfError(iGc->Construct()); |
|
1044 iTitle.Copy(RThread().FullName()); |
|
1045 } |
|
1046 |
|
1047 EXPORT_C void CTClient::ResetFocus() |
|
1048 { |
|
1049 iGroup->ClearCurrentWindow(); |
|
1050 iGroup->SetCurrentWindow(iGroup->Child()); |
|
1051 } |
|
1052 |
|
1053 EXPORT_C TWindowTitle *CTClient::Title() |
|
1054 { |
|
1055 return(&iTitle); |
|
1056 } |
|
1057 |
|
1058 EXPORT_C TBool CTClient::QueueRead() |
|
1059 { |
|
1060 TBool ret=iEventHandler->IsActive(); |
|
1061 if (ret==EFalse) |
|
1062 iEventHandler->Request(); |
|
1063 return(ret); |
|
1064 } |
|
1065 |
|
1066 EXPORT_C void CTClient::CancelRead() |
|
1067 { |
|
1068 iEventHandler->Cancel(); |
|
1069 } |
|
1070 |
|
1071 EXPORT_C void CTClient::SetCancelFunction(const TCallBack &aCallBack) |
|
1072 { |
|
1073 iEventHandler->SetCancelFunction(aCallBack); |
|
1074 } |
|
1075 |
|
1076 EXPORT_C void CTClient::CancelRedrawRead() |
|
1077 { |
|
1078 iRedrawEventHandler->Cancel(); |
|
1079 } |
|
1080 |
|
1081 EXPORT_C void CTClient::SetRedrawCancelFunction(const TCallBack &aCallBack) |
|
1082 { |
|
1083 iRedrawEventHandler->SetCancelFunction(aCallBack); |
|
1084 } |
|
1085 |
|
1086 EXPORT_C void CTClient::RequestRedraw() |
|
1087 { |
|
1088 iRedrawEventHandler->Request(); |
|
1089 } |
|
1090 |
|
1091 EXPORT_C void CTClient::LogMessage(const TLogMessageText &aMessage) |
|
1092 { |
|
1093 iWs.LogMessage(aMessage); |
|
1094 iWs.Flush(); |
|
1095 } |
|
1096 |
|
1097 EXPORT_C TBool CTClient::IsEventWaiting() |
|
1098 { |
|
1099 iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished |
|
1100 return (iEventHandler->iStatus!=KRequestPending); |
|
1101 } |
|
1102 |
|
1103 TBool CTClient::WaitUntilEventPending(const TRequestStatus& aStatus) |
|
1104 { |
|
1105 if (aStatus!=KRequestPending) |
|
1106 return ETrue; |
|
1107 User::After(2000000); //Need something smarter than this |
|
1108 return (aStatus!=KRequestPending); |
|
1109 } |
|
1110 |
|
1111 EXPORT_C TBool CTClient::WaitUntilRedrawPending() |
|
1112 { |
|
1113 return WaitUntilEventPending(iRedrawEventHandler->iStatus); |
|
1114 } |
|
1115 |
|
1116 EXPORT_C TBool CTClient::WaitUntilEventPending() |
|
1117 { |
|
1118 return WaitUntilEventPending(iEventHandler->iStatus); |
|
1119 } |
|
1120 |
|
1121 EXPORT_C TInt CTClient::WaitForRedrawsToFinish() |
|
1122 { |
|
1123 return WaitForEventsToFinish(EFalse); |
|
1124 } |
|
1125 |
|
1126 EXPORT_C TInt CTClient::WaitForAllEventProcessingToFinish() |
|
1127 { |
|
1128 return WaitForEventsToFinish(ETrue); |
|
1129 } |
|
1130 |
|
1131 TInt CTClient::WaitForEventsToFinish(TBool aAll) |
|
1132 { |
|
1133 CStopTheScheduler* stop=new CStopTheScheduler(this,ETlibRedrawActivePriority-1,aAll); |
|
1134 if (!stop) |
|
1135 return KErrNoMemory; |
|
1136 stop->Call(); |
|
1137 CActiveScheduler::Start(); |
|
1138 delete stop; |
|
1139 return KErrNone; |
|
1140 } |
|
1141 |
|
1142 |
|
1143 // CStopTheScheduler // |
|
1144 |
|
1145 void CStopTheScheduler::RunL() |
|
1146 { |
|
1147 #ifdef __WINS__ |
|
1148 RDebug::Print(_L("CStopTheScheduler::RunL - enter - %d"), iCStopTheSchedulerRunCount); |
|
1149 #endif |
|
1150 if (iClient) |
|
1151 { |
|
1152 iClient->iWs.NumWindowGroups(); //Make sure all asyncronus calls have finished |
|
1153 } |
|
1154 |
|
1155 if (!iClient || (iClient->RedrawHandler()->iStatus==KRequestPending && (!iAll || iClient->EventHandler()->iStatus==KRequestPending))) |
|
1156 { |
|
1157 #ifdef __WINS__ |
|
1158 RDebug::Print(_L("CStopTheScheduler::RunL - Stop - %d"), iCStopTheSchedulerRunCount); |
|
1159 #endif |
|
1160 CActiveScheduler::Stop(); |
|
1161 } |
|
1162 else |
|
1163 { |
|
1164 #ifdef __WINS__ |
|
1165 RDebug::Print(_L("CStopTheScheduler::RunL - Call - %d"), iCStopTheSchedulerRunCount); |
|
1166 #endif |
|
1167 Call(); |
|
1168 } |
|
1169 #ifdef __WINS__ |
|
1170 RDebug::Print(_L("CStopTheScheduler::RunL - exit - %d"), iCStopTheSchedulerRunCount); |
|
1171 iCStopTheSchedulerRunCount++; |
|
1172 #endif |
|
1173 } |
|
1174 |
|
1175 void WaitForRedrawsToFinish() |
|
1176 { |
|
1177 CStopTheScheduler* ps=new CStopTheScheduler(ETlibRedrawActivePriority-1); |
|
1178 if(ps) |
|
1179 { |
|
1180 ps->Call(); |
|
1181 CActiveScheduler::Start(); |
|
1182 delete ps; |
|
1183 } |
|
1184 } |
|
1185 |
|
1186 |
|
1187 // CTEventBase // |
|
1188 |
|
1189 EXPORT_C CTEventBase::CTEventBase(RWsSession *aWs, TInt aPriority) : CActive(aPriority), iWs(aWs) |
|
1190 { |
|
1191 } |
|
1192 |
|
1193 EXPORT_C CTEventBase::~CTEventBase() |
|
1194 { |
|
1195 } |
|
1196 |
|
1197 EXPORT_C void CTEventBase::Construct() |
|
1198 { |
|
1199 CActiveScheduler::Add(this); |
|
1200 Request(); |
|
1201 } |
|
1202 |
|
1203 EXPORT_C void CTEventBase::RunL() |
|
1204 { |
|
1205 if (iStatus==KErrNone) |
|
1206 { |
|
1207 ++iCount; |
|
1208 TRAPD(err,doRunL()); |
|
1209 if (err<=0) // Positive value means this has been destroyed |
|
1210 { |
|
1211 if (iCancelRequested) |
|
1212 CancelHandler(); |
|
1213 Request(); |
|
1214 // if (err!=KErrNone) |
|
1215 // User::LeaveIfError(err); Should have a guaranteed to work error dialog here I guess |
|
1216 } |
|
1217 } |
|
1218 else if (iStatus==KErrCancel && iCancelRequested) |
|
1219 { |
|
1220 CancelHandler(); |
|
1221 Request(); |
|
1222 } |
|
1223 else |
|
1224 TbPanic(ETestBasePanicEventStat); |
|
1225 } |
|
1226 |
|
1227 void CTEventBase::SetCancelFunction(const TCallBack &aCallBack) |
|
1228 { |
|
1229 if (!IsActive() && iCancelRequested) |
|
1230 TbPanic(ETestBasePanicCancelFunction); |
|
1231 iCancelCallBack=aCallBack; |
|
1232 iCancelRequested=ETrue; |
|
1233 DoCancel(); |
|
1234 } |
|
1235 |
|
1236 EXPORT_C void CTEventBase::CancelHandler() |
|
1237 { |
|
1238 iCancelCallBack.CallBack(); |
|
1239 iCancelRequested=EFalse; |
|
1240 } |
|
1241 |
|
1242 // TLibWsEvent // |
|
1243 |
|
1244 EXPORT_C CTWindowGroup *TlibWsEvent::WindowGroup() |
|
1245 { |
|
1246 CTWindowGroup *group=(CTWindowGroup *)Handle(); |
|
1247 __ASSERT_DEBUG(group->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); |
|
1248 return(group); |
|
1249 } |
|
1250 |
|
1251 EXPORT_C CTBaseWin *TlibWsEvent::BaseWin() |
|
1252 { |
|
1253 CTBaseWin *win=(CTBaseWin *)Handle(); |
|
1254 __ASSERT_DEBUG(win->iType==EWinTypeClient || win->iType==EWinTypeGroup,TbPanic(ETestBasePanicWinType)); |
|
1255 return(win); |
|
1256 } |
|
1257 |
|
1258 // CTEvent // |
|
1259 |
|
1260 EXPORT_C CTEvent::CTEvent(RWsSession *aWs) : CTEventBase(aWs, ETlibWsEventActivePriority) |
|
1261 { |
|
1262 __DECLARE_NAME(_S("CTEvent")); |
|
1263 } |
|
1264 |
|
1265 EXPORT_C CTEvent::~CTEvent() |
|
1266 { |
|
1267 Cancel(); |
|
1268 } |
|
1269 |
|
1270 EXPORT_C void CTEvent::DoCancel() |
|
1271 { |
|
1272 iWs->EventReadyCancel(); |
|
1273 } |
|
1274 |
|
1275 EXPORT_C void CTEvent::Request() |
|
1276 { |
|
1277 iWs->EventReady(&iStatus); |
|
1278 SetActive(); |
|
1279 } |
|
1280 |
|
1281 EXPORT_C void CTEvent::LogEvent(const TWsEvent &) |
|
1282 { |
|
1283 } |
|
1284 |
|
1285 EXPORT_C void CTEvent::doRunL() |
|
1286 { |
|
1287 TlibWsEvent event; |
|
1288 |
|
1289 iWs->GetEvent(event); |
|
1290 LogEvent(event); |
|
1291 if (event.Handle()!=0 && event.Handle()!=ENullWsHandle) |
|
1292 { |
|
1293 switch(event.Type()) |
|
1294 { |
|
1295 case EEventKey: |
|
1296 event.WindowGroup()->KeyL(*event.Key(),event.Time()); |
|
1297 break; |
|
1298 case EEventKeyDown: |
|
1299 __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); |
|
1300 event.WindowGroup()->KeyDownL(*event.Key(),event.Time()); |
|
1301 break; |
|
1302 case EEventKeyUp: |
|
1303 __ASSERT_ALWAYS(event.Key()->iCode==0 && event.Key()->iRepeats==0, TbPanic(ETestBasePanicKeyParams)); |
|
1304 event.WindowGroup()->KeyUpL(*event.Key(),event.Time()); |
|
1305 break; |
|
1306 case EEventModifiersChanged: |
|
1307 event.BaseWin()->ModifiersChanged(*event.ModifiersChanged(),event.Time()); |
|
1308 break; |
|
1309 case EEventPointer: |
|
1310 event.BaseWin()->PointerL(*event.Pointer(),event.Time()); |
|
1311 break; |
|
1312 case EEventDragDrop: |
|
1313 event.BaseWin()->DragDropL(*event.Pointer(),event.Time()); |
|
1314 break; |
|
1315 case EEventPointerEnter: |
|
1316 event.BaseWin()->PointerEnter(event.Time()); |
|
1317 break; |
|
1318 case EEventPointerExit: |
|
1319 event.BaseWin()->PointerExit(event.Time()); |
|
1320 break; |
|
1321 case EEventPointerBufferReady: |
|
1322 event.BaseWin()->PointerBufferReady(event.Time()); |
|
1323 break; |
|
1324 case EEventSwitchOn: |
|
1325 event.BaseWin()->SwitchOn(event.Time()); |
|
1326 break; |
|
1327 case EEventFocusLost: |
|
1328 event.WindowGroup()->FocusLost(); |
|
1329 break; |
|
1330 case EEventFocusGained: |
|
1331 event.WindowGroup()->FocusGained(); |
|
1332 break; |
|
1333 case EEventPassword: |
|
1334 event.WindowGroup()->PasswordL(event.Time()); |
|
1335 break; |
|
1336 case EEventMessageReady: |
|
1337 event.WindowGroup()->MessageReady(event); |
|
1338 break; |
|
1339 case EEventErrorMessage: |
|
1340 event.WindowGroup()->ErrorMessage(*event.ErrorMessage(), event.Time()); |
|
1341 break; |
|
1342 case EEventSwitchOff: |
|
1343 case EEventKeySwitchOff: |
|
1344 { |
|
1345 TTimeIntervalMicroSeconds32 ii=1000000; |
|
1346 User::After(ii); //WINS does not always work without this! |
|
1347 UserHal::SwitchOff(); |
|
1348 } |
|
1349 break; |
|
1350 case EEventScreenDeviceChanged: |
|
1351 event.WindowGroup()->ScreenDeviceChanged(); |
|
1352 break; |
|
1353 case EEventNull: |
|
1354 break; |
|
1355 default: |
|
1356 if (event.Type()>=EEventUser) |
|
1357 { |
|
1358 event.WindowGroup()->UserEvent(event.Type()); |
|
1359 break; |
|
1360 } |
|
1361 else |
|
1362 { |
|
1363 //if not in BufferSecurity test - panic |
|
1364 TInt value = EFalse; |
|
1365 TInt err = RProperty::Get(KUidWServSecurityTesting,EWServSecTestBufferSecurity,value); |
|
1366 if ((err != KErrNone) || (value != (TInt)ETrue)) |
|
1367 TbPanic(ETestBasePanicInvalidEvent); |
|
1368 } |
|
1369 break; |
|
1370 } |
|
1371 } |
|
1372 } |
|
1373 |
|
1374 EXPORT_C CTRedraw::CTRedraw(RWsSession *aWs) : CTEventBase(aWs, ETlibRedrawActivePriority) |
|
1375 { |
|
1376 __DECLARE_NAME(_S("CTRedraw")); |
|
1377 } |
|
1378 |
|
1379 EXPORT_C CTRedraw::~CTRedraw() |
|
1380 { |
|
1381 Cancel(); |
|
1382 } |
|
1383 |
|
1384 EXPORT_C void CTRedraw::Request() |
|
1385 { |
|
1386 iWs->RedrawReady(&iStatus); |
|
1387 SetActive(); |
|
1388 } |
|
1389 |
|
1390 EXPORT_C void CTRedraw::DoCancel() |
|
1391 { |
|
1392 iWs->RedrawReadyCancel(); |
|
1393 } |
|
1394 |
|
1395 EXPORT_C void CTRedraw::doRunL() |
|
1396 { |
|
1397 TWsRedrawEvent redraw; |
|
1398 iWs->GetRedraw(redraw); |
|
1399 if (redraw.Handle()!=0 && redraw.Handle()!=ENullWsHandle) |
|
1400 { |
|
1401 __ASSERT_ALWAYS(!redraw.Rect().IsEmpty(),TbPanic(ETestBasePanicNullRedraw)); |
|
1402 ((CTWin *)redraw.Handle())->Redraw(redraw.Rect()); |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 EXPORT_C void CTUser::Splat(CTClient *aClient, const TRect &aRect, const TRgb &aRgb) |
|
1407 { |
|
1408 RBlankWindow win(aClient->iWs); |
|
1409 win.Construct(*(aClient->iGroup->WinTreeNode()),1); |
|
1410 win.SetColor(aRgb); |
|
1411 win.SetExtent(aRect.iTl,aRect.Size()); |
|
1412 win.Activate(); |
|
1413 aClient->iWs.Flush(); |
|
1414 win.Close(); |
|
1415 } |
|
1416 |
|
1417 void doTestLibStartUpL(TInt aScreenNumber, CTClient *&aClient, CActiveScheduler *&aActiveScheduler,CTrapCleanup *&aCleanUpStack,TCreateClientFunc aFunc) |
|
1418 { |
|
1419 User::LeaveIfNull(aCleanUpStack=CTrapCleanup::New()); |
|
1420 aActiveScheduler=new(ELeave) CActiveScheduler; |
|
1421 CActiveScheduler::Install(aActiveScheduler); |
|
1422 aClient=aFunc(); |
|
1423 aClient->SetScreenNumber(aScreenNumber); |
|
1424 aClient->ConstructL(); |
|
1425 CActiveScheduler::Start(); |
|
1426 } |
|
1427 |
|
1428 EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc,TInt aScreenNumber) |
|
1429 { |
|
1430 __UHEAP_MARK; |
|
1431 CTrapCleanup* cleanUpStack=NULL; |
|
1432 CActiveScheduler *activeScheduler=NULL; |
|
1433 CTClient *client=NULL; |
|
1434 TRAPD(err,doTestLibStartUpL(aScreenNumber, client,activeScheduler,cleanUpStack,aFunc)); |
|
1435 delete client; |
|
1436 delete activeScheduler; |
|
1437 delete cleanUpStack; |
|
1438 __UHEAP_MARKEND; |
|
1439 return(err); |
|
1440 } |
|
1441 |
|
1442 EXPORT_C TInt TestLibStartUp(TCreateClientFunc aFunc) |
|
1443 { |
|
1444 return TestLibStartUp(aFunc, KDefaultScreen); |
|
1445 } |
|
1446 |