textinput/peninputvkbcn/ctrlsrc/peninputvkblayoutpool.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:  vkb layout	pool management
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <peninputvkbcn.rsg>
       
    20 #include <peninputvkbctrllayout.h>
       
    21 #include <coemain.h>
       
    22  
       
    23 #include "peninputvkblayoutpool.h"
       
    24 #include "peninputvkbImlayout.h"
       
    25 
       
    26 // ========	MEMBER FUNCTIONS ========
       
    27 
       
    28 // ------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // ------------------------------------------------------------------------
       
    31 //
       
    32 CAknFepLayoutPool* CAknFepLayoutPool::NewL( CAknFepCtrlVkbLayout& aVkbLayout )
       
    33 	{
       
    34 	CAknFepLayoutPool* self	= NewLC( aVkbLayout );
       
    35 	CleanupStack::Pop();
       
    36 	
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 // ------------------------------------------------------------------------
       
    41 // Constructor
       
    42 // ------------------------------------------------------------------------
       
    43 //
       
    44 CAknFepLayoutPool* CAknFepLayoutPool::NewLC( CAknFepCtrlVkbLayout& aVkbLayout )
       
    45 	{
       
    46 	CAknFepLayoutPool* self	= new (ELeave) CAknFepLayoutPool();
       
    47 
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL( aVkbLayout );	
       
    50 
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 // ------------------------------------------------------------------------
       
    55 // Destructor
       
    56 // ------------------------------------------------------------------------
       
    57 // 
       
    58 CAknFepLayoutPool::~CAknFepLayoutPool()
       
    59 	{
       
    60 	iImLayoutList.ResetAndDestroy();
       
    61 	iImLayoutList.Close();
       
    62 	}
       
    63 
       
    64 // ------------------------------------------------------------------------
       
    65 // Constructor
       
    66 // ------------------------------------------------------------------------
       
    67 //
       
    68 CAknFepLayoutPool::CAknFepLayoutPool() 
       
    69 	{
       
    70 	}
       
    71 
       
    72 // ------------------------------------------------------------------------
       
    73 // Constructor
       
    74 // ------------------------------------------------------------------------
       
    75 //	  
       
    76 void CAknFepLayoutPool::ConstructL( CAknFepCtrlVkbLayout& aVkbLayout )  
       
    77 	{
       
    78 	ConstructFromResourceL( aVkbLayout );	 
       
    79 	}
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // Construct from resource file
       
    83 // ---------------------------------------------------------
       
    84 //		
       
    85 void CAknFepLayoutPool::ConstructFromResourceL( CAknFepCtrlVkbLayout& aVkbLayout )
       
    86 	{
       
    87     CCoeEnv* coeEnv = CCoeEnv::Static();
       
    88 	TResourceReader	reader;
       
    89 	
       
    90 	//Read imlayout	from resource
       
    91 	coeEnv->CreateResourceReaderLC(reader, R_AKN_FEP_VKB_IM_LAYOUT_LIST);
       
    92 	
       
    93 	TInt count = reader.ReadInt16();
       
    94 	TInt i;
       
    95 	
       
    96 	for	(i = 0;	i <	count; i++)
       
    97 		{
       
    98 		CAknFepVkbImLayout*	imLayout = CAknFepVkbImLayout::NewL(reader);
       
    99 		AddImLayout(imLayout);	  
       
   100 		} 
       
   101 			   
       
   102 	CleanupStack::PopAndDestroy(); // reader
       
   103 
       
   104 	//Read vkblayout from resource
       
   105     aVkbLayout.SetResourceId( R_AKN_FEP_VKB_VKB_LAYOUT_LIST );
       
   106     aVkbLayout.ConstructFromResourceL();
       
   107     iVkbLayoutInfoList = aVkbLayout.VkbLayoutInfoList();	
       
   108 	}
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // Add a image layout to array
       
   112 // ---------------------------------------------------------
       
   113 // 
       
   114 void CAknFepLayoutPool::AddImLayout(CAknFepVkbImLayout*	aImLayout) 
       
   115 	{
       
   116 	iImLayoutList.Append(aImLayout);	
       
   117 	}
       
   118 
       
   119 // ---------------------------------------------------------
       
   120 // Remove one image	layout from	array based	on image layout	id
       
   121 // ---------------------------------------------------------
       
   122 //			  
       
   123 void CAknFepLayoutPool::RemoveImLayout(const TInt aImLayout) 
       
   124 	{
       
   125 	const TInt count = iImLayoutList.Count();
       
   126 
       
   127 	for	(TInt i	= 0; i < count;	i++)
       
   128 		{
       
   129 		if (iImLayoutList[i]->LayoutID() ==	aImLayout)
       
   130 			{
       
   131 			CAknFepVkbImLayout*	ImLayout = iImLayoutList[i]; 
       
   132 			delete ImLayout;
       
   133 			iImLayoutList.Remove(i);
       
   134 
       
   135 			return;
       
   136 			}
       
   137 		}
       
   138 	}
       
   139 	
       
   140 // ---------------------------------------------------------
       
   141 // Get one image layout	from array based on	image layout id
       
   142 // ---------------------------------------------------------
       
   143 // 
       
   144 CAknFepVkbImLayout*	CAknFepLayoutPool::GetImLayout(const TInt aImLayout) const	
       
   145 	{
       
   146 	const TInt count = iImLayoutList.Count();
       
   147 
       
   148 	for	(TInt i	= 0; i < count;	i++)
       
   149 		{
       
   150 		if (iImLayoutList[i]->LayoutID() ==	aImLayout)
       
   151 			{
       
   152 			return iImLayoutList[i];
       
   153 			}
       
   154 		}
       
   155 
       
   156 	return NULL;
       
   157 	}
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // Add one image layout	to array 
       
   161 // ---------------------------------------------------------
       
   162 // 
       
   163 void CAknFepLayoutPool::AddVkbLayout(CPeninputVkbLayoutInfo* aVkbLayout) 
       
   164 	{
       
   165 	iVkbLayoutInfoList.Append(aVkbLayout);	  
       
   166 	}
       
   167 
       
   168 // ---------------------------------------------------------
       
   169 // Remove one vkb layout from array	based on vkb layout	id
       
   170 // ---------------------------------------------------------
       
   171 //			  
       
   172 void CAknFepLayoutPool::RemoveVkbLayout(const TInt aVkbLayout) 
       
   173 	{
       
   174 	const TInt count = iVkbLayoutInfoList.Count();
       
   175 	
       
   176 	for	(TInt i	= 0; i < count;	i++)
       
   177 		{
       
   178 		if (iVkbLayoutInfoList[i]->LayoutID() == aVkbLayout)
       
   179 			{
       
   180 			CPeninputVkbLayoutInfo* VkbLayout = iVkbLayoutInfoList[i];	
       
   181 			delete VkbLayout;
       
   182 			iVkbLayoutInfoList.Remove(i);
       
   183 
       
   184 			return;
       
   185 			}
       
   186 		}
       
   187 	}
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // Get one vkb layout from array based on vkb layout id
       
   191 // ---------------------------------------------------------
       
   192 //
       
   193 CPeninputVkbLayoutInfo* CAknFepLayoutPool::GetVkbLayout(const TInt	aVkbLayout)	const	
       
   194 	{
       
   195 	const TInt count = iVkbLayoutInfoList.Count();
       
   196 	
       
   197 	for	(TInt i	= 0; i < count;	i++)
       
   198 		{
       
   199 		if (iVkbLayoutInfoList[i]->LayoutID() == aVkbLayout)
       
   200 			{
       
   201 			return iVkbLayoutInfoList[i];
       
   202 			}
       
   203 		}
       
   204 
       
   205 	return NULL;
       
   206 	}
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // Get one vkb layout from array based on vkb layout id
       
   210 // ---------------------------------------------------------
       
   211 //
       
   212 void CAknFepLayoutPool::ResetImLayout()
       
   213 	{
       
   214 	iImLayoutList.ResetAndDestroy();		
       
   215 	}
       
   216 
       
   217 // ------------------------------------------------------------------------
       
   218 // Remove vkb layout and delete	them			
       
   219 // ------------------------------------------------------------------------
       
   220 // 
       
   221 void CAknFepLayoutPool::ResetVkbLayout()
       
   222 	{
       
   223 	iVkbLayoutInfoList.ResetAndDestroy();	 
       
   224 	}
       
   225 	
       
   226 // ------------------------------------------------------------------------
       
   227 // Remove vkb and image	layout and delete them			  
       
   228 // ------------------------------------------------------------------------
       
   229 // 
       
   230 void CAknFepLayoutPool::Reset()
       
   231 	{
       
   232 	ResetImLayout();
       
   233 	ResetVkbLayout();
       
   234 	}
       
   235 	 
       
   236 //	End	Of File