diff -r 000000000000 -r 2f259fa3e83a akntouchgesturefw/src/akntouchgesturefwsimulation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/akntouchgesturefw/src/akntouchgesturefwsimulation.cpp Tue Feb 02 01:00:49 2010 +0200 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Touch gesture fw simulation class. +* +*/ + + +#include "akntouchgesturefwimpl.h" +#include "akntouchgesturefwsimulation.h" + +using namespace AknTouchGestureFw; + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Sets the pointer number of an advanced pointer event. +// --------------------------------------------------------------------------- +// +void TAdvancedPointerEventHelper::SetPointerNumberToEvent( + TAdvancedPointerEvent* aEvent, + TInt aPointerNumber ) + { + // Just to hack to set the pointer number: these members may not be + // supported in the future... + aEvent->iModifiers |= EModifierAdvancedPointerEvent; + aEvent->iData.multiPos3D.iPointerNumber = aPointerNumber; + } + + +// --------------------------------------------------------------------------- +// CAknTouchGestureFwSimulation::~CAknTouchGestureFwSimulation +// --------------------------------------------------------------------------- +// +CAknTouchGestureFwSimulation::~CAknTouchGestureFwSimulation() + { + iDataArray.Reset(); + iDataArray.Close(); + } + + +// --------------------------------------------------------------------------- +// CAknTouchGestureFwSimulation::InitSimulationL +// --------------------------------------------------------------------------- +// +void CAknTouchGestureFwSimulation::InitSimulationL( + CAknTouchGestureFw* aGestureFw, + CAknTouchGestureFwImpl* aGestureEngine ) + { + CAknTouchGestureFwSimulation* instance = + static_cast< CAknTouchGestureFwSimulation* >( + CCoeEnv::Static( KAknTouchGestureFwSimulation ) ); + if ( !instance ) + { + instance = + new ( ELeave ) CAknTouchGestureFwSimulation(); + } + // Check if already in array + TBool gestureFwFound( EFalse ); + for ( TInt i = 0; i < instance->iDataArray.Count(); i++ ) + { + if ( instance->iDataArray[ i ].iGestureFw == aGestureFw ) + { + gestureFwFound = ETrue; + break; + } + } + // Add only if fw was not found from array + if ( !gestureFwFound ) + { + TAknTouchGestureFwSimulationData newData; + newData.iGestureFw = aGestureFw; + newData.iGestureEngine = aGestureEngine; + instance->iDataArray.AppendL( newData ); + } + } + + +// --------------------------------------------------------------------------- +// CAknTouchGestureFwSimulation::EndSimulation +// --------------------------------------------------------------------------- +// +void CAknTouchGestureFwSimulation::EndSimulation( + CAknTouchGestureFw* aGestureFw ) + { + CAknTouchGestureFwSimulation* instance = + static_cast< CAknTouchGestureFwSimulation* >( + CCoeEnv::Static( KAknTouchGestureFwSimulation ) ); + if ( !instance ) + { + return; + } + for ( TInt i = 0; i < instance->iDataArray.Count(); i++ ) + { + if ( instance->iDataArray[ i ].iGestureFw == aGestureFw ) + { + instance->iDataArray.Remove( i ); + break; + } + } + } + + +// --------------------------------------------------------------------------- +// Simulates a single pointer event. +// --------------------------------------------------------------------------- +// +void CAknTouchGestureFwSimulation::SimulateL( CAknTouchGestureFw* aGestureFw, + TPointerEvent& aEvent, + TInt aPointerNumber, + TTime aTimeStamp ) + { + CAknTouchGestureFwImpl* engine( NULL ); + for ( TInt i = 0; i < iDataArray.Count(); i++ ) + { + if ( iDataArray[ i ].iGestureFw == aGestureFw ) + { + engine = iDataArray[ i ].iGestureEngine; + break; + } + } + if ( engine ) + { + TAdvancedPointerEvent* ctrlEvent = + static_cast( &aEvent ); + TAdvancedPointerEventHelper::SetPointerNumberToEvent( + ctrlEvent, aPointerNumber ); + + TPointerEventData pointerData( + *ctrlEvent, aPointerNumber, aTimeStamp, ETrue, ETrue ); + engine->HandleSimulatedPointerEventL( pointerData ); + } + } + + +// --------------------------------------------------------------------------- +// Default C++ constructor. +// --------------------------------------------------------------------------- +// +CAknTouchGestureFwSimulation::CAknTouchGestureFwSimulation() + : CCoeStatic( KAknTouchGestureFwSimulation ) + { + } + +// End of File