svgtopt/SVG/SVGEngine/inc/SVGEventHandler.h
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     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 header file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __INC_CSVGEVENTHANDLER__
       
    20 #define __INC_CSVGEVENTHANDLER__
       
    21 
       
    22 #if !defined(__E32BASE_H__)
       
    23 #include <e32base.h>
       
    24 #endif
       
    25 
       
    26 #include "SVGEvent.h"
       
    27 
       
    28 
       
    29 
       
    30 class MSvgElement;
       
    31 class MSvgEventReceiver;
       
    32 
       
    33 
       
    34 /**
       
    35  * Class description goes here.
       
    36  *
       
    37  *  @lib SVGEngine.lib
       
    38  *  @since 1.0
       
    39  */
       
    40 class CSvgEventHandler : public CBase
       
    41     {
       
    42     private:
       
    43         class TEventReceiverListItem
       
    44             {
       
    45             public:
       
    46                 MSvgEventReceiver*                          iElement;
       
    47                 TUint32                                     iBeginTime;
       
    48                 TUint32                                     iAbsoluteEnd;
       
    49                 MSvgEventReceiver*                          iTargetElement;
       
    50                 TUint8                                      iEventMask;
       
    51                 TUint16                                     iSubEventMask;
       
    52                 TUint8										iWasDeleted;	
       
    53             };
       
    54 
       
    55     public:
       
    56 
       
    57         /**
       
    58          * Two phase constructor
       
    59          *
       
    60          * @since 1.0
       
    61          * @param None
       
    62          * @return An instance of the CSVgEventHandler class
       
    63          */
       
    64         static CSvgEventHandler*                    NewLC();
       
    65 
       
    66         /**
       
    67          * Two phase constructor
       
    68          *
       
    69          * @since 1.0
       
    70          * @param None
       
    71          * @return An instance of the CSVgEventHandler class
       
    72          */
       
    73         static CSvgEventHandler*                    NewL();
       
    74 
       
    75         /**
       
    76          * Destructor
       
    77          *
       
    78          * @since 1.0
       
    79          * @param None
       
    80          * @return None
       
    81          */
       
    82                                                     ~CSvgEventHandler();
       
    83 
       
    84     public:
       
    85 		TInt32										Count();
       
    86 
       
    87 		TInt32										AnimationElementsCount();
       
    88     
       
    89         void    ResetTimes();
       
    90         /**
       
    91          * Process events received from the client
       
    92          *
       
    93          * @since 1.0
       
    94          * @param aEvent - An object containing event information (implements MSvgEvent interface)
       
    95          * @return A boolean indicating success/failure in handling the event
       
    96          */
       
    97         TBool                                       ProcessEventL( MSvgEvent* aEvent );
       
    98 
       
    99         /**
       
   100          * Add an object to the list of objects that are notified of an event
       
   101          *
       
   102          * @since 1.0
       
   103          * @param aElement - An SVG element that wants to be registered for an event (implements MSvgEventReceiver interface)
       
   104          * @param aEventMask - A bit mask that indicates the types of events an object listens for
       
   105          * @return None
       
   106          */
       
   107         void                                        AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   108                                                                             TUint8 aEventMask,
       
   109                                                                             TUint32 aBeginTime = 0,
       
   110                                                                             TUint32 aEndTime = 0);
       
   111 
       
   112         /**
       
   113          * Add an object to the list of objects that are notified of an event
       
   114          *
       
   115          * @since 3.2
       
   116          * @param aElement - An SVG element that wants to be registered for an event (implements MSvgEventReceiver interface)
       
   117          * @param aEvent - An SVG Event that the target element needs to generate
       
   118          * @param aEventMask - A bit mask that indicates the types of events an object listens for
       
   119          * @return None
       
   120          */
       
   121         void                                        AddToEventReceiverListL( MSvgEventReceiver* aElement,
       
   122                                                                             TSvgEvent aEvent,
       
   123                                                                             TUint8 aEventMask,
       
   124                                                                             TUint32 aBeginTime = 0,
       
   125                                                                             TUint32 aEndTime = 0);
       
   126 
       
   127         /**
       
   128          * Remove an object from the list of objects that are notified of an event
       
   129          *
       
   130          * @since 1.0
       
   131          * @param aElement - An SVG element that wants to be unregistered for an event (implements MSvgEventReceiver interface)
       
   132          * @return None
       
   133          */
       
   134         void                                        RemoveFromEventReceiverList( MSvgEventReceiver* aElement );
       
   135 
       
   136 		void										ClearNullsFromEventReceiverList();
       
   137 		
       
   138         /**
       
   139          * Provide the event end time information to the Event Handler
       
   140          *
       
   141          * @since 1.0
       
   142          * @param aElement - An element that, ultimately, processes the event (eg. an animation element)
       
   143          * @param aTime - The end time for an event on the target element
       
   144          * @param aTargetElement - The element for which the event is processed
       
   145          * @return
       
   146          */
       
   147         void                                        AddEventBeginTime(MSvgEventReceiver* aElement,
       
   148                                                                     TUint32 aTime, MSvgEventReceiver* aTargetElement );
       
   149 
       
   150 
       
   151         /**
       
   152          * Reset the status of the event handler and all the event receivers
       
   153          *
       
   154          * @since 1.0
       
   155          * @param None
       
   156          * @return None
       
   157          */
       
   158         void                                        Reset();
       
   159         void 										SetCurrentTime(TInt32 aTime);
       
   160 		void 										Reset(MSvgEvent* aEvent);
       
   161 
       
   162         /**
       
   163          * An internal method that sorts the events in a time scale
       
   164          *
       
   165          * @since 1.0
       
   166          * @param None
       
   167          * @return None
       
   168          */
       
   169         void                                        SortEventList();
       
   170 
       
   171         /**
       
   172          * Standard active object DoCancel method
       
   173          *
       
   174          * @since 1.0
       
   175          * @param None
       
   176          * @return None
       
   177          */
       
   178         void DoCancel();
       
   179 
       
   180         /**
       
   181          * Standard avtive object RunL method
       
   182          *
       
   183          * @since 1.0
       
   184          * @param
       
   185          * @return
       
   186          */
       
   187         void RunL();
       
   188 
       
   189        /**
       
   190          * returns the next (or prev) focussable object starting with a given index
       
   191          * search wraps around to start or end
       
   192          *
       
   193          * @since 1.0
       
   194          * @param aIndex - search for a focussable object with this index
       
   195          * @param aNext - Etrue (next) EFalse (prev) (go forward or backward for search)
       
   196          * @param aEventMask - Event mask for event types the client is interested in
       
   197          * @param aNewIndex - Return the actual index where the object was found
       
   198          * @return The focussable object or NULL if not found
       
   199          */
       
   200 
       
   201         MSvgEventReceiver* GetEventReceiver(TInt32 aIndex, TBool aNext, TUint8 aMask, TInt32& aNewIndex);
       
   202 
       
   203 		void ReInitialize();
       
   204 		void DeactivateAnimations();
       
   205 
       
   206         /** 
       
   207          * EventMask: Return the event mask of the registered element
       
   208          *
       
   209          * @param MSvgEventReceiver the target element.
       
   210          * @returns: TUnit8, the event mask
       
   211          */
       
   212         TUint8 EventMask(MSvgEventReceiver* aElement);
       
   213         
       
   214         /** 
       
   215          * Checks whether the element is interactive or not and if 
       
   216          * interactive updates aSubEventMask.
       
   217          * @since v3.2
       
   218          * @param CSvgElementImpl the element.
       
   219          * @param aSubEventMask - contains the list of interactive events 
       
   220          *                        that the element can respond to.
       
   221          *                        It is a bitmask using TSvgInteractionEvent
       
   222          * @returns: ETrue if interactive otherwise EFalse.
       
   223          */
       
   224         TBool CheckInteractivityAndGetSubEventMask(CSvgElementImpl* aElement,
       
   225                                                     TUint16& aSubEventMask);
       
   226          /**
       
   227          * Checks whether the aSubEventMask is has a valid value set
       
   228          * @since v3.2
       
   229          * @param : aSubEventMask - The bitmap mask which contains the list
       
   230          *                          of interactive events if any with the element.  
       
   231          * @return: Etrue - if aSubEventMask has some valid bits set else EFalse.
       
   232          */
       
   233         TBool IsValidSubEventMask(TUint16 aSubEventMask);
       
   234         
       
   235     private:
       
   236 
       
   237         /**
       
   238          * Private constructor
       
   239          *
       
   240          * @since 1.0
       
   241          * @param None
       
   242          * @return None
       
   243          */
       
   244                                                     CSvgEventHandler();
       
   245 
       
   246         /**
       
   247          * A private constructor that constructs heap objects
       
   248          *
       
   249          * @since 1.0
       
   250          * @param None
       
   251          * @return None
       
   252          */
       
   253         void                                        ConstructL();
       
   254 
       
   255         CArrayFixFlat<TEventReceiverListItem>*      iEventReceiverList;
       
   256         TUint8                                      iInProcess;
       
   257         TInt32                                      iCurrentTime;
       
   258     public:
       
   259         void DoAnimProcL(MSvgEvent*  aEvent);
       
   260     };
       
   261 
       
   262 #endif //__INC_CSVGEventHandler__