williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
#ifndef AKNPOINTEREVENTSUPPRESSOR_H
|
williamr@2
|
19 |
#define AKNPOINTEREVENTSUPPRESSOR_H
|
williamr@2
|
20 |
|
williamr@2
|
21 |
// INCLUDES
|
williamr@2
|
22 |
#include <coecntrl.h>
|
williamr@2
|
23 |
|
williamr@2
|
24 |
// CLASS DECLARATION
|
williamr@2
|
25 |
|
williamr@2
|
26 |
/**
|
williamr@2
|
27 |
* Utility class for removing unwanted pointer events, for instance
|
williamr@2
|
28 |
* when distinguishing tap events from intended drags.
|
williamr@2
|
29 |
*
|
williamr@2
|
30 |
* Usage pattern, where iSuppressor is a CAknPointerEventSuppressor*:
|
williamr@2
|
31 |
*
|
williamr@2
|
32 |
* void CMyControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
williamr@2
|
33 |
* {
|
williamr@2
|
34 |
* if (iSuppressor->SuppressPointerEvent(aPointerEvent))
|
williamr@2
|
35 |
* return;
|
williamr@2
|
36 |
*
|
williamr@2
|
37 |
* switch (aPointerEvent.iType)
|
williamr@2
|
38 |
* {
|
williamr@2
|
39 |
* case TPointerEvent::EButton1Down:
|
williamr@2
|
40 |
* iTap = ETrue;
|
williamr@2
|
41 |
* break;
|
williamr@2
|
42 |
* case TPointerEvent::EButton1Up:
|
williamr@2
|
43 |
* if (iTap)
|
williamr@2
|
44 |
* HandleTapL(aPointerEvent);
|
williamr@2
|
45 |
* break;
|
williamr@2
|
46 |
* case TPointerEvent::EDrag:
|
williamr@2
|
47 |
* iTap = EFalse;
|
williamr@2
|
48 |
* HandleDragL(aPointerEvent);
|
williamr@2
|
49 |
* break;
|
williamr@2
|
50 |
* default:
|
williamr@2
|
51 |
* break;
|
williamr@2
|
52 |
* }
|
williamr@2
|
53 |
* }
|
williamr@2
|
54 |
*
|
williamr@2
|
55 |
* @since S60 5.0
|
williamr@2
|
56 |
*/
|
williamr@2
|
57 |
NONSHARABLE_CLASS(CAknPointerEventSuppressor) : public CBase
|
williamr@2
|
58 |
{
|
williamr@2
|
59 |
public:
|
williamr@2
|
60 |
/**
|
williamr@2
|
61 |
* Factory function
|
williamr@2
|
62 |
*
|
williamr@2
|
63 |
* This creates a pointer event suppressor that will suppress
|
williamr@2
|
64 |
* drag events while the pointer interaction may be a tap.
|
williamr@2
|
65 |
*/
|
williamr@2
|
66 |
IMPORT_C static CAknPointerEventSuppressor* NewL();
|
williamr@2
|
67 |
/**
|
williamr@2
|
68 |
* Destructor.
|
williamr@2
|
69 |
*/
|
williamr@2
|
70 |
IMPORT_C ~CAknPointerEventSuppressor();
|
williamr@2
|
71 |
|
williamr@2
|
72 |
/**
|
williamr@2
|
73 |
* Tests whether a pointer event should be suppressed.
|
williamr@2
|
74 |
*
|
williamr@2
|
75 |
* A control that wants pointer event suppression should feed
|
williamr@2
|
76 |
* all pointer events to this function. It will return ETrue if
|
williamr@2
|
77 |
* the pointer event should be ignored by the control.
|
williamr@2
|
78 |
* Only controls that have unrelated behaviour on tap and drag
|
williamr@2
|
79 |
* actions need to use pointer event suppression.
|
williamr@2
|
80 |
*
|
williamr@2
|
81 |
* If this class is used to suppress drag events during a possible
|
williamr@2
|
82 |
* tap, and this function does not suppress a drag event, the
|
williamr@2
|
83 |
* client can be sure that a drag action is happening.
|
williamr@2
|
84 |
*
|
williamr@2
|
85 |
* @param aPointerEvent the pointer event which may need to be suppressed.
|
williamr@2
|
86 |
* @return ETrue if the pointer event should be suppressed, or EFalse if it should be handled.
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
IMPORT_C TBool SuppressPointerEvent(const TPointerEvent& aPointerEvent);
|
williamr@2
|
89 |
/**
|
williamr@2
|
90 |
* Set the maximum time period that drag events should be
|
williamr@2
|
91 |
* ignored during a pointer interaction.
|
williamr@2
|
92 |
*
|
williamr@2
|
93 |
* @param aDuration the maximum duration of a tap action.
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
IMPORT_C void SetMaxTapDuration(TTimeIntervalMicroSeconds aDuration);
|
williamr@2
|
96 |
/**
|
williamr@2
|
97 |
* Set the maximum pointer movement for which drag events
|
williamr@2
|
98 |
* should be ignored during a pointer interaction.
|
williamr@2
|
99 |
*
|
williamr@2
|
100 |
* @param aMoveLimits the pixel movement limits within which a touch action is considered a tap
|
williamr@2
|
101 |
*/
|
williamr@2
|
102 |
IMPORT_C void SetMaxTapMove(TSize aMoveLimits);
|
williamr@2
|
103 |
/**
|
williamr@2
|
104 |
* Set the minimum time between drag events.
|
williamr@2
|
105 |
* This can be used to reduce the frequency of drag event reception when
|
williamr@2
|
106 |
* events are not desired at maximum speed.
|
williamr@2
|
107 |
*
|
williamr@2
|
108 |
* @param aInterval the minimum interval between which drag events are wanted
|
williamr@2
|
109 |
*/
|
williamr@2
|
110 |
IMPORT_C void SetMinInterDragInterval(TTimeIntervalMicroSeconds aInterval);
|
williamr@2
|
111 |
|
williamr@2
|
112 |
private:
|
williamr@2
|
113 |
CAknPointerEventSuppressor();
|
williamr@2
|
114 |
|
williamr@2
|
115 |
private:
|
williamr@2
|
116 |
TTimeIntervalMicroSeconds iMaxTapDuration;
|
williamr@2
|
117 |
TSize iMaxTapMove;
|
williamr@2
|
118 |
TTimeIntervalMicroSeconds iMinInterDragInterval;
|
williamr@2
|
119 |
TTime iDownTime;
|
williamr@2
|
120 |
TPoint iDownPos;
|
williamr@2
|
121 |
TBool iTap;
|
williamr@2
|
122 |
TTime iLastEventTime;
|
williamr@2
|
123 |
};
|
williamr@2
|
124 |
|
williamr@2
|
125 |
|
williamr@2
|
126 |
#endif |