williamr@2: /* williamr@2: * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: #ifndef AKNPOINTEREVENTSUPPRESSOR_H williamr@2: #define AKNPOINTEREVENTSUPPRESSOR_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Utility class for removing unwanted pointer events, for instance williamr@2: * when distinguishing tap events from intended drags. williamr@2: * williamr@2: * Usage pattern, where iSuppressor is a CAknPointerEventSuppressor*: williamr@2: * williamr@2: * void CMyControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) williamr@2: * { williamr@2: * if (iSuppressor->SuppressPointerEvent(aPointerEvent)) williamr@2: * return; williamr@2: * williamr@2: * switch (aPointerEvent.iType) williamr@2: * { williamr@2: * case TPointerEvent::EButton1Down: williamr@2: * iTap = ETrue; williamr@2: * break; williamr@2: * case TPointerEvent::EButton1Up: williamr@2: * if (iTap) williamr@2: * HandleTapL(aPointerEvent); williamr@2: * break; williamr@2: * case TPointerEvent::EDrag: williamr@2: * iTap = EFalse; williamr@2: * HandleDragL(aPointerEvent); williamr@2: * break; williamr@2: * default: williamr@2: * break; williamr@2: * } williamr@2: * } williamr@2: * williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknPointerEventSuppressor) : public CBase williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Factory function williamr@2: * williamr@2: * This creates a pointer event suppressor that will suppress williamr@2: * drag events while the pointer interaction may be a tap. williamr@2: */ williamr@2: IMPORT_C static CAknPointerEventSuppressor* NewL(); williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CAknPointerEventSuppressor(); williamr@2: williamr@2: /** williamr@2: * Tests whether a pointer event should be suppressed. williamr@2: * williamr@2: * A control that wants pointer event suppression should feed williamr@2: * all pointer events to this function. It will return ETrue if williamr@2: * the pointer event should be ignored by the control. williamr@2: * Only controls that have unrelated behaviour on tap and drag williamr@2: * actions need to use pointer event suppression. williamr@2: * williamr@2: * If this class is used to suppress drag events during a possible williamr@2: * tap, and this function does not suppress a drag event, the williamr@2: * client can be sure that a drag action is happening. williamr@2: * williamr@2: * @param aPointerEvent the pointer event which may need to be suppressed. williamr@2: * @return ETrue if the pointer event should be suppressed, or EFalse if it should be handled. williamr@2: */ williamr@2: IMPORT_C TBool SuppressPointerEvent(const TPointerEvent& aPointerEvent); williamr@2: /** williamr@2: * Set the maximum time period that drag events should be williamr@2: * ignored during a pointer interaction. williamr@2: * williamr@2: * @param aDuration the maximum duration of a tap action. williamr@2: */ williamr@2: IMPORT_C void SetMaxTapDuration(TTimeIntervalMicroSeconds aDuration); williamr@2: /** williamr@2: * Set the maximum pointer movement for which drag events williamr@2: * should be ignored during a pointer interaction. williamr@2: * williamr@2: * @param aMoveLimits the pixel movement limits within which a touch action is considered a tap williamr@2: */ williamr@2: IMPORT_C void SetMaxTapMove(TSize aMoveLimits); williamr@2: /** williamr@2: * Set the minimum time between drag events. williamr@2: * This can be used to reduce the frequency of drag event reception when williamr@2: * events are not desired at maximum speed. williamr@2: * williamr@2: * @param aInterval the minimum interval between which drag events are wanted williamr@2: */ williamr@2: IMPORT_C void SetMinInterDragInterval(TTimeIntervalMicroSeconds aInterval); williamr@2: williamr@2: private: williamr@2: CAknPointerEventSuppressor(); williamr@2: williamr@2: private: williamr@2: TTimeIntervalMicroSeconds iMaxTapDuration; williamr@2: TSize iMaxTapMove; williamr@2: TTimeIntervalMicroSeconds iMinInterDragInterval; williamr@2: TTime iDownTime; williamr@2: TPoint iDownPos; williamr@2: TBool iTap; williamr@2: TTime iLastEventTime; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif