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