svgtopt/SVG/SVGEngine/src/SVGEventHandler.cpp
changeset 0 d46562c3d99d
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Engine source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "SVGEventHandler.h"
       
    20 #include "SVGEventReceiver.h"
       
    21 
       
    22 #include "SVGElementImpl.h"
       
    23 #include "SVGListener.h"
       
    24 #include "SVGAnimationBase.h"
       
    25 // ---------------------------------------------------------------------------
       
    26 // Two phase constructor
       
    27 // ---------------------------------------------------------------------------
       
    28 CSvgEventHandler* CSvgEventHandler::NewLC()
       
    29     {
       
    30     CSvgEventHandler* self = new ( ELeave ) CSvgEventHandler();
       
    31     CleanupStack::PushL( self );
       
    32     self->ConstructL();
       
    33     return self;
       
    34     }
       
    35 
       
    36 //
       
    37 // ---------------------------------------------------------------------------
       
    38 // Two phase constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 CSvgEventHandler* CSvgEventHandler::NewL()
       
    41     {
       
    42     CSvgEventHandler* self = NewLC();
       
    43     CleanupStack::Pop();
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Private method to build heap objects
       
    49 // ---------------------------------------------------------------------------
       
    50 void CSvgEventHandler::ConstructL()
       
    51     {
       
    52     iEventReceiverList = new ( ELeave ) CArrayFixFlat<TEventReceiverListItem>( 20 );
       
    53     }
       
    54 
       
    55 //
       
    56 // ---------------------------------------------------------------------------
       
    57 // Constructor
       
    58 // ---------------------------------------------------------------------------
       
    59 CSvgEventHandler::CSvgEventHandler() : iInProcess( 0 ), iCurrentTime( 0 )
       
    60     {
       
    61     }
       
    62 
       
    63 //
       
    64 // ---------------------------------------------------------------------------
       
    65 // Destructor
       
    66 // ---------------------------------------------------------------------------
       
    67 CSvgEventHandler::~CSvgEventHandler()
       
    68     {
       
    69 	if ( iEventReceiverList )
       
    70 		{
       
    71     	delete iEventReceiverList;
       
    72 		iEventReceiverList = NULL;
       
    73 		}
       
    74     }
       
    75 
       
    76 
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 // void CSvgEventHandler::Reset()
       
    80 // Reset the status of the event handler and all the event receivers
       
    81 // ---------------------------------------------------------------------------
       
    82 void CSvgEventHandler::Reset()
       
    83     {
       
    84     // Need to wait if other thread is changing tree.
       
    85 	if( iEventReceiverList )
       
    86 		{
       
    87 		iEventReceiverList->Reset();
       
    88 		}
       
    89     }
       
    90 
       
    91 //
       
    92 // --------------------------------------------------------------------------
       
    93 // TBool CSvgEventHandler::ProcessEventL( MSvgEvent* aEvent )
       
    94 // Process events received from the client
       
    95 // ---------------------------------------------------------------------------
       
    96 TBool CSvgEventHandler::ProcessEventL( MSvgEvent* aEvent )
       
    97     {
       
    98     TBool redrawNeeded = EFalse;
       
    99     if ( aEvent->EventType() == ESvgEngineEventScreenUpdate )
       
   100          return ETrue;       // No element will recieve this event
       
   101 
       
   102     if ( iEventReceiverList->Count() <= 0 )
       
   103         return redrawNeeded;    // No receiver is available
       
   104 
       
   105     // Timer event
       
   106     if ( aEvent->EventType() == ESvgEngineEventTimer )
       
   107         {
       
   108         // Update current time
       
   109         iCurrentTime = ( ( MSvgTimerEvent * ) aEvent )->Time();
       
   110         // call reset-reference-element to animation elements
       
   111         TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   112 		for ( TInt j = 0; j < eventReceiverListCnt; j++ )
       
   113             {
       
   114             if ( !(( *iEventReceiverList )[j].iWasDeleted) && 0 !=
       
   115                  ( aEvent->EventMask() |
       
   116                    ( *iEventReceiverList )[j].iEventMask ) )
       
   117                 {
       
   118 				if( (*iEventReceiverList )[j].iTargetElement )
       
   119 					{
       
   120 					(*iEventReceiverList )[j].iTargetElement->ResetReferenceAttrSet();
       
   121 					}
       
   122 
       
   123                 }
       
   124             }
       
   125 		eventReceiverListCnt = iEventReceiverList->Count();            
       
   126         for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   127             {
       
   128             if ( !(( *iEventReceiverList )[i].iWasDeleted) && 0 !=
       
   129                  ( aEvent->EventMask() |
       
   130                    ( *iEventReceiverList )[i].iEventMask ) )
       
   131                 {
       
   132                 ( *iEventReceiverList )[i].iElement->ResetReferenceElementL();
       
   133                 }
       
   134             }
       
   135         }
       
   136     // Internal event & key event need time to be added
       
   137     if ( aEvent->EventType() == ESvgEngineInternalEvent &&
       
   138 		             ! (( MSvgInternalEvent * )aEvent)->UserSeek() )
       
   139 		{
       
   140         ( ( MSvgInternalEvent * ) aEvent )->SetTime( iCurrentTime );
       
   141 		}
       
   142     if ( aEvent->EventType() == ESvgEngineEventKeyPress )
       
   143 		{
       
   144         ( ( MSvgUiKeyEvent * ) aEvent )->SetTime( iCurrentTime );
       
   145 		}
       
   146 
       
   147     // Sending events to elements
       
   148     for ( TInt i = 0; i < iEventReceiverList->Count(); i++ )
       
   149         {
       
   150         if ( !(( *iEventReceiverList )[i].iWasDeleted) && 0 !=
       
   151              ( aEvent->EventMask() | ( *iEventReceiverList )[i].iEventMask ) )
       
   152             {
       
   153             // Send event to list[i].iElement
       
   154             
       
   155             //check if the subeventmask is some valid bits set
       
   156             if( IsValidSubEventMask(( *iEventReceiverList )[i].iSubEventMask))
       
   157                 {
       
   158                 if(
       
   159                 ( *iEventReceiverList )[i].iElement->
       
   160                 ReceiveEventL(aEvent,
       
   161                              ( *iEventReceiverList )[i].iSubEventMask  ) )
       
   162                     {
       
   163                     redrawNeeded=ETrue;    
       
   164                     }
       
   165                 
       
   166                 }
       
   167             else if ( ( *iEventReceiverList )[i].iElement->ReceiveEventL( aEvent) )
       
   168                 redrawNeeded = ETrue;
       
   169             
       
   170             }
       
   171         }
       
   172 
       
   173 	ClearNullsFromEventReceiverList();
       
   174 	
       
   175     return redrawNeeded;
       
   176     }
       
   177 
       
   178 // -------------------------------------------------------------------------
       
   179 // TBool IsValidSubEventMask(TUint16 aSubEventMask)
       
   180 //
       
   181 // Checks whether aSubEventMask contains some valid bits set for 
       
   182 // interactive events
       
   183 // 
       
   184 // Returns: True if any valid bit is set else false.
       
   185 //
       
   186 // --------------------------------------------------------------------------
       
   187 TBool CSvgEventHandler::IsValidSubEventMask(TUint16 aSubEventMask)
       
   188     {
       
   189     TUint16 temp=0x1FF;
       
   190     temp=temp&aSubEventMask;
       
   191     if(temp==aSubEventMask)
       
   192         {
       
   193         return ETrue;
       
   194         }
       
   195     else
       
   196         {
       
   197         return EFalse;
       
   198         }
       
   199     }
       
   200 
       
   201 // --------------------------------------------------------------------------
       
   202 // void CSvgEventHandler::AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   203 //
       
   204 // AddToEventReceiverListL: Add an object to the list of objects that are
       
   205 // notified of an event.
       
   206 //
       
   207 // Returns: none
       
   208 //
       
   209 // ---------------------------------------------------------------------------
       
   210 void CSvgEventHandler::AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   211                                                 TUint8 aEventMask,
       
   212                                                 TUint32 aBeginTime,
       
   213                                                 TUint32 aEndTime)
       
   214     {
       
   215     // check to see if receiver is already in list and simply return
       
   216     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   217     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   218         {
       
   219         if ( !(( *iEventReceiverList )[i].iWasDeleted) && (*iEventReceiverList)[i].iElement == aElement )
       
   220             {
       
   221             return;
       
   222             }
       
   223         }
       
   224 
       
   225     TEventReceiverListItem listitem;
       
   226     listitem.iSubEventMask=0xFFFF;
       
   227     listitem.iElement = aElement;
       
   228     listitem.iEventMask = aEventMask;
       
   229     listitem.iAbsoluteEnd = aEndTime;
       
   230 	listitem.iTargetElement = NULL;
       
   231 	listitem.iBeginTime = aBeginTime;
       
   232 	listitem.iWasDeleted = 0;
       
   233     iEventReceiverList->AppendL( listitem );
       
   234     }
       
   235 
       
   236 // --------------------------------------------------------------------------
       
   237 // void CSvgEventHandler::AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   238 //
       
   239 // AddToEventReceiverListL: Add an object to the list of objects that are
       
   240 // notified of an event.
       
   241 //
       
   242 // Returns: none
       
   243 //
       
   244 // ---------------------------------------------------------------------------
       
   245 void CSvgEventHandler::AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   246                                                 TSvgEvent aEvent,
       
   247                                                 TUint8 aEventMask,
       
   248                                                 TUint32 aBeginTime,
       
   249                                                 TUint32 aEndTime)
       
   250     {
       
   251     TEventReceiverListItem listitem;
       
   252     listitem.iElement = aElement;
       
   253     listitem.iSubEventMask=0xFFFF;
       
   254     TSvgInteractionEvent lsubeventtype;
       
   255     switch(aEvent)
       
   256         {
       
   257         case ESvgEventFocusin:
       
   258         lsubeventtype=ESvgInteractiveEventFocusin;
       
   259         break;
       
   260                 
       
   261         case ESvgEventFocusout:
       
   262         lsubeventtype=ESvgInteractiveEventFocusout;
       
   263         break;
       
   264                 
       
   265         case ESvgEventActivate:
       
   266         lsubeventtype=ESvgInteractiveEventActivate;
       
   267         break;
       
   268                 
       
   269         case ESvgEventClick:
       
   270         lsubeventtype=ESvgInteractiveEventClick;
       
   271         break;
       
   272                 
       
   273         case ESvgEventMousedown:
       
   274         lsubeventtype=ESvgInteractiveEventMousedown;
       
   275         break;
       
   276                 
       
   277         case ESvgEventMouseup:
       
   278         lsubeventtype=ESvgInteractiveEventMouseup;
       
   279         break;
       
   280                 
       
   281         case ESvgEventMouseover:
       
   282         lsubeventtype=ESvgInteractiveEventMouseover;
       
   283         break;
       
   284                 
       
   285         case ESvgEventMousemove:
       
   286         lsubeventtype=ESvgInteractiveEventMousemove;
       
   287         break;
       
   288                 
       
   289         case ESvgEventMouseout:
       
   290         lsubeventtype=ESvgInteractiveEventMouseout;
       
   291         break;
       
   292                 
       
   293         default:
       
   294         lsubeventtype=(TSvgInteractionEvent)0;
       
   295         break;
       
   296         }
       
   297     // check to see if receiver is already in list and just update the 
       
   298     // iSubEventMask and return
       
   299     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   300     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   301         {
       
   302         if ( !(( *iEventReceiverList )[i].iWasDeleted) && (*iEventReceiverList)[i].iElement == aElement )
       
   303             {
       
   304          
       
   305                 (*iEventReceiverList)[i].iSubEventMask=
       
   306                 ( *iEventReceiverList)[i].iSubEventMask | lsubeventtype;               
       
   307             
       
   308             return;
       
   309             }
       
   310         }
       
   311     listitem.iSubEventMask=listitem.iSubEventMask & lsubeventtype;
       
   312     listitem.iEventMask = aEventMask;
       
   313     listitem.iAbsoluteEnd = aEndTime;
       
   314 	listitem.iTargetElement = NULL;
       
   315 	listitem.iBeginTime = aBeginTime;
       
   316 	listitem.iWasDeleted = 0;
       
   317     iEventReceiverList->AppendL( listitem );
       
   318     }
       
   319 // --------------------------------------------------------------------------
       
   320 // TUint16 CSvgEventHandler::CheckInteractivityAndGetSubEventMask
       
   321 // (CSvgElementImpl* aElement,
       
   322 //
       
   323 // CheckInteractivityAndGetSubEventMask: Check whether the element 
       
   324 // is interactive or not and get the iSubEventmask
       
   325 //
       
   326 // Returns: ETrue if interactive else False
       
   327 //
       
   328 // ---------------------------------------------------------------------------
       
   329 TBool CSvgEventHandler::CheckInteractivityAndGetSubEventMask(
       
   330                                         CSvgElementImpl* aElement, TUint16& aSubEventMask )
       
   331     {
       
   332     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   333     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   334         {
       
   335         if((*iEventReceiverList)[i].iElement==aElement && 
       
   336            IsValidSubEventMask((*iEventReceiverList)[i].iSubEventMask) )
       
   337             {
       
   338             aSubEventMask=(*iEventReceiverList)[i].iSubEventMask;
       
   339             return ETrue;
       
   340             }
       
   341         }
       
   342         return EFalse;
       
   343     }
       
   344 
       
   345 // --------------------------------------------------------------------------
       
   346 // TUint8 CSvgEventHandler::EventMask(MSvgEventReceiver* aElement)
       
   347 // EventMask: Return the event mask of the registered element
       
   348 //
       
   349 // Returns: TUnit8, the event mask
       
   350 //
       
   351 // ---------------------------------------------------------------------------
       
   352 TUint8 CSvgEventHandler::EventMask(MSvgEventReceiver* aElement)
       
   353     {
       
   354     
       
   355     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   356     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   357         {
       
   358         if ( !(( *iEventReceiverList )[i].iWasDeleted) && (*iEventReceiverList)[i].iElement == aElement )
       
   359             {
       
   360             return (*iEventReceiverList)[i].iEventMask;
       
   361             }
       
   362         }
       
   363     return 0;
       
   364     }
       
   365 
       
   366 
       
   367 
       
   368 //
       
   369 // --------------------------------------------------------------------------
       
   370 // void CSvgEventHandler::RemoveFromEventReceiverList( MSvgEventReceiver* aElement )
       
   371 // Remove an object to the list of objects that are notified of an event
       
   372 // ---------------------------------------------------------------------------
       
   373 void CSvgEventHandler::RemoveFromEventReceiverList( MSvgEventReceiver* aElement )
       
   374     {
       
   375     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   376     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   377         {
       
   378         if ( !(( *iEventReceiverList )[i].iWasDeleted) && (*iEventReceiverList)[i].iElement == aElement )
       
   379             {
       
   380             //just setting to NULL for now because this could be called inside of ReceiveEvent
       
   381             //loop that already has the iEventReceiverList count.
       
   382             
       
   383             (*iEventReceiverList)[i].iWasDeleted = 1;
       
   384             //iEventReceiverList->Delete( i );
       
   385 			break;
       
   386             }
       
   387         }
       
   388     }
       
   389 
       
   390 // --------------------------------------------------------------------------
       
   391 // void CSvgEventHandler::ClearNullsFromEventReceiverList( )
       
   392 // Remove a null object
       
   393 // ---------------------------------------------------------------------------
       
   394 void CSvgEventHandler::ClearNullsFromEventReceiverList()
       
   395     {
       
   396     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   397     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   398         {
       
   399         if ( (*iEventReceiverList)[i].iWasDeleted )
       
   400             {
       
   401             iEventReceiverList->Delete( i );
       
   402             i = i - 1;
       
   403             eventReceiverListCnt = eventReceiverListCnt - 1;
       
   404             }
       
   405         }
       
   406     }
       
   407 
       
   408 
       
   409 // --------------------------------------------------------------------------
       
   410 // void  CSvgEventHandler::AddEventBeginTime(MSvgEventReceiver* aElement,  TUint32 aTime, MSvgEventReceiver* aTargetElement )
       
   411 // Provide the event end time information to the Event Handler
       
   412 // ---------------------------------------------------------------------------
       
   413 void  CSvgEventHandler::AddEventBeginTime(MSvgEventReceiver* aElement,  TUint32 aTime, MSvgEventReceiver* aTargetElement )
       
   414     {
       
   415 
       
   416     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   417     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   418         {
       
   419         if( !(( *iEventReceiverList )[i].iWasDeleted) && aElement == iEventReceiverList->operator[](i).iElement && (iEventReceiverList->operator[](i).iEventMask == KSvgEventMaskTimer ))
       
   420             {
       
   421              iEventReceiverList->operator[](i).iBeginTime = aTime;
       
   422              iEventReceiverList->operator[](i).iTargetElement = aTargetElement;
       
   423 			 break;
       
   424             }
       
   425         }
       
   426     }
       
   427 // --------------------------------------------------------------------------
       
   428 // TInt32 CSvgEventHandler::Count()
       
   429 // gives the number of elements in the eent receiver list
       
   430 // ---------------------------------------------------------------------------
       
   431 TInt32 CSvgEventHandler::Count()
       
   432     {
       
   433 	if(!iEventReceiverList) return 0;
       
   434 	return  iEventReceiverList->Count();
       
   435     }
       
   436 // --------------------------------------------------------------------------
       
   437 // void CSvgEventHandler::SortEventList()
       
   438 // An internal method that sorts the events in a time scale
       
   439 // ---------------------------------------------------------------------------
       
   440 void CSvgEventHandler::SortEventList()
       
   441     {
       
   442 
       
   443 	ClearNullsFromEventReceiverList();
       
   444 	
       
   445   // this algorithm is slighlty modified to use insertion sort.
       
   446  TInt i, j, tmpItemIndex;
       
   447   TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   448   for (i=1; i < eventReceiverListCnt; i++)
       
   449   {
       
   450 
       
   451 	TEventReceiverListItem  tmpitem;
       
   452     j = i;
       
   453        tmpitem.iElement = iEventReceiverList->operator[](i).iElement;
       
   454        tmpitem.iEventMask = iEventReceiverList->operator[](i).iEventMask;
       
   455        tmpitem.iAbsoluteEnd = iEventReceiverList->operator[](i).iAbsoluteEnd;
       
   456        tmpitem.iTargetElement = iEventReceiverList->operator[](i).iTargetElement;
       
   457 	   tmpitem.iBeginTime = iEventReceiverList->operator[](i).iBeginTime;
       
   458 	   tmpitem.iWasDeleted = iEventReceiverList->operator[](i).iWasDeleted;
       
   459        tmpItemIndex = i;
       
   460 
       
   461 			    while (j > 0)
       
   462 			    	{
       
   463 					if( (tmpitem.iTargetElement == iEventReceiverList->operator[](j-1).iTargetElement )   &&
       
   464 		                (tmpitem.iEventMask == iEventReceiverList->operator[](j-1).iEventMask) )
       
   465 
       
   466 
       
   467 				    {
       
   468 					     if(tmpitem.iBeginTime <
       
   469 			                        iEventReceiverList->operator[](j-1).iBeginTime)
       
   470 			             	{
       
   471 
       
   472 						   iEventReceiverList->operator[](tmpItemIndex).iElement 		= iEventReceiverList->operator[](j-1).iElement;
       
   473 				           iEventReceiverList->operator[](tmpItemIndex).iEventMask 		= iEventReceiverList->operator[](j-1).iEventMask;
       
   474 				           iEventReceiverList->operator[](tmpItemIndex).iAbsoluteEnd 	= iEventReceiverList->operator[](j-1).iAbsoluteEnd;
       
   475 				           iEventReceiverList->operator[](tmpItemIndex).iTargetElement 	= iEventReceiverList->operator[](j-1).iTargetElement;
       
   476 						   iEventReceiverList->operator[](tmpItemIndex).iBeginTime		=  iEventReceiverList->operator[](j-1).iBeginTime;
       
   477 						   tmpItemIndex = j-1;
       
   478 						    j = j - 1;
       
   479 						 	}
       
   480 				   		 else
       
   481 				    		{
       
   482 				    		break;
       
   483 				    		}
       
   484 				    }
       
   485 				    else
       
   486 				    	{
       
   487 				    	j--;
       
   488 				    	}
       
   489 			  		}
       
   490 			   iEventReceiverList->operator[](tmpItemIndex).iElement 		= tmpitem.iElement;
       
   491 			   iEventReceiverList->operator[](tmpItemIndex).iEventMask 		= tmpitem.iEventMask;
       
   492 			   iEventReceiverList->operator[](tmpItemIndex).iAbsoluteEnd 	= tmpitem.iAbsoluteEnd;
       
   493 			   iEventReceiverList->operator[](tmpItemIndex).iTargetElement	= tmpitem.iTargetElement;
       
   494 			   iEventReceiverList->operator[](tmpItemIndex).iBeginTime		= tmpitem.iBeginTime;
       
   495 
       
   496   }
       
   497 
       
   498     }
       
   499 
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 // returns the next (or prev) focussable object starting with a given index
       
   503 // search wraps around to start or end
       
   504 // ---------------------------------------------------------------------------
       
   505 MSvgEventReceiver* CSvgEventHandler::GetEventReceiver( TInt32 aIndex, TBool aNext, TUint8 aMask, TInt32& aNewIndex )
       
   506     {
       
   507     // Check underflow
       
   508     if ( aIndex < 0 || !iEventReceiverList->Count() )
       
   509         {
       
   510         return NULL;
       
   511         }
       
   512 
       
   513     // This will ensure we loop around to start
       
   514     if( aIndex >= iEventReceiverList->Count() )
       
   515         {
       
   516         aIndex = iEventReceiverList->Count() - 1;
       
   517         }
       
   518 
       
   519     // Search forward or backward
       
   520     if( aNext )
       
   521         {
       
   522         while( aIndex < iEventReceiverList->Count() )
       
   523             {
       
   524             if( !(( *iEventReceiverList )[aIndex].iWasDeleted) && iEventReceiverList->operator[]( aIndex ).iEventMask & aMask )
       
   525                 {
       
   526                 aNewIndex = aIndex;
       
   527                 return iEventReceiverList->operator[]( aIndex ).iElement;
       
   528                 }
       
   529 
       
   530             aIndex++;
       
   531             }
       
   532         }
       
   533     else
       
   534         {
       
   535         while( aIndex >= 0 )
       
   536             {
       
   537             if( !(( *iEventReceiverList )[aIndex].iWasDeleted) && iEventReceiverList->operator[]( aIndex ).iEventMask & aMask )
       
   538                 {
       
   539                 aNewIndex = aIndex;
       
   540                 return iEventReceiverList->operator[]( aIndex ).iElement;
       
   541                 }
       
   542 
       
   543             aIndex--;
       
   544             }
       
   545         }
       
   546 
       
   547     return NULL;
       
   548     }
       
   549 // --------------------------------------------------------------------------
       
   550 // void CSvgEventHandler::Reset(MSvgEvent* aEvent)
       
   551 // ---------------------------------------------------------------------------
       
   552 void CSvgEventHandler::Reset(MSvgEvent* aEvent)
       
   553 	{
       
   554 
       
   555 	this->DeactivateAnimations();
       
   556 
       
   557     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   558 	for ( TInt j = 0; j < eventReceiverListCnt; j++ )
       
   559             {
       
   560             if ( !(( *iEventReceiverList )[j].iWasDeleted) && 0 !=
       
   561                  ( aEvent->EventMask() |
       
   562                    ( *iEventReceiverList )[j].iEventMask ) )
       
   563                 {
       
   564 				if( (*iEventReceiverList )[j].iTargetElement )
       
   565 					{
       
   566 					(*iEventReceiverList )[j].iTargetElement->ResetReferenceAttrSet();
       
   567 					}
       
   568 
       
   569                 }
       
   570             }
       
   571 	
       
   572 	eventReceiverListCnt = iEventReceiverList->Count();
       
   573 	for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   574         {
       
   575         	if (!(( *iEventReceiverList )[i].iWasDeleted))
       
   576         	{
       
   577               // Send event to list[i].iElement
       
   578              ( *iEventReceiverList )[i].iElement->Reset( aEvent );
       
   579         	}
       
   580         	
       
   581         	if (iEventReceiverList->Count() != eventReceiverListCnt)
       
   582         	{
       
   583         		//get a new count because the list changed size in the reset call above
       
   584         		eventReceiverListCnt = iEventReceiverList->Count();
       
   585         		//start back over at zero so we make sure all elements get their reset called
       
   586         		i = 0;
       
   587         	}
       
   588         }
       
   589 }
       
   590 
       
   591 // --------------------------------------------------------------------------
       
   592 // void CSvgEventHandler::ReInitialize()
       
   593 // ---------------------------------------------------------------------------
       
   594 void CSvgEventHandler::ReInitialize()
       
   595 	{
       
   596 	TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   597 	for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   598         {
       
   599         	if (!(( *iEventReceiverList )[i].iWasDeleted))
       
   600         	{
       
   601 		 	iEventReceiverList->operator[](i).iBeginTime = 0;
       
   602          ( *iEventReceiverList )[i].iElement->ReInitializeAnimation();
       
   603         	}
       
   604         }
       
   605 	}
       
   606 
       
   607 // --------------------------------------------------------------------------
       
   608 // void CSvgEventHandler::DeactivateAnimations()
       
   609 // ---------------------------------------------------------------------------
       
   610 void CSvgEventHandler::DeactivateAnimations()
       
   611 {
       
   612 TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   613 for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   614         {
       
   615         	if (!(( *iEventReceiverList )[i].iWasDeleted))
       
   616         	{
       
   617         		iEventReceiverList->operator[](i).iBeginTime = 0;
       
   618          		( *iEventReceiverList )[i].iElement->DeactivateAnimation();
       
   619         	}
       
   620         }
       
   621 }
       
   622 // --------------------------------------------------------------------------
       
   623 // void CSvgEventHandler::SetCurrentTime(TInt32 aTime)
       
   624 // ---------------------------------------------------------------------------
       
   625 void CSvgEventHandler::SetCurrentTime(TInt32 aTime)
       
   626 {
       
   627 iCurrentTime = aTime;
       
   628 }
       
   629 // --------------------------------------------------------------------------
       
   630 // void CSvgEventHandler::DoAnimProcL(MSvgEvent*  aEvent)
       
   631 // ---------------------------------------------------------------------------
       
   632 void CSvgEventHandler::DoAnimProcL(MSvgEvent*  aEvent)
       
   633 {
       
   634 if(aEvent->EventType() != ESvgEngineEventTimer)return;
       
   635 TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   636 for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   637         {
       
   638           if (!(( *iEventReceiverList )[i].iWasDeleted))
       
   639           {	
       
   640 		  	( *iEventReceiverList )[i].iElement->DoAnimProcL(aEvent);
       
   641           }
       
   642         }
       
   643 }
       
   644 
       
   645 // --------------------------------------------------------------------------
       
   646 // TInt32 CSvgEventHandler::AnimationElementsCount()
       
   647 // ---------------------------------------------------------------------------
       
   648 TInt32 CSvgEventHandler::AnimationElementsCount()
       
   649     {
       
   650 	TInt32 lCount = 0;
       
   651 	if(iEventReceiverList)
       
   652 		{
       
   653 		TInt aEventReceiverListCnt = iEventReceiverList->Count();
       
   654 		for(TInt i=0; i < aEventReceiverListCnt; i++)
       
   655 			{
       
   656 			if (!(( *iEventReceiverList )[i].iWasDeleted))
       
   657         		{
       
   658 				CSvgElementImpl* lElem= NULL;
       
   659 				lElem  = (CSvgElementImpl*) (*iEventReceiverList)[i].iElement;
       
   660 				if(lElem != NULL)
       
   661 					{
       
   662 					if( lElem->IsAnimatedElement() )
       
   663 						{
       
   664                			lCount++;
       
   665 						}
       
   666 					}
       
   667         		}
       
   668 			}
       
   669 		}
       
   670 	return lCount;
       
   671 
       
   672     }
       
   673 void CSvgEventHandler::ResetTimes()
       
   674     {
       
   675     TInt eventReceiverListCnt = iEventReceiverList->Count();
       
   676     for ( TInt i = 0; i < eventReceiverListCnt; i++ )
       
   677         {
       
   678         if (!(( *iEventReceiverList )[i].iWasDeleted) )
       
   679         	{
       
   680     	    CSvgElementImpl* lElem= NULL;
       
   681 			lElem  = (CSvgElementImpl*) (*iEventReceiverList)[i].iElement;
       
   682 			
       
   683             if( lElem->IsAnimatedElement() )
       
   684 			    {
       
   685 			     CSvgAnimationBase *temp =  (CSvgAnimationBase *)((*iEventReceiverList )[i].iElement);
       
   686         	     temp->ResetTimes();
       
   687 			    }
       
   688         	}
       
   689         }
       
   690     }