textinput/peninputvkbcn/ctrlsrc/peninputvkbctrlpool.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002-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:  vkn control pool management
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <peninputlayoutbasecontrol.h>
       
    20 
       
    21 #include "peninputvkbctrlpool.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ------------------------------------------------------------------------
       
    26 // Constructor
       
    27 // ------------------------------------------------------------------------
       
    28 //
       
    29 CAknFepVkbCtrlPool* CAknFepVkbCtrlPool::NewL()
       
    30     {
       
    31     CAknFepVkbCtrlPool* self = NewLC();
       
    32     CleanupStack::Pop(self);
       
    33 
       
    34     return self;        
       
    35     }
       
    36  
       
    37 // ------------------------------------------------------------------------
       
    38 // Constructor
       
    39 // ------------------------------------------------------------------------
       
    40 //    
       
    41 CAknFepVkbCtrlPool* CAknFepVkbCtrlPool::NewLC()
       
    42     {
       
    43     CAknFepVkbCtrlPool* self = new (ELeave) CAknFepVkbCtrlPool();
       
    44 
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47 
       
    48     return self;        
       
    49     }
       
    50 
       
    51 // ------------------------------------------------------------------------
       
    52 // Constructor
       
    53 // ------------------------------------------------------------------------
       
    54 //   
       
    55 void CAknFepVkbCtrlPool::ConstructL() 
       
    56     {
       
    57     }
       
    58 
       
    59 // ------------------------------------------------------------------------
       
    60 // Destructor
       
    61 // ------------------------------------------------------------------------
       
    62 //         
       
    63 CAknFepVkbCtrlPool::~CAknFepVkbCtrlPool()    
       
    64     {
       
    65     iControlList.ResetAndDestroy();
       
    66     iControlList.Close();
       
    67     }
       
    68 
       
    69 // ------------------------------------------------------------------------
       
    70 // Add one control to the pool, the control should have one control ID
       
    71 // ------------------------------------------------------------------------
       
    72 //    
       
    73 void CAknFepVkbCtrlPool::AddControl(CFepUiBaseCtrl* aControl)
       
    74     {
       
    75     iControlList.Append(aControl);
       
    76     }
       
    77 
       
    78 // ------------------------------------------------------------------------
       
    79 // Remove one control from the pool based on control ID
       
    80 // ------------------------------------------------------------------------
       
    81 //     
       
    82 void CAknFepVkbCtrlPool::RemoveControl(const TInt aControlID) 
       
    83     {
       
    84     CFepUiBaseCtrl* ctrl = Control(aControlID);
       
    85     const TInt index = iControlList.Find(ctrl);
       
    86     delete ctrl;
       
    87     iControlList.Remove(index);
       
    88     }
       
    89     
       
    90 // ------------------------------------------------------------------------
       
    91 // Get one control from the pool based on control ID
       
    92 // ------------------------------------------------------------------------
       
    93 //     
       
    94 CFepUiBaseCtrl* CAknFepVkbCtrlPool::Control(const TInt aControlID) const
       
    95     {
       
    96     const TInt count = iControlList.Count();
       
    97     CFepUiBaseCtrl* ctrl = NULL;
       
    98     
       
    99     for (TInt i = 0; i < count; i++)
       
   100         {
       
   101         if (iControlList[i]->ControlId() == aControlID)
       
   102             {
       
   103             ctrl = iControlList[i];
       
   104             break;
       
   105             }
       
   106         }
       
   107 
       
   108     return ctrl;            
       
   109     }
       
   110 
       
   111 // ------------------------------------------------------------------------
       
   112 // Get one control from the pool based on the index of control array
       
   113 // ------------------------------------------------------------------------
       
   114 //   
       
   115 CFepUiBaseCtrl* CAknFepVkbCtrlPool::ControlByIndex(const TInt aIndex) const
       
   116     {
       
   117     CFepUiBaseCtrl* ctrl = NULL;
       
   118     const TInt count = iControlList.Count();
       
   119 
       
   120     if ((aIndex < count) && (aIndex >= 0))
       
   121         {
       
   122         ctrl = iControlList[aIndex];
       
   123         }
       
   124 
       
   125     return ctrl;          
       
   126     }
       
   127 
       
   128 // ------------------------------------------------------------------------
       
   129 // Get current control count in the pool
       
   130 // ------------------------------------------------------------------------
       
   131 // 
       
   132 TInt CAknFepVkbCtrlPool::ControlCount() const
       
   133     {
       
   134     return iControlList.Count();
       
   135     }
       
   136 
       
   137 // ------------------------------------------------------------------------
       
   138 // Remove all controls and delete them            
       
   139 // ------------------------------------------------------------------------
       
   140 // 
       
   141 void CAknFepVkbCtrlPool::Reset()
       
   142     {
       
   143     iControlList.ResetAndDestroy();
       
   144     }
       
   145 
       
   146 // End Of File