vtuis/videotelui/src/features/numberentry/cvtuinumberentry.cpp
branchRCL_3
changeset 35 779871d1e4f4
parent 0 ed9695c8bcbe
equal deleted inserted replaced
34:f15ac8e65a02 35:779871d1e4f4
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Number entry UI feature implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <cvtlogger.h>
       
    20 
       
    21 #include "cvtuinumberentry.h"
       
    22 #include "cvtuifeaturemanager.h"
       
    23 #include "mvtuicommandmanager.h"
       
    24 #include "mvtuicomponentmanager.h"
       
    25 #include "mvtuicommandui.h"
       
    26 #include "tvtuifeatureids.h"
       
    27 #include "CVtUiNumberEntryControl.h"
       
    28 #include "CVtUiAppUi.h"
       
    29 
       
    30 
       
    31 // We need this to be able to make control's priority lower than activation
       
    32 // control's priority is
       
    33 extern const TInt KVtUiNumberEntryActivationPriority;
       
    34 
       
    35 // Priority of number entry control.
       
    36 const TInt KVtUiNumberEntryControlPriorityHidden =
       
    37     KVtUiNumberEntryActivationPriority - 1;
       
    38 
       
    39 // ======== LOCAL FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CVtUiNumberEntry::NewL
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CVtUiNumberEntry* CVtUiNumberEntry::NewL(
       
    46     CVtUiFeatureManager& aFeatureManager )
       
    47     {
       
    48     __VTPRINTENTER( "NE.NewL" )
       
    49     CVtUiNumberEntry* self =
       
    50         new ( ELeave ) CVtUiNumberEntry( aFeatureManager );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop(); // self
       
    54     __VTPRINTEXIT( "NE.NewL" )
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CVtUiNumberEntry::~CVtUiNumberEntry
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CVtUiNumberEntry::~CVtUiNumberEntry()
       
    63     {
       
    64     __VTPRINTENTER( "NE.~" )
       
    65     DeleteNumberEntryControl();
       
    66     __VTPRINTEXIT( "NE.~" )
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CVtUiNumberEntry::StartL
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CVtUiNumberEntry::StartL()
       
    74     {
       
    75     __VTPRINTENTER( "NE.StartL" )
       
    76     if ( State() == MVtUiFeature::EUnprepared )
       
    77         {
       
    78         PrepareL();
       
    79         iFeatureManager.ComponentManager().RequestActivationL(
       
    80             MVtUiComponent::EComponentIdNumberEntry );
       
    81         iFeatureState = MVtUiFeature::EActive;
       
    82         }
       
    83     __VTPRINTEXIT( "NE.StartL" )
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CVtUiNumberEntry::Stop
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CVtUiNumberEntry::Stop()
       
    91     {
       
    92     __VTPRINTENTER( "NE.Stop" )
       
    93     if ( State() == MVtUiFeature::EActive )
       
    94         {
       
    95         TRAP_IGNORE( iFeatureManager.ComponentManager().DeActivateComponentL(
       
    96             MVtUiComponent::EComponentIdNumberEntry ) );
       
    97         iFeatureState = MVtUiFeature::EReady;
       
    98         }
       
    99     Unprepare();
       
   100     __VTPRINTEXIT( "NE.Stop" )
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CVtUiNumberEntry::InitFeatureL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CVtUiNumberEntry::InitFeatureL()
       
   108     {
       
   109     __VTPRINTENTER( "NE.InitFeatureL" )
       
   110     CreateNumberEntryControlL();
       
   111     __VTPRINTEXIT( "NE.InitFeatureL" )
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CVtUiNumberEntry::ControlActivated
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CVtUiNumberEntry::ControlActivatedL()
       
   119     {
       
   120     __VTPRINTENTER( "NE.ControlActivatedL" )
       
   121     __VTPRINTEXIT( "NE.ControlActivatedL" )
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CVtUiNumberEntry::ControlDeactivated
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CVtUiNumberEntry::ControlDeactivated()
       
   129     {
       
   130     __VTPRINTENTER( "NE.ControlDeactivated" )
       
   131     __VTPRINTEXIT( "NE.ControlDeactivated" )
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CVtUiNumberEntry::CVtUiNumberEntry
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 CVtUiNumberEntry::CVtUiNumberEntry( CVtUiFeatureManager& aFeatureManager )
       
   139     : CVtUiFeatureBase( EVtUiFeatureIdNumberEntry, aFeatureManager )
       
   140     {
       
   141     __VTPRINTENTER( "NE.ctor" )
       
   142     __VTPRINTEXIT( "NE.ctor" )
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CVtUiNumberEntry::ConstructL
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CVtUiNumberEntry::ConstructL()
       
   150     {
       
   151     __VTPRINTENTER( "NE.ConstructL" )
       
   152     BaseConstructL();
       
   153     __VTPRINTEXIT( "NE.ConstructL" )
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CVtUiNumberEntry::PrepareL
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 void CVtUiNumberEntry::PrepareL()
       
   161     {
       
   162     __VTPRINTENTER( "NE.PrepareL" )
       
   163     iNumberEntryControl->SetNumberEntryControlObserver( this );
       
   164     iNumberEntryControl->RegisterComponentL(
       
   165         iFeatureManager.ComponentManager() );
       
   166     iFeatureManager.AppUi().AddToStackL( iNumberEntryControl,
       
   167         KVtUiNumberEntryControlPriorityHidden, ECoeStackFlagRefusesFocus );
       
   168     iFeatureState = MVtUiFeature::EReady;
       
   169     __VTPRINTEXIT( "NE.PrepareL" )
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CVtUiNumberEntry::Unprepare()
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void CVtUiNumberEntry::Unprepare()
       
   177     {
       
   178     __VTPRINTENTER( "NE.Unprepare" )
       
   179     if ( iFeatureState > MVtUiFeature::EUnprepared )
       
   180 	    {
       
   181 	    iNumberEntryControl->SetNumberEntryControlObserver( NULL );
       
   182 	    iFeatureManager.AppUi().RemoveFromStack( iNumberEntryControl );
       
   183 	    iNumberEntryControl->UnregisterComponent(
       
   184 	        iFeatureManager.ComponentManager() );
       
   185 	    iFeatureState = MVtUiFeature::EUnprepared;
       
   186 	  	}
       
   187     __VTPRINTEXIT( "NE.Unprepare" )
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 // CVtUiNumberEntry::CreateNumberEntryControlL
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CVtUiNumberEntry::CreateNumberEntryControlL()
       
   195     {
       
   196     __VTPRINTENTER( "NE.CreateNumberEntryControlL" )
       
   197     iNumberEntryControl = new ( ELeave ) CVtUiNumberEntryControl( *this,
       
   198         iFeatureManager.UiStates() );
       
   199     iNumberEntryControl->ConstructL( TRect() );
       
   200     iNumberEntryControl->SetMopParent( &iFeatureManager.AppUi() );
       
   201     __VTPRINTEXIT( "NE.CreateNumberEntryControlL" )
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // CVtUiNumberEntry::DeleteNumberEntryControl
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 void CVtUiNumberEntry::DeleteNumberEntryControl()
       
   209     {
       
   210     __VTPRINTENTER( "NE.DeleteNumberEntryControl" )
       
   211     delete iNumberEntryControl;
       
   212     iNumberEntryControl = NULL;
       
   213     iFeatureState = MVtUiFeature::EUnprepared;
       
   214     __VTPRINTEXIT( "NE.DeleteNumberEntryControl" )
       
   215     }