fep/aknfep/src/AknFepUiInputStateJapanesePredictiveBase.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:            Provides the
       
    15 *                TAknFepUiInputStateJapanesePredictiveBase methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include "AknFepUiInputStateJapanesePredictiveBase.h"
       
    32 #include "AknFepUIManagerStateInterface.h"  // MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"       // MAknFepManagerUIInterface
       
    34 #include "AknFepUICtrlContainerJapanese.h"  // MAknFepUICtrlContainerJapanese
       
    35 #include "AknFepUICtrlCandidatePaneInterface.h"
       
    36                                         // MAknFepUICtrlCandidatePaneInterface
       
    37 #include "AknFepGlobalEnums.h"
       
    38 #include "AknFepPanic.h"                                       
       
    39 #include <PtiDefs.h>                    // keys
       
    40 #include <PtiEngine.h>
       
    41 #include <PtiCompositionDataIF.h>       // MPtiEngineCompositionDataInterface
       
    42 #include <aknfep.rsg>
       
    43 
       
    44 
       
    45 // CONSTANTS
       
    46 
       
    47 /**
       
    48  *  TAknFepUiInputStateJapanesePredictiveBase class.
       
    49  * 
       
    50  */
       
    51 //============================ MEMBER FUNCTIONS ==============================
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // TAknFepUiInputStateJapanesePredictiveBase::
       
    55 //                      TAknFepUiInputStateJapanesePredictiveBase
       
    56 // C++ default Constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 TAknFepUiInputStateJapanesePredictiveBase::
       
    60     TAknFepUiInputStateJapanesePredictiveBase(
       
    61                                 MAknFepUIManagerStateInterface* aOwner,
       
    62                                 MAknFepUICtrlContainerJapanese* aUIContainer)
       
    63     :TAknFepUiInputStateJapaneseBase(aOwner, aUIContainer)
       
    64     {
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // TAknFepUiInputStateJapanesePredictiveBase::CloseUI
       
    69 // Closing UI
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void TAknFepUiInputStateJapanesePredictiveBase::CloseUI()
       
    73     {
       
    74     MAknFepUICtrlContainerJapanese* uicontainer = UIContainer();
       
    75     MAknFepUICtrlCandidatePaneInterface* predictivePane =
       
    76         uicontainer->CandidatePane(MAknFepUICtrlContainerJapanese::
       
    77                                    EJapanesePredictiveCandidatePane);
       
    78     // Closeing candidate pop-up list
       
    79     predictivePane->HideWindow();
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // TAknFepUiInputStateJapanesePredictiveBase::HandleNumericLongKeyL
       
    84 // Handling Numeric long keypress event
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 TBool TAknFepUiInputStateJapanesePredictiveBase::HandleNumericLongKeyL(TInt /*aKey*/)
       
    88     {
       
    89     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
    90     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
    91     // Not handling long keypress events if exist transitory input string
       
    92     TPtrC text = data->ConvertingString();
       
    93     if (text.Length() > 1)
       
    94         {
       
    95         return ETrue;
       
    96         }
       
    97     // Long keypress events are handled by HandleNumericLongKeyL of
       
    98     // CompletionState
       
    99     iOwner->ChangeState(EMultiCompletion);
       
   100     return EFalse;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // TAknFepUiInputStateJapanesePredictiveBase::HandleNaviKeyL
       
   105 // Handling Navigate keypress event
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 TBool TAknFepUiInputStateJapanesePredictiveBase::
       
   109   HandleNaviKeyL(TInt aKey, TKeyPressLength /*aLength*/)
       
   110     {
       
   111     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   112     MAknFepUICtrlContainerJapanese* uicontainer = UIContainer();
       
   113     MAknFepUICtrlCandidatePaneInterface* predictivePane =
       
   114         uicontainer->CandidatePane(MAknFepUICtrlContainerJapanese::
       
   115                                    EJapanesePredictiveCandidatePane);
       
   116     TBool ret = EFalse;
       
   117 	if (predictivePane->CurrentItemIndexOfCandidate() > -1)
       
   118 		{
       
   119 	    TAknFepUICtrlScroll direction = EScrollNone;
       
   120 
       
   121 	    // move hightlight of candidate in cadidate pop-up list
       
   122 	    switch(aKey)
       
   123 	        {
       
   124 	        case EKeyLeftArrow:
       
   125 	        case EStdKeyLeftArrow:      /* 0x0e */
       
   126 	            {
       
   127 	            direction = EScrollLeft;
       
   128 	            }
       
   129 	            break;
       
   130 	        case EKeyRightArrow:
       
   131 	        case EStdKeyRightArrow:     /* 0x0f */
       
   132 	            {
       
   133 	            direction = EScrollRight;
       
   134 	            }
       
   135 	            break;
       
   136 	        case EKeyDownArrow:
       
   137 	        case EStdKeyDownArrow:      /* 0x11 */
       
   138 	            {
       
   139 	            direction = EScrollDown;
       
   140 	            }
       
   141 	            break;
       
   142 	        case EKeyUpArrow:
       
   143 	        case EStdKeyUpArrow:        /* 0x10 */
       
   144 	            {
       
   145 	            direction = EScrollUp;
       
   146 	            }
       
   147 	            break;
       
   148 	        default:
       
   149 	            break;
       
   150 	        }
       
   151 	    
       
   152 	    predictivePane->MoveItem(direction);
       
   153 	    TInt index = predictivePane->CurrentItemIndexOfCandidate();
       
   154 	    ptiEngine->HandleCommandL(EPtiCommandUserActionSetCurrentIndexOfCandidates ,&index);
       
   155 	    ret = ETrue;
       
   156 		}
       
   157     return ret;
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // TAknFepUiInputStateJapanesePredictiveBase::UpdateInlineEditingCharacterL
       
   162 // Update inline editing string
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 TBool TAknFepUiInputStateJapanesePredictiveBase::UpdateInlineEditingCharacterL()
       
   166     {
       
   167     TBool ret = EFalse;
       
   168     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   169     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   170     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   171     // Check ComposirionData
       
   172     __ASSERT_DEBUG(data->CompletedString().Length() <= 0,
       
   173         RDebug::Print(_L("In TAknFepUiInputStateJapanesePredictiveBase::UpdateInlineEditingCharacterL,\nINVALID DATA: CompletedString. CompletedString was not OperaOperated!")));
       
   174     
       
   175     TPtrC text = data->ConvertingString();
       
   176 
       
   177     if (text.Length() > 0)
       
   178         {
       
   179         // Update of inline editing characters
       
   180         fepMan->UpdateInlineEditL(text, text.Length());
       
   181         ret = ETrue;
       
   182         }
       
   183     else
       
   184         {
       
   185         // Check ConvertingString length
       
   186         __ASSERT_DEBUG(text.Length() == 0,
       
   187             RDebug::Print(
       
   188                _L("In TAknFepUiInputStateJapanesePredictiveBase::UpdateInlineEditingCharacterL,\nINVALID DATA: ConvertingString. Roll back to initial State!")));
       
   189         
       
   190         MAknFepUICtrlContainerJapanese* uicontainer = UIContainer();
       
   191         MAknFepUICtrlCandidatePaneInterface* predictivePane =
       
   192             uicontainer->CandidatePane(MAknFepUICtrlContainerJapanese::
       
   193                                        EJapanesePredictiveCandidatePane);
       
   194         ptiEngine->ClearCurrentWord();
       
   195         fepMan->CancelInlineEdit();
       
   196         predictivePane->HideWindow();
       
   197         iOwner->ChangeState(EInitial);
       
   198         
       
   199         }
       
   200     
       
   201     return ret;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // TAknFepUiInputStateJapanesePredictiveBase::UpdateCandidateListL
       
   206 // 
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 TBool TAknFepUiInputStateJapanesePredictiveBase::UpdateCandidateListL(TInt aIndex /*= 0*/)
       
   210     {
       
   211     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   212     CPtiEngine* ptiEngine = iOwner->PtiEngine();
       
   213     CDesCArrayFlat* candidateArray = iOwner->CandidateArray();
       
   214     MAknFepUICtrlContainerJapanese* uicontainer = UIContainer();
       
   215     MAknFepUICtrlCandidatePaneInterface* predictivePane =
       
   216         uicontainer->CandidatePane(MAknFepUICtrlContainerJapanese::
       
   217                                    EJapanesePredictiveCandidatePane);
       
   218     const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData();
       
   219     // Get coordinate of input area
       
   220     TPoint  leftSideOfBaseLine;
       
   221     TInt    height;
       
   222     TInt    ascent;
       
   223     TInt    documentOffset = data->CursorPosition() > 0 ? data->CursorPosition() : 0;
       
   224     
       
   225     fepMan->GetScreenCoordinatesL(leftSideOfBaseLine,
       
   226                                   height,
       
   227                                   ascent,
       
   228                                   documentOffset);
       
   229     // show candidate pop-up list
       
   230     predictivePane->SetWindowPosition(leftSideOfBaseLine, height, ascent);            
       
   231     predictivePane->ShowCandidateListL(candidateArray, aIndex, iCbaResourceID);
       
   232     return ETrue;
       
   233     }
       
   234 // End of file