fep/aknfep/src/AknFepUIInputStatePredictiveInputMiniQwertyChinesePhrase.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2002-2005 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:            Implementation of predictive input phrase state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #include "AknFepUICtrlCandidatePane.h"
       
    30 #include "AknFepUiInputStatePredictiveInputMiniQwertyChinesePhrase.h"
       
    31 #include "AknFepUiCtrlContainerChinese.h"
       
    32 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    34 #include "aknfepuictrleditpane.h"
       
    35 
       
    36 #include <PtiEngine.h>                      //CPtiEngine
       
    37 
       
    38 TAknFepInputStatePredictiveInputMiniQwertyChinesePhrase::
       
    39 TAknFepInputStatePredictiveInputMiniQwertyChinesePhrase(
       
    40                                 MAknFepUIManagerStateInterface* aOwner,
       
    41                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    42     :TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer)
       
    43     {
       
    44     iState = EPredictiveInput;
       
    45     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    46     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    47 
       
    48     candidatePane->SelectFirstPhrase(); 
       
    49 
       
    50     TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
    51                             uiContainer->CandidatePane()->IsFirstPage());
       
    52     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    53     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    54 
       
    55     UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
    56     UIContainer()->ShowVerticalScrollArrows(multiplePages);
       
    57     uiContainer->FocusCandidatePane(ETrue);
       
    58     candidatePane->ShowCandidateOrdinals(ETrue);
       
    59     UpdateIndicator();
       
    60     }
       
    61 
       
    62 TBool TAknFepInputStatePredictiveInputMiniQwertyChinesePhrase::HandleKeyL(TInt aKey, 
       
    63                                                                           TKeyPressLength aLength)
       
    64     {  
       
    65     TInt selected = UIContainer()->CandidatePane()->SelectedIndex();
       
    66     TInt numbertotal = UIContainer()->CandidatePane()->VisibleCandidateCount();
       
    67     
       
    68     if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
    69         {
       
    70     	return ETrue;
       
    71         }
       
    72     else if (iOwner->FepMan()->FnKeyState())
       
    73         {
       
    74         return ETrue;
       
    75         }
       
    76     else if(aKey == EStdKeyBackspace )
       
    77         {
       
    78         iOwner->FepMan()->TryCloseUiL();
       
    79         return ETrue;
       
    80         }               
       
    81     else if (aKey ==EKeyRightFunc)//fn key
       
    82     	{
       
    83     	iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
    84     	return ETrue;
       
    85     	} 
       
    86     else if ( aKey ==EStdKeySpace)
       
    87     	{
       
    88     	if (ECangJie ==iOwner->FepMan()->InputMode())
       
    89     		{
       
    90     		TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
    91 	        if(text.Length())
       
    92 	            {            
       
    93 	            MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    94 	            fepMan->NewTextL(text);
       
    95 	            fepMan->CommitInlineEditL();
       
    96 	            iOwner->PtiEngine()->SetPredictiveChineseChar(text);
       
    97 	            if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
    98 	                {
       
    99 	                fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   100 	                iOwner->FepMan()->TryCloseUiL();
       
   101 	                }
       
   102 	            else
       
   103 	                {
       
   104 	                iOwner->ChangeState(EPredictiveCandidate);
       
   105 	                }
       
   106 	            }
       
   107 	        return ETrue;
       
   108     		}
       
   109     	else 
       
   110     		{
       
   111             return ETrue; 
       
   112     		}
       
   113     	}	 	           
       
   114     else if ( aKey == EKeyLeftShift || aKey == EKeyRightShift)
       
   115         {
       
   116 //        iOwner->FepMan()->TryCloseUiL();
       
   117 //        return EFalse;
       
   118         iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   119         return ETrue;
       
   120         }      
       
   121     else if ( aKey == EStdKeyDevice0 || aKey == EStdKeyDevice3 || aKey == EStdKeyEnter )
       
   122         {
       
   123         TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   124         if(text.Length())
       
   125             {            
       
   126             MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   127             fepMan->NewTextL(text);
       
   128             fepMan->CommitInlineEditL();
       
   129             iOwner->PtiEngine()->SetPredictiveChineseChar(text);
       
   130             if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
   131                 {
       
   132                 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   133                 iOwner->FepMan()->TryCloseUiL();
       
   134                 }
       
   135             else
       
   136                 {
       
   137                 iOwner->ChangeState(EPredictiveCandidate);
       
   138                 UIContainer()->EditPaneWindow()->SetChangeState(ETrue);
       
   139                 }
       
   140             }
       
   141         return ETrue;
       
   142         }   
       
   143     else if (aKey == EStdKeyLeftArrow)//in the same row
       
   144         {
       
   145         if (selected == 0)
       
   146            {
       
   147        	    UIContainer()->CandidatePane()->SelectIndex(numbertotal-1);
       
   148            }
       
   149         else
       
   150            {
       
   151        	    UIContainer()->CandidatePane()->SelectIndex(selected - 1);
       
   152            } 
       
   153         UIContainer()->CandidatePane()->SetHighlighted(ETrue);     
       
   154         return ETrue;	
       
   155         }
       
   156     else if (aKey == EStdKeyRightArrow)//in the same row
       
   157         {
       
   158     	if (selected == numbertotal-1)
       
   159     		{
       
   160        	    UIContainer()->CandidatePane()->SelectIndex(0);
       
   161     		}
       
   162     	else
       
   163     		{
       
   164        	    UIContainer()->CandidatePane()->SelectIndex(selected + 1);
       
   165     		}
       
   166     	UIContainer()->CandidatePane()->SetHighlighted(ETrue);     
       
   167         return ETrue;		
       
   168         }        
       
   169     else
       
   170         {
       
   171         return TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   172         } 
       
   173    // return EFalse;       
       
   174     } 
       
   175   
       
   176 // ---------------------------------------------------------------------------
       
   177 // TAknFepInputStatePredictiveInputMiniQwertyChinesePhrase::HandleCommandL
       
   178 // Handling Command
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void TAknFepInputStatePredictiveInputMiniQwertyChinesePhrase::HandleCommandL(
       
   182     TInt aCommandId )
       
   183     {
       
   184     TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   185     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   186     switch ( aCommandId )
       
   187         {
       
   188         // Handle the event frome command.
       
   189     case EAknSoftkeySelect:
       
   190         //    case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA            
       
   191         if ( text.Length() )
       
   192             {
       
   193             fepMan->NewTextL( text );
       
   194             fepMan->CommitInlineEditL();
       
   195             iOwner->PtiEngine()->SetPredictiveChineseChar( text );
       
   196             if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   197                 {
       
   198                 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   199                 iOwner->FepMan()->TryCloseUiL();
       
   200                 }
       
   201             else
       
   202                 {
       
   203                 iOwner->ChangeState( EPredictiveCandidate );
       
   204                 }
       
   205             }
       
   206         break;
       
   207     default:
       
   208         TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   209         break;
       
   210     }
       
   211 }
       
   212 // End of file