web_plat/stmgesturefw_api/inc/rt_gestureobserver.h
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 66 cacf6ee57968
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
     1 /*
       
     2 * Copyright (c) 2008-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 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:  RT Gesture helper interface
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _RT_GESTUREOBSERVER_H_
       
    19 #define _RT_GESTUREOBSERVER_H_
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 namespace RT_GestureHelper
       
    24 {
       
    25 
       
    26 /// flag that indicates gesture code is a holding code
       
    27 /// clients should use MGestureEvent::IsHolding
       
    28 const TInt EFlagHold       = 0x10000000;
       
    29 
       
    30 enum TGestureCode
       
    31     {
       
    32     // states
       
    33     EGestureStart          = 0x00000001, // gesture just started (user pressed stylus down)
       
    34     EGestureDrag           = 0x00000002, // user moved stylus (may be holding or not holding)
       
    35     EGestureReleased       = 0x00000003, // user lifted stylus while user was holding
       
    36     // gestures
       
    37     EGestureUnknown        = 0x00000005, // gesture was not recognised
       
    38     // these codes are sent when user lifts stylus (if holding not started)
       
    39     EGestureTap            = 0x00000006,
       
    40     EGestureDoubleTap      = 0x00000007, // only if double tap is enabled
       
    41                                          // (via CGestureHelper::SetDoubleTapEnabled or
       
    42                                          // CGestureControl::SetDoubleTapEnabled)
       
    43     EGestureSwipeLeft      = 0x00000008,
       
    44     EGestureSwipeRight     = 0x00000009,
       
    45     EGestureSwipeUp        = 0x0000000A,
       
    46     EGestureSwipeDown      = 0x0000000B,
       
    47 
       
    48     EGestureFlick          = 0x0000000C,
       
    49     EGestureLongTap        = 0x0000000D,
       
    50     EGestureDrop           = 0x0000000E,
       
    51 
       
    52     // these codes are sent when user initiates holding by keeping stylus in
       
    53     // same place for a longer duration
       
    54     EGestureHoldLeft       = EGestureSwipeLeft  | EFlagHold,
       
    55     EGestureHoldRight      = EGestureSwipeRight | EFlagHold,
       
    56     EGestureHoldUp         = EGestureSwipeUp    | EFlagHold,
       
    57     EGestureHoldDown       = EGestureSwipeDown  | EFlagHold,
       
    58     EGesturePinch
       
    59     };
       
    60 
       
    61 /**
       
    62  * Point of float accuracy
       
    63  */
       
    64 NONSHARABLE_STRUCT( TRealPoint )
       
    65     {
       
    66     inline TRealPoint();
       
    67     inline TRealPoint( const TRealPoint& aPoint );
       
    68     inline TRealPoint( TReal aX, TReal aY );
       
    69     inline TBool operator==( const TRealPoint& aPoint ) const;
       
    70 
       
    71     TReal32 iX;
       
    72     TReal32 iY;
       
    73     };
       
    74 
       
    75 /**
       
    76  * a gesture event
       
    77  */
       
    78 
       
    79 enum TAxis
       
    80     {
       
    81     EAxisBoth,
       
    82     EAxisHorizontal,
       
    83     EAxisVertical
       
    84     };
       
    85 
       
    86 
       
    87 class TGestureEvent
       
    88 {
       
    89 public:
       
    90     inline TGestureCode Code( TAxis /*aRelevantAxis*/ ) const { return iCode; };
       
    91     inline TBool IsHolding() const { return iIsHolding; };
       
    92     inline TPoint StartPos() const { return iStartPos; };
       
    93     inline TPoint CurrentPos() const { return iCurrPos; };
       
    94     inline TRealPoint Speed() const { return iSpeed; };
       
    95     inline TRealPoint SpeedPercent ( const TRect& /*aEdges*/ ) const { return iSpeedPercent; };
       
    96     inline TPoint Distance() const { return iDistance; };
       
    97 
       
    98     inline void SetCurrentPos(TPoint aPos) { iCurrPos = aPos; };
       
    99     inline void SetStartPos(TPoint aPos) {iStartPos = aPos; };
       
   100     inline void SetCode(TGestureCode aCode) {iCode = aCode; };
       
   101     inline void SetSpeed(TRealPoint aSpeed) { iSpeed = aSpeed; };
       
   102     inline void SetDistance(TPoint aDistance) { iDistance = aDistance; };
       
   103     inline void SetSpeedPercent(TRealPoint aSpeedPercent) { iSpeedPercent = aSpeedPercent; };
       
   104 
       
   105     inline void SetIsHolding(TBool aIsHolding) { iIsHolding = aIsHolding; };
       
   106 
       
   107 private:
       
   108     TGestureCode   iCode;
       
   109     TBool          iIsHolding;
       
   110     TPoint         iStartPos;
       
   111     TPoint         iCurrPos;
       
   112     TRealPoint     iSpeed;
       
   113     TRealPoint     iSpeedPercent;
       
   114     TPoint         iDistance;
       
   115 };
       
   116 
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // Default constructor for real point
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 inline TRealPoint::TRealPoint()
       
   123         : iX( 0 ), iY( 0 )
       
   124     {
       
   125     }
       
   126 
       
   127 // ----------------------------------------------------------------------------
       
   128 // Copy constructor for real point
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 inline TRealPoint::TRealPoint( const TRealPoint& aPoint )
       
   132         : iX( aPoint.iX ), iY( aPoint.iY )
       
   133     {
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
       
   137 // Copy constructor for real point
       
   138 // ----------------------------------------------------------------------------
       
   139 //
       
   140 inline TRealPoint::TRealPoint( TReal aX, TReal aY )
       
   141         : iX( aX ), iY( aY )
       
   142     {
       
   143     }
       
   144 
       
   145 // ----------------------------------------------------------------------------
       
   146 // Default constructor for real point
       
   147 // ----------------------------------------------------------------------------
       
   148 //
       
   149 inline TBool TRealPoint::operator==( const TRealPoint& aPoint ) const
       
   150     {
       
   151     return iX == aPoint.iX && iY == aPoint.iY;
       
   152     }
       
   153 
       
   154 
       
   155 } // namespace RT_GestureHelper
       
   156 
       
   157 #endif // _RT_GESTUREOBSERVER_H_