textinput/peninputarc/src/peninputlayoutcontrol/peninputlayouttimer.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-2005 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:  Implementation for timer used in layout
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "peninputlayouttimer.h"
       
    20 
       
    21 // ======== MEMBER FUNCTIONS ========
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CLayoutTimer::NewL
       
    25 // two-phase constructor
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CLayoutTimer* CLayoutTimer::NewL(MTimerHandler* aTimerHandler,TTimeType aMode,
       
    29                                                     TBool aAutoFlag)
       
    30     {
       
    31     CLayoutTimer *self = new(ELeave) CLayoutTimer(aTimerHandler,aMode,aAutoFlag);
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL();
       
    34     CleanupStack::Pop(self);
       
    35     return self;
       
    36     }
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CLayoutTimer::CLayoutTimer
       
    41 // Default constructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CLayoutTimer::CLayoutTimer(MTimerHandler* aTimerHandler,TTimeType aMode,
       
    45                             TBool aAutoFlag)
       
    46                            : CActive(0),iType(aMode),
       
    47                            iAutoRepeat(aAutoFlag),iTimerHandler(aTimerHandler)
       
    48     {
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CLayoutTimer::ConstructL
       
    53 // 2nd phase constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 void CLayoutTimer::ConstructL()
       
    57     {
       
    58     TInt err = iTimer.CreateLocal();
       
    59     User::LeaveIfError(err);
       
    60     CActiveScheduler::Add(this);
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CLayoutTimer::~CLayoutTimer
       
    65 // Destructor
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CLayoutTimer::~CLayoutTimer()
       
    69     {
       
    70     Cancel();
       
    71     iTimer.Close();
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CLayoutTimer::RunL
       
    76 // called when time out
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CLayoutTimer::RunL()
       
    80     {
       
    81     iTimerHandler->HandleTimerOut (iType);
       
    82     if(iAutoRepeat)
       
    83         {
       
    84         iTimer.After(iStatus,iInterval);
       
    85         SetActive();        
       
    86         }
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CLayoutTimer::RunError
       
    91 // called if RunL leaves
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 TInt CLayoutTimer::RunError(TInt /*aError*/)
       
    95     {
       
    96     return KErrNone;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CLayoutTimer::DoCancel
       
   101 // called when stroker timer has been cancelled
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CLayoutTimer::DoCancel()
       
   105     {
       
   106     iTimer.Cancel();
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CLayoutTimer::SetTimer
       
   111 // Set the timer and activate it
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 void CLayoutTimer::SetTimer (TTimeIntervalMicroSeconds32 aDelay)
       
   115     {
       
   116     Cancel();
       
   117     iInterval = aDelay;
       
   118     iTimer.After(iStatus,aDelay);
       
   119     SetActive();
       
   120     }
       
   121 //end of file