webengine/webkitutils/stmgesturefw/src/gesturehelpereventsender.cpp
branchRCL_3
changeset 49 919f36ff910f
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
       
     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:  Gesture event sender implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "gesturehelpereventsender.h"
       
    19 
       
    20 CGestureEventSender* CGestureEventSender::NewL( MStmGestureListener& aObserver )
       
    21     {
       
    22     CGestureEventSender* self = new (ELeave) CGestureEventSender(aObserver);
       
    23     
       
    24     return self;
       
    25     }
       
    26 
       
    27 CGestureEventSender::CGestureEventSender( MStmGestureListener& aObserver ) 
       
    28     :iObserver(aObserver)
       
    29     { 
       
    30     }
       
    31 
       
    32 CGestureEventSender::~CGestureEventSender()
       
    33     {
       
    34     }
       
    35 
       
    36 void CGestureEventSender::AddEvent(TStmGestureUid aUid, const MStmGesture* aGestureEvent)
       
    37 {
       
    38     TStmGestureEvent event;
       
    39     if (aGestureEvent) {
       
    40         event.SetCode(aGestureEvent->gestureUid());
       
    41         event.SetCurrentPos(aGestureEvent->getLocation());
       
    42         event.SetSpeed(TRealPoint(aGestureEvent->getSpeedX()*1000,aGestureEvent->getSpeedY()*1000));//App needs the speed in pixels/sec
       
    43         event.SetType(TStmTapType(aGestureEvent->getType()));
       
    44         event.SetDetails(aGestureEvent->getDetails());
       
    45         event.SetGestureDirection(aGestureEvent->getDirection());
       
    46         event.SetPinchEndPos(aGestureEvent->getPinchEndPos());
       
    47         event.SetGestureState(EGestureEnter);
       
    48     }
       
    49     else {
       
    50         if (aUid != stmGesture::EGestureUidPinch) {
       
    51             return;
       
    52         }    
       
    53         event.SetCode(aUid);
       
    54         event.SetGestureState(EGestureExit);
       
    55     }
       
    56         
       
    57     EmitEventL(event);
       
    58     if (event.Code() == stmGesture::EGestureUidTap) {
       
    59         event.SetCode(stmGesture::EGestureUidRelease);
       
    60         EmitEventL(event);
       
    61     }
       
    62 }
       
    63 
       
    64 void CGestureEventSender::EmitEventL( const TStmGestureEvent& aGesture )
       
    65 {
       
    66     iObserver.HandleGestureEventL(aGesture);
       
    67 }