phoneapp/phoneuicontrol/inc/cphonekeyeventforwarder.h
branchRCL_3
changeset 62 5266b1f337bd
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
       
     1 /*
       
     2 * Copyright (c) 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:  It is keyevent forwarder.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHONEKEYEVENTFORWARDER_H
       
    20 #define CPHONEKEYEVENTFORWARDER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include    <bldvariant.hrh> //Feature flags
       
    24 #include    <coecntrl.h>
       
    25 #include    <peninputsrveventhandler.h>
       
    26 #include    <peninputclient.h>
       
    27  
       
    28 // FORWARD DECLARATIONS
       
    29 class MPhoneStateMachine;
       
    30 class MPhoneKeyEventHandler;
       
    31 class MPhoneViewCommandHandle;
       
    32 class CPhoneTimer;
       
    33 class CPhoneQwertyHandler;
       
    34 class MPhoneQwertyModeObserver;
       
    35 class CEikMenuBar;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  It is keyevent forwarder.
       
    41 *
       
    42 */
       
    43 class CPhoneKeyEventForwarder 
       
    44     : public CCoeControl,
       
    45     public MPenUiActivationHandler
       
    46     {
       
    47     public:  // Constructors and destructor      
       
    48         
       
    49         /**
       
    50         * Two-phased constructor.
       
    51         *
       
    52         * @param aRect rectangle of this control.
       
    53         * @param aStateMachine state machine
       
    54         * @param aViewCommandHandle View command handle
       
    55         * @return new instance.
       
    56         */
       
    57         static CPhoneKeyEventForwarder* NewL( const TRect& aRect, 
       
    58                 MPhoneStateMachine* aStateMachine,
       
    59                 MPhoneViewCommandHandle* aViewCommandHandle  );
       
    60         
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         ~CPhoneKeyEventForwarder();     
       
    65 
       
    66     public: // New functions.
       
    67        
       
    68     public: // Functions from base classes
       
    69  
       
    70         /**
       
    71         * From CCoeControl, returns the amount of component controls.
       
    72         *
       
    73         * @return Returns the amount of component controls.
       
    74         */
       
    75         TInt CountComponentControls() const;              
       
    76         
       
    77         /**
       
    78         * From CCoeControl, returns a control by index.
       
    79         *    
       
    80         * @param aIndex It is the index of the control. 
       
    81         * @return Returns a control by index.
       
    82         */
       
    83         CCoeControl* ComponentControl( TInt aIndex ) const;
       
    84 
       
    85         /**
       
    86         * From CCoeControl, informs that the size is changed to update 
       
    87         * the sizes of component controls appropriately.
       
    88         */
       
    89         void SizeChanged();
       
    90 
       
    91         /**
       
    92         * From CCoeControl, draws the contents of the view.
       
    93         *
       
    94         * @param aRect It is the area to be redrawn.
       
    95         */
       
    96         void Draw( const TRect& aRect ) const;
       
    97     
       
    98         /**
       
    99         * From CCoeControl, offers a key event to the view. 
       
   100         *
       
   101         * @param aKeyEvent It contains information about the key event.
       
   102         * @param aType It is the type of the event.
       
   103         * @return Returns information which indicates whether the keypress
       
   104         *         was processed or not.
       
   105         */
       
   106         TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   107             TEventCode aType );
       
   108         
       
   109         /**
       
   110         * This function should be called from AppUi, after framework has
       
   111         * Looped through CCoeControlStack
       
   112         *
       
   113         * @param aKeyEvent It contains information about the key event.
       
   114         * @param aType It is the type of the event.
       
   115         * @return Returns information which indicates whether the keypress
       
   116         *         was processed or not.
       
   117         */
       
   118         TKeyResponse OfferKeyEventAfterControlStackL( 
       
   119                 const TKeyEvent& aKeyEvent,
       
   120                 TEventCode aType );
       
   121 
       
   122         /**
       
   123          * @see MPenUiActivationHandler
       
   124          */
       
   125         void OnPeninputUiDeactivated();
       
   126 
       
   127         /**
       
   128          * @see MPenUiActivationHandler
       
   129          */        
       
   130         void OnPeninputUiActivated();
       
   131         
       
   132 
       
   133     private:
       
   134 
       
   135         /**
       
   136         * C++ default constructor.
       
   137         */
       
   138         CPhoneKeyEventForwarder( MPhoneStateMachine* aStateMachine,
       
   139                 MPhoneViewCommandHandle* aViewCommandHandle  );
       
   140 
       
   141         /**
       
   142         * Symbian OS constructor.
       
   143         */
       
   144         void ConstructL( const TRect& aRect );
       
   145 
       
   146         /**
       
   147         * This function should be called before FEP or other components in 
       
   148         * CCoeControl stack
       
   149         *
       
   150         * @param aKeyEvent It contains information about the key event.
       
   151         * @param aType It is the type of the event.
       
   152         * @return Returns information which indicates whether the keypress
       
   153         *         was processed or not.
       
   154         */
       
   155         TKeyResponse OfferKeyEventBeforeControlStackL( 
       
   156                 const TKeyEvent& aKeyEvent,
       
   157                 TEventCode aType );
       
   158         
       
   159         /** 
       
   160         * Handle EEventKeyDown
       
   161         * @param aKeyEvent     Tells which key was pressed.
       
   162         * @return              tells whether the event was consumed or not.
       
   163         */
       
   164         TKeyResponse HandleEventKeyDownBeforeControlStackL( const TKeyEvent& aKeyEvent );
       
   165         
       
   166         /** 
       
   167         * Handle EEventKey
       
   168         * @param aKeyEvent     Tells which key was pressed.
       
   169         * @return              tells whether the event was consumed or not.
       
   170         */
       
   171         TKeyResponse HandleEventKeyBeforeControlStackL( const TKeyEvent& aKeyEvent );
       
   172         
       
   173         /** 
       
   174         * Handle EEventKeyUp
       
   175         * @param aKeyEvent     Tells which key was pressed.
       
   176         * @return              tells whether the event was consumed or not.
       
   177         */
       
   178         TKeyResponse HandleEventKeyUpBeforeControlStackL( const TKeyEvent& aKeyEvent );
       
   179 
       
   180       
       
   181         /**
       
   182         * Callback function for long press of a particular key
       
   183         */
       
   184         static TInt DoHandleLongPressKeyEventCallbackL( TAny* aAny );
       
   185         
       
   186         /**
       
   187         * Convert key code
       
   188         */   
       
   189         void ConvertKeyCodeL( TUint& aCode, const TKeyEvent& aKeyEvent ); 
       
   190 
       
   191         /**
       
   192         * Handle key long press
       
   193         */
       
   194         void HandleLongPressKeyEventL();
       
   195         
       
   196         /**
       
   197          * Checks from the statemachine is the given keyevent 
       
   198          * one which produces a legal character in the current mode.
       
   199          */
       
   200         TBool IsKeyAllowedL( const TKeyEvent& aKeyEvent );
       
   201                 
       
   202         /**
       
   203          * Checks is the given key special character (*, 0, # ) from half-qwerty
       
   204          * keyboard and conver key code if needed.
       
   205          */
       
   206         TBool ConvertHalfQwertySpecialChar( TUint& aCode, const TKeyEvent& aKeyEvent );
       
   207         
       
   208         /**
       
   209          * Checks if key should be blocked from phone.
       
   210          * 
       
   211          * @ return ETrue if alpha mode, EFalse otherwise.
       
   212          */
       
   213         TBool IsKeyBlocked( const TKeyEvent& aKeyEvent ) const;
       
   214         
       
   215         /**
       
   216          * Test if key has flags indicating that it has been simulated by the
       
   217          * touch dialer.
       
   218          */
       
   219         TBool IsKeySimulatedByTouchDialer( const TKeyEvent& aKeyEvent ) const;
       
   220         
       
   221         /**
       
   222          * Handles dialer key event. This includes handling multitapping of *-key. 
       
   223          * If multitap happens, function creates back space event 
       
   224          * to delete previous character, and replaces it with
       
   225          * the next one in the cyclig character list *+pw.
       
   226          */
       
   227         void HandleTouchDialerKeyEventL( const TKeyEvent& aKeyEvent );
       
   228 
       
   229     private:    // Data
       
   230         
       
   231         /**
       
   232         * State machine
       
   233         */
       
   234         MPhoneStateMachine* iStateMachine;
       
   235         
       
   236         /**
       
   237          * Interface to view command handle
       
   238          */
       
   239         MPhoneViewCommandHandle* iViewCommandHandle;
       
   240         
       
   241         /**
       
   242          * For long key press. Long press is handled within a 
       
   243          * specific duration.
       
   244          */
       
   245         CPhoneTimer* iLongPressKeyEventTimer; 
       
   246 
       
   247         /**
       
   248          * Key press time
       
   249          */
       
   250         TTime iKeyPressTime;
       
   251 
       
   252         /**
       
   253          * Key code
       
   254          */
       
   255         TUint iKeyPressedDown;
       
   256         
       
   257         /**
       
   258          * Key scan code from EEventKey Updated in HandleEventKeyDownL. 
       
   259          * Zeroed in HandleEventKeyUpL.
       
   260          */
       
   261         TInt iScanCode;
       
   262 
       
   263         /**
       
   264         * Has information of used qwerty keyboard.
       
   265         * Own.
       
   266         */
       
   267         CPhoneQwertyHandler* iQwertyHandler;
       
   268         
       
   269         /**
       
   270          * Time of the previous key press. Used for multitap behaviour.
       
   271          */
       
   272         TTime iPreviousKeyPressTime;
       
   273         
       
   274         /**
       
   275          * Keycode of the previous keypress. Used for multitap behaviour.
       
   276          */
       
   277         TInt iPreviousScanCode;
       
   278         
       
   279         /**
       
   280          * Points to next character in multitap character list.
       
   281          */
       
   282         TInt iMultitapIndex;
       
   283         
       
   284         /**
       
   285          * True if there has been a key event but not a closing key up event.
       
   286          * Needed to detect situations where key up event is handled before key event.
       
   287          */
       
   288         TBool iExpectKeyUpEvent;
       
   289         
       
   290         /**
       
   291          * Server that sends events via callback when the virtual keyboard is opened/closed.
       
   292          */     
       
   293         RPeninputServer iPeninputServer;
       
   294         
       
   295         /**
       
   296          * Status of virtual keyboard.
       
   297          */     
       
   298         TBool iVirtualKeyBoardOpen;
       
   299         
       
   300         
       
   301         /**
       
   302          * Indicates if menu or dialog was displayed
       
   303          * when the key was pressed down.
       
   304          */
       
   305         TBool iDisplayingMenuOrDialogOnEventKeyDown;
       
   306         
       
   307         /**
       
   308          * Application menu.
       
   309          * Not owned.
       
   310          */     
       
   311         CEikMenuBar* iMenu;
       
   312     };
       
   313 
       
   314 #endif      // CPHONEKEYEVENTFORWARDER_H
       
   315             
       
   316 // End of File