uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiScheduler.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUISCHEDULER_H__
       
    21 #define __HUISCHEDULER_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <uiacceltk/HuiCommand.h>
       
    26 #include <uiacceltk/HuiObserverArray.h>
       
    27 
       
    28 
       
    29 /* Forward declaration. */
       
    30 class CHuiEnv;
       
    31 
       
    32 
       
    33 /**
       
    34  * The scheduler executes commands at certain points in time. There is one
       
    35  * scheduler instance created for each environment. Everyone has access to 
       
    36  * their environment's scheduler, and can send commands with it. Commands
       
    37  * include, for instance, visual animation commands and action commands sent
       
    38  * by controls. An action command would be sent, for example, when a menu 
       
    39  * item is selected or a button is pressed.
       
    40  */
       
    41 NONSHARABLE_CLASS(CHuiScheduler) : public CBase
       
    42 	{
       
    43 public:
       
    44 
       
    45 	/* Constructors and destructor. */
       
    46 
       
    47 	/**
       
    48 	 * Constructor. This is only done internally in the toolkit. Applications
       
    49 	 * cannot construct schedulers.
       
    50 	 *
       
    51 	 * @param aEnv  Environment that owns the scheduler.
       
    52 	 */
       
    53 	CHuiScheduler(CHuiEnv& aEnv);
       
    54 	
       
    55 	/**
       
    56 	 * Destructor.
       
    57 	 */
       
    58 	virtual ~CHuiScheduler();
       
    59 
       
    60 
       
    61 	/* Methods. */
       
    62 
       
    63     /**
       
    64      * Called to notify the scheduler that time has passed and it may be 
       
    65      * necessary to trigger new animations and actions.
       
    66      *
       
    67      * @param aElapsedTime  Number of elapsed seconds.
       
    68      */
       
    69     void AdvanceTime(TReal32 aElapsedTime);	
       
    70 
       
    71     /**
       
    72      * Post a new command that will be executed immediately or after a
       
    73      * period of time.
       
    74      *
       
    75      * @param aCommand  Command to send.
       
    76      * @param aDelayMilliSeconds  Time to wait before executing.
       
    77      */
       
    78     void PostCommandL(const THuiCommand& aCommand, TInt aDelayMilliSeconds);
       
    79     
       
    80     /** 
       
    81      * Cancel all commands related to an object.
       
    82      *
       
    83      * @param aVisual  Visual.
       
    84      */     
       
    85     void CancelCommands(const TAny* aObject);
       
    86     
       
    87     /** 
       
    88      * Cancel commands related to an object.
       
    89      *
       
    90      * @param aVisual       Visual.
       
    91      & @param aCommandType  Type of command to cancel.
       
    92      */     
       
    93     void CancelCommands(const TAny* aObject, THuiOp aCommandOperation);
       
    94     
       
    95     /** 
       
    96      * Cancel commands related to a specific object.
       
    97      *
       
    98      * @param aControl      Control.
       
    99      * @param aCommandType  Type of command.
       
   100      * @param aParam        Parameter for custom event.
       
   101      */     
       
   102     void CancelCommands(const TAny* aObject, THuiCommandType aCommandType, TInt aParam);
       
   103     
       
   104     /**
       
   105      * Determines how much time is remaining until a command is to be
       
   106      * executed.
       
   107      *
       
   108      * @param aObject       Object.
       
   109      * @param aCommandType  Type of command.
       
   110      *     
       
   111      * @return  Time interval in milliseconds. -1, if no commands found.
       
   112      */
       
   113     TInt TimeUntilCommand(const TAny* aObject, THuiCommandType aCommandType);
       
   114     
       
   115     /**
       
   116      * Counts the number of pending commands.
       
   117      *
       
   118      * @return  Number of commands waiting to be executed.
       
   119      */
       
   120     TInt PendingCount() const;
       
   121     
       
   122 
       
   123 private:
       
   124     
       
   125     /* Private methods */
       
   126         
       
   127     /**
       
   128      * Removes a pending command from the queue.
       
   129      *
       
   130      * @param aIndex  Index of the pending command.
       
   131      */
       
   132     void RemovePendingCommand(TInt aIndex);
       
   133 
       
   134 
       
   135 private:
       
   136 
       
   137 	/**
       
   138 	 * A command to be executed at a certain point in time. A list of these delayed
       
   139 	 * command events is stored in the HuiScheduler.
       
   140 	 * 
       
   141 	 */
       
   142 	 
       
   143     class TDelayedCommand
       
   144         {
       
   145     public:
       
   146     	/** Constructor. A command may be passed in the initialiser. */
       
   147         TDelayedCommand(const THuiCommand* aCommand)
       
   148                 : iCommand(aCommand)
       
   149             {
       
   150             }
       
   151         
       
   152         /** The time when this command will be executed. */
       
   153         TTime iExecutionTime;
       
   154 
       
   155         /** 
       
   156          * The command that will be executed.
       
   157          * 
       
   158          * @see THuiCommand
       
   159          * */        
       
   160         const THuiCommand* iCommand;
       
   161         };
       
   162 
       
   163     /** Scheduler's environment. */
       
   164     CHuiEnv& iEnv;
       
   165     
       
   166     /** Pending commands waiting for execution. */
       
   167     RArray<TDelayedCommand> iPendingCommands;
       
   168     
       
   169 	};
       
   170 
       
   171 #endif  // __HUISCHEDULER_H__