fep/aknfep/src/AknFepUiInputStateCompletionJapaneseMultitap.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 TAknFepUiInputStateCompletionJapaneseMultitap methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include "AknFepUiInputStateCompletionJapaneseMultitap.h"
       
    32 #include "AknFepUIManagerStateInterface.h"   // MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"        // MAknFepManagerUIInterface
       
    34 #include "AknFepGlobalEnums.h"
       
    35 #include "AknFepPanic.h"
       
    36 #include "AknFepManager.h"                   // CAknFepCaseManager
       
    37 
       
    38 #include <PtiDefs.h>                     // keys
       
    39 #include <PtiEngine.h>
       
    40 #include <PtiCompositionDataIF.h>        // MPtiEngineCompositionDataInterface
       
    41 
       
    42 // CONSTANTS
       
    43 
       
    44 /**
       
    45  *  TAknFepUiInputStateCompletionJapaneseMultitap class.
       
    46  * 
       
    47  */
       
    48 //============================ MEMBER FUNCTIONS ==============================
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // TAknFepUiInputStateCompletionJapaneseMultitap::
       
    52 //                              TAknFepUiInputStateCompletionJapaneseMultitap
       
    53 // C++ default Constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TAknFepUiInputStateCompletionJapaneseMultitap::
       
    57     TAknFepUiInputStateCompletionJapaneseMultitap(
       
    58                                     MAknFepUIManagerStateInterface* aOwner,
       
    59                                     MAknFepUICtrlContainerJapanese* aUIContainer)
       
    60     :TAknFepUiInputStateJapaneseBase(aOwner, aUIContainer)
       
    61     {
       
    62     iState = EMultiCompletion;
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // TAknFepUiInputStateCompletionJapaneseMultitap::HandleCommandL
       
    68 // Handling Command
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void TAknFepUiInputStateCompletionJapaneseMultitap::HandleCommandL(TInt aCommandId)
       
    72     {
       
    73     if (aCommandId == EAknFepAllCompletion)
       
    74         {
       
    75         iOwner->PtiEngine()->HandleCommandL(EPtiCommandUserActionAllComplete);
       
    76         CommitInlineEditingCharacterL();
       
    77         iOwner->ChangeState(EInitial);
       
    78         }
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // TAknFepUiInputStateCompletionJapaneseMultitap::HandleNumericShortKeyL
       
    83 // Handling short keypress events of the numeric and the star.
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 TBool TAknFepUiInputStateCompletionJapaneseMultitap::HandleNumericShortKeyL(TInt /*aKey*/)
       
    87     {
       
    88     return UpdateInlineEditingCharacterL();
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // TAknFepUiInputStateCompletionJapaneseMultitap::HandleNaviKeyL
       
    93 // Handling Navigate keypress event
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 TBool TAknFepUiInputStateCompletionJapaneseMultitap::HandleNaviKeyL(TInt /*aKey*/,
       
    97                                                                     TKeyPressLength /*aLength*/)
       
    98     {
       
    99     return UpdateInlineEditingCharacterL();
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // TAknFepUiInputStateCompletionJapaneseMultitap::HandleAuxKeyL
       
   104 // Handling auxiliary keypress events including OK and Backspace
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 TBool TAknFepUiInputStateCompletionJapaneseMultitap::HandleAuxKeyL(TInt aKey,
       
   108                                                                    TKeyPressLength aLength)
       
   109     {
       
   110     TBool ret = ETrue;
       
   111     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   112 
       
   113     if (aKey == EKeyOK
       
   114      || aKey == EStdKeyDevice3          /* 0xA7 */
       
   115      || aKey == EStdKeyEnter
       
   116      || aKey == EStdKeyNkpEnter)
       
   117         {
       
   118         TPtiEngineCommand ptiCommand = EPtiCommandUserActionComplete;
       
   119         if (aLength == ELongKeyPress)
       
   120             {
       
   121             ptiCommand = EPtiCommandUserActionAllComplete;
       
   122             }
       
   123         ptiEngine->HandleCommandL(ptiCommand);
       
   124         ret = UpdateInlineEditingCharacterL();
       
   125         }
       
   126 
       
   127     return ret;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // TAknFepUiInputStateCompletionJapaneseMultitap::HandleNumericLongKeyL
       
   132 // Handling Numeric long keypress event
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 TBool TAknFepUiInputStateCompletionJapaneseMultitap::HandleNumericLongKeyL(TInt aKey)
       
   136     {
       
   137     TBool ret = ProcessNumericLongKeyPressL(aKey);
       
   138     iOwner->ChangeState(EInitial);
       
   139     return ret;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // TAknFepUiInputStateCompletionJapaneseMultitap::UpdateInlineEditingCharacterL
       
   144 // Update inline editing string
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 TBool TAknFepUiInputStateCompletionJapaneseMultitap::UpdateInlineEditingCharacterL()
       
   148     {
       
   149     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   150     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   151     TBool ret = EFalse;
       
   152     
       
   153     if(CommitInlineEditingCharacterL())
       
   154         {
       
   155         const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   156         TPtrC text = data->ConvertingString();
       
   157         TInt cursorpos = data->CursorPosition();
       
   158         if (text.Length() > 0)
       
   159             {
       
   160             if (data->NumberOfPhrase() > 0)
       
   161                 {
       
   162                 TPtrC8 clauseChar = data->LengthOfPhrase();
       
   163                 cursorpos = clauseChar[0];
       
   164                 }
       
   165             iOwner->ChangeState(EEntry);
       
   166             fepMan->StartInlineEditL();
       
   167             fepMan->UpdateInlineEditL(text, cursorpos);
       
   168             }
       
   169         else
       
   170             {
       
   171             __ASSERT_DEBUG(text.Length() == 0,
       
   172                 RDebug::Print(
       
   173                    _L("In TAknFepUiInputStateCompletionJapaneseMultitap::UpdateInlineEditingCharacterL,\nINVALID DATA: ConvertingString. Roll back to initial State!")));
       
   174             ptiEngine->ClearCurrentWord();
       
   175             iOwner->ChangeState(EInitial);
       
   176             }
       
   177 
       
   178         ret = ETrue;
       
   179         }
       
   180     
       
   181     return ret;
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // TAknFepUiInputStateCompletionJapaneseMultitap::CommitInlineEditingCharacterL
       
   186 // Commit inline editing string
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 TBool TAknFepUiInputStateCompletionJapaneseMultitap::CommitInlineEditingCharacterL()
       
   190     {
       
   191     TBool ret = EFalse;
       
   192     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   193     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   194     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   195     TPtrC text = data->CompletedString();
       
   196     if (text.Length() > 0)
       
   197         {
       
   198         fepMan->CommitInlineEditL(text, text.Length());
       
   199         ret = ETrue;
       
   200         }
       
   201     return ret;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // TAknFepUiInputStateCompletionJapaneseMultitap::ProcessNumericLongKeyPressL
       
   206 // 
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 TBool TAknFepUiInputStateCompletionJapaneseMultitap::ProcessNumericLongKeyPressL(TInt aKey)
       
   210     {
       
   211     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   212     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   213     TBool ret = EFalse;
       
   214 
       
   215     ptiEngine->DeleteKeyPress();
       
   216 
       
   217     if (!iOwner->IsQwerty()
       
   218      && fepMan->IsSupportsSecretText()
       
   219      && fepMan->IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
   220         {
       
   221         iOwner->PtiEngine()->ClearCurrentWord();
       
   222         TPtiEngineCommand cmd = (TPtiEngineCommand)(EPtiCommandUserActionCompleteHalf0 + (aKey - '0'));
       
   223         ptiEngine->HandleCommandL(cmd);
       
   224         const MPtiEngineCompositionDataInterface* srcretdata = ptiEngine->CompositionData();
       
   225         TPtrC srcrettext = srcretdata->CompletedString();
       
   226         if (srcrettext.Length() > 0)
       
   227             {
       
   228             TBuf<1> buf;
       
   229             buf.Append(srcrettext[0]);
       
   230 
       
   231             // if the previous character is the special character (line feed or space),
       
   232             // it is necessary to clear the flag.
       
   233             TInt specialcharFlags = CAknFepManager::EFlagLineFeedCharacter
       
   234                                   | CAknFepManager::EFlagSpaceCharacter
       
   235                                   | CAknFepManager::EFlagFullWidthSpaceCharacter;
       
   236             if (fepMan->IsFlagSet(specialcharFlags))
       
   237                 {
       
   238                 fepMan->ClearFlag(specialcharFlags);
       
   239                 }
       
   240 
       
   241             fepMan->NewCharacterL(buf);
       
   242             fepMan->CommitInlineEditL();
       
   243             }
       
   244         ptiEngine->ClearCurrentWord();
       
   245         ret = ETrue;
       
   246         }
       
   247     else
       
   248         {
       
   249     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   250     TPtrC text = data->ConvertingString();
       
   251     if (text.Length() > 0)
       
   252         {
       
   253         ptiEngine->HandleCommandL(EPtiCommandUserActionAllComplete);
       
   254             ret = CommitInlineEditingCharacterL();
       
   255             __ASSERT_DEBUG(ret, AknFepPanic(EAknFepPanicCandidatesEmpty));
       
   256             }
       
   257         else
       
   258             {
       
   259             fepMan->CancelInlineEdit();
       
   260             iOwner->PtiEngine()->ClearCurrentWord();
       
   261             }
       
   262     if (fepMan->EditorHasFreeSpace())
       
   263         {
       
   264         TPtiEngineCommand cmd = (TPtiEngineCommand)(EPtiCommandUserActionCompleteHalf0 + (aKey - '0'));
       
   265 
       
   266             ptiEngine->HandleCommandL(cmd);
       
   267             fepMan->StartInlineEditL();
       
   268             const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   269             TPtrC text = data->CompletedString();
       
   270             if (text.Length() > 0)
       
   271                 {
       
   272                 fepMan->CommitInlineEditL(text, text.Length());
       
   273                 ret = ETrue;
       
   274                 }
       
   275             else
       
   276                 {
       
   277                 ptiEngine->ClearCurrentWord();
       
   278                 fepMan->CancelInlineEdit();
       
   279                 iOwner->ChangeState(EInitial);
       
   280                 }
       
   281             }
       
   282         }
       
   283     return ret;
       
   284     }
       
   285 // End of file