2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Long Tap Detector with animation informing of long tap functionality
20 #ifndef CAKNLONGTAPDETECTORCONTROLLER_H
21 #define CAKNLONGTAPDETECTORCONTROLLER_H
27 class CAknLongTapAnimation;
30 * Avkon LongTapDetector CallBack.
32 * Inherit from this class and implement HandleLongTapEventL to
33 * get a callback when/if a long tap occurs.
38 class MAknLongTapDetectorCallBack
42 * Callback method. Get's called when a long tap occurs.
43 * @param aPenEventLocation Long tap event location relative to parent control.
44 * @param aPenEventScreenLocation Long tap event location relative to screen.
46 virtual void HandleLongTapEventL( const TPoint& aPenEventLocation,
47 const TPoint& aPenEventScreenLocation ) = 0;
52 * Avkon Long Tap Detector.
54 * Receives pointer events from owner application or owner control and returns
55 * location if a long tap event occurs.
56 * After short period of time (default 0,15s) animation is displayed next to stylus on the screen to
57 * inform the user of long tap functionality. Animation can be turned OFF by application if wanted.
62 NONSHARABLE_CLASS( CAknLongTapDetector ) : public CTimer, MCoeMessageMonitorObserver
64 public: // Constructors and destructor
67 * Two-phased constructor.
68 * @param aOwner Pointer to owner of this component. Ownership not transferred.
70 IMPORT_C static CAknLongTapDetector* NewL( MAknLongTapDetectorCallBack* aOwner );
73 * Two-phased constructor.
74 * @param aOwner Pointer to owner of this component. Ownership not transferred.
76 IMPORT_C static CAknLongTapDetector* NewLC( MAknLongTapDetectorCallBack* aOwner );
81 virtual ~CAknLongTapDetector();
83 public: // New functions
86 * Receives and handles pointer events from owner's HandlePointerEventL() -method.
87 * Used to control timers in detecting long tap events.
88 * @param aEvent Pointer event from owner.
90 IMPORT_C void PointerEventL( const TPointerEvent& aEvent );
93 * Sets new time delay before long tap detector animation starts. Default delay is 0,15s.
94 * @param aMicroSeconds New delay in microseconds.
96 IMPORT_C void SetTimeDelayBeforeAnimation( const TInt aMicroSeconds );
99 * Sets new time delay before long tap detector event is returned. Default delay is 0,8s.
100 * @param aMicroSeconds New delay in microseconds.
102 IMPORT_C void SetLongTapDelay( const TInt aMicroSeconds );
105 * Sets long tap animation ON/OFF. Default is ON.
106 * @param aAnimation ETrue turns animations ON and EFalse turns animations OFF.
108 IMPORT_C void EnableLongTapAnimation( const TBool aAnimation );
111 * Checks if the animation is running
112 * @return ETrue if the animation is running, EFalse if not
114 IMPORT_C TBool IsAnimationRunning() const;
117 * Cancels the long tap animation
119 IMPORT_C void CancelAnimationL();
122 * This function is used to capture key events during the longtap animation.
123 * If such events are received, the longtap animation is then cancelled (TSW Error
126 void MonitorWsMessage(const TWsEvent& aEvent);
128 protected: // From CActive
131 * Handles CTimer events. Called by system framework.
136 * Cancels an outstanding request.
140 private: // Constructors
143 * C++ default constructor.
144 * @param aOwner Owner.
146 CAknLongTapDetector( MAknLongTapDetectorCallBack* aOwner );
149 * By default Symbian 2nd phase constructor is private.
153 private: // New functions
155 void StartAnimationL();
156 void StopAnimation();
160 enum TLongTapDetectorState
162 EWaiting, // normal state
163 EWaitingForAnimation, // Only "Pen down" event received, CTimer started
164 EShowingAnimation // Long tap animation started
168 * Current state of LongTapDetector.
170 TLongTapDetectorState iState;
173 * Pointer to owner of this LongTapDetector object.
176 MAknLongTapDetectorCallBack* iOwner;
179 * Delay before animation starts in microseconds.
181 TInt iTimeDelayBeforeAnimation;
184 * Delay before long tap event is reported in microseconds.
189 * Pointer event received from owner.
191 TPointerEvent iPointerEvent;
194 * Is long tap animation shown or not.
196 TBool iShowAnimation;
199 * Long tap animation.
202 CAknLongTapAnimation* iAnimation;
205 #endif // CAKNLONGTAPDETECTOR_H