mulwidgets/alfscrollbarwidget/src/alfscrollbarlongtaptimer.cpp
branchRCL_3
changeset 26 0e9bb658ef58
parent 0 e83bab7cf002
equal deleted inserted replaced
25:4ea6f81c838a 26:0e9bb658ef58
       
     1 /*
       
     2 * Copyright (c) 2007 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: Timer for creating longtap event 
       
    15 *
       
    16 */
       
    17 #include "alfscrollbarlongtaptimer.h"
       
    18 #include <alf/ialfscrollbardefaultbaseelement.h>
       
    19 #include "ialfscrollbarbaseelementinternal.h"
       
    20 
       
    21 const int KInitialTimeInterval = 200000;
       
    22 const int KTimeInterval =  100000;
       
    23 
       
    24 namespace Alf
       
    25     {
       
    26 
       
    27 //---------------------------------------------------------------------------
       
    28 // Constructor
       
    29 //---------------------------------------------------------------------------
       
    30 //        
       
    31 AlfScrollBarLongTapTimer::AlfScrollBarLongTapTimer(
       
    32     IAlfScrollBarDefaultBaseElement* aBaseElement):CActive(EPriorityStandard)
       
    33     {
       
    34     iTimer.CreateLocal();
       
    35     iBaseElement = aBaseElement;
       
    36     CActiveScheduler::Add(this);
       
    37     iState = EStopped;
       
    38     }
       
    39 
       
    40 //---------------------------------------------------------------------------
       
    41 // Destructor 
       
    42 //---------------------------------------------------------------------------
       
    43 //
       
    44 AlfScrollBarLongTapTimer::~AlfScrollBarLongTapTimer()
       
    45     {
       
    46     Stop();
       
    47     iTimer.Close();
       
    48     }
       
    49 //---------------------------------------------------------------------------
       
    50 // Activates the timer. 
       
    51 //---------------------------------------------------------------------------
       
    52 //  
       
    53 void AlfScrollBarLongTapTimer::Start()
       
    54     {
       
    55     if (iState == ERunning)
       
    56         return;
       
    57     if (!IsActive())
       
    58         {
       
    59         iTimer.After(iStatus, TTimeIntervalMicroSeconds32(KInitialTimeInterval));
       
    60         SetActive();
       
    61         }
       
    62     iState = ERunning;    
       
    63     }
       
    64 //---------------------------------------------------------------------------
       
    65 // stops the timer. 
       
    66 //---------------------------------------------------------------------------
       
    67 // 
       
    68 void AlfScrollBarLongTapTimer::Stop()
       
    69     {
       
    70     Cancel();
       
    71     iState = EStopped;
       
    72     }
       
    73 //---------------------------------------------------------------------------
       
    74 // Handles an active object's request completion event.
       
    75 //---------------------------------------------------------------------------
       
    76 //     
       
    77 void AlfScrollBarLongTapTimer::RunL()
       
    78     {
       
    79     IAlfScrollBarBaseElementInternal* elementInternal = 
       
    80         static_cast<IAlfScrollBarBaseElementInternal*> (
       
    81         iBaseElement->makeInterface(IAlfScrollBarBaseElementInternal::type()));
       
    82    
       
    83     if (iState == ERunning)
       
    84             {
       
    85             iTimer.After(iStatus, TTimeIntervalMicroSeconds32(KTimeInterval));    
       
    86             SetActive();
       
    87             }
       
    88     if(elementInternal)
       
    89         {
       
    90         elementInternal->handleLongTapEvent();
       
    91         }    
       
    92     }
       
    93 
       
    94 //---------------------------------------------------------------------------
       
    95 // Implements cancellation of an outstanding request.
       
    96 //---------------------------------------------------------------------------
       
    97 // 
       
    98 void AlfScrollBarLongTapTimer::DoCancel()
       
    99     {
       
   100     iTimer.Cancel();
       
   101     }
       
   102 
       
   103     }