fep/aknfep/src/AknFepVietnameseToneManager.cpp
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2009 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:          
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 #include "AknFepVietnameseToneManager.h"
       
    28 #include "AknFepManager.h"
       
    29 
       
    30 
       
    31 CAknFepVietnameseToneManager::CAknFepVietnameseToneManager()
       
    32     {
       
    33     }
       
    34 
       
    35 CAknFepVietnameseToneManager::~CAknFepVietnameseToneManager()
       
    36     {
       
    37     }
       
    38 
       
    39 CAknFepVietnameseToneManager* CAknFepVietnameseToneManager::NewL()
       
    40     {
       
    41     CAknFepVietnameseToneManager* self = new (ELeave) CAknFepVietnameseToneManager;
       
    42     CleanupStack::PushL(self);
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop();
       
    45     return self;
       
    46     }
       
    47 
       
    48 void CAknFepVietnameseToneManager::ConstructL()
       
    49     {
       
    50     }
       
    51 
       
    52 void CAknFepVietnameseToneManager::StopToneMarkLooping()
       
    53     {
       
    54     iToneIndex = 0;
       
    55     iVowelIndex = 0;
       
    56     iIsLooping = EFalse;
       
    57     }
       
    58 
       
    59 TBool CAknFepVietnameseToneManager::StartToneMarkLooping()
       
    60     {
       
    61     __ASSERT_DEBUG(iFepMan != NULL, 
       
    62         RDebug::Print(
       
    63         _L("In CAknFepVietnameseToneManager::StartLooping,\nINVALID PARAM: Empty Fep Manager!")));
       
    64 
       
    65     StopToneMarkLooping();
       
    66 
       
    67     const TText prevChr = iFepMan->PreviousChar();
       
    68     
       
    69     // Judge if the prevChr is a vowel or not
       
    70     for (TUint i = 0; i < sizeof(VietVowelList) / sizeof(TText); ++i)
       
    71         {
       
    72         if (prevChr == VietVowelList[i])
       
    73             {
       
    74             iIsLooping = ETrue;
       
    75             iVowelIndex = i;
       
    76             break;
       
    77             }
       
    78         }
       
    79 
       
    80     return iIsLooping;
       
    81     }
       
    82 
       
    83 TText CAknFepVietnameseToneManager::GetVowelWithToneMark() const
       
    84     {
       
    85     // First vowel row lists those tone marks themselves
       
    86     return VietToneMatrix[iVowelIndex+1][iToneIndex];
       
    87     }
       
    88 
       
    89 void CAknFepVietnameseToneManager::StartKeyLooping(TInt aKey)
       
    90     {
       
    91     iLoopingKey = aKey;
       
    92     iIsKeyLooping = ETrue;
       
    93     iIsLoopingCombined = EFalse;
       
    94     }
       
    95 
       
    96 void CAknFepVietnameseToneManager::StopKeyLooping()
       
    97     {
       
    98     iLoopingKey = 0;
       
    99     iIsKeyLooping = EFalse;
       
   100     iIsLoopingCombined = EFalse;
       
   101     }
       
   102 
       
   103 TInt CAknFepVietnameseToneManager::ToneMarkIndex() const
       
   104     {
       
   105     const TText prevChr = iFepMan->PreviousChar();
       
   106 
       
   107     // All tone mark is after number in product key mapping.
       
   108     // Notice: The order in product key mapping should be the same with in tone mark array. 
       
   109     for (TUint i = 0; i < KNumberOfToneMarks; ++i)
       
   110         {
       
   111         TBuf<1> num;
       
   112         num.Num( i + 2 );
       
   113         if (prevChr == num [0])
       
   114             {
       
   115             return i;
       
   116             }
       
   117         }
       
   118     
       
   119     return KErrNotFound;
       
   120     }
       
   121 
       
   122 TBool CAknFepVietnameseToneManager::GetLoopingToneMarkVowel( TText& aText ) const
       
   123     {
       
   124     const TText prev2prevChr = iFepMan->PreviousToPreviousChar( ETrue );
       
   125 
       
   126     // Judge if the previous to previous Character is a vowel or not
       
   127     TInt vowelIndex = KErrNotFound;
       
   128     for (TUint i = 0; i < sizeof(VietVowelList) / sizeof(TText); ++i)
       
   129         {
       
   130         if ( prev2prevChr == VietVowelList[i] )
       
   131             {
       
   132             vowelIndex = i;
       
   133             break;
       
   134             }
       
   135         }
       
   136     
       
   137     if (vowelIndex >= 0)
       
   138         {
       
   139         aText =  VietToneMatrix[vowelIndex+1][ ToneMarkIndex() ];
       
   140         return ETrue;
       
   141         }
       
   142     
       
   143     return EFalse;
       
   144     }
       
   145