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