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