epoc32/include/mw/aknlongtapdetector.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2005-2009 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 "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:  Long Tap Detector with animation informing of long tap functionality
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef CAKNLONGTAPDETECTORCONTROLLER_H
    21 #define CAKNLONGTAPDETECTORCONTROLLER_H
    22 
    23 #include <w32std.h>
    24 #include <e32base.h>
    25 #include <coemain.h>
    26 
    27 class CAknLongTapAnimation;
    28 
    29 /**
    30  * Avkon LongTapDetector CallBack.
    31  *
    32  * Inherit from this class and implement HandleLongTapEventL to
    33  * get a callback when/if a long tap occurs.
    34  *
    35  * @lib avkon.lib
    36  * @since S60 5.0
    37  */
    38 class MAknLongTapDetectorCallBack
    39     {
    40 public:
    41     /**
    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.
    45     */
    46     virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, 
    47                                       const TPoint& aPenEventScreenLocation ) = 0;
    48     };
    49 
    50 
    51 /**
    52  * Avkon Long Tap Detector. 
    53  *
    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.
    58  *
    59  * @lib avkon.lib
    60  * @since S60 5.0
    61  */
    62 NONSHARABLE_CLASS( CAknLongTapDetector ) : public CTimer, MCoeMessageMonitorObserver
    63     {
    64 public: // Constructors and destructor	
    65 
    66     /**
    67      * Two-phased constructor.
    68      * @param aOwner Pointer to owner of this component. Ownership not transferred.
    69      */
    70     IMPORT_C static CAknLongTapDetector* NewL( MAknLongTapDetectorCallBack* aOwner );
    71 
    72     /**
    73      * Two-phased constructor.
    74      * @param aOwner Pointer to owner of this component. Ownership not transferred.
    75      */
    76     IMPORT_C static CAknLongTapDetector* NewLC( MAknLongTapDetectorCallBack* aOwner );
    77 
    78     /**
    79     * Destructor.
    80     */
    81     virtual ~CAknLongTapDetector();
    82 
    83 public: // New functions
    84 
    85     /**
    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.
    89     */
    90     IMPORT_C void PointerEventL( const TPointerEvent& aEvent );
    91 
    92     /**
    93     * Sets new time delay before long tap detector animation starts. Default delay is 0,15s.	
    94     * @param aMicroSeconds New delay in microseconds.
    95     */
    96     IMPORT_C void SetTimeDelayBeforeAnimation( const TInt aMicroSeconds );
    97 
    98     /**
    99     * Sets new time delay before long tap detector event is returned. Default delay is 0,8s.
   100     * @param aMicroSeconds New delay in microseconds.
   101     */
   102     IMPORT_C void SetLongTapDelay( const TInt aMicroSeconds );
   103 
   104     /**
   105     * Sets long tap animation ON/OFF. Default is ON.
   106     * @param aAnimation ETrue turns animations ON and EFalse turns animations OFF.
   107     */
   108     IMPORT_C void EnableLongTapAnimation( const TBool aAnimation );
   109 
   110     /**
   111     * Checks if the animation is running
   112     * @return ETrue if the animation is running, EFalse if not
   113     */
   114     IMPORT_C TBool IsAnimationRunning() const;
   115     
   116     /**
   117     * Cancels the long tap animation
   118     */
   119     IMPORT_C void CancelAnimationL();
   120 
   121 		/**
   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
   124 		 * ASAA-79TCJP).
   125 		 */
   126 		void MonitorWsMessage(const TWsEvent& aEvent);
   127 
   128 protected: // From CActive
   129 
   130     /**
   131     * Handles CTimer events. Called by system framework.
   132     */
   133     void RunL();
   134     
   135     /**
   136     * Cancels an outstanding request.
   137     */
   138     void DoCancel();
   139 
   140 private: // Constructors
   141 
   142     /**
   143     * C++ default constructor.
   144     * @param aOwner Owner.
   145     */
   146     CAknLongTapDetector( MAknLongTapDetectorCallBack* aOwner );
   147 
   148     /**
   149     * By default Symbian 2nd phase constructor is private.
   150     */
   151     void ConstructL();
   152 
   153 private: // New functions
   154 
   155     void StartAnimationL();
   156     void StopAnimation();	
   157 
   158 private: // Data
   159 
   160     enum TLongTapDetectorState
   161         {
   162         EWaiting, 				// normal state
   163         EWaitingForAnimation,	// Only "Pen down" event received, CTimer started
   164         EShowingAnimation		// Long tap animation started
   165         };
   166 
   167     /**
   168     * Current state of LongTapDetector.
   169     */
   170     TLongTapDetectorState iState;
   171     
   172     /**
   173     * Pointer to owner of this LongTapDetector object.
   174     * Not own.
   175     */
   176     MAknLongTapDetectorCallBack* iOwner;
   177 
   178     /**
   179     * Delay before animation starts in microseconds.
   180     */
   181     TInt iTimeDelayBeforeAnimation;
   182 
   183     /**
   184     * Delay before long tap event is reported in microseconds.
   185     */
   186     TInt iLongTapDelay; 
   187 
   188     /**
   189     * Pointer event received from owner.
   190     */
   191     TPointerEvent iPointerEvent;
   192 
   193     /**
   194     * Is long tap animation shown or not.
   195     */
   196     TBool iShowAnimation;
   197     
   198     /**
   199     * Long tap animation.
   200     * Own.
   201     */
   202     CAknLongTapAnimation* iAnimation;
   203     };
   204 
   205 #endif // CAKNLONGTAPDETECTOR_H
   206 
   207 // End of File
   208