fep/aknfep/src/AknFepUiInputStateEntryLatinJapanese.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2002-2004 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 *       Provides the TAknFepUiInputStateEntryLatinJapanese methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include "AknFepUiInputStateEntryLatinJapanese.h"
       
    32 #include "AknFepUIManagerStateInterface.h"   // MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"        // MAknFepManagerUIInterface
       
    34 #include "AknFepCaseManager.h"               // CAknFepCaseManager
       
    35 #include "AknFepManager.h"
       
    36 #include "AknFepGlobalEnums.h"
       
    37 
       
    38 #include <PtiEngine.h>
       
    39 #include <PtiCompositionDataIF.h>        // MPtiEngineCompositionDataInterface
       
    40 
       
    41 // CONSTANTS
       
    42 
       
    43 /**
       
    44  *  TAknFepUiInputStateEntryLatinJapanese class.
       
    45  *
       
    46  */
       
    47 //============================ MEMBER FUNCTIONS ==============================
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // TAknFepUiInputStateEntryLatinJapanese::
       
    51 //                                  TAknFepUiInputStateEntryLatinJapanese
       
    52 // Default constructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 TAknFepUiInputStateEntryLatinJapanese::TAknFepUiInputStateEntryLatinJapanese(
       
    56                                 MAknFepUIManagerStateInterface* aOwner,
       
    57                                 MAknFepUICtrlContainerJapanese* aUIContainer)
       
    58     :TAknFepUiInputStateEntryJapaneseMultitap(aOwner, aUIContainer)
       
    59     {
       
    60     }
       
    61 
       
    62 /**
       
    63  * MPtiObserver interface.
       
    64  */
       
    65 //============================ MEMBER FUNCTIONS ==============================
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // TAknFepUiInputStateEntryLatinJapanese::KeyTimerExpired
       
    69 // Call this function when Multitap timer of PtiEngine was time-out
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void TAknFepUiInputStateEntryLatinJapanese::KeyTimerExpired()
       
    73     {
       
    74     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
    75     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
    76     TPtrC text = data->CompletedString();
       
    77     if (text.Length() > 0)
       
    78         {
       
    79         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    80 
       
    81         if (fepMan->IsSupportsSecretText()
       
    82          && fepMan->IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
    83             {
       
    84             TRAP_IGNORE(fepMan->CommitInlineEditL());
       
    85             // Update case without Qwerty
       
    86             if (!iOwner->IsQwerty())
       
    87                 {
       
    88                 UpdateCase(text);
       
    89                 }
       
    90             }
       
    91         else
       
    92             {
       
    93             iOwner->ChangeState(EMultiCompletion);
       
    94             // Update case without Qwerty
       
    95             if (!iOwner->IsQwerty())
       
    96                 {
       
    97                 UpdateCase(text);
       
    98                 }
       
    99 
       
   100             // Commit a character
       
   101             TRAP_IGNORE(iOwner->FepMan()->CommitInlineEditL(text, text.Length()));
       
   102 
       
   103             // Update case with Qwerty
       
   104             if (iOwner->IsQwerty())
       
   105                 {
       
   106                 CAknFepCaseManager* caseMan = iOwner->CaseMan();
       
   107                 caseMan->UpdateCase(ENullNaviEvent);
       
   108                 }
       
   109             }
       
   110         }
       
   111     iData = 0;
       
   112     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   113     ptiengine->ClearCurrentWord();
       
   114     iOwner->ChangeState(EInitial);
       
   115    }
       
   116 
       
   117 /**
       
   118 *  TAknFepUiInputStateEntryLatinJapanese class.
       
   119 *
       
   120 */
       
   121 //============================ MEMBER FUNCTIONS ==============================
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // TAknFepUiInputStateEntryLatinJapanese::HandleNumericShortKeyL
       
   125 // Handling short keypress events of the numeric and the star.
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 TBool TAknFepUiInputStateEntryLatinJapanese::HandleNumericShortKeyL(TInt aKey)
       
   129     {
       
   130     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   131     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   132     TBool ret = EFalse;
       
   133 
       
   134     if (iData && iData != aKey)
       
   135         {
       
   136         if (!iOwner->IsQwerty()
       
   137          && iOwner->FepMan()->IsSupportsSecretText()
       
   138          && fepMan->IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
   139             {
       
   140             const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   141             TPtrC text = data->ConvertingString();
       
   142             if (text.Length() > 0)
       
   143                 {
       
   144                 fepMan->CommitInlineEditL();
       
   145                 if (!iOwner->IsQwerty())
       
   146                     {
       
   147                     UpdateCase(text);
       
   148                     }
       
   149                 }
       
   150             ptiEngine->ClearCurrentWord();
       
   151             iOwner->ChangeState(EInitial);
       
   152             iData = 0;
       
   153             ret = EFalse;
       
   154             }
       
   155         else
       
   156             {
       
   157             ptiEngine->HandleCommandL(EPtiCommandUserActionComplete);
       
   158             iOwner->ChangeState(EMultiCompletion);
       
   159             }
       
   160         }
       
   161     else
       
   162         {
       
   163         iData = aKey;
       
   164 
       
   165         const MPtiEngineCompositionDataInterface* previousData = ptiEngine->CompositionData();
       
   166         TChar previousChar = 0;
       
   167         TPtrC previousText(previousData->ConvertingString());
       
   168         if (previousText.Length() > 0)
       
   169             {
       
   170             previousChar = previousText[0];
       
   171             }
       
   172 
       
   173         // Append a key to PtiEngine
       
   174         ptiEngine->AppendKeyPress((TPtiKey)aKey);
       
   175 
       
   176         const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   177         TPtrC text(data->ConvertingString());
       
   178         if (text.Length() > 0)
       
   179             {
       
   180             TChar ch = text[0];
       
   181             TBool validNewCandidate = fepMan->CharIsValidInEditor(ch);
       
   182             // Check if the character is valid for the editor.
       
   183             if ( !validNewCandidate )
       
   184                 {
       
   185                 TChar firstNewCandidate = ch;
       
   186                 TBool goneThroughAllCandidates(EFalse);
       
   187                 TPtrC8 sequence = ptiEngine->CurrentInputSequence();
       
   188 
       
   189                 if ( sequence.Length() )
       
   190                     {
       
   191                     TPtiKey key = (TPtiKey)sequence[0];
       
   192 
       
   193                     // Go through candidates and check if valid characters are found.
       
   194                     do  {
       
   195                         TPtrC text = ptiEngine->AppendKeyPress(key);
       
   196                         ch = text[0];
       
   197                         goneThroughAllCandidates = (ch == firstNewCandidate);
       
   198                         validNewCandidate = fepMan->CharIsValidInEditor(ch);
       
   199                         }
       
   200                     while (!validNewCandidate && !goneThroughAllCandidates);
       
   201                     }
       
   202 
       
   203                 if (!validNewCandidate)
       
   204                     {
       
   205                     // No valid characters at all.
       
   206                     ptiEngine->DeleteKeyPress();
       
   207                     iOwner->ChangeState(EMultiCompletion);
       
   208                     ptiEngine->HandleCommandL(EPtiCommandUserActionComplete);
       
   209                     iOwner->FepMan()->CommitInlineEditL();
       
   210                     ptiEngine->ClearCurrentWord();
       
   211                     iOwner->ChangeState(EInitial);
       
   212                     return ETrue;
       
   213                     }
       
   214                 else if (ch == previousChar)
       
   215                     {
       
   216                     // The valid key loop count is 1.
       
   217                     // The current characters are committed, and send the same key again.
       
   218                     iOwner->ChangeState(EMultiCompletion);
       
   219                     ptiEngine->HandleCommandL(EPtiCommandUserActionComplete);
       
   220                     iOwner->FepMan()->CommitInlineEditL();
       
   221                     ptiEngine->ClearCurrentWord();
       
   222                     iOwner->ChangeState(EInitial);
       
   223                     iOwner->FepMan()->SimulateKeyEventL(aKey, ETrue);
       
   224                     return ETrue;
       
   225                     }
       
   226                 }
       
   227             }
       
   228 
       
   229         ret = UpdateInlineEditingCharacterL();
       
   230         // Qwerty input without Secret input mode is continuing to Comleteion.
       
   231         if (ret && iOwner->IsQwerty())
       
   232             {
       
   233             if (iOwner->FepMan()->IsSupportsSecretText()
       
   234              || iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagPassNextKey))
       
   235                 {
       
   236                 iOwner->ChangeState(EMultiCompletion);
       
   237                 ptiEngine->HandleCommandL(EPtiCommandUserActionComplete);
       
   238                 iOwner->FepMan()->CommitInlineEditL();
       
   239                 ptiEngine->ClearCurrentWord();
       
   240                 iOwner->ChangeState(EInitial);
       
   241                 ret = ETrue;
       
   242                 }
       
   243             else
       
   244                 {
       
   245                 // Qwerty need to change status
       
   246                 ptiEngine->HandleCommandL(EPtiCommandUserActionComplete);
       
   247                 iOwner->ChangeState(EMultiCompletion);
       
   248                 ret = EFalse;
       
   249                 }
       
   250             }
       
   251         }
       
   252     return ret;
       
   253     }
       
   254 // End of file