|
1 // Copyright (c) 1995-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 // Interface code for animated DLL's |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include "server.h" |
|
20 #include "gc.h" |
|
21 #include "rootwin.h" |
|
22 #include "windowgroup.h" |
|
23 #include "ANIM.H" |
|
24 #include "wstop.h" |
|
25 #include "EVENT.H" |
|
26 #include "ScrDev.H" |
|
27 #include "offscreenbitmap.h" |
|
28 #include "panics.h" |
|
29 #include "wsfont.h" |
|
30 |
|
31 GLREF_D CDebugLogBase *wsDebugLog; |
|
32 |
|
33 static const TInt64 KFlashOnTime(700000); |
|
34 static const TInt64 KFlashOffTime(300000); |
|
35 static const TInt64 KOneSecond(1000000); |
|
36 static const TInt64 KOneMinute(60 * KOneSecond); |
|
37 static const TInt64 KOneDay(24 * 60 * 60 * KOneSecond); |
|
38 static const TInt64 KOneHalfSecond(500000); |
|
39 |
|
40 enum {EWindowUpdate=0x0001}; |
|
41 |
|
42 // Anim DLL code // |
|
43 CWsAnimGc *CWsAnim::WsAnimGc=NULL; |
|
44 |
|
45 void CWsAnim::InitStaticsL() |
|
46 { |
|
47 WsAnimGc=new (ELeave) CWsAnimGc(); |
|
48 } |
|
49 |
|
50 void CWsAnim::DeleteStatics() |
|
51 { |
|
52 delete WsAnimGc; |
|
53 WsAnimGc=NULL; |
|
54 } |
|
55 |
|
56 CWsAnim::CWsAnim(CWsAnimDll *aDll) : iClient(aDll->WsOwner()), iAnimAddedInHandler(EFalse), iLastFrame(-1), iFlashOn(ETrue) |
|
57 { |
|
58 __DECLARE_NAME(_S("CWsAnim")); |
|
59 } |
|
60 |
|
61 void CWsAnim::WindowClosing(CWsAnim *aWsAnim) |
|
62 { |
|
63 CWsAnim *anim=aWsAnim; |
|
64 CWsAnim *next; |
|
65 while(anim) |
|
66 { |
|
67 next=anim->iNextWin; |
|
68 CloseAnim(anim); |
|
69 anim=next; |
|
70 } |
|
71 } |
|
72 |
|
73 void CWsAnim::CloseAnim(CWsAnim *aWsAnim) |
|
74 { |
|
75 TInt handle=aWsAnim->iAnimDll->AnimObjectHandle(aWsAnim); |
|
76 if (handle<0) |
|
77 delete aWsAnim; |
|
78 else |
|
79 aWsAnim->iAnimDll->Remove(handle); |
|
80 } |
|
81 |
|
82 CWsAnim::~CWsAnim() |
|
83 { |
|
84 WsAnimGc->AnimDeleted(this); |
|
85 if (iWindow) // In case it never got linked |
|
86 { |
|
87 CWsAnim **pAnim; |
|
88 for(pAnim= &iWindow->iAnimList;(*pAnim)!=this;pAnim= &(*pAnim)->iNextWin) |
|
89 {} |
|
90 *pAnim=iNextWin; |
|
91 } |
|
92 else if (iSprite) |
|
93 iSprite->iAnim=NULL; |
|
94 |
|
95 // force the anim for the event handler list. |
|
96 TWindowServerEvent::RemoveEventHandler(iAnim); |
|
97 TWindowServerEvent::RemoveNotificationHandler(iAnim); |
|
98 delete iAnim; |
|
99 TWindowServerEvent::PotentialEventHandlerL(-1); //PotentialEventHandler cannot leave when passed a negative parameter. |
|
100 } |
|
101 |
|
102 void CWsAnim::Connect(CWsClientWindow *aWindow) |
|
103 { |
|
104 if (iSprite) |
|
105 Panic(); |
|
106 iWindow=aWindow; |
|
107 iNextWin=aWindow->iAnimList; |
|
108 aWindow->iAnimList=this; |
|
109 } |
|
110 |
|
111 void CWsAnim::Connect(CWsSprite *aSprite) |
|
112 { |
|
113 if (iWindow) |
|
114 Panic(); |
|
115 iSprite=aSprite; |
|
116 iSprite->iAnim=this; |
|
117 } |
|
118 |
|
119 LOCAL_C void HandleLeaveInCWsAnimConstructL(TAny* aAnim) |
|
120 { |
|
121 STATIC_CAST(CWsAnim*,aAnim)->SetMessage(NULL); |
|
122 CWsAnim::UserDeactivateAnimGc(); |
|
123 } |
|
124 |
|
125 void CWsAnim::ConstructL(CAnim *aAnim, TAny *aArgs, CWsAnimDll *aAnimDll, TBool aIsWindow) |
|
126 { |
|
127 TBool isFocused=(iSprite!=NULL); |
|
128 if (!isFocused) |
|
129 isFocused=CWsTop::FocusWindowGroup()==iWindow->WinGroup(); |
|
130 iAnimDll=aAnimDll; |
|
131 iAnimSync=ESyncNone; |
|
132 iAnim=aAnim; |
|
133 iAnim->iFunctions=this; |
|
134 SetMessage(&iClient->ClientMessage()); |
|
135 CleanupStack::PushL(TCleanupItem(HandleLeaveInCWsAnimConstructL,this)); |
|
136 if (aIsWindow) |
|
137 { |
|
138 CWindowAnim* windowAnim=WindowAnim(); |
|
139 windowAnim->iWindowFunctions=this; |
|
140 windowAnim->iGc=WsAnimGc; |
|
141 windowAnim->ConstructL(aArgs, isFocused); |
|
142 } |
|
143 else |
|
144 { |
|
145 CSpriteAnim* spriteAnim=STATIC_CAST(CSpriteAnim*,iAnim); |
|
146 spriteAnim->iSpriteFunctions=this; |
|
147 spriteAnim->ConstructL(aArgs); |
|
148 } |
|
149 CleanupStack::PopAndDestroy(this); // doesn't really destroy "this" - it actually calls HandleLeaveInCWsAnimConstructL |
|
150 } |
|
151 |
|
152 void CWsAnim::Redraw(CFbsBitGc * aGc, const TRegion *aRegion) |
|
153 { |
|
154 WS_ASSERT_DEBUG(iWindow,EWsPanicAnimHasNoWindow); |
|
155 if (!iWindow) |
|
156 return; |
|
157 |
|
158 TWindowInfo::TRegionPair regionPair; |
|
159 regionPair.iRegion1 = aRegion; |
|
160 regionPair.iRegion2 = NULL; |
|
161 iRedrawRegionPair = ®ionPair; |
|
162 |
|
163 // We don't attempt to make use of iRect because it often isn't set up by the client code. |
|
164 |
|
165 // Work out which frame we are in: |
|
166 TTime now = iWindow->Screen()->Now(); |
|
167 if (iLastFrame < 0) |
|
168 iStartTime = now; |
|
169 TInt64 elapsed = now.Int64() - iStartTime.Int64(); |
|
170 TInt64 adjustedStart = iStartTime.Int64(); |
|
171 TInt frame = 0; |
|
172 switch (iAnimSync) |
|
173 { |
|
174 case ESyncNone: |
|
175 if (iInterval > 0) |
|
176 { |
|
177 frame = elapsed / iInterval.Int64(); |
|
178 } |
|
179 else |
|
180 { |
|
181 frame = -1; |
|
182 } |
|
183 break; |
|
184 case ESyncFlash: |
|
185 { |
|
186 TInt64 fraction = elapsed % (KFlashOnTime + KFlashOffTime); |
|
187 frame = (elapsed - fraction) / (KFlashOnTime + KFlashOffTime) * 2; |
|
188 if (fraction > KFlashOnTime) |
|
189 { |
|
190 frame = frame + 1; |
|
191 iFlashOn = EFalse; |
|
192 } |
|
193 else |
|
194 { |
|
195 iFlashOn = ETrue; |
|
196 } |
|
197 } |
|
198 break; |
|
199 case ESyncSecond: |
|
200 adjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneSecond); |
|
201 elapsed = now.Int64() - adjustedStart; |
|
202 frame = elapsed / KOneSecond; |
|
203 break; |
|
204 case ESyncMinute: |
|
205 adjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneMinute); |
|
206 elapsed = now.Int64() - adjustedStart; |
|
207 frame = elapsed / KOneMinute; |
|
208 break; |
|
209 case ESyncDay: |
|
210 adjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneDay); |
|
211 elapsed = now.Int64() - adjustedStart; |
|
212 frame = elapsed / KOneDay; |
|
213 break; |
|
214 } |
|
215 |
|
216 // If the frame has changed, animate: |
|
217 if (frame != iLastFrame && frame != -1) |
|
218 { |
|
219 if (frame == iLastFrame + 1 && iLastFrame != -1) |
|
220 { |
|
221 Animate(NULL); |
|
222 } |
|
223 else |
|
224 { |
|
225 TDateTime dt = now.DateTime(); |
|
226 Animate(&dt); |
|
227 } |
|
228 iLastFrame = frame; |
|
229 } |
|
230 |
|
231 // Regardless of whether we animated or not, redraw: |
|
232 WsAnimGc->Activate(iWindow, this, aRegion, aGc); |
|
233 WindowAnim()->Redraw(); |
|
234 WsAnimGc->Deactivate(); |
|
235 |
|
236 // Schedule ourselves again (we usually only have to do this when we animate, |
|
237 // but it is possible for our scheduled rectangle to get lost in a redraw): |
|
238 TInt64 timeToNextFrame = 0; |
|
239 switch (iAnimSync) |
|
240 { |
|
241 case ESyncNone: |
|
242 if (iInterval > 0) |
|
243 { |
|
244 timeToNextFrame = iStartTime.Int64() + iInterval.Int64() * (frame + 1) - iWindow->Screen()->Now().Int64(); |
|
245 } |
|
246 break; |
|
247 case ESyncFlash: |
|
248 if (iFlashOn) |
|
249 { |
|
250 timeToNextFrame = iStartTime.Int64() + (KFlashOnTime + KFlashOffTime) * frame / 2 + KFlashOnTime - iWindow->Screen()->Now().Int64(); |
|
251 } |
|
252 else |
|
253 { |
|
254 timeToNextFrame = iStartTime.Int64() + (KFlashOnTime + KFlashOffTime) * (frame + 1 ) / 2 - iWindow->Screen()->Now().Int64(); |
|
255 } |
|
256 break; |
|
257 case ESyncSecond: |
|
258 timeToNextFrame = adjustedStart + KOneSecond * (frame + 1) - iWindow->Screen()->Now().Int64(); |
|
259 break; |
|
260 case ESyncMinute: |
|
261 timeToNextFrame = adjustedStart + KOneMinute * (frame + 1) - iWindow->Screen()->Now().Int64(); |
|
262 break; |
|
263 case ESyncDay: |
|
264 timeToNextFrame = adjustedStart + KOneDay * (frame + 1) - iWindow->Screen()->Now().Int64(); |
|
265 break; |
|
266 } |
|
267 |
|
268 if (iAnimSync != ESyncNone || iInterval > 0) |
|
269 { |
|
270 iWindow->Screen()->ScheduleAnimation(BestRect(), timeToNextFrame, 0, 0); |
|
271 } |
|
272 |
|
273 iRedrawRegionPair = NULL; |
|
274 } |
|
275 |
|
276 void CWsAnim::FocusChanged(TBool aNewFocusState) |
|
277 { |
|
278 WindowAnim()->FocusChanged(aNewFocusState); |
|
279 WsAnimGc->UserDeactivate(); |
|
280 } |
|
281 |
|
282 void CWsAnim::Animate(TDateTime *aDateTime) |
|
283 { |
|
284 iAnim->Animate(aDateTime); |
|
285 WsAnimGc->UserDeactivate(); |
|
286 } |
|
287 |
|
288 void CWsAnim::UserDeactivateAnimGc() |
|
289 { |
|
290 WsAnimGc->UserDeactivate(); |
|
291 } |
|
292 |
|
293 // Callback functions // |
|
294 |
|
295 void CWsAnim::ActivateGc() |
|
296 { |
|
297 if (!iWindow) |
|
298 Panic(); |
|
299 |
|
300 // Window animation drawing commands need to go through the render stage pipeline. This means |
|
301 // that drawing commands issued outside animation redraws (for instance, during Animate() or |
|
302 // when the animation receives a command) will mark the animation area as invalid, but the |
|
303 // commands themselves will be ignored as drawing will only happen during the next WSERV redraw |
|
304 // cycle (CWindowAnim::Redraw). |
|
305 |
|
306 // In this new situation MAnimWindowFunctions::ActivateGc doesn't need to activate the graphics |
|
307 // context (drawing commands issued outside CWindowAnim::Redraw are ignored), but to avoid some |
|
308 // behavior breaks (for instance, panic situations) we mark the GC as "activated by the user". |
|
309 WsAnimGc->UserActivate(iWindow, this); |
|
310 } |
|
311 |
|
312 void CWsAnim::DeactivateGc() |
|
313 { |
|
314 if (!iWindow) |
|
315 Panic(); |
|
316 |
|
317 // Window animation drawing commands need to go through the render stage pipeline. This means |
|
318 // that drawing commands issued outside animation redraws (for instance, during Animate() or |
|
319 // when the animation receives a command) will mark the animation area as invalid, but the |
|
320 // commands themselves will be ignored as drawing will only happen during the next WSERV redraw |
|
321 // cycle (CWindowAnim::Redraw). |
|
322 |
|
323 // In this new situation MAnimFreeTimerWindowFunctions::DeactivateGc just marks the animation |
|
324 // area as invalid so it gets redrawn later. |
|
325 WsAnimGc->UserDeactivate(); |
|
326 } |
|
327 |
|
328 /* |
|
329 Because lots of animations don't set a rectangle, or set an empty one, we need |
|
330 to make a best guess at what to use rather than assuming anything. |
|
331 */ |
|
332 TRect CWsAnim::BestRect() const |
|
333 { |
|
334 TRect rect; |
|
335 if (iRect.IsEmpty()) |
|
336 { |
|
337 rect = iWindow->AbsRect(); |
|
338 } |
|
339 else |
|
340 { |
|
341 rect = iRect; |
|
342 rect.Move(iWindow->Origin()); |
|
343 rect.Intersection(iWindow->AbsRect()); |
|
344 } |
|
345 return rect; |
|
346 } |
|
347 |
|
348 void CWsAnim::Invalidate(const TRect &aRect) |
|
349 { |
|
350 if (!iWindow) |
|
351 { |
|
352 if (iSprite) |
|
353 { |
|
354 iSprite->RootWindow()->InvalidateWholeScreen(); |
|
355 } |
|
356 return; |
|
357 } |
|
358 iWindow->Redraw()->ClientExposing(); |
|
359 TRect rect(aRect); |
|
360 rect.Move(iWindow->Origin()); |
|
361 |
|
362 CWsTop::TriggerRedraws(iWindow->RootWindow()); |
|
363 } |
|
364 |
|
365 void CWsAnim::Update() |
|
366 { |
|
367 if (!iWindow) |
|
368 Panic(); |
|
369 } |
|
370 |
|
371 void CWsAnim::Parameters(TWindowInfo &aData) |
|
372 { |
|
373 if (!iWindow) |
|
374 Panic(); |
|
375 aData.iScreenPos=iWindow->FullRect(); |
|
376 aData.iMode=iWindow->DisplayMode(); |
|
377 aData.iRegionPair=iRedrawRegionPair; |
|
378 } |
|
379 |
|
380 void CWsAnim::VisibleRegion(TRegion& aRegion) |
|
381 { |
|
382 if(iWindow) |
|
383 { |
|
384 aRegion.Copy(iWindow->VisibleRegion()); |
|
385 } |
|
386 } |
|
387 |
|
388 void CWsAnim::SetSync(TAnimSync aSyncMode) |
|
389 { |
|
390 if (iAnimSync != aSyncMode) |
|
391 { |
|
392 iAnimSync=aSyncMode; |
|
393 iLastFrame = -1; |
|
394 if (iAnimSync != ESyncNone) |
|
395 iWindow->Screen()->ScheduleAnimation(BestRect(),0,0,0); |
|
396 if (iAnimSync == ESyncFlash) |
|
397 iFlashOn = ETrue; |
|
398 } |
|
399 } |
|
400 |
|
401 void CWsAnim::SetInterval(TInt aInterval) |
|
402 { |
|
403 if (iAnimSync!=ESyncNone) |
|
404 Panic(); |
|
405 iLastFrame = -1; |
|
406 if (aInterval < 0) |
|
407 aInterval = 0; |
|
408 // convert intervals to milliseconds (there are two intervals per second) |
|
409 iInterval = aInterval*KOneHalfSecond; |
|
410 if (iInterval > 0) |
|
411 { |
|
412 iWindow->Screen()->ScheduleAnimation(BestRect(),iInterval,0,0); |
|
413 } |
|
414 } |
|
415 |
|
416 void CWsAnim::SetNextInterval(TInt aInterval) |
|
417 { |
|
418 if (iAnimSync!=ESyncNone) |
|
419 Panic(); |
|
420 aInterval = (aInterval <= 0) ? 1 : aInterval; |
|
421 iWindow->Screen()->ScheduleAnimation(BestRect(),aInterval*KOneHalfSecond,0,0); |
|
422 } |
|
423 |
|
424 void CWsAnim::SetRect(const TRect &aRect) |
|
425 { |
|
426 if (!iWindow) |
|
427 Panic(); |
|
428 iRect=aRect; |
|
429 iWindow->UpdateAnimArea(); // backed up windows only |
|
430 } |
|
431 |
|
432 const TRect& CWsAnim::Rect() const |
|
433 { |
|
434 return(iRect); |
|
435 } |
|
436 |
|
437 TDateTime CWsAnim::SystemTime() const |
|
438 { |
|
439 TDateTime dt=iWindow->Screen()->Now().DateTime(); |
|
440 TInt hour=dt.Hour(); |
|
441 TInt minute=dt.Minute(); |
|
442 TInt second=dt.Second(); |
|
443 TInt microSecond=dt.MicroSecond(); |
|
444 switch(iAnimSync) |
|
445 { |
|
446 case ESyncDay: |
|
447 hour=0; |
|
448 minute=0; |
|
449 /*Fall through*/ |
|
450 case ESyncMinute: |
|
451 second=0; |
|
452 /*Fall through*/ |
|
453 case ESyncNone: |
|
454 case ESyncFlash: |
|
455 case ESyncSecond: |
|
456 microSecond=0; |
|
457 break; |
|
458 } |
|
459 TDateTime dateTime; |
|
460 dateTime.Set(dt.Year(),dt.Month(),dt.Day(),hour,minute,second,microSecond); |
|
461 return(dateTime); |
|
462 } |
|
463 |
|
464 TBool CWsAnim::FlashStateOn() const |
|
465 { |
|
466 return(iFlashOn); |
|
467 } |
|
468 |
|
469 const RThread &CWsAnim::Client() |
|
470 { |
|
471 return(iClient->Client()); |
|
472 } |
|
473 |
|
474 void CWsAnim::ReplyBuf(const TDesC8 &aDes) |
|
475 { |
|
476 CWsClient::ReplyBuf(aDes); |
|
477 } |
|
478 |
|
479 void CWsAnim::ReplyBuf(const TDesC16 &aDes) |
|
480 { |
|
481 CWsClient::ReplyBuf(aDes); |
|
482 } |
|
483 |
|
484 void CWsAnim::Panic() const |
|
485 { |
|
486 iClient->PPanic(EWservPanicAnimDll); |
|
487 } |
|
488 |
|
489 void CWsAnim::Panic(TClientPanic aPanic) const |
|
490 { |
|
491 iClient->PPanic(aPanic); |
|
492 } |
|
493 |
|
494 const CFbsScreenDevice *CWsAnim::ScreenDevice() |
|
495 { |
|
496 CScreen* screen=NULL; //To stop a warning |
|
497 if (iWindow) |
|
498 screen=iWindow->Screen(); |
|
499 else if (iSprite) |
|
500 screen=iSprite->Screen(); |
|
501 else |
|
502 Panic(); |
|
503 return screen->ScreenDevice(); |
|
504 } |
|
505 |
|
506 CFbsFont *CWsAnim::DuplicateFontL(TInt aHandle) |
|
507 { |
|
508 CFbsFont *font=NULL; |
|
509 TInt err; |
|
510 font=CAnimFbsFont::NewL(aHandle,err); |
|
511 if (err!=KErrNone) |
|
512 { |
|
513 WS_ASSERT_DEBUG(font==NULL,EWsPanicFailedToInitialise); |
|
514 if (err==KErrNoMemory) |
|
515 User::Leave(err); |
|
516 iClient->PPanic(EWservPanicFont); |
|
517 } |
|
518 return(font); |
|
519 } |
|
520 |
|
521 void CWsAnim::CloseFont(CFbsFont *aFont) |
|
522 { |
|
523 if (aFont) |
|
524 ((CAnimFbsFont *)aFont)->Close(); |
|
525 } |
|
526 |
|
527 CFbsBitmap *CWsAnim::DuplicateBitmapL(TInt aHandle) |
|
528 { |
|
529 CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); |
|
530 TInt err=bitmap->Duplicate(aHandle); |
|
531 if (err!=KErrNone) |
|
532 { |
|
533 delete bitmap; |
|
534 if (err==KErrNoMemory) |
|
535 User::Leave(err); |
|
536 iClient->PPanic(EWservPanicBitmap); |
|
537 } |
|
538 return(bitmap); |
|
539 } |
|
540 |
|
541 TSize CWsAnim::WindowSize() const |
|
542 { |
|
543 if (!iWindow) |
|
544 Panic(); |
|
545 return(iWindow->Size()); |
|
546 } |
|
547 |
|
548 TBool CWsAnim::IsHidden() |
|
549 { |
|
550 if (!iWindow) |
|
551 Panic(); |
|
552 |
|
553 return iWindow->IsHidden(); |
|
554 } |
|
555 |
|
556 void CWsAnim::SetVisible(TBool aState) |
|
557 { |
|
558 //The (WsAnimGc->IsActive() && aState) part of the below if statement is in place to accomodate bc with |
|
559 //the original wserv. |
|
560 //We panic when we call SetVisible(ETrue) and the CWsAnimGc has been activated because the origininal wserv did. |
|
561 //We don't panic when we call SetVisible(EFalse) and the CWsAnimGc is activated because the original wserv didn't. |
|
562 if( !iWindow || (WsAnimGc->IsActive() && aState) ) |
|
563 { |
|
564 Panic(); |
|
565 } |
|
566 |
|
567 iWindow->SetVisible(aState); |
|
568 |
|
569 STACK_REGION region; |
|
570 VisibleRegion(region); |
|
571 TRect rect = region.BoundingRect(); |
|
572 region.Close(); |
|
573 if(!rect.IsEmpty()) |
|
574 iWindow->Screen()->ScheduleAnimation(rect,0,0,0); |
|
575 } |
|
576 |
|
577 MAnimGeneralFunctions::TAnimSync CWsAnim::Sync() const |
|
578 { |
|
579 return(iAnimSync); |
|
580 } |
|
581 |
|
582 void CWsAnim::GetRawEvents(TBool aGetEvents) const |
|
583 { |
|
584 if (aGetEvents) |
|
585 { |
|
586 if (!iAnimAddedInHandler) |
|
587 { |
|
588 TWindowServerEvent::AddEventHandler(iAnim); |
|
589 iAnimAddedInHandler = ETrue; |
|
590 } |
|
591 } |
|
592 else |
|
593 { |
|
594 if (iAnimAddedInHandler) |
|
595 { |
|
596 TWindowServerEvent::RemoveEventHandler(iAnim); |
|
597 iAnimAddedInHandler = EFalse; |
|
598 } |
|
599 } |
|
600 } |
|
601 |
|
602 void CWsAnim::PostRawEvent(const TRawEvent &aRawEvent) const |
|
603 { |
|
604 TWindowServerEvent::ProcessRawEvent(aRawEvent); |
|
605 } |
|
606 |
|
607 void CWsAnim::PostKeyEvent(const TKeyEvent &aRawEvent) const |
|
608 { |
|
609 TWindowServerEvent::ProcessKeyEvent(aRawEvent,0); |
|
610 } |
|
611 |
|
612 /** |
|
613 Generate repeated key events. |
|
614 */ |
|
615 void CWsAnim::PostKeyEvent(const TKeyEvent& aRawEvent, TInt aRepeats) const |
|
616 { |
|
617 TWindowServerEvent::ProcessKeyEvent(aRawEvent,aRepeats); |
|
618 } |
|
619 |
|
620 TInt CWsAnim::RegisterForNotifications(TUint32 aNotifications) |
|
621 { |
|
622 if (aNotifications) |
|
623 { |
|
624 return TWindowServerEvent::AddNotificationHandler(iAnim,aNotifications); |
|
625 } |
|
626 else |
|
627 { |
|
628 TWindowServerEvent::RemoveNotificationHandler(iAnim); |
|
629 return KErrNone; |
|
630 } |
|
631 } |
|
632 |
|
633 |
|
634 const RMessagePtr2* CWsAnim::Message() |
|
635 { |
|
636 return iMessage; |
|
637 } |
|
638 |
|
639 void CWsAnim::SetMessage(const RMessagePtr2* aMessage) |
|
640 { |
|
641 iMessage=aMessage; |
|
642 } |
|
643 |
|
644 TInt CWsAnim::CommandReply(TInt aOpcode, TAny* aArgs) |
|
645 { |
|
646 SetMessage(&iClient->ClientMessage()); // ClientMessage returns a reference, so taking the address of it is okay (it it returned it by value, then taking the address would be taking the address of a temporary which would be dodgey) |
|
647 TInt returnValue=0; |
|
648 TRAP(returnValue,returnValue=iAnim->CommandReplyL(aOpcode, aArgs)); |
|
649 SetMessage(NULL); |
|
650 return returnValue; |
|
651 } |
|
652 |
|
653 TSpriteMember *CWsAnim::GetSpriteMember(TInt aMember) const |
|
654 { |
|
655 if (!iSprite) |
|
656 Panic(); |
|
657 return REINTERPRET_CAST(TSpriteMember*,&(*iSprite->iMembers)[aMember]->iBitmap); //The 2 classes involved in the cast have exactly the same data members in the same order |
|
658 } |
|
659 |
|
660 void CWsAnim::UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate) |
|
661 { |
|
662 if (!iSprite) |
|
663 Panic(); |
|
664 iSprite->Update(aMember,aRect,aFullUpdate); |
|
665 } |
|
666 |
|
667 void CWsAnim::Activate(TBool aActive) |
|
668 { |
|
669 if (!iSprite) |
|
670 Panic(); |
|
671 if (!aActive) |
|
672 iSprite->Deactivate(); |
|
673 else |
|
674 { |
|
675 if (iSprite->IsActive()) |
|
676 Panic(); |
|
677 iSprite->Activate(); |
|
678 } |
|
679 } |
|
680 |
|
681 void CWsAnim::SizeChangedL() |
|
682 { |
|
683 if (!iSprite) |
|
684 Panic(); |
|
685 iSprite->CWsSpriteBase::CompleteL(); |
|
686 } |
|
687 |
|
688 void CWsAnim::SetPosition(const TPoint &aPos) |
|
689 { |
|
690 iSprite->SetPos(aPos); |
|
691 } |
|
692 |
|
693 TAny* CWsAnim::ExtendedInterface(TInt aInterface) |
|
694 { |
|
695 switch(aInterface) |
|
696 { |
|
697 case ENumberOfExtendedInterfaces: |
|
698 return reinterpret_cast<TAny*>(EInterfaceCount-1); |
|
699 case EWindowExtensionInterface: |
|
700 return static_cast<MAnimGeneralFunctionsWindowExtension*>(this); |
|
701 case EEventExtentionInterface: |
|
702 return static_cast<MAnimGeneralFunctionsEventExtension*>(this); |
|
703 default: |
|
704 return NULL; |
|
705 } |
|
706 } |
|
707 |
|
708 TInt CWsAnim::Screens() const |
|
709 { |
|
710 return CWsTop::NumberOfScreens(); |
|
711 } |
|
712 |
|
713 TInt CWsAnim::FocusScreens() const |
|
714 { |
|
715 return CWsTop::CurrentFocusScreen()->ScreenNumber(); |
|
716 } |
|
717 |
|
718 void CWsAnim::SetFocusScreen(TInt aScreenNo) |
|
719 { |
|
720 if (aScreenNo<CWsTop::NumberOfScreens() && aScreenNo>=0) |
|
721 { |
|
722 CWsTop::SetCurrentFocusScreen(aScreenNo); |
|
723 } |
|
724 else |
|
725 { |
|
726 Panic(); |
|
727 } |
|
728 } |
|
729 |
|
730 TInt CWsAnim::WindowGroups(TInt aScreen) const |
|
731 { |
|
732 return(CWsWindowGroup::NumWindowGroupsOnScreen(CWsTop::Screen(aScreen)->RootWindow()->Child(),ETrue,0)); |
|
733 } |
|
734 |
|
735 TBool CWsAnim::WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aFullOrdinalPosition) const |
|
736 { |
|
737 CWsWindowGroup* group=CWsTop::Screen(aScreen)->RootWindow()->WindowGroup(aFullOrdinalPosition); |
|
738 if (!group) |
|
739 return EFalse; |
|
740 aInfo.iId=group->Identifier(); |
|
741 if (group->ReceivesFocus() && group->ScreenDeviceValid()) |
|
742 aInfo.iFlags=TWindowGroupInfo::EIsFocusable; |
|
743 else |
|
744 aInfo.iFlags=0; |
|
745 aInfo.iOrdinalPriority=group->OrdinalPriority(); |
|
746 HBufC* groupName=group->GroupName(); |
|
747 aInfo.iNameLength=groupName?group->GroupName()->Length():0; |
|
748 if (!group->IsChained(aInfo.iParentId)) |
|
749 aInfo.iParentId=-1; |
|
750 return ETrue; |
|
751 } |
|
752 |
|
753 TInt CWsAnim::WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aFullOrdinalPosition) const |
|
754 { |
|
755 CWsWindowGroup* group=CWsTop::Screen(aScreen)->RootWindow()->WindowGroup(aFullOrdinalPosition); |
|
756 if (!group) |
|
757 return EFalse; |
|
758 HBufC* name=group->GroupName(); |
|
759 if (name) |
|
760 aWindowName.Set(*name); |
|
761 else |
|
762 aWindowName.Set(NULL,0); |
|
763 return ETrue; |
|
764 } |
|
765 |
|
766 TInt CWsAnim::SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority) |
|
767 { |
|
768 CWsWindowGroup* group=CWsWindowGroup::WindowGroupFromIdentifier(aWindowGroupId); |
|
769 if (group) |
|
770 { |
|
771 group->SetOrdinalPriority(aPos,aOrdinalPriority); |
|
772 return KErrNone; |
|
773 } |
|
774 return KErrNotFound; |
|
775 } |
|
776 |
|
777 void CWsAnim::WindowConfig(TWindowConfig& aWindowConfig) const |
|
778 { |
|
779 aWindowConfig.iFlags = 0x00; |
|
780 if (iWindow->IsTranslucent()) |
|
781 { |
|
782 aWindowConfig.iFlags |= TWindowConfig::ETransparencyEnabled; |
|
783 if (iWindow->HasAlpha()) |
|
784 { |
|
785 aWindowConfig.iFlags |= TWindowConfig::EAlphaBlendedTransparency; |
|
786 } |
|
787 } |
|
788 } |
|
789 |
|
790 TBool CWsAnim::SpriteCanBeSeen() const |
|
791 { |
|
792 if(!iSprite) |
|
793 Panic(); |
|
794 return iSprite->CanBeSeen(); |
|
795 } |
|
796 |
|
797 // |
|
798 |
|
799 CObjectConIx* CWsAnimDll::AnimObjectConIx=NULL; |
|
800 |
|
801 void CWsAnimDll::InitStaticsL() |
|
802 { |
|
803 CWsAnimDll::AnimObjectConIx=CObjectConIx::NewL(); |
|
804 } |
|
805 |
|
806 void CWsAnimDll::DeleteStatics() |
|
807 { |
|
808 delete CWsAnimDll::AnimObjectConIx; |
|
809 } |
|
810 |
|
811 CWsAnimDll::CWsAnimDll(CWsClient *aOwner) : CWsObject(aOwner,WS_HANDLE_ANIM_DLL) |
|
812 { |
|
813 __DECLARE_NAME(_S("CWsAnimDll")); |
|
814 } |
|
815 |
|
816 CWsAnimDll::~CWsAnimDll() |
|
817 { |
|
818 delete iInstanceIndex; |
|
819 AnimObjectConIx->Remove(iInstanceCon); |
|
820 delete iAnimDll; |
|
821 iAnimLib.Close(); |
|
822 } |
|
823 |
|
824 TInt CWsAnimDll::doCreateInstanceL(CWsAnim *aInstance, TInt aType, TAny *aArgs, TBool aIsWindow) |
|
825 { |
|
826 iInstanceCon->AddL(aInstance); |
|
827 aInstance->ConstructL(iAnimDll->CreateInstanceL(aType),aArgs,this,aIsWindow); |
|
828 return(iInstanceIndex->AddL(aInstance)); |
|
829 } |
|
830 |
|
831 TInt CWsAnimDll::CreateInstanceL(TUint32 aHandle, TInt aType, TAny *aArgs, TBool aIsWindow) |
|
832 { |
|
833 TWindowServerEvent::PotentialEventHandlerL(1); |
|
834 CWsAnim *instance=new(ELeave) CWsAnim(this); |
|
835 CleanupClosePushL(*instance); |
|
836 if (aIsWindow) |
|
837 { |
|
838 CWsClientWindow *win; |
|
839 iWsOwner->HandleToClientWindow(aHandle,&win); |
|
840 instance->Connect(win); |
|
841 } |
|
842 else |
|
843 { |
|
844 CWsObject *sprite=iWsOwner->HandleToObj(aHandle, WS_HANDLE_SPRITE); |
|
845 if (!sprite) |
|
846 OwnerPanic(EWservPanicSprite); |
|
847 instance->Connect(STATIC_CAST(CWsSprite*,sprite)); |
|
848 } |
|
849 TInt handle=doCreateInstanceL(instance, aType, aArgs, aIsWindow); |
|
850 CleanupStack::Pop(instance); |
|
851 return(handle); |
|
852 } |
|
853 |
|
854 void CWsAnimDll::LoadL(const TDesC &aDllName) |
|
855 { |
|
856 NewObjL(); |
|
857 TFileName name(aDllName); |
|
858 User::LeaveIfError(iAnimLib.Load(name)); |
|
859 if (wsDebugLog) |
|
860 { |
|
861 TBuf<256> buf; |
|
862 _LIT(KWSERVLoadedAnimDll,"Loaded Anim DLL: "); |
|
863 buf.Append(KWSERVLoadedAnimDll); |
|
864 buf.Append(iAnimLib.FileName()); |
|
865 wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,buf); |
|
866 } |
|
867 TUidType uid=iAnimLib.Type(); |
|
868 if (uid[1]!=KWservAnimDllUid) |
|
869 User::Leave(KErrNotSupported); |
|
870 CreateCAnimDll f; |
|
871 f=(CreateCAnimDll)User::LeaveIfNull((TAny *)iAnimLib.Lookup(1)); |
|
872 iAnimDll=(*f)(); |
|
873 iInstanceIndex=CObjectIx::NewL(); |
|
874 iInstanceCon=AnimObjectConIx->CreateL(); |
|
875 } |
|
876 |
|
877 void CWsAnimDll::Remove(TInt aHandle) |
|
878 { |
|
879 iInstanceIndex->Remove(aHandle); |
|
880 } |
|
881 |
|
882 void CWsAnimDll::CommandL(TInt aOpcode, const TAny *aCmdData) |
|
883 { |
|
884 TWsAnimDllCmdUnion pData; |
|
885 |
|
886 pData.any=aCmdData; |
|
887 switch(aOpcode) |
|
888 { |
|
889 case EWsAnimDllOpFree: |
|
890 delete this; |
|
891 break; |
|
892 case EWsAnimDllOpCreateInstance: |
|
893 case EWsAnimDllOpCreateInstanceSprite: |
|
894 SetReply(CreateInstanceL(*pData.UInt,*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2) |
|
895 ,aOpcode==EWsAnimDllOpCreateInstance)); |
|
896 break; |
|
897 case EWsAnimDllOpCommandReply: |
|
898 case EWsAnimDllOpCommand: |
|
899 case EWsAnimDllOpDestroyInstance: |
|
900 { |
|
901 CWsAnim *anim=(CWsAnim *)iInstanceIndex->At(*pData.UInt); |
|
902 TInt ret; |
|
903 //Deleting a non existant Anim is allowed as the Anim will be destroyed |
|
904 //when the window it is on (or a parent of) it destroyed |
|
905 if (anim==NULL && aOpcode!=EWsAnimDllOpDestroyInstance) |
|
906 OwnerPanic(EWservPanicAnim); |
|
907 switch(aOpcode) |
|
908 { |
|
909 case EWsAnimDllOpCommandReply: |
|
910 SetReply(anim->CommandReply(*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2))); |
|
911 CWsAnim::UserDeactivateAnimGc(); |
|
912 break; |
|
913 case EWsAnimDllOpCommand: |
|
914 TRAP(ret,anim->Anim()->Command(*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2))); |
|
915 if (ret!=KErrNone && ret!=CWsClient::EPanicLeave) |
|
916 OwnerPanic(EWservPanicAnimLeave); |
|
917 CWsAnim::UserDeactivateAnimGc(); |
|
918 break; |
|
919 case EWsAnimDllOpDestroyInstance: |
|
920 if (anim) // Added to go with changes described above |
|
921 Remove(*pData.UInt); |
|
922 break; |
|
923 default: |
|
924 break; |
|
925 } |
|
926 } |
|
927 break; |
|
928 default: |
|
929 OwnerPanic(EWservPanicOpcode); |
|
930 } |
|
931 } |
|
932 |
|
933 CAnimFbsFont::~CAnimFbsFont() |
|
934 {} |
|
935 |
|
936 CAnimFbsFont::CAnimFbsFont() |
|
937 {} |
|
938 |
|
939 CAnimFbsFont* CAnimFbsFont::NewL(TInt aHandle,TInt& aError) |
|
940 { |
|
941 CAnimFbsFont *font=new(ELeave) CAnimFbsFont(); |
|
942 font->iAccessCount=1; |
|
943 aError=font->Duplicate(aHandle); |
|
944 if (aError!=KErrNone) |
|
945 { |
|
946 delete font; |
|
947 font=NULL; |
|
948 } |
|
949 return(font); |
|
950 } |
|
951 |
|
952 void CAnimFbsFont::Open() |
|
953 { |
|
954 iAccessCount++; |
|
955 } |
|
956 |
|
957 void CAnimFbsFont::Close() |
|
958 { |
|
959 if (--iAccessCount==0) |
|
960 delete this; |
|
961 } |
|
962 |
|
963 |
|
964 /*MAnimGeneralFunctions*/ |
|
965 void MAnimGeneralFunctions::Reserved1() const |
|
966 {} |
|
967 |
|
968 void MAnimGeneralFunctions::Reserved2() const |
|
969 {} |
|
970 |
|
971 void MAnimGeneralFunctions::Reserved3() const |
|
972 {} |
|
973 |
|
974 |
|
975 /*MAnimGeneralFunctionsExtension*/ |
|
976 |
|
977 void MAnimGeneralFunctionsWindowExtension::Reserved1() const |
|
978 {} |
|
979 |
|
980 void MAnimGeneralFunctionsWindowExtension::Reserved2() const |
|
981 {} |
|
982 |
|
983 void MAnimGeneralFunctionsWindowExtension::Reserved3() const |
|
984 {} |
|
985 |
|
986 /*MAnimWindowFunctions*/ |
|
987 |
|
988 void MAnimWindowFunctions::Reserved() const |
|
989 {} |
|
990 |
|
991 void MAnimWindowFunctions::Reserved1() const |
|
992 {} |
|
993 |
|
994 void MAnimWindowFunctions::Reserved2() const |
|
995 {} |
|
996 |
|
997 void MAnimWindowFunctions::Reserved3() const |
|
998 {} |
|
999 |
|
1000 |
|
1001 /*MAnimFreeTimerWindowFunctions*/ |
|
1002 |
|
1003 void MAnimFreeTimerWindowFunctions::Reserved3() const |
|
1004 {} |
|
1005 |
|
1006 |
|
1007 /*MAnimSpriteFunctions*/ |
|
1008 |
|
1009 void MAnimSpriteFunctions::Reserved() const |
|
1010 {} |
|
1011 |
|
1012 void MAnimSpriteFunctions::Reserved2() const |
|
1013 {} |
|
1014 |
|
1015 void MAnimSpriteFunctions::Reserved3() const |
|
1016 {} |
|
1017 |
|
1018 void MAnimSpriteFunctions::Reserved4() const |
|
1019 {} |
|
1020 |
|
1021 /*MAnimGeneralFunctionsEventExtension*/ |
|
1022 |
|
1023 void MAnimGeneralFunctionsEventExtension::Reserved1() const |
|
1024 {} |
|
1025 |
|
1026 void MAnimGeneralFunctionsEventExtension::Reserved2() const |
|
1027 {} |