akntouchgesturefw/inc/akntouchgesturefwimpl.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Touch gesture framework implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_AKNTOUCHGESTUREFWIMPL_H
       
    19 #define C_AKNTOUCHGESTUREFWIMPL_H
       
    20 
       
    21 #include <coemain.h>
       
    22 #include <e32base.h>
       
    23 #include <akntouchgesturefwevents.h>
       
    24 
       
    25 #include "akntouchgesturefwutils.h"
       
    26 
       
    27 class CCoeControl;
       
    28 
       
    29 namespace AknTouchGestureFw
       
    30 {
       
    31 
       
    32 class MAknTouchGestureFwObserver;
       
    33 class CAknTouchGestureFwRecognitionEngine;
       
    34 
       
    35 /**
       
    36  * Implementation of CGestureFw interface
       
    37  */
       
    38 NONSHARABLE_CLASS( CAknTouchGestureFwImpl ) : public CBase,
       
    39                                               public MCoeForegroundObserver,
       
    40                                               public MCoeMessageMonitorObserver
       
    41     {
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Two-phased constructor.
       
    46      * 
       
    47      * @param  aObserver  Gesture framework observer.
       
    48      * @param  aControl   Control receiving the gesture pointer events.
       
    49      */
       
    50     static CAknTouchGestureFwImpl* NewL(
       
    51             MAknTouchGestureFwObserver& aObserver,
       
    52             CCoeControl* aControl );
       
    53 
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      * 
       
    57      * @param  aObserver  Gesture framework observer.
       
    58      * @param  aControl   Control receiving the gesture pointer events.
       
    59      */
       
    60     static CAknTouchGestureFwImpl* NewLC(
       
    61             MAknTouchGestureFwObserver& aObserver,
       
    62             CCoeControl* aControl );
       
    63 
       
    64     /**
       
    65      * Destructor.
       
    66      */
       
    67     virtual ~CAknTouchGestureFwImpl();
       
    68 
       
    69     /**
       
    70      * Handles simulated pointer events.
       
    71      *
       
    72      * @param  aPointerData  Pointer event related data.
       
    73      */
       
    74     void HandleSimulatedPointerEventL( const TPointerEventData& aPointerData );
       
    75 
       
    76     /**
       
    77      * Sets target control for window server events.
       
    78      *
       
    79      * @param  aControl  New subscriber control.
       
    80      *
       
    81      * @leave KErrNotFound In case the target control has no window.
       
    82      */
       
    83     void SetSubscriberControlL( CCoeControl* aControl );
       
    84 
       
    85     /**
       
    86      * Sets gesture groups which should be recognized.
       
    87      * 
       
    88      * @param  aGestureGroups  New gesture interest.
       
    89      */ 
       
    90     void SetGestureInterestL( TUint aGestureGroups );
       
    91 
       
    92     /**
       
    93      * Returns gesture groups which should be recognized.
       
    94      * 
       
    95      * @return Current gesture interest.
       
    96      */
       
    97     TUint GestureInterest() const;
       
    98     
       
    99     /**
       
   100      * Defines gesture groups, which trigger tactile feedback automatically.
       
   101      *
       
   102      * @param aGestureGroups - Those gesture groups, which trigger tactile
       
   103      *                         feedback automatically as touch gestures
       
   104      *                         are recognized or being in the process
       
   105      *                         of recognizing.   
       
   106      */ 
       
   107     void SetFeedbackForGroupsL( TUint aGestureGroups );
       
   108     
       
   109     /**
       
   110      * Defines gesture types, which trigger tactile feedback automatically.
       
   111      *
       
   112      * @param aGestureGroup - Gesture group, which tactile- and audio feedback
       
   113      *                        is affected by this function call.     
       
   114      *
       
   115      * @param aGestureTypesForTactile - Bitmask of gesture types, which
       
   116      *                                  trigger tactile feedback automatically.
       
   117      * @param aGestureTypesForAudio - Bitmask of gesture types, which
       
   118      *                                trigger audio feedback automatically.   
       
   119      */                      
       
   120     void SetFeedbackForTypesL(
       
   121         TAknTouchGestureFwGroup aGestureGroup,
       
   122         TUint aGestureTypesForTactile,
       
   123         TUint aGestureTypesForAudio );
       
   124 
       
   125     /**
       
   126      * Enables testing features.
       
   127      */ 
       
   128     void EnableTestingFeatures();
       
   129 
       
   130 private:
       
   131 
       
   132     /**
       
   133      * C++ constructor.
       
   134      * 
       
   135      * @param  aControl  Control receiving the gesture pointer events.
       
   136      */
       
   137     CAknTouchGestureFwImpl( CCoeControl* aControl );
       
   138 
       
   139     /**
       
   140      * Symbian second-phase constructor.
       
   141      *
       
   142      * @param  aObserver  Gesture framework observer.
       
   143      */
       
   144     void ConstructL( MAknTouchGestureFwObserver& aObserver );
       
   145 
       
   146     /**
       
   147      * Handles pointer events.
       
   148      *
       
   149      * @param  aPointerData  Pointer event related data.
       
   150      */ 
       
   151     void HandlePointerEventL( const TPointerEventData& aPointerData );
       
   152 
       
   153     /**
       
   154      * Cancels ongoing recognition.
       
   155      */
       
   156     void CancelRecognition();
       
   157 
       
   158     /**
       
   159      * Enables drag events and advanced pointer events for window if needed.
       
   160      */
       
   161     void EnableAdditionalEvents();
       
   162 
       
   163     /**
       
   164      * Returns @c ETrue if pointer event is targeted to gesture control.
       
   165      * 
       
   166      * @param  aTargetControl  Event target control.
       
   167      * @param  aEvent          Pointer event.
       
   168 	 *
       
   169      * @return @c ETrue if pointer event is targeted to control.
       
   170      */
       
   171     TBool PointerEventTargetedToControl( CCoeControl* aTargetControl,
       
   172 	                                     TPointerEvent& aEvent ) const;
       
   173 
       
   174     /**
       
   175      * Converts position in window area according to control window
       
   176      * coordinates.
       
   177      * 
       
   178      * @param  aWindow    Window with position.
       
   179      * @param  aPosition  Position to convert.
       
   180      */
       
   181     void ConvertPositionToControlWindow( RDrawableWindow* aWindow,
       
   182 	                                     TPoint& aPosition ) const;
       
   183 
       
   184 // from base class MCoeForegroundObserver
       
   185 
       
   186     /**
       
   187      * Handles the application coming to the foreground.
       
   188      */
       
   189     void HandleGainingForeground();
       
   190 
       
   191     /**
       
   192      * Handles the application going into the background.
       
   193      */
       
   194     void HandleLosingForeground();
       
   195 
       
   196 public: // From base class MCoeMessageMonitorObserver.
       
   197 
       
   198     /**
       
   199      * Received windows messages for monitoring.
       
   200      *
       
   201      * @param  aEvent  The window server event data.
       
   202      */
       
   203     void MonitorWsMessage( const TWsEvent& aEvent );
       
   204 
       
   205 private: // data
       
   206 
       
   207     /**
       
   208      * ETrue if gesture framework is monitoring WS events
       
   209      */
       
   210     TBool iMonitoringWs;
       
   211 
       
   212     /**
       
   213      * Control environment.
       
   214      * Not own.
       
   215      */
       
   216     CCoeEnv* iCoeEnv;
       
   217 
       
   218     /**
       
   219      * Subcriber control.
       
   220      * Not own.
       
   221      */
       
   222     CCoeControl* iSubscriberControl;
       
   223 
       
   224     /**
       
   225      * Window control.
       
   226      * Not own.
       
   227      */
       
   228     CCoeControl* iWindowControl;
       
   229 
       
   230     /**
       
   231      * Gesture recognition engine.
       
   232      * Own.
       
   233      */
       
   234     CAknTouchGestureFwRecognitionEngine* iRecognitionEngine;
       
   235     };
       
   236 
       
   237 } // AknTouchGestureFw
       
   238 
       
   239 #endif // C_AKNTOUCHGESTUREFWIMPL_H