fep/aknfep/src/AknFepUiInputStateCompletionHiraganaKanji.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     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 TAknFepUiInputStateCompletionHiraganaKanji methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include "AknFepUiInputStateCompletionHiraganaKanji.h"
       
    32 #include "AknFepUIManagerStateInterface.h"   // MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"        // MAknFepManagerUIInterface
       
    34 #include "AknFepUICtrlCandidatePaneInterface.h"
       
    35                                         // MAknFepUICtrlCandidatePaneInterface
       
    36 #include "AknFepUICtrlContainerJapanese.h"
       
    37 #include "AknFepGlobalEnums.h"
       
    38 #include "AknFepManager.h"
       
    39 
       
    40 #include <PtiDefs.h>                     // keys
       
    41 #include <PtiEngine.h>
       
    42 #include <PtiCompositionDataIF.h>        // MPtiEngineCompositionDataInterface
       
    43 
       
    44 /**
       
    45  *  TAknFepUiInputStateCompletionHiraganaKanji class.
       
    46  * 
       
    47  */
       
    48 //============================ MEMBER FUNCTIONS ==============================
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // TAknFepUiInputStateCompletionHiraganaKanji::
       
    52 //                                  TAknFepUiInputStateCompletionHiraganaKanji
       
    53 // C++ default Constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TAknFepUiInputStateCompletionHiraganaKanji::
       
    57     TAknFepUiInputStateCompletionHiraganaKanji(
       
    58                                     MAknFepUIManagerStateInterface* aOwner,
       
    59                                     MAknFepUICtrlContainerJapanese* aUIContainer)
       
    60     :TAknFepUiInputStateCompletionJapaneseMultitap(aOwner, aUIContainer)
       
    61     {
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // TAknFepUiInputStateCompletionHiraganaKanji::HandleNumericShortKeyL
       
    66 // Handling short keypress events of the numeric and the star.
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TBool TAknFepUiInputStateCompletionHiraganaKanji::HandleNumericShortKeyL(TInt aKey)
       
    70     {
       
    71     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    72     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
    73     TBool ret = CommitInlineEditingCharacterL();
       
    74     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
    75     TPtrC text = data->ConvertingString();
       
    76     if (text.Length() > 0)
       
    77         { // for last character is space or line feed
       
    78         iOwner->ChangeState(EInitial);
       
    79         fepMan->SimulateKeyEventL(aKey, ETrue);
       
    80         ret = ETrue;
       
    81         }
       
    82     else
       
    83         {
       
    84         iOwner->ChangeState(EInitial);
       
    85         if (iOwner->IsQwerty())
       
    86             {
       
    87             if (IsQwertyKey(aKey) && aKey != EStdKeySpace)
       
    88                 {
       
    89                 // Run on aKey if pressing qwerty key.
       
    90                 ret = EFalse;
       
    91                 }
       
    92             }
       
    93         else
       
    94             {
       
    95             if (IsNumberKey(aKey))
       
    96                 {
       
    97                 // Run on aKey if pressing number key.
       
    98                 ret = EFalse;
       
    99                 }
       
   100             }
       
   101         }
       
   102 
       
   103     return ret;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // TAknFepUiInputStateCompletionHiraganaKanji::HandleNumericLongKeyL
       
   108 // Handling Numeric long keypress event
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 TBool TAknFepUiInputStateCompletionHiraganaKanji::HandleNumericLongKeyL(TInt aKey)
       
   112     {
       
   113     TBool ret = EFalse;
       
   114     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   115     ret = ProcessNumericLongKeyPressL(aKey);
       
   116     if (iOwner->IsPredictive() && fepMan->EditorHasFreeSpace())
       
   117         {
       
   118         iOwner->ChangeState(ENextWord);
       
   119         }
       
   120     else
       
   121         {
       
   122         iOwner->ChangeState(EInitial);
       
   123         }
       
   124     return ret;
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // TAknFepUiInputStateCompletionHiraganaKanji::HandleAuxKeyL
       
   129 // Handling auxiliary keypress events including OK and Backspace
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 TBool TAknFepUiInputStateCompletionHiraganaKanji::HandleAuxKeyL(TInt aKey,
       
   133                                                                 TKeyPressLength aLength)
       
   134     {
       
   135     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   136     TPtiEngineCommand ptiCommand = EPtiCommandUserActionAllComplete;
       
   137 
       
   138     if (aKey == EKeyOK 
       
   139      || aKey == EStdKeyDevice3          /* 0xA7 */
       
   140      || aKey == EStdKeyEnter
       
   141      || aKey == EStdKeyNkpEnter)
       
   142         {
       
   143         if (aLength == EShortKeyPress)
       
   144             {
       
   145             ptiCommand = EPtiCommandUserActionComplete;
       
   146             }
       
   147         ptiEngine->HandleCommandL(ptiCommand);
       
   148 
       
   149         UpdateInlineEditingCharacterL();
       
   150         return ETrue;
       
   151         }
       
   152     return EFalse;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // TAknFepUiInputStateCompletionHiraganaKanji::UpdateInlineEditingCharacterL
       
   157 // Update inline editing string
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 TBool TAknFepUiInputStateCompletionHiraganaKanji::UpdateInlineEditingCharacterL()
       
   161     {
       
   162     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   163     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   164     TBool ret = EFalse;
       
   165 
       
   166     TBool isnextwordchar = !fepMan->IsFlagSet(CAknFepManager::EFlagLineFeedCharacter
       
   167                                     | CAknFepManager::EFlagSpaceCharacter
       
   168                                     | CAknFepManager::EFlagFullWidthSpaceCharacter);
       
   169     
       
   170     if(CommitInlineEditingCharacterL())
       
   171         {
       
   172         const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   173         TPtrC text = data->ConvertingString();
       
   174         TInt cursorpos = data->CursorPosition();
       
   175         if (text.Length() > 0)
       
   176             {
       
   177             if (fepMan->EditorHasFreeSpace())
       
   178                 {
       
   179                 if (data->NumberOfPhrase() > 0)
       
   180                     {
       
   181                     TPtrC8 clauseChar = data->LengthOfPhrase();
       
   182                     cursorpos = clauseChar[0];
       
   183                     }
       
   184                 iOwner->ChangeState(EConversion);
       
   185                 fepMan->StartInlineEditL();
       
   186                 fepMan->UpdateInlineEditL(text, cursorpos);
       
   187                 }
       
   188             else
       
   189                 {
       
   190                 iOwner->ChangeState(EInitial);
       
   191                 }
       
   192             }
       
   193         else
       
   194             {
       
   195             __ASSERT_DEBUG(text.Length() == 0,
       
   196                 RDebug::Print(
       
   197                    _L("In TAknFepUiInputStateCompletionJapaneseMultitap::UpdateInlineEditingCharacterL,\nINVALID DATA: ConvertingString. Roll back to initial State!")));
       
   198             ptiEngine->ClearCurrentWord();
       
   199             if(iOwner->IsPredictive()
       
   200             && (fepMan->EditorHasFreeSpace() && isnextwordchar) )
       
   201                 {
       
   202                 iOwner->ChangeState(ENextWord);
       
   203                 }
       
   204             else
       
   205                 {
       
   206                 MAknFepUICtrlContainerJapanese* uicontainer = UIContainer();
       
   207                 MAknFepUICtrlCandidatePaneInterface* predictivePane =
       
   208                 uicontainer->CandidatePane(MAknFepUICtrlContainerJapanese::EJapanesePredictiveCandidatePane);
       
   209                 // Closeing candidate pop-up list
       
   210                 predictivePane->HideWindow();
       
   211                 iOwner->ChangeState(EInitial);
       
   212                 }
       
   213             }
       
   214 
       
   215         ret = ETrue;
       
   216         }
       
   217     
       
   218     return ret;
       
   219     }
       
   220 // End of file