windowing/windowserver/nga/SERVER/openwfc/ANIMDLL.CPP
changeset 0 5d03bc08d59c
child 11 fed1595b188e
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 "panics.h"
       
    28 #include "wsfont.h"
       
    29 #include "pointer.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 CWsAnim::CWsAnim(CWsAnimDll *aDll) : iClient(aDll->WsOwner()), iAnimAddedInHandler(EFalse), iLastFrame(-1)
       
    44 	{
       
    45 	__DECLARE_NAME(_S("CWsAnim"));
       
    46 	iBitFlags.Set(EFlashOn);
       
    47 	}
       
    48 
       
    49 void CWsAnim::WindowClosing(CWsAnim *aWsAnim)
       
    50 	{
       
    51 	CWsAnim *anim=aWsAnim;
       
    52 	CWsAnim *next;
       
    53 	
       
    54 	while(anim)
       
    55 		{
       
    56 		next=anim->iNextWin;
       
    57 		CloseAnim(anim);
       
    58 		anim=next;
       
    59 		}
       
    60 	}
       
    61 
       
    62 void CWsAnim::CloseAnim(CWsAnim *aWsAnim)
       
    63 	{
       
    64 	if(aWsAnim)
       
    65 		{
       
    66 		TInt handle=aWsAnim->iAnimDll->AnimObjectHandle(aWsAnim);
       
    67 		if (handle<0)
       
    68 			delete aWsAnim;
       
    69 		else
       
    70 			aWsAnim->iAnimDll->Remove(handle);
       
    71 		}
       
    72 	}
       
    73 
       
    74 CWsAnim::~CWsAnim()
       
    75 	{
       
    76 	if (iWindow)	// In case it never got linked
       
    77 		{
       
    78 		iWindow->SetupVisibleRegionTracking(EFalse);
       
    79 		MWsWindowTreeObserver* windowTreeObserver = iClient->Screen()->WindowTreeObserver();
       
    80 		if (windowTreeObserver && (iBitFlags.IsSet(EWinAnimConstructed)))
       
    81 			{
       
    82 			windowTreeObserver->NodeReleased(*this);
       
    83 			iBitFlags.Clear(EWinAnimConstructed);
       
    84 			}
       
    85 		CWsAnim **pAnim;
       
    86 		for(pAnim= &iWindow->iAnimList;(*pAnim)!=this;pAnim= &(*pAnim)->iNextWin)
       
    87 			{}
       
    88 		*pAnim=iNextWin;
       
    89 		
       
    90 		}
       
    91 	else if (iSprite)
       
    92 		{
       
    93 		// coverity[extend_simple_error]
       
    94 		iSprite->iAnim=NULL;
       
    95 		iSprite->SetHasAnimation(EFalse);
       
    96 		if(iSprite->Win())
       
    97 			iSprite->Win()->SetupVisibleRegionTracking(EFalse);
       
    98 		}
       
    99 	// force the anim for the event handler list.
       
   100 	TWindowServerEvent::RemoveEventHandler(Anim());
       
   101 	TWindowServerEvent::RemoveNotificationHandler(Anim());
       
   102 	delete iAnim.iWindowAnim;
       
   103 	delete iAnimGc;
       
   104 	// coverity[extend_simple_error]
       
   105 	TWindowServerEvent::PotentialEventHandlerL(-1);		//PotentialEventHandler cannot leave when passed a negative parameter.
       
   106 	}
       
   107 
       
   108 void CWsAnim::Connect(CWsClientWindow *aWindow)
       
   109 	{
       
   110 	//coverity[var_compare_op]
       
   111 	WS_ASSERT_DEBUG(aWindow,EWsPanicWindowNull);
       
   112 	if ((iSprite))
       
   113 		Panic();
       
   114 
       
   115 	iWindow=aWindow;
       
   116 	iNextWin=aWindow->iAnimList;
       
   117 	aWindow->iAnimList=this;
       
   118 	iBitFlags.Assign(EAdvancedPointersEnabled, aWindow->AdvancedPointersEnabled());
       
   119 	iWindow->SetupVisibleRegionTracking(ETrue);
       
   120 	}
       
   121 
       
   122 void CWsAnim::Connect(CWsSprite *aSprite)
       
   123 	{
       
   124 	WS_ASSERT_DEBUG(aSprite,EWsPanicNoSprite);
       
   125 	if (iWindow)
       
   126 		Panic();
       
   127 	iSprite=aSprite;
       
   128 	iSprite->iAnim=this;
       
   129 	iSprite->SetHasAnimation(ETrue);
       
   130 	iBitFlags.Assign(EAdvancedPointersEnabled, aSprite->AdvancedPointersEnabled());
       
   131 	if(iSprite->Win())
       
   132 		{
       
   133 		iSprite->Win()->SetupVisibleRegionTracking(ETrue);
       
   134 		}
       
   135 	}
       
   136 
       
   137 LOCAL_C void HandleLeaveInCWsAnimConstructL(TAny* aAnim)
       
   138 	{
       
   139 	STATIC_CAST(CWsAnim*,aAnim)->SetMessage(NULL);
       
   140 	STATIC_CAST(CWsAnim*,aAnim)->UserDeactivateAnimGc();
       
   141 	}
       
   142 
       
   143 void CWsAnim::ConstructL(CAnim *aAnim, TAny *aArgs, CWsAnimDll *aAnimDll, TBool aIsWindow)
       
   144 	{
       
   145 	TBool isFocused=(iSprite!=NULL);
       
   146 	if (!isFocused)
       
   147 		isFocused=CWsTop::FocusWindowGroup()==iWindow->WinGroup();
       
   148 	iAnimDll=aAnimDll;
       
   149 	iAnimSync=ESyncNone;
       
   150 	if(!aAnim)
       
   151 	    {
       
   152 	    RDebug::Printf("CreateInstanceL did not create an anim instance.");
       
   153 	    Panic();
       
   154 	    }
       
   155 	aAnim->iFunctions=this;
       
   156 	SetMessage(&iClient->ClientMessage());
       
   157 	CleanupStack::PushL(TCleanupItem(HandleLeaveInCWsAnimConstructL,this));
       
   158 	if (aIsWindow)
       
   159 		{
       
   160 		iAnim.iWindowAnim = static_cast<CWindowAnim*>(aAnim);
       
   161 		iAnimGc = new (ELeave) CWsAnimGc(*this);
       
   162 		iAnim.iWindowAnim->iWindowFunctions=this;
       
   163 		iAnim.iWindowAnim->iGc=iAnimGc;
       
   164 		iAnim.iWindowAnim->ConstructL(aArgs, isFocused);
       
   165 		iBitFlags.Set(EWinAnimConstructed);
       
   166 		WS_ASSERT_DEBUG(iClient->Screen(), EWsPanicNoScreen);
       
   167 		if (iClient->Screen())
       
   168 			{
       
   169 			MWsWindowTreeObserver* windowTreeObserver = iClient->Screen()->WindowTreeObserver();
       
   170 			if (windowTreeObserver)
       
   171 				{
       
   172 				windowTreeObserver->NodeCreated(*this, ParentNode());
       
   173 				const TRect rect = BestRect();
       
   174 				windowTreeObserver->NodeExtentChanged(*this, rect);
       
   175 				windowTreeObserver->NodeActivated(*this); //window-anim inherits activate status from iWindow
       
   176 				}
       
   177 			}
       
   178 		}
       
   179 	else
       
   180 		{
       
   181 		iAnim.iSpriteAnim = static_cast<CSpriteAnim*>(aAnim);
       
   182 		iAnim.iSpriteAnim->iSpriteFunctions=this;
       
   183 		iAnim.iSpriteAnim->ConstructL(aArgs);
       
   184 		}
       
   185 	CleanupStack::PopAndDestroy(this); // doesn't really destroy "this" - it actually calls HandleLeaveInCWsAnimConstructL
       
   186 	}
       
   187 
       
   188 /**
       
   189 This function should only be called in the context of a redraw (i.e. CScreenRedraw::OnAnimation) 
       
   190 @panic EWsPanicAnim will be raised in debug build if this function is called in the wrong context.
       
   191 */
       
   192 void CWsAnim::RedrawWindowAnimL(const TTime& aTimeNow, MWsGraphicsContext* aGc, const TRegion* aRegion)
       
   193 	{
       
   194 	WS_ASSERT_DEBUG(iWindow, EWsPanicAnimHasNoWindow);
       
   195 	WS_ASSERT_DEBUG(iWindow->Screen(), EWsPanicNoScreen);
       
   196 	WS_ASSERT_DEBUG(iWindow->Screen()->IsAnimating(), EWsPanicAnim);
       
   197 	iBitFlags.Set(EInRedraw);
       
   198 	
       
   199 	TInt frame;
       
   200 	TInt64 adjustedStart;
       
   201 	 // Don't call AnimateL() on CFreeTimerWindowAnim animations
       
   202 	if(iAnimSync!=ESyncNone || iInterval!=0)
       
   203 	    {
       
   204 	    AnimateL(aTimeNow, frame, adjustedStart);
       
   205 	    }
       
   206 	RedrawWindowAnimL(aGc, aRegion);
       
   207 	ReSchedule(aTimeNow, frame, adjustedStart);
       
   208 	
       
   209 	iBitFlags.Clear(EInRedraw);
       
   210 	}
       
   211 
       
   212 /**
       
   213 This function should only be called in the context of a redraw (i.e. CScreenRedraw::OnAnimation)
       
   214 @panic EWsPanicAnim will be raised in debug build if this function is called in the wrong context. 
       
   215 */
       
   216 void CWsAnim::AnimateSpriteAnimL(const TTime& aTimeNow)
       
   217 	{
       
   218 	WS_ASSERT_DEBUG(iSprite, EWsPanicNoSprite);
       
   219 	WS_ASSERT_DEBUG(iSprite->Screen(), EWsPanicNoScreen);
       
   220     WS_ASSERT_DEBUG(iSprite->Screen()->IsAnimating(), EWsPanicAnim);
       
   221     iBitFlags.Set(EInRedraw);
       
   222     	
       
   223 	TInt frame;
       
   224 	TInt64 adjustedStart;
       
   225 	AnimateL(aTimeNow, frame, adjustedStart);
       
   226 	ReSchedule(aTimeNow, frame, adjustedStart);
       
   227 	
       
   228 	iBitFlags.Clear(EInRedraw);
       
   229 	}
       
   230 
       
   231 void CWsAnim::AnimateL(const TTime& aTimeNow, TInt& aFrame, TInt64& aAdjustedStart)
       
   232 	{
       
   233 	// Work out which frame we are in:
       
   234 	if (iLastFrame < 0)
       
   235 		iStartTime = aTimeNow;
       
   236 	TInt64 elapsed = aTimeNow.Int64() - iStartTime.Int64();
       
   237 	aAdjustedStart = iStartTime.Int64();
       
   238 	aFrame = 0;
       
   239 	switch (iAnimSync)
       
   240 		{
       
   241 		case ESyncNone:
       
   242 			if (iInterval > 0)
       
   243 				{
       
   244 				aFrame = elapsed / iInterval.Int64();
       
   245 				}
       
   246 				else
       
   247 				{
       
   248 				aFrame = -1; //This would be a CFreeTimerWindowAnim
       
   249 				}
       
   250 			break;
       
   251 		case ESyncFlash:
       
   252 			{
       
   253 			TInt64 fraction = elapsed % (KFlashOnTime + KFlashOffTime);
       
   254 			aFrame = (elapsed - fraction) / (KFlashOnTime + KFlashOffTime) * 2;
       
   255 			if (fraction > KFlashOnTime)
       
   256 				{
       
   257 				aFrame += 1;
       
   258 				iBitFlags.Clear(EFlashOn);
       
   259 				}
       
   260 			else
       
   261 				{
       
   262 				iBitFlags.Set(EFlashOn);
       
   263 				}
       
   264 			}
       
   265 			break;
       
   266 		case ESyncSecond:
       
   267 			aAdjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneSecond);
       
   268 			elapsed = aTimeNow.Int64() - aAdjustedStart;
       
   269 			aFrame = elapsed / KOneSecond;
       
   270 			break;
       
   271 		case ESyncMinute:
       
   272 			aAdjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneMinute);
       
   273 			elapsed = aTimeNow.Int64() - aAdjustedStart;
       
   274 			aFrame = elapsed / KOneMinute;
       
   275 			break;
       
   276 		case ESyncDay:
       
   277 			aAdjustedStart = iStartTime.Int64() - (iStartTime.Int64() % KOneDay);
       
   278 			elapsed = aTimeNow.Int64() - aAdjustedStart;
       
   279 			aFrame = elapsed / KOneDay;
       
   280 			break;
       
   281 		}
       
   282 
       
   283 	// If the frame has changed, animate:
       
   284 	if (aFrame != iLastFrame && aFrame != -1)
       
   285 		{
       
   286 		if (aFrame == iLastFrame + 1 && iLastFrame != -1)
       
   287 			{
       
   288 			Animate(NULL); //This can leave
       
   289 			}
       
   290 		else
       
   291 			{
       
   292 			TDateTime dt = aTimeNow.DateTime();
       
   293 			Animate(&dt);
       
   294 			}
       
   295 		iLastFrame = aFrame;
       
   296 		}
       
   297 	}
       
   298 
       
   299 void CWsAnim::RedrawWindowAnimL(MWsGraphicsContext * aGc, const TRegion *aRegion)
       
   300 	{
       
   301 	WS_ASSERT_DEBUG(iWindow,EWsPanicAnimHasNoWindow);
       
   302 	
       
   303 	// We don't attempt to make use of iRect because it often isn't set up by the client code.
       
   304 	TWindowInfo::TRegionPair regionPair;
       
   305 	regionPair.iRegion1 = aRegion;
       
   306 	regionPair.iRegion2 = NULL;
       
   307 	iRedrawRegionPair = &regionPair;
       
   308 	
       
   309 	if(iWindow && iAnim.iWindowAnim)
       
   310 		{
       
   311 		// Regardless of whether we animated or not, redraw:
       
   312 		iAnimGc->Activate(aRegion, aGc);
       
   313 		iAnim.iWindowAnim->Redraw();	//This can leave
       
   314 		iAnimGc->Deactivate();
       
   315 		}
       
   316 	
       
   317 	iRedrawRegionPair = NULL;				
       
   318 	}
       
   319 
       
   320 void CWsAnim::ReSchedule(const TTime& aTimeNow, const TInt& aFrame, const TInt64& aAdjustedStart)
       
   321 	{
       
   322 	// Schedule ourselves again (we usually only have to do this when we animate,
       
   323 	// but it is possible for our scheduled rectangle to get lost in a redraw):
       
   324 	TInt64 timeToNextFrame = 0;
       
   325 	switch (iAnimSync)
       
   326 		{
       
   327 		case ESyncNone:
       
   328 			if (iInterval > 0)
       
   329 				{
       
   330 				timeToNextFrame = iStartTime.Int64() + iInterval.Int64() * (aFrame + 1) - aTimeNow.Int64();
       
   331 				}
       
   332 			break;
       
   333 		case ESyncFlash:
       
   334 			if (iBitFlags.IsSet(EFlashOn))
       
   335 				{
       
   336 				timeToNextFrame = iStartTime.Int64() + (KFlashOnTime + KFlashOffTime) * aFrame / 2 + KFlashOnTime - aTimeNow.Int64();
       
   337 				}
       
   338 			else
       
   339 				{
       
   340 				timeToNextFrame = iStartTime.Int64() + (KFlashOnTime + KFlashOffTime) * (aFrame + 1 ) / 2 - aTimeNow.Int64();
       
   341 				}
       
   342 			break;
       
   343 		case ESyncSecond:
       
   344 			timeToNextFrame = aAdjustedStart + KOneSecond * (aFrame + 1) - aTimeNow.Int64();
       
   345 			break;
       
   346 		case ESyncMinute:
       
   347 			timeToNextFrame = aAdjustedStart + KOneMinute * (aFrame + 1) - aTimeNow.Int64();
       
   348 			break;
       
   349 		case ESyncDay:
       
   350 			timeToNextFrame = aAdjustedStart + KOneDay * (aFrame + 1) - aTimeNow.Int64();
       
   351 			break;
       
   352 		}
       
   353 	
       
   354 	if (iAnimSync != ESyncNone || iInterval > 0)
       
   355 		{
       
   356 		ScheduleSelf(timeToNextFrame);
       
   357 		}
       
   358 			
       
   359 	}
       
   360 
       
   361 /**
       
   362 Mark the animation area as invalid so it gets redrawn later. 
       
   363 */
       
   364 void CWsAnim::ScheduleSelf(const TTimeIntervalMicroSeconds& aFrom)
       
   365 	{
       
   366 	ASSERT( (iWindow && iAnim.iWindowAnim) || (iSprite && iAnim.iSpriteAnim) );
       
   367 	
       
   368 	if(iWindow && iAnim.iWindowAnim)
       
   369 		{
       
   370 		WS_ASSERT_DEBUG(iWindow->Screen(), EWsPanicNoScreen);
       
   371 		const TRect rect = BestRect();
       
   372 		iWindow->Screen()->ScheduleAnimation(EWindowAnim, rect, aFrom, 0, 0, iWindow);
       
   373 		}
       
   374 	else if(iSprite && iAnim.iSpriteAnim)
       
   375 		{
       
   376 		WS_ASSERT_DEBUG(iSprite->Screen(), EWsPanicNoScreen);
       
   377 		const TRect rect = iSprite->Rect();
       
   378 		if(iSprite->Win())
       
   379 			iSprite->Screen()->ScheduleAnimation(ESpriteAnim, rect, aFrom, 0, 0, iSprite->Win());
       
   380 		else
       
   381 			iSprite->Screen()->ScheduleAnimation(EFloatingSpriteAnim, rect, aFrom, 0, 0, NULL);
       
   382 		}
       
   383 	}
       
   384 
       
   385 void CWsAnim::UserDeactivateAnimGc()
       
   386 	{
       
   387 	if (iAnimGc) // For sprite anims iAnimGc is NULL
       
   388 	    {
       
   389         //If we have been receiving draw commands outside the context of 
       
   390 	    //CScreenRedraw::OnAnimation, then we need to schedule a redraw.
       
   391 	    if (iAnimGc->IsActive() && iBitFlags.IsClear(EInRedraw))
       
   392 	         {
       
   393 	         ScheduleSelf(0);
       
   394 	         }
       
   395 	    iAnimGc->UserDeactivate();
       
   396 	    }
       
   397 	}
       
   398 
       
   399 void CWsAnim::FocusChanged(TBool aNewFocusState)
       
   400 	{
       
   401 	WS_ASSERT_DEBUG(iWindow && iAnimGc && iAnim.iWindowAnim,EWsPanicAnim);
       
   402 	iAnim.iWindowAnim->FocusChanged(aNewFocusState);
       
   403 	UserDeactivateAnimGc();
       
   404 	}
       
   405 
       
   406 void CWsAnim::Animate(TDateTime *aDateTime)
       
   407 	{
       
   408 	WS_ASSERT_DEBUG(Anim(),EWsPanicAnim);
       
   409 	Anim()->Animate(aDateTime);
       
   410 	UserDeactivateAnimGc();
       
   411 	}
       
   412 
       
   413 // Callback functions //
       
   414 
       
   415 void CWsAnim::ActivateGc()
       
   416 	{
       
   417 	if (!iWindow)
       
   418 		Panic();
       
   419 
       
   420 	// Window animation drawing commands need to go through the render stage pipeline. This means
       
   421 	// that drawing commands issued outside animation redraws (for instance, during Animate() or
       
   422 	// when the animation receives a command) will mark the animation area as invalid, but the
       
   423 	// commands themselves will be ignored as drawing will only happen during the next WSERV redraw
       
   424 	// cycle (CWindowAnim::Redraw).
       
   425 
       
   426 	// In this new situation MAnimWindowFunctions::ActivateGc doesn't need to activate the graphics
       
   427 	// context (drawing commands issued outside CWindowAnim::Redraw are ignored), but to avoid some
       
   428 	// behavior breaks (for instance, panic situations) we mark the GC as "activated by the user".
       
   429 	iAnimGc->UserActivate();
       
   430 	}
       
   431 
       
   432 void CWsAnim::DeactivateGc()
       
   433 	{
       
   434 	if (!iWindow)
       
   435 		Panic();
       
   436 
       
   437 	// Window animation drawing commands need to go through the render stage pipeline. This means
       
   438 	// that drawing commands issued outside animation redraws (for instance, during Animate() or
       
   439 	// when the animation receives a command) will mark the animation area as invalid, but the
       
   440 	// commands themselves will be ignored as drawing will only happen during the next WSERV redraw
       
   441 	// cycle (CWindowAnim::Redraw).
       
   442 
       
   443 	// In this new situation MAnimFreeTimerWindowFunctions::DeactivateGc just marks the animation
       
   444 	// area as invalid so it gets redrawn later.
       
   445 	
       
   446 	UserDeactivateAnimGc();
       
   447 	}
       
   448 
       
   449 /*
       
   450 Because lots of animations don't set a rectangle, or set an empty one, we need
       
   451 to make a best guess at what to use rather than assuming anything.
       
   452 */
       
   453 TRect CWsAnim::BestRect() const
       
   454 	{
       
   455 	WS_ASSERT_DEBUG(iWindow,EWsPanicAnimHasNoWindow);
       
   456 	TRect rect;
       
   457 	if (iRect.IsEmpty())
       
   458 		{
       
   459 		rect = iWindow->AbsRect();
       
   460 		}
       
   461 	else
       
   462 		{
       
   463 		rect = iRect;
       
   464 		rect.Move(iWindow->Origin());
       
   465 		rect.Intersection(iWindow->AbsRect());
       
   466 		}
       
   467 	return rect;
       
   468 	}
       
   469 
       
   470 void CWsAnim::Invalidate(const TRect &aRect)
       
   471 	{
       
   472 	if (!iWindow)
       
   473 		{
       
   474 		if (iSprite) 
       
   475 			{
       
   476 			iSprite->RootWindow()->InvalidateWholeScreen();
       
   477 			}
       
   478 		return;
       
   479 		}
       
   480 	iWindow->Redraw()->ClientExposing();
       
   481 	TRect rect(aRect);
       
   482 	rect.Move(iWindow->Origin());
       
   483 
       
   484 	CWsTop::TriggerRedraws(iWindow->RootWindow());
       
   485 	}
       
   486 
       
   487 void CWsAnim::Update()
       
   488 	{
       
   489 	if (!iWindow)
       
   490 		Panic();
       
   491 	}
       
   492 
       
   493 void CWsAnim::Parameters(TWindowInfo &aData)
       
   494 	{
       
   495 	if (!iWindow)
       
   496 		Panic();
       
   497 	aData.iScreenPos=iWindow->FullRect();
       
   498 	aData.iMode=iWindow->DisplayMode();
       
   499 	aData.iRegionPair=iRedrawRegionPair;
       
   500 	}
       
   501 
       
   502 void CWsAnim::VisibleRegion(TRegion& aRegion)
       
   503 	{
       
   504 	if(iWindow)
       
   505 		{
       
   506 		aRegion.Copy(iWindow->VisibleRegion());
       
   507 		}
       
   508 	}
       
   509 
       
   510 void CWsAnim::SetSync(TAnimSync aSyncMode)
       
   511 	{
       
   512 	if (iAnimSync != aSyncMode)
       
   513 		{
       
   514 		iAnimSync=aSyncMode;
       
   515 		iLastFrame = -1;
       
   516 		
       
   517 		if (iAnimSync != ESyncNone)
       
   518 			ScheduleSelf(0);
       
   519 
       
   520 		if (iAnimSync == ESyncFlash)
       
   521 			iBitFlags.Set(EFlashOn);
       
   522 		}
       
   523 	}
       
   524 
       
   525 void CWsAnim::SetInterval(TInt aInterval)
       
   526 	{
       
   527 	if (iAnimSync!=ESyncNone)
       
   528 		Panic();
       
   529 	iLastFrame = -1;	
       
   530 	if (aInterval < 0)
       
   531 		aInterval = 0;
       
   532 	// convert intervals to milliseconds (there are two intervals per second)
       
   533 	iInterval = aInterval*KOneHalfSecond;
       
   534 	if (iInterval > 0)
       
   535 		{
       
   536 		ScheduleSelf(iInterval);
       
   537 		}
       
   538 	
       
   539 	}
       
   540 
       
   541 void CWsAnim::SetNextInterval(TInt aInterval)
       
   542 	{
       
   543 	if (iAnimSync!=ESyncNone)
       
   544 		Panic();
       
   545 	aInterval = (aInterval <= 0) ? 1 : aInterval; 
       
   546 	ScheduleSelf(aInterval*KOneHalfSecond);
       
   547 	}
       
   548 
       
   549 void CWsAnim::SetRect(const TRect &aRect)
       
   550 	{
       
   551 	if (!iWindow)
       
   552 		Panic();
       
   553 	
       
   554 	if (iRect != aRect)
       
   555 		{
       
   556 		iRect=aRect;
       
   557 		iWindow->UpdateAnimArea(); // backed up windows only
       
   558 		
       
   559 		MWsWindowTreeObserver* windowTreeObserver = iClient->Screen()->WindowTreeObserver();
       
   560 		if (windowTreeObserver && iBitFlags.IsSet(EWinAnimConstructed))
       
   561 			{
       
   562 			const TRect rect = BestRect();
       
   563 			windowTreeObserver->NodeExtentChanged(*this, rect);
       
   564 			}
       
   565 		}
       
   566 	}
       
   567 
       
   568 const TRect& CWsAnim::Rect() const
       
   569 	{
       
   570 	return(iRect);
       
   571 	}
       
   572 
       
   573 TDateTime CWsAnim::SystemTime() const
       
   574 	{
       
   575 	TDateTime dt=iWindow->Screen()->Now().DateTime();
       
   576 	TInt hour=dt.Hour();
       
   577 	TInt minute=dt.Minute();
       
   578 	TInt second=dt.Second();
       
   579 	TInt microSecond=dt.MicroSecond();
       
   580 	switch(iAnimSync)
       
   581 		{
       
   582 	case ESyncDay:
       
   583 		hour=0; 
       
   584 		minute=0;
       
   585 		/*Fall through*/
       
   586 	case ESyncMinute:
       
   587 		second=0; 
       
   588 		/*Fall through*/
       
   589 	case ESyncNone:
       
   590 	case ESyncFlash:
       
   591 	case ESyncSecond:
       
   592 		microSecond=0;
       
   593 		break;
       
   594 		}
       
   595 	TDateTime dateTime;
       
   596 	dateTime.Set(dt.Year(),dt.Month(),dt.Day(),hour,minute,second,microSecond);
       
   597 	return(dateTime);
       
   598 	}
       
   599 
       
   600 TBool CWsAnim::FlashStateOn() const
       
   601 	{
       
   602 	return(iBitFlags.IsSet(EFlashOn));
       
   603 	}
       
   604 
       
   605 const RThread &CWsAnim::Client()
       
   606 	{
       
   607 	return(iClient->Client());
       
   608 	}
       
   609 
       
   610 void CWsAnim::ReplyBuf(const TDesC8 &aDes)
       
   611 	{
       
   612 	CWsClient::ReplyBuf(aDes);
       
   613 	}
       
   614 
       
   615 void CWsAnim::ReplyBuf(const TDesC16 &aDes)
       
   616 	{
       
   617 	CWsClient::ReplyBuf(aDes);
       
   618 	}
       
   619 
       
   620 void CWsAnim::SessionPanic() const
       
   621 	{
       
   622 	iClient->SessionPanic(EWservPanicAnimDll);
       
   623 	}
       
   624 
       
   625 void CWsAnim::Panic() const
       
   626 	{
       
   627 	iClient->PPanic(EWservPanicAnimDll);
       
   628 	}
       
   629 	
       
   630 void CWsAnim::Panic(TClientPanic aPanic) const
       
   631 	{
       
   632 	iClient->PPanic(aPanic);
       
   633 	}
       
   634 
       
   635 void CWsAnim::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const
       
   636 	{
       
   637 	if(iNextWin)
       
   638 		iNextWin->SendState(aWindowTreeObserver);
       
   639 	
       
   640 	if(iBitFlags.IsSet(EWinAnimConstructed))
       
   641 		{
       
   642 		aWindowTreeObserver.NodeCreated(*this, ParentNode());
       
   643 		const TRect rect = BestRect();
       
   644 		aWindowTreeObserver.NodeExtentChanged(*this, rect);
       
   645 		aWindowTreeObserver.NodeActivated(*this); //window-anim inherits activate status from iWindow
       
   646 		}
       
   647 	}
       
   648 
       
   649 const CFbsScreenDevice *CWsAnim::ScreenDevice()
       
   650 	{
       
   651 	return NULL; // Deprecated by PREQ 2095
       
   652 	}
       
   653 
       
   654 CFbsFont *CWsAnim::DuplicateFontL(TInt aHandle)
       
   655 	{
       
   656 	CFbsFont *font=NULL;
       
   657 	TInt err;
       
   658 	font=CAnimFbsFont::NewL(aHandle,err);
       
   659 	if (err!=KErrNone)
       
   660 		{
       
   661 		WS_ASSERT_DEBUG(font==NULL,EWsPanicFailedToInitialise);
       
   662 		if (err==KErrNoMemory)
       
   663 			User::Leave(err);
       
   664 		iClient->PPanic(EWservPanicFont);
       
   665 		}
       
   666 	return(font);
       
   667 	}
       
   668 
       
   669 void CWsAnim::CloseFont(CFbsFont *aFont)
       
   670 	{
       
   671 	if (aFont)
       
   672 		((CAnimFbsFont *)aFont)->Close();
       
   673 	}
       
   674 
       
   675 CFbsBitmap *CWsAnim::DuplicateBitmapL(TInt aHandle)
       
   676 	{
       
   677 	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
       
   678 	TInt err=bitmap->Duplicate(aHandle);
       
   679 	if (err!=KErrNone)
       
   680 		{
       
   681 		delete bitmap;
       
   682 		if (err==KErrNoMemory)
       
   683 			User::Leave(err);
       
   684 		iClient->PPanic(EWservPanicBitmap);
       
   685 		}
       
   686 	return(bitmap);
       
   687 	}
       
   688 
       
   689 TSize CWsAnim::WindowSize() const
       
   690 	{
       
   691 	if (!iWindow)
       
   692 		Panic();
       
   693 	return(iWindow->Size());
       
   694 	}
       
   695 
       
   696 TBool CWsAnim::IsHidden()
       
   697 	{
       
   698 	if (!iWindow)
       
   699 		Panic();
       
   700 
       
   701 	return iWindow->IsHidden();
       
   702 	}
       
   703 
       
   704 void CWsAnim::SetVisible(TBool aState)
       
   705 	{	
       
   706 	//The (iAnimGc->IsActive() && aState) part of the below if statement is in place to accomodate bc with 
       
   707 	//the original wserv. 
       
   708 	//We panic when we call SetVisible(ETrue) and the CWsAnimGc has been activated because the origininal wserv did.
       
   709 	//We don't panic when we call SetVisible(EFalse) and the CWsAnimGc is activated because the original wserv didn't.
       
   710  
       
   711 	if( !iWindow || (iAnimGc->IsActive() && aState) )
       
   712 		{
       
   713 		Panic();	
       
   714 		}
       
   715 		
       
   716 	iWindow->SetVisible(aState);
       
   717 	
       
   718 	STACK_REGION region;
       
   719 	VisibleRegion(region);
       
   720 	TRect rect = region.BoundingRect();
       
   721 	region.Close();
       
   722 	if(!rect.IsEmpty())
       
   723 		iWindow->Screen()->ScheduleAnimation(EWindowAnim, rect,0,0,0, iWindow);
       
   724 	}
       
   725 
       
   726 MAnimGeneralFunctions::TAnimSync CWsAnim::Sync() const
       
   727 	{
       
   728 	return(iAnimSync);
       
   729 	}
       
   730 
       
   731 void CWsAnim::GetRawEvents(TBool aGetEvents) const
       
   732 	{
       
   733 	if (aGetEvents)
       
   734 		{
       
   735 		if (!iAnimAddedInHandler)
       
   736 			{
       
   737 			TWindowServerEvent::AddEventHandler(Anim(), iBitFlags.IsSet(EAdvancedPointersEnabled));
       
   738 			iAnimAddedInHandler = ETrue;
       
   739 			}
       
   740 		}
       
   741 	else
       
   742 		{
       
   743 		if (iAnimAddedInHandler)
       
   744 			{
       
   745 			TWindowServerEvent::RemoveEventHandler(Anim());
       
   746 			iAnimAddedInHandler = EFalse;
       
   747 			}
       
   748 		}
       
   749 	}
       
   750 
       
   751 void CWsAnim::PostRawEvent(const TRawEvent &aRawEvent) const
       
   752 	{
       
   753 	// Cannot remove const from aRawEvent parameter type for compatibility reasons.
       
   754 	if (TWsPointer::PreProcessClientEvent(const_cast<TRawEvent &>(aRawEvent), iBitFlags.IsSet(EAdvancedPointersEnabled)))
       
   755 		{
       
   756 		TWindowServerEvent::ProcessRawEvent(aRawEvent);
       
   757 		}
       
   758 	}
       
   759 
       
   760 void CWsAnim::PostKeyEvent(const TKeyEvent &aRawEvent) const
       
   761 	{
       
   762 	TWindowServerEvent::ProcessKeyEvent(aRawEvent,0);
       
   763 	}
       
   764 	
       
   765 /**
       
   766 Generate repeated key events. 
       
   767 */	
       
   768 void CWsAnim::PostKeyEvent(const TKeyEvent& aRawEvent, TInt aRepeats) const
       
   769 	{
       
   770 	TWindowServerEvent::ProcessKeyEvent(aRawEvent,aRepeats);
       
   771  	}
       
   772 
       
   773 TInt CWsAnim::RegisterForNotifications(TUint32 aNotifications)
       
   774 	{
       
   775 	if (aNotifications)
       
   776 		{
       
   777 		return TWindowServerEvent::AddNotificationHandler(Anim(),aNotifications);
       
   778 		}
       
   779 	else
       
   780 		{
       
   781 		TWindowServerEvent::RemoveNotificationHandler(Anim());
       
   782 		return KErrNone;
       
   783 		}
       
   784 	}
       
   785 
       
   786 const RMessagePtr2* CWsAnim::Message()
       
   787 	{
       
   788 	return iMessage;
       
   789 	}
       
   790 
       
   791 void CWsAnim::SetMessage(const RMessagePtr2* aMessage)
       
   792 	{
       
   793 	iMessage=aMessage;
       
   794 	}
       
   795 
       
   796 TInt CWsAnim::CommandReply(TInt aOpcode, TAny* aArgs)
       
   797 	{
       
   798 	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)
       
   799 	TInt returnValue=0;
       
   800 	TRAP(returnValue,returnValue=Anim()->CommandReplyL(aOpcode, aArgs));
       
   801 	SetMessage(NULL);
       
   802 	return returnValue;
       
   803 	}
       
   804 
       
   805 TSpriteMember *CWsAnim::GetSpriteMember(TInt aMember) const
       
   806 	{
       
   807 	if (!iSprite)
       
   808 		Panic();
       
   809 	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
       
   810 	}
       
   811 
       
   812 void CWsAnim::UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate)
       
   813 	{
       
   814 	if (!iSprite)
       
   815 		Panic();
       
   816 	iSprite->Update(aMember,aRect,aFullUpdate);
       
   817 	}
       
   818 
       
   819 void CWsAnim::Activate(TBool aActive)
       
   820 	{
       
   821 	if (!iSprite)
       
   822 		Panic();
       
   823 	if (!aActive)
       
   824 		iSprite->Deactivate();
       
   825 	else
       
   826 		{
       
   827 		if (iSprite->IsActive())
       
   828 			Panic();
       
   829 		iSprite->Activate();
       
   830 		}
       
   831 	}
       
   832 
       
   833 void CWsAnim::SizeChangedL()
       
   834 	{
       
   835 	if (!iSprite)
       
   836 		Panic();
       
   837 	iSprite->CWsSpriteBase::CompleteL();
       
   838 	}
       
   839 
       
   840 void CWsAnim::SetPosition(const TPoint &aPos)
       
   841 	{
       
   842 	iSprite->SetPos(aPos);
       
   843 	}
       
   844 
       
   845 TAny* CWsAnim::ExtendedInterface(TInt aInterface)
       
   846 	{
       
   847 	switch(aInterface)
       
   848 		{
       
   849 	case ENumberOfExtendedInterfaces:
       
   850 		return reinterpret_cast<TAny*>(EInterfaceCount-1);
       
   851 	case EWindowExtensionInterface:
       
   852 		return static_cast<MAnimGeneralFunctionsWindowExtension*>(this);
       
   853 	case EEventExtentionInterface:
       
   854 		return static_cast<MAnimGeneralFunctionsEventExtension*>(this);
       
   855 	default:
       
   856 		return NULL;
       
   857 		}
       
   858 	}
       
   859 
       
   860 TInt CWsAnim::Screens() const
       
   861 	{
       
   862 	return CWsTop::NumberOfScreens();
       
   863 	}
       
   864 
       
   865 TInt CWsAnim::FocusScreens() const
       
   866 	{
       
   867 	return CWsTop::CurrentFocusScreen()->ScreenNumber();
       
   868 	}
       
   869 
       
   870 void CWsAnim::SetFocusScreen(TInt aScreenNo)
       
   871  	{
       
   872  	if (aScreenNo<CWsTop::NumberOfScreens() && aScreenNo>=0)
       
   873  		{
       
   874  		CWsTop::SetCurrentFocusScreen(aScreenNo);
       
   875  		}
       
   876  	else
       
   877  		{
       
   878  		Panic();
       
   879  		}
       
   880  	}
       
   881 
       
   882 TInt CWsAnim::WindowGroups(TInt aScreen) const
       
   883 	{
       
   884 	return(CWsWindowGroup::NumWindowGroupsOnScreen(CWsTop::Screen(aScreen)->RootWindow()->Child(),ETrue,0));
       
   885 	}
       
   886 
       
   887 TBool CWsAnim::WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aFullOrdinalPosition) const
       
   888 	{
       
   889 	CWsWindowGroup* group=CWsTop::Screen(aScreen)->RootWindow()->WindowGroup(aFullOrdinalPosition);
       
   890 	if (!group)
       
   891 		return EFalse;
       
   892 	aInfo.iId=group->Identifier();
       
   893 	if (group->ReceivesFocus() && group->ScreenDeviceValid())
       
   894 		aInfo.iFlags=TWindowGroupInfo::EIsFocusable;
       
   895 	else
       
   896 		aInfo.iFlags=0;
       
   897 	aInfo.iOrdinalPriority=group->OrdinalPriority();
       
   898 	HBufC* groupName=group->GroupName();
       
   899 	aInfo.iNameLength=groupName?group->GroupName()->Length():0;
       
   900 	if (!group->IsChained(aInfo.iParentId))
       
   901 		aInfo.iParentId=-1;
       
   902 	return ETrue;
       
   903 	}
       
   904 
       
   905 TInt CWsAnim::WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aFullOrdinalPosition) const
       
   906 	{
       
   907 	CWsWindowGroup* group=CWsTop::Screen(aScreen)->RootWindow()->WindowGroup(aFullOrdinalPosition);
       
   908 	if (!group)
       
   909 		return EFalse;
       
   910 	HBufC* name=group->GroupName();
       
   911 	if (name)
       
   912 		aWindowName.Set(*name);
       
   913 	else
       
   914 		aWindowName.Set(NULL,0);
       
   915 	return ETrue;
       
   916 	}
       
   917 
       
   918 TInt CWsAnim::SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority)
       
   919 	{
       
   920 	CWsWindowGroup* group=CWsWindowGroup::WindowGroupFromIdentifier(aWindowGroupId);
       
   921 	if (group)
       
   922 		{
       
   923 		group->SetOrdinalPriority(aPos,aOrdinalPriority);
       
   924 		return KErrNone;
       
   925 		}
       
   926 	return KErrNotFound;
       
   927 	}
       
   928 
       
   929 void CWsAnim::WindowConfig(TWindowConfig& aWindowConfig) const
       
   930 	{
       
   931 	aWindowConfig.iFlags = 0x00;
       
   932 	if (iWindow->IsTranslucent())
       
   933 		{
       
   934 		aWindowConfig.iFlags |= TWindowConfig::ETransparencyEnabled;
       
   935 		if (iWindow->HasAlpha())
       
   936 			{
       
   937 			aWindowConfig.iFlags |= TWindowConfig::EAlphaBlendedTransparency;
       
   938 			}		
       
   939 		}
       
   940 	}
       
   941 
       
   942 TBool CWsAnim::SpriteCanBeSeen() const
       
   943 	{
       
   944 	if(!iSprite)
       
   945 		Panic();
       
   946 	return iSprite->CanBeSeen();
       
   947 	}
       
   948 
       
   949 /** @see MWsWindowTreeNode */
       
   950 MWsWindowTreeNode::TType CWsAnim::NodeType() const
       
   951 	{
       
   952 	return (iSprite) ? iSprite->NodeType() : MWsWindowTreeNode::EWinTreeNodeAnim;
       
   953 	}
       
   954 
       
   955 /** @see MWsWindowTreeNode */
       
   956 const MWsWindow* CWsAnim::Window() const
       
   957 	{
       
   958 	return NULL;
       
   959 	}
       
   960 
       
   961 /** @see MWsWindowTreeNode */
       
   962 const MWsSprite* CWsAnim::Sprite() const
       
   963 	{
       
   964 	return iSprite;
       
   965 	}
       
   966 
       
   967 /** @see MWsWindowTreeNode */
       
   968 const MWsStandardTextCursor* CWsAnim::StandardTextCursor() const
       
   969 	{
       
   970 	return NULL;
       
   971 	}
       
   972 
       
   973 /** @see MWsWindowTreeNode */
       
   974 const MWsWindowGroup* CWsAnim::WindowGroup() const
       
   975 	{
       
   976 	if (iSprite)
       
   977 		return iSprite->WindowGroup();
       
   978 	else if (iWindow)
       
   979 		return iWindow->WindowGroup();
       
   980 	Panic();
       
   981 	return NULL;
       
   982 	}
       
   983 
       
   984 /** @see MWsWindowTreeNode */
       
   985 const MWsWindowTreeNode* CWsAnim::ParentNode() const
       
   986 	{
       
   987 	if (iSprite)
       
   988 		return iSprite->ParentNode();
       
   989 	else if (iWindow)
       
   990 		return iWindow; //A window-anim is considered to be a child of the window
       
   991 	Panic();
       
   992 	return NULL;
       
   993 	}
       
   994 
       
   995 //
       
   996 
       
   997 CObjectConIx* CWsAnimDll::AnimObjectConIx=NULL;
       
   998 
       
   999 void CWsAnimDll::InitStaticsL()
       
  1000 	{
       
  1001 	CWsAnimDll::AnimObjectConIx=CObjectConIx::NewL();
       
  1002 	}
       
  1003 
       
  1004 void CWsAnimDll::DeleteStatics()
       
  1005 	{
       
  1006 	delete CWsAnimDll::AnimObjectConIx;
       
  1007 	}
       
  1008 
       
  1009 CWsAnimDll::CWsAnimDll(CWsClient *aOwner) : CWsObject(aOwner,WS_HANDLE_ANIM_DLL)
       
  1010 	{
       
  1011 	__DECLARE_NAME(_S("CWsAnimDll"));
       
  1012 	}
       
  1013 
       
  1014 CWsAnimDll::~CWsAnimDll()
       
  1015 	{
       
  1016 	delete iInstanceIndex;
       
  1017 	AnimObjectConIx->Remove(iInstanceCon);
       
  1018 	delete iAnimDll;
       
  1019 	iAnimLib.Close();
       
  1020 	}
       
  1021 
       
  1022 TInt CWsAnimDll::doCreateInstanceL(CWsAnim *aInstance, TInt aType, TAny *aArgs, TBool aIsWindow)
       
  1023 	{
       
  1024 	iInstanceCon->AddL(aInstance);
       
  1025 	aInstance->ConstructL(iAnimDll->CreateInstanceL(aType),aArgs,this,aIsWindow);
       
  1026 	return(iInstanceIndex->AddL(aInstance));
       
  1027 	}
       
  1028 
       
  1029 TInt CWsAnimDll::CreateInstanceL(TUint32 aHandle, TInt aType, TAny *aArgs, TBool aIsWindow)
       
  1030 	{
       
  1031 	TWindowServerEvent::PotentialEventHandlerL(1);
       
  1032 	CWsAnim *instance=new(ELeave) CWsAnim(this);
       
  1033 	CleanupClosePushL(*instance);
       
  1034 	if (aIsWindow)
       
  1035 		{
       
  1036 		CWsClientWindow *win;
       
  1037 		iWsOwner->HandleToClientWindow(aHandle,&win);
       
  1038 		instance->Connect(win);
       
  1039 		}
       
  1040 	else
       
  1041 		{
       
  1042 		CWsObject *sprite=iWsOwner->HandleToObj(aHandle, WS_HANDLE_SPRITE);
       
  1043 		if (!sprite)
       
  1044 			OwnerPanic(EWservPanicSprite);
       
  1045 		instance->Connect(STATIC_CAST(CWsSprite*,sprite));
       
  1046 		}
       
  1047 	TInt handle=doCreateInstanceL(instance, aType, aArgs, aIsWindow);
       
  1048 	CleanupStack::Pop(instance);	
       
  1049 	return(handle);
       
  1050 	}
       
  1051 
       
  1052 void CWsAnimDll::LoadL(const TDesC &aDllName)
       
  1053 	{
       
  1054 	NewObjL();
       
  1055 	TFileName name(aDllName);
       
  1056 	User::LeaveIfError(iAnimLib.Load(name));
       
  1057 	if (wsDebugLog)
       
  1058 		{
       
  1059 		TBuf<256> buf;
       
  1060 		_LIT(KWSERVLoadedAnimDll,"Loaded Anim DLL:  ");
       
  1061 		buf.Append(KWSERVLoadedAnimDll);
       
  1062 		buf.Append(iAnimLib.FileName());
       
  1063 		wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant,buf);
       
  1064 		}
       
  1065 	TUidType uid=iAnimLib.Type();
       
  1066 	if (uid[1]!=KWservAnimDllUid)
       
  1067 		User::Leave(KErrNotSupported);
       
  1068 	CreateCAnimDll f;
       
  1069 	f=(CreateCAnimDll)User::LeaveIfNull((TAny *)iAnimLib.Lookup(1));
       
  1070 	iAnimDll=(*f)();
       
  1071 	iInstanceIndex=CObjectIx::NewL();
       
  1072 	iInstanceCon=AnimObjectConIx->CreateL();
       
  1073 	}
       
  1074 
       
  1075 void CWsAnimDll::Remove(TInt aHandle)
       
  1076 	{
       
  1077 	iInstanceIndex->Remove(aHandle);
       
  1078 	}
       
  1079 
       
  1080 void CWsAnimDll::CommandL(TInt aOpcode, const TAny *aCmdData)
       
  1081 	{
       
  1082 	TWsAnimDllCmdUnion pData;
       
  1083 
       
  1084 	pData.any=aCmdData;
       
  1085 	switch(aOpcode)
       
  1086 		{
       
  1087 		case EWsAnimDllOpFree:
       
  1088 			delete this;
       
  1089 			break;
       
  1090 		case EWsAnimDllOpCreateInstance:
       
  1091 		case EWsAnimDllOpCreateInstanceSprite:
       
  1092 			SetReply(CreateInstanceL(*pData.UInt,*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2)
       
  1093 																					,aOpcode==EWsAnimDllOpCreateInstance));
       
  1094 			break;
       
  1095 		case EWsAnimDllOpCommandReply:
       
  1096 		case EWsAnimDllOpCommand:
       
  1097 		case EWsAnimDllOpDestroyInstance:
       
  1098 			{
       
  1099 			CWsAnim *anim=(CWsAnim *)iInstanceIndex->At(*pData.UInt);
       
  1100 			TInt ret;
       
  1101 			//Deleting a non existant Anim is allowed as the Anim will be destroyed
       
  1102 			//when the window it is on (or a parent of) it destroyed
       
  1103 			if (anim==NULL && aOpcode!=EWsAnimDllOpDestroyInstance)
       
  1104 				OwnerPanic(EWservPanicAnim);
       
  1105 			switch(aOpcode)
       
  1106 				{
       
  1107 				case EWsAnimDllOpCommandReply:
       
  1108 					{
       
  1109 					TInt reply=KErrNone;
       
  1110 					TRAP(ret,reply=anim->CommandReply(*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2)));
       
  1111 					anim->UserDeactivateAnimGc();
       
  1112 					if (ret!=KErrNone)
       
  1113 						User::Leave(ret);
       
  1114 					SetReply(reply);
       
  1115 					}
       
  1116 					break;
       
  1117 				case EWsAnimDllOpCommand:
       
  1118 					TRAP(ret,anim->Anim()->Command(*((TInt *)(pData.UInt+1)),(TAny *)(pData.UInt+2)));
       
  1119 					if (ret!=KErrNone && ret!=CWsClient::EPanicLeave)
       
  1120 						OwnerPanic(EWservPanicAnimLeave);
       
  1121 					anim->UserDeactivateAnimGc();
       
  1122 					break;
       
  1123 				case EWsAnimDllOpDestroyInstance:
       
  1124 					if (anim) // Added to go with changes described above
       
  1125 						Remove(*pData.UInt);
       
  1126 					break;
       
  1127 				default:
       
  1128 					break;
       
  1129 				}
       
  1130 			}
       
  1131 			break;
       
  1132 		default:
       
  1133 			OwnerPanic(EWservPanicOpcode);
       
  1134 		}
       
  1135 	}
       
  1136 
       
  1137 CAnimFbsFont::~CAnimFbsFont()
       
  1138 	{}
       
  1139 
       
  1140 CAnimFbsFont::CAnimFbsFont()
       
  1141 	{}
       
  1142 
       
  1143 CAnimFbsFont* CAnimFbsFont::NewL(TInt aHandle,TInt& aError)
       
  1144 	{
       
  1145 	CAnimFbsFont *font=new(ELeave) CAnimFbsFont();
       
  1146 	font->iAccessCount=1;
       
  1147 	aError=font->Duplicate(aHandle);
       
  1148 	if (aError!=KErrNone)
       
  1149 		{
       
  1150 		delete font;
       
  1151 		font=NULL;
       
  1152 		}
       
  1153 	return(font);
       
  1154 	}
       
  1155 
       
  1156 void CAnimFbsFont::Open()
       
  1157 	{
       
  1158 	iAccessCount++;
       
  1159 	}
       
  1160 
       
  1161 void CAnimFbsFont::Close()
       
  1162 	{
       
  1163 	if (--iAccessCount==0)
       
  1164 		delete this;
       
  1165 	}
       
  1166 
       
  1167 
       
  1168 /*MAnimGeneralFunctions*/
       
  1169 void MAnimGeneralFunctions::Reserved1() const
       
  1170 	{}
       
  1171 	
       
  1172 void MAnimGeneralFunctions::Reserved2() const
       
  1173 	{}
       
  1174 	
       
  1175 void MAnimGeneralFunctions::Reserved3() const
       
  1176 	{}
       
  1177 
       
  1178 	
       
  1179 /*MAnimGeneralFunctionsExtension*/
       
  1180 
       
  1181 void MAnimGeneralFunctionsWindowExtension::Reserved1() const
       
  1182 	{}
       
  1183 
       
  1184 void MAnimGeneralFunctionsWindowExtension::Reserved2() const
       
  1185 	{}
       
  1186 
       
  1187 void MAnimGeneralFunctionsWindowExtension::Reserved3() const
       
  1188 	{}
       
  1189 
       
  1190 
       
  1191 /*MAnimWindowFunctions*/
       
  1192 
       
  1193 void MAnimWindowFunctions::Reserved() const
       
  1194 	{}
       
  1195 
       
  1196 void MAnimWindowFunctions::Reserved1() const
       
  1197 	{}
       
  1198 	
       
  1199 void MAnimWindowFunctions::Reserved2() const
       
  1200 	{}
       
  1201 	
       
  1202 void MAnimWindowFunctions::Reserved3() const
       
  1203 	{}
       
  1204 	
       
  1205 
       
  1206 /*MAnimFreeTimerWindowFunctions*/
       
  1207 
       
  1208 void MAnimFreeTimerWindowFunctions::Reserved3() const
       
  1209 	{}
       
  1210 
       
  1211 
       
  1212 /*MAnimSpriteFunctions*/
       
  1213 
       
  1214 void MAnimSpriteFunctions::Reserved() const
       
  1215 	{}
       
  1216 
       
  1217 void MAnimSpriteFunctions::Reserved2() const
       
  1218 	{}
       
  1219 	
       
  1220 void MAnimSpriteFunctions::Reserved3() const
       
  1221 	{}
       
  1222 	
       
  1223 void MAnimSpriteFunctions::Reserved4() const
       
  1224 	{}	
       
  1225 
       
  1226 /*MAnimGeneralFunctionsEventExtension*/
       
  1227 
       
  1228 void MAnimGeneralFunctionsEventExtension::Reserved1() const
       
  1229 	{}
       
  1230 	
       
  1231 void MAnimGeneralFunctionsEventExtension::Reserved2() const
       
  1232 	{}