textinput/peninputsplititut/src/peninputsplititutchnuistatestrokezhuyincomposition.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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:  drop-down list control
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <peninputinputcontextfield.h>
       
    20 #include <PtiEngine.h>
       
    21 #include <peninputdropdownlist.h>
       
    22 #include <peninputcmdparam.h>
       
    23 #include <peninputsplititutnew.rsg>
       
    24 #include <peninputsplititutconfig_chinese.rsg>
       
    25 #include <AknFepGlobalEnums.h>
       
    26 
       
    27 #include "peninputsplititutchnuistatestrokezhuyincomposition.h"
       
    28 #include "peninputsplititutuimgrbase.h"
       
    29 #include "peninputsplititutdatamgr.h"
       
    30 #include "peninputsplititutlayoutcontext.h"
       
    31 #include "peninputsplititutconverter.h"
       
    32 
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS =============================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CChnSplitItutUiStateStrokeZhuyinComposition::NewL
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CChnSplitItutUiStateStrokeZhuyinComposition* CChnSplitItutUiStateStrokeZhuyinComposition::NewL(
       
    41     CSplitItutUiMgrBase* aOwner)
       
    42     {
       
    43     CChnSplitItutUiStateStrokeZhuyinComposition* self = 
       
    44         new (ELeave) CChnSplitItutUiStateStrokeZhuyinComposition(aOwner);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL(); 
       
    47     CleanupStack::Pop(self);
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CChnSplitItutUiStateStrokeZhuyinComposition::~CChnSplitItutUiStateStrokeZhuyinComposition
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CChnSplitItutUiStateStrokeZhuyinComposition::~CChnSplitItutUiStateStrokeZhuyinComposition()
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CChnSplitItutUiStateStrokeZhuyinComposition::CChnSplitItutUiStateStrokeZhuyinComposition
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CChnSplitItutUiStateStrokeZhuyinComposition::CChnSplitItutUiStateStrokeZhuyinComposition(
       
    64     CSplitItutUiMgrBase* aOwner):CSplitItutUiStateBase(aOwner)
       
    65     {
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CChnSplitItutUiStateStrokeZhuyinComposition::OnEntryL
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CChnSplitItutUiStateStrokeZhuyinComposition::OnEntryL()
       
    73     {
       
    74     /*
       
    75     TInt immode = iOwner->DataMgr()->InputMode();
       
    76 
       
    77     if (immode == EStroke)
       
    78         {
       
    79         TInt resID;
       
    80         if (iOwner->DataMgr()->InputLanguage() == ELangPrcChinese)
       
    81             {
       
    82             resID = R_FINGER_INPUT_KEYPAD_STROKE_COMPOSITION_PRC;
       
    83             }
       
    84         else
       
    85             {
       
    86             resID = R_FINGER_INPUT_KEYPAD_STROKE_COMPOSITION_TRA;
       
    87             }        
       
    88         iOwner->DataMgr()->NotifyChangeControlLayout(
       
    89             MItutPropertySubscriber::EItutPropertyKeypadResourceId, 
       
    90             resID);
       
    91         }
       
    92     else if (immode == EZhuyin)
       
    93         {
       
    94         iOwner->DataMgr()->NotifyChangeControlLayout(
       
    95             MItutPropertySubscriber::EItutPropertyKeypadResourceId, 
       
    96             R_FINGER_INPUT_KEYPAD_ZHUYIN_COMPOSITION);
       
    97         }
       
    98 
       
    99     // update resource id of keypad, candidate drop list
       
   100     iOwner->DataMgr()->NotifyChangeControlLayout(
       
   101         MItutPropertySubscriber::EItutPropertyCandidateListResourceId,
       
   102         R_AKN_FEP_NORMAL_CAND_DROP_DOWN_LIST);
       
   103 
       
   104     // show spell
       
   105     CFepInputContextField* spellctrl = 
       
   106         static_cast<CFepInputContextField*>(iOwner->LayoutContext()->Control(ECtrlIdSpellICF));
       
   107     TFepInputContextFieldData spelldata;
       
   108     spelldata.iCmd = EPeninputICFInitial;
       
   109     spelldata.iStartPos = 0;
       
   110     spelldata.iLength = 0;
       
   111     spelldata.iText.Set( KNullDesC );
       
   112     spelldata.iCurSel = TCursorSelection(0, 0);
       
   113     spelldata.iCursorVisibility = ETrue;
       
   114     spelldata.iCursorSelVisible = ETrue;
       
   115     spellctrl->SetTextL(spelldata);
       
   116     spellctrl->Hide(EFalse);
       
   117 
       
   118     // show candidate drop list
       
   119     CFepCtrlDropdownList* candlist = 
       
   120         static_cast<CFepCtrlDropdownList*>(iOwner->LayoutContext()->Control(ECtrlIdStdCandsList));
       
   121     candlist->Hide(EFalse);
       
   122     
       
   123     //hide navi button
       
   124     iOwner->LayoutContext()->ShowArrowBtn(0);
       
   125     
       
   126     //hide indicator 
       
   127     iOwner->LayoutContext()->Control(ECtrlIdIndicator)->Hide(ETrue);
       
   128     */
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // CChnSplitItutUiStateStrokeZhuyinComposition::OnExit
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CChnSplitItutUiStateStrokeZhuyinComposition::OnExit()
       
   136     {
       
   137     /*
       
   138     // hide dropdownlist & reset its status
       
   139     CFepCtrlDropdownList* candlist = 
       
   140         static_cast<CFepCtrlDropdownList*>(iOwner->LayoutContext()->Control(ECtrlIdStdCandsList));
       
   141     candlist->ResetAndClear(CFepCtrlDropdownList::EListExpandable);
       
   142     iOwner->DataMgr()->ClearChnCandidates(EItutCandidates);
       
   143     candlist->Hide(ETrue);
       
   144 
       
   145     CFepInputContextField* spellctrl = 
       
   146         static_cast<CFepInputContextField*>(iOwner->LayoutContext()->Control(ECtrlIdSpellICF));
       
   147 
       
   148     spellctrl->Hide(ETrue);
       
   149 
       
   150     //show navi button
       
   151     iOwner->LayoutContext()->ShowArrowBtn(EBtnArrowLeft | EBtnArrowRight
       
   152              | EBtnArrowUp| EBtnArrowDown);
       
   153     
       
   154     //show indicator 
       
   155     iOwner->LayoutContext()->Control(ECtrlIdIndicator)->Hide(EFalse);
       
   156 
       
   157     iOwner->DataMgr()->PtiEngine()->ClearCurrentWord();
       
   158     */
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CChnSplitItutUiStateStrokeZhuyinComposition::HandleKeyL
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 TBool CChnSplitItutUiStateStrokeZhuyinComposition::HandleKeyL(TInt /*aCmd*/, TInt /*aKey*/)
       
   166     {
       
   167     /*
       
   168     TInt immode = iOwner->DataMgr()->InputMode();
       
   169     
       
   170     if (immode != EStroke && immode != EZhuyin)
       
   171         {
       
   172         return EFalse;
       
   173         }
       
   174 
       
   175     if (!(aKey == EKeyBackspace || 
       
   176          (aKey >= EPtiKey0 && aKey <= EPtiKey9) ||
       
   177          (aKey == EPtiKeyStar)))
       
   178         {
       
   179         return EFalse;
       
   180         }
       
   181     
       
   182     if (aKey == EKeyBackspace)
       
   183         {
       
   184         if (!iOwner->DataMgr()->PtiEngine()->DeleteKeyPress().Length())
       
   185             {
       
   186             iOwner->SetCurrentStateL(CSplitItutUiMgrBase::EStateStandby);
       
   187             
       
   188             iOwner->SetClrConsume(ETrue);
       
   189             
       
   190             return ETrue;
       
   191             }
       
   192         } 
       
   193     else if (aKey == EPtiKeyStar)
       
   194         {
       
   195         if (immode == EStroke)
       
   196             {
       
   197             return ETrue;
       
   198             }
       
   199         else
       
   200             {
       
   201             // input mode is zhuyin
       
   202             // input tonemark
       
   203             if (!iOwner->DataMgr()->PtiEngine()->IncrementToneMark(ETrue))
       
   204                 {
       
   205                 // tonemark did not set correctly, everything unchanged
       
   206                 return ETrue;
       
   207                 }
       
   208             }
       
   209         }
       
   210     else
       
   211         {
       
   212         if (immode == EZhuyin ||
       
   213            (immode == EStroke && aKey >= EPtiKey0 && aKey <= EPtiKey6))
       
   214             {
       
   215             // append keypress
       
   216             iOwner->DataMgr()->PtiEngine()->AppendKeyPress(TPtiKey(aKey));
       
   217             } 
       
   218         else if (immode == EStroke && aKey >= EPtiKey7 && aKey <= EPtiKey9)
       
   219             {
       
   220             // just ignore	
       
   221             return ETrue;
       
   222             }
       
   223         }
       
   224 
       
   225     // display 1st spell, ptiengine's phonetic spelling start index is 1, not 0
       
   226     iOwner->DataMgr()->PtiEngine()->SelectPhoneticSpelling(1);
       
   227 
       
   228     CFepInputContextField* spellctrl = 
       
   229         static_cast<CFepInputContextField*>(iOwner->LayoutContext()->Control(ECtrlIdSpellICF));
       
   230     TPtrC spelltext = iOwner->DataMgr()->PtiEngine()->GetPhoneticSpelling(1);
       
   231 
       
   232     TFepInputContextFieldData spelldata;
       
   233 
       
   234     spelldata.iCmd = EPeninputICFInitial;
       
   235     spelldata.iStartPos = 0;
       
   236     spelldata.iLength = spelltext.Length();
       
   237     spelldata.iMidPos = -1;
       
   238     spelldata.iText.Set(spelltext);
       
   239 
       
   240     spelldata.iCurSel = TCursorSelection(spelltext.Length(), spelltext.Length());
       
   241     spelldata.iCursorVisibility = EFalse;
       
   242     spelldata.iCursorSelVisible = EFalse;
       
   243 
       
   244     spellctrl->SetTextL(spelldata);
       
   245 
       
   246     // get candidates of 1st spell 
       
   247     TPtrC cands = iOwner->DataMgr()->PtiEngine()->CandidatePage();
       
   248 
       
   249     iOwner->DataMgr()->ClearChnCandidates(EItutCandidates);
       
   250     RPointerArray<HBufC>& candslist = 
       
   251         TItutDataConverter::AnyToRptrArray(iOwner->DataMgr()->RequestData(EChnCandidates));
       
   252     TItutDataConverter::ConvertChnPhraseCandidateL(cands, candslist);
       
   253 
       
   254     CFepCtrlDropdownList* canddroplist = 
       
   255         static_cast<CFepCtrlDropdownList*>(iOwner->LayoutContext()->Control(ECtrlIdStdCandsList));
       
   256     canddroplist->SetCandidatesL(candslist, CFepCtrlDropdownList::EListExpandableWithBubble);
       
   257     */
       
   258     return ETrue;
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CChnSplitItutUiStateStrokeZhuyinComposition::StateType
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 CSplitItutUiMgrBase::TUiState CChnSplitItutUiStateStrokeZhuyinComposition::StateType()
       
   266     {
       
   267     return CSplitItutUiMgrBase::EStateComposition;
       
   268     }
       
   269     
       
   270 // ---------------------------------------------------------------------------
       
   271 // CChnSplitItutUiStateStrokeZhuyinComposition::HandleCtrlEventL
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 TBool CChnSplitItutUiStateStrokeZhuyinComposition::HandleCtrlEventL(TInt /*aEventType*/, 
       
   275                                                                CFepUiBaseCtrl* /*aCtrl*/, 
       
   276                                                                const TDesC& /*aEventData*/)
       
   277     {
       
   278     /*
       
   279     switch (aEventType)
       
   280         {
       
   281         case EItutCmdCandidateSelected:
       
   282             {
       
   283             if (aCtrl->ControlId() == ECtrlIdStdCandsList)
       
   284                 {
       
   285                 iOwner->SetCurrentStateL(CSplitItutUiMgrBase::EStatePredict);
       
   286                 return iOwner->CurrentState()->HandleCtrlEventL(aEventType,
       
   287                                                                 aCtrl,
       
   288                                                                 aEventData);
       
   289                 }
       
   290             }
       
   291             break;
       
   292         case EItutCmdGetNextCandidatePage:
       
   293             {
       
   294             if (aCtrl->ControlId() == ECtrlIdStdCandsList)
       
   295                 {
       
   296                 RPointerArray<HBufC>& candslist = TItutDataConverter::AnyToRptrArray(
       
   297                     iOwner->DataMgr()->RequestData(EChnCandidates));
       
   298 
       
   299                 // original candidate count before fetch new candidate
       
   300                 TInt candscnt = candslist.Count();
       
   301                 if (iOwner->DataMgr()->GetNextPageCandidateL(candslist) == KErrNone)
       
   302                     {
       
   303                     static_cast<CFepCtrlDropdownList*>(aCtrl)->AddCandidatesL(candslist);    
       
   304                     }
       
   305 
       
   306                 return ETrue;
       
   307                 }
       
   308             }
       
   309             break;
       
   310         case EItutCmdCandidateExisted:
       
   311             {
       
   312             if (aCtrl->ControlId() == ECtrlIdStdCandsList)
       
   313                 {
       
   314                 static_cast<CFepCtrlDropdownList*>(aCtrl)->SetFlagCandidateExist(
       
   315                     iOwner->DataMgr()->NextPageCandidateExist());
       
   316                 return ETrue;
       
   317                 }
       
   318             }
       
   319             break;
       
   320         // consume star key at zhuyin composition state
       
   321         case EEventRawKeyDownEvent:
       
   322             {
       
   323             const TKeyEvent *key = reinterpret_cast<const TKeyEvent*>(aEventData.Ptr());
       
   324             
       
   325             if (key->iScanCode == EStdKeyNkpAsterisk && iOwner->DataMgr()->InputMode() == EZhuyin)
       
   326                 {
       
   327                 HandleKeyL(ECmdPenInputFingerKeyPress, EPtiKeyStar);
       
   328                 return ETrue;
       
   329                 }
       
   330             }
       
   331             break;
       
   332         case EEventRawKeyUpEvent:
       
   333             {
       
   334             const TKeyEvent *key = reinterpret_cast<const TKeyEvent*>(aEventData.Ptr());
       
   335             
       
   336             if (key->iScanCode == EStdKeyNkpAsterisk && iOwner->DataMgr()->InputMode() == EZhuyin)
       
   337                 {
       
   338                 return ETrue;
       
   339                 }
       
   340             }
       
   341             break;
       
   342         default:
       
   343             break;
       
   344         }
       
   345     */
       
   346     return EFalse;    
       
   347     }
       
   348 
       
   349 // End Of File