web_plat/stmgesturefw_api/inc/stmgesturelistener.h
changeset 42 d39add9822e2
equal deleted inserted replaced
38:6297cdf66332 42:d39add9822e2
       
     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 the License "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:   
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __STMGESTURELISTENER_H__
       
    19 #define __STMGESTURELISTENER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <rt_gestureif.h>
       
    23 
       
    24 
       
    25 typedef stmGesture::MGestureIf MStmGesture;
       
    26 typedef stmGesture::TGestureUid TStmGestureUid;
       
    27 typedef stmGesture::TTapType TStmTapType;
       
    28 typedef stmGesture::TGestureDirection TStmGestureDirection;
       
    29 
       
    30 /**
       
    31  * Point of float accuracy
       
    32  */
       
    33 NONSHARABLE_STRUCT( TRealPoint )
       
    34     {
       
    35     inline TRealPoint();
       
    36     inline TRealPoint( const TRealPoint& aPoint );
       
    37     inline TRealPoint( TReal aX, TReal aY );
       
    38     inline TBool operator==( const TRealPoint& aPoint ) const;
       
    39 
       
    40     TReal32 iX;
       
    41     TReal32 iY;
       
    42     };
       
    43 
       
    44 /**
       
    45  * Enum to distinguish between Gesture Entry and Exit. 
       
    46  * Currently supported only for Pinch
       
    47  */
       
    48 enum TStmGestureState {
       
    49     EGestureEnter     = 0,
       
    50     EGestureExit
       
    51 
       
    52 };
       
    53 
       
    54 /**
       
    55  * Interface Class to the Application
       
    56  */
       
    57 
       
    58 class TStmGestureEvent
       
    59 {
       
    60 public:    
       
    61     inline TStmGestureUid Code() const                      { return iGestureUid; };
       
    62     inline TPoint CurrentPos() const                        { return iCurrPos; }; 
       
    63     inline TRealPoint Speed() const                         { return iSpeed; }; 
       
    64     inline TStmTapType Type() const                         { return iType; }; 
       
    65     inline int Details() const                              { return iDetails; };
       
    66     inline TStmGestureDirection GestureDirection() const    { return iDirection; }; 
       
    67     inline TPoint PinchEndPos() const                       { return iPinchEndPos; };
       
    68     inline TStmGestureState GestureState() const            { return iGestureState; };
       
    69             
       
    70     inline void SetCode(TStmGestureUid aGestureUid)         { iGestureUid = aGestureUid; };
       
    71     inline void SetCurrentPos(TPoint aPos)                  { iCurrPos = aPos; };
       
    72     inline void SetSpeed(TRealPoint aSpeed)                 { iSpeed = aSpeed; }; 
       
    73     inline void SetType(TStmTapType aType)                  { iType = aType; }; 
       
    74     inline void SetDetails(int aDetails)                    { iDetails = aDetails; }; 
       
    75     inline void SetGestureDirection(TStmGestureDirection aDirection)  { iDirection = aDirection; }; 
       
    76     inline void SetPinchEndPos(TPoint aPinchEndPos)         { iPinchEndPos = aPinchEndPos; }; 
       
    77     inline void SetGestureState(TStmGestureState aGestureState)       { iGestureState = aGestureState; }; 
       
    78     
       
    79 private:    
       
    80     TStmGestureUid              iGestureUid;   // Code of the gesture 
       
    81     TPoint                      iCurrPos;      // Current position where gesture occured
       
    82     TRealPoint                  iSpeed;        // speed X and speed Y
       
    83     TStmTapType                 iType;         // single-tap or double-tap
       
    84     int                         iDetails;      // details like pinch factor
       
    85     TStmGestureDirection        iDirection;    // Gesture Direction  
       
    86     TPoint                      iPinchEndPos;  // End of pinching position
       
    87     TStmGestureState            iGestureState; // Gesture State. currently supports only for pinch
       
    88     
       
    89 };
       
    90 
       
    91 class MStmGestureListener
       
    92     {
       
    93 public:
       
    94     /**
       
    95      * Handle the gesture event
       
    96      * @param aEvent event describing the gesture 
       
    97      */
       
    98     virtual void HandleGestureEventL(const TStmGestureEvent& aGesture) = 0;
       
    99     };
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // Default constructor for real point
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 inline TRealPoint::TRealPoint()
       
   106         : iX( 0 ), iY( 0 )
       
   107     {    
       
   108     }
       
   109 
       
   110 // ----------------------------------------------------------------------------
       
   111 // Copy constructor for real point
       
   112 // ----------------------------------------------------------------------------
       
   113 //
       
   114 inline TRealPoint::TRealPoint( const TRealPoint& aPoint )
       
   115         : iX( aPoint.iX ), iY( aPoint.iY )
       
   116     {    
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // Copy constructor for real point
       
   121 // ----------------------------------------------------------------------------
       
   122 //
       
   123 inline TRealPoint::TRealPoint( TReal aX, TReal aY )
       
   124         : iX( aX ), iY( aY )
       
   125     {    
       
   126     }
       
   127 
       
   128 // ----------------------------------------------------------------------------
       
   129 // Default constructor for real point
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 inline TBool TRealPoint::operator==( const TRealPoint& aPoint ) const
       
   133     {    
       
   134     return iX == aPoint.iX && iY == aPoint.iY;
       
   135     }
       
   136 
       
   137 
       
   138 #endif  // __ICS_GESTURELISTENER_H__