idlehomescreen/xmluirendering/uiengine/inc/xnkeyeventdispatcher.h
changeset 0 f72a12da539e
child 34 d05a55b217df
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Key event dispatcher header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __XNKEYEVENTDISPATCHER_H__
       
    20 #define __XNKEYEVENTDISPATCHER_H__
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <coecntrl.h>
       
    25 #include <eikmobs.h>
       
    26 
       
    27 // Uder includes
       
    28 #include "xnviewmanager.h"
       
    29 
       
    30 // Forward declarations
       
    31 class CXnNode;
       
    32 class CXnUiEngine;
       
    33 class CEikButtonGroupContainer;
       
    34 class CXnViewData;
       
    35 class CXnPluginData;
       
    36 
       
    37 // Class declaration
       
    38 
       
    39 /**
       
    40  *  Control adapter class implementation.
       
    41  *  
       
    42  *  @ingroup group_xnlayoutengine
       
    43  *  @lib xn3layoutengine.lib
       
    44  *  @since Series 60 3.1
       
    45  */
       
    46 NONSHARABLE_CLASS( CXnKeyEventDispatcher ) : public CCoeControl,   
       
    47     public MCoeMessageMonitorObserver,
       
    48     public MXnViewObserver
       
    49     {
       
    50 public:
       
    51     // Constructors and destructor
       
    52     
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      */
       
    56     static CXnKeyEventDispatcher* NewL( CXnUiEngine& aUiEngine );
       
    57 
       
    58     /**
       
    59      * Destructor.
       
    60      */
       
    61     ~CXnKeyEventDispatcher();
       
    62 
       
    63 private:
       
    64     // From CCoeControl
       
    65 
       
    66     /**
       
    67      * @see CCoeControl
       
    68      */
       
    69     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
    70             TEventCode aType );
       
    71             
       
    72 private: 
       
    73     // from MCoeMessageMonitorObserver
       
    74     
       
    75     /**
       
    76     * @see MCoeMessageMonitorObserver 
       
    77     */
       
    78     void MonitorWsMessage( const TWsEvent& aEvent );
       
    79         
       
    80 public:
       
    81     // New functions
       
    82    
       
    83     /**
       
    84      * Set the node to which key events are given
       
    85      * 
       
    86      * @since Series 60 3.1
       
    87      * @param aNode Node to set
       
    88      * @param aSource A source of event that triggered focus change.
       
    89      */
       
    90     void SetNodeL( CXnNode* aNode, TInt aSource = 0 );
       
    91 
       
    92     /**
       
    93      * Set the node to which key events are given, but do not notify.
       
    94      * 
       
    95      * @since Series 60 3.1
       
    96      * @param aNode Node to set
       
    97      */
       
    98     void SetNodeWithoutNotificationL( CXnNode* aNode );
       
    99     
       
   100     /**
       
   101      * Get the node to which holds focus
       
   102      * 
       
   103      * @since Series 60 3.1
       
   104      * @return Focused node, NULL if no focus.
       
   105      */
       
   106     CXnNode* FocusedNode() const;
       
   107     
       
   108     /**
       
   109      * Set the node to which menu events are given
       
   110      * 
       
   111      * @since Series 60 3.1
       
   112      * @param aNode Node to set
       
   113      */
       
   114     void SetMenuNodeL( CXnNode* aNode );
       
   115 
       
   116     /**
       
   117      * Removes the node to which menu events are given
       
   118      * 
       
   119      * @since Series 60 3.2        
       
   120      */
       
   121     void ResetMenuNodeL();
       
   122 
       
   123     /**
       
   124      * Refresh current menu
       
   125      * 
       
   126      * @since Series 60 3.1
       
   127      */
       
   128     void RefreshMenuL();
       
   129 
       
   130     /**
       
   131      * Checks whether the menu is focused.
       
   132      * 
       
   133      * @since S60 3.1
       
   134      * @return ETrue if menu is focused.
       
   135      */
       
   136     TBool IsMenuFocused() const;
       
   137 
       
   138     /**
       
   139      * Set node as passive, and add it to the passive focused node array.
       
   140      * 
       
   141      * @since Series 60 3.2
       
   142      * @param aNode Node to use.
       
   143      */
       
   144     void AddPassiveFocusedNodeL( CXnNode* aNode );
       
   145 
       
   146     /**
       
   147      * Unset the passive focus from the node, and remove it from the passive
       
   148      * focused node array.
       
   149      * 
       
   150      * @since Series 60 3.2
       
   151      * @param aNode Node to use.
       
   152      */
       
   153     void RemovePassiveFocusedNodeL( CXnNode* aNode );
       
   154 
       
   155     /**
       
   156      * Clear the passive focused node array, and unset the passive focus 
       
   157      * states.
       
   158      * 
       
   159      * @since Series 60 3.2
       
   160      */
       
   161     void ClearPassiveFocusedNodesL();
       
   162 
       
   163 private:
       
   164     // new functions
       
   165     
       
   166     void SetNodeL( CXnNode* aToLose, CXnNode* aToGain, TBool aNotify,
       
   167         TInt aSource = 0 );
       
   168     
       
   169     void ResolveAndSetFocusL();
       
   170     
       
   171     void ClearStateL();
       
   172     
       
   173 protected:
       
   174     // New functions
       
   175 
       
   176     /**
       
   177      * C++ default constructor.
       
   178      */
       
   179     CXnKeyEventDispatcher( CXnUiEngine& aUiEngine );
       
   180 
       
   181     /**
       
   182      * Two-phased constructor.
       
   183      */
       
   184     void ConstructL();
       
   185 
       
   186 private:
       
   187     // from MXnViewObserver
       
   188     
       
   189     void NotifyViewActivatedL( const CXnViewData& aViewData );
       
   190 
       
   191     void NotifyViewDeactivatedL( const CXnViewData& aViewData );
       
   192 
       
   193     void NotifyConfigureWidgetL( const CHsContentInfo& aContentInfo,
       
   194         CXnPluginData& aPluginData );
       
   195 
       
   196     void NotifyWidgetAdditionL( const CXnPluginData& aPluginData );
       
   197     void NotifyWidgetRemovalL( const CXnPluginData& aPluginData );
       
   198     void NotifyViewAdditionL( const CXnPluginData& /*aPluginData*/ ){};
       
   199     void NotifyViewRemovalL( const CXnPluginData& /*aPluginData*/ ){};
       
   200 
       
   201 private:
       
   202     // Data
       
   203 
       
   204     /** Reference to uiengine */
       
   205     CXnUiEngine& iUiEngine;
       
   206     /** Losefocus trigger, owned */
       
   207     CXnNode* iLoseFocus;
       
   208     /** Gainfocus trigger, owned */
       
   209     CXnNode* iGainFocus;
       
   210     /** Node that receives key events */
       
   211     CXnNode* iNode;
       
   212     /** Previous key event receiver */
       
   213     CXnNode* iPreviousNode;
       
   214     /** Node that receives menu events */
       
   215     CXnNode* iMenuNode;
       
   216     /** Node that was focused when keyevent started */
       
   217     CXnNode* iKeyEventNode;
       
   218     /** Event code for keyevents */
       
   219     TEventCode iEventCode;
       
   220     /** Focused node is changed during keyevent process */
       
   221     TBool iFocusChanged;
       
   222     /** Command button array for softkeys, not owned */
       
   223     CEikButtonGroupContainer* iCbaContainer;
       
   224     /** For storing the nodes that have passive focus. */
       
   225     RPointerArray< CXnNode > iPassiveFocusedNodes;
       
   226     };
       
   227 
       
   228 #endif //__XNKEYEVENTDISPATCHER_H__