textinput/peninputvkbcn/ctrlsrc/peninputvkbImlayout.cpp
branchRCL_3
changeset 21 ecbabf52600f
parent 0 eb1f2e154e89
equal deleted inserted replaced
20:ebd48d2de13c 21:ecbabf52600f
       
     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:  image layout implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "peninputvkbImlayout.h"
       
    20 
       
    21 // CONSTANTS
       
    22 _LIT(KPipeSympol,'|');
       
    23 const TInt KBufferSize = 5;
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // Constructor
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 CAknFepControlInfo* CAknFepControlInfo::NewL(TResourceReader& aReader)
       
    32     {
       
    33     CAknFepControlInfo* self = new (ELeave) CAknFepControlInfo();
       
    34 
       
    35     CleanupStack::PushL(self);
       
    36     self->ConstructFromResourceL(aReader); 
       
    37     CleanupStack::Pop();
       
    38     
       
    39     return self;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // Destructor
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 CAknFepControlInfo::~CAknFepControlInfo()
       
    47     {
       
    48     }
       
    49     
       
    50 // ---------------------------------------------------------
       
    51 // Construct from resource file
       
    52 // ---------------------------------------------------------
       
    53 //    
       
    54 void CAknFepControlInfo::ConstructFromResourceL(TResourceReader& aReader)
       
    55     {
       
    56     iControlID = aReader.ReadInt16();
       
    57     iBeginRow = aReader.ReadInt16();
       
    58     iBeginColumn = aReader.ReadInt16();
       
    59     iEndRow = aReader.ReadInt16();
       
    60     iEndColumn = aReader.ReadInt16();
       
    61     }
       
    62     
       
    63 // ---------------------------------------------------------
       
    64 // Constructor
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CAknFepVkbImLayout* CAknFepVkbImLayout::NewL(TResourceReader& aReader)
       
    68     {
       
    69     CAknFepVkbImLayout* self = NewLC(aReader);
       
    70     CleanupStack::Pop(self);
       
    71   
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // Constructor
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 CAknFepVkbImLayout* CAknFepVkbImLayout::NewLC(TResourceReader& aReader)
       
    80     {
       
    81     CAknFepVkbImLayout* self = new (ELeave) CAknFepVkbImLayout();
       
    82 
       
    83     CleanupStack::PushL(self);
       
    84     self->ConstructL(aReader);
       
    85   
       
    86     return self;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // Destructor
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 CAknFepVkbImLayout::~CAknFepVkbImLayout()
       
    94     {
       
    95     delete iPermittedLanguage;
       
    96     iControlInfoList.ResetAndDestroy();
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------
       
   100 // Constructor
       
   101 // ---------------------------------------------------------
       
   102 //
       
   103 void CAknFepVkbImLayout::ConstructL(TResourceReader& aReader)
       
   104     {
       
   105     ConstructFromResourceL(aReader);
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // Construct from resource file
       
   110 // ---------------------------------------------------------
       
   111 //          
       
   112 void CAknFepVkbImLayout::ConstructFromResourceL(TResourceReader& aReader)
       
   113     {
       
   114     iLayoutID = aReader.ReadInt16();
       
   115     iPermittedLanguage = aReader.ReadHBufCL();
       
   116     iColumns = aReader.ReadInt16();
       
   117     iRows = aReader.ReadInt16();
       
   118     
       
   119     const TInt count = aReader.ReadInt16();
       
   120     
       
   121     for (TInt i = 0; i < count; i++)
       
   122         {
       
   123         CAknFepControlInfo* controlInfo = CAknFepControlInfo::NewL(aReader);
       
   124         AddControlInfo(controlInfo);
       
   125         }
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // Construct from resource file
       
   130 // ---------------------------------------------------------
       
   131 // 
       
   132 TBool CAknFepVkbImLayout::IsAvailableForLang(const TInt aLangID)
       
   133     {
       
   134     TBuf<KBufferSize> buf;
       
   135     buf.Append(KPipeSympol);
       
   136     buf.AppendNum(aLangID);
       
   137     buf.Append(KPipeSympol);
       
   138     
       
   139     if (iPermittedLanguage->Find(buf) != KErrNotFound)
       
   140         {
       
   141         return ETrue;
       
   142         }
       
   143 
       
   144     return EFalse;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // Get control infor based on control id
       
   149 // ---------------------------------------------------------
       
   150 // 
       
   151 CAknFepControlInfo* CAknFepVkbImLayout::FindControlInfo(const TInt aControlID)
       
   152     {
       
   153     const TInt count = iControlInfoList.Count();
       
   154     
       
   155     for (TInt i = 0; i < count; i++)
       
   156         {
       
   157         if (iControlInfoList[i]->ControlID() == aControlID)
       
   158             {
       
   159             return iControlInfoList[i];
       
   160             }
       
   161         }
       
   162 
       
   163     return NULL;
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------
       
   167 // Add a control info to info list
       
   168 // ---------------------------------------------------------
       
   169 // 
       
   170 void CAknFepVkbImLayout::AddControlInfo(CAknFepControlInfo* aControlInfo)
       
   171     {
       
   172     iControlInfoList.Append(aControlInfo);
       
   173     }
       
   174  
       
   175 // ---------------------------------------------------------
       
   176 // Remove a control info from info list
       
   177 // ---------------------------------------------------------
       
   178 // 
       
   179 void CAknFepVkbImLayout::RmoveControlInfo(CAknFepControlInfo* aControlInfo)
       
   180     {
       
   181     CAknFepControlInfo* controlInfo = FindControlInfo(aControlInfo->ControlID());
       
   182     if (controlInfo)
       
   183         {
       
   184         RmoveControlInfo(controlInfo->ControlID());
       
   185         }
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------
       
   189 // Remove a control info from info list based on control id
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CAknFepVkbImLayout::RmoveControlInfo(const TInt aControlID)
       
   193     {
       
   194     const TInt count = iControlInfoList.Count();
       
   195 
       
   196     for (TInt i = 0; i < count; i++)
       
   197         {
       
   198         if (iControlInfoList[i]->ControlID() == aControlID)
       
   199             {
       
   200             CAknFepControlInfo* controlInfo = iControlInfoList[i];
       
   201             delete controlInfo;
       
   202             iControlInfoList.Remove(i);
       
   203             break;
       
   204             }
       
   205         }      
       
   206     }
       
   207 
       
   208 //  End Of File