|
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 candidate chinese phrase state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepUiInputStatePredictiveCandidateChinesePhrase.h" |
|
30 #include "AknFepUICtrlCandidatePane.h" |
|
31 #include "AknFepUiCtrlContainerChinese.h" |
|
32 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
33 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
34 |
|
35 #include <PtiEngine.h> //CPtiEngine |
|
36 |
|
37 TAknFepInputStatePredictiveCandidateChinesePhrase:: |
|
38 TAknFepInputStatePredictiveCandidateChinesePhrase( |
|
39 MAknFepUIManagerStateInterface* aOwner, |
|
40 MAknFepUICtrlContainerChinese* aUIContainer) |
|
41 :TAknFepInputStateCandidateBaseChinesePhrase(aOwner, aUIContainer) |
|
42 { |
|
43 iState = EPredictiveCandidate; |
|
44 |
|
45 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
46 |
|
47 // set container window position to follow cursor |
|
48 TPoint baseLine = TPoint(0,0); |
|
49 TInt height = 0; |
|
50 TInt ascent = 0; |
|
51 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
52 if (ret == KErrNone) |
|
53 { |
|
54 uiContainer->SetContainerPosition(baseLine, height); |
|
55 } |
|
56 uiContainer->FocusCandidatePane(ETrue); |
|
57 |
|
58 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
59 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
60 // for some reason needs to feed back to ptiengine current Chinese phrase just before get the prediction |
|
61 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
62 candidatePane->SelectFirstPhrase(); |
|
63 ptiengine->SetPredictiveChineseChar(text); |
|
64 |
|
65 TRAPD(ignore,ptiengine->GetChinesePhraseCandidatesL(*(candidatePane->CandidateArray()))); |
|
66 if (ignore == KErrNone) |
|
67 { |
|
68 candidatePane->SplitPhraseCandidatesIntoPages(); |
|
69 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate); |
|
70 candidatePane->SetCandidateBuffer(); |
|
71 |
|
72 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
73 uiContainer->CandidatePane()->IsFirstPage()); |
|
74 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
75 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
76 |
|
77 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
78 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
79 candidatePane->ShowCandidateOrdinals(EFalse); |
|
80 UpdateIndicator(); |
|
81 } |
|
82 } |
|
83 |
|
84 TBool TAknFepInputStatePredictiveCandidateChinesePhrase::HandleKeyL(TInt aKey, |
|
85 TKeyPressLength aLength) |
|
86 { |
|
87 TBool ret = ETrue; |
|
88 |
|
89 if(iOwner->IsValidChineseInputKey(aKey) && aLength != ELongKeyPress) |
|
90 { |
|
91 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
92 // needs to clear current word for current engine, otherwise buffer is not cleared |
|
93 ptiengine->ClearCurrentWord(); |
|
94 ptiengine->ResetToneMark(); |
|
95 |
|
96 iOwner->ChangeState(EEntry); |
|
97 ret = EFalse; //passes to entry state to handle the key |
|
98 } |
|
99 if(!HandleVerticalNavigation(aKey)) |
|
100 { |
|
101 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
102 // Do navigation... |
|
103 if (aKey == EKeyLeftArrow && aLength != ELongKeyPress) |
|
104 { |
|
105 // if (candidatePane->SelectedIndex() == 0 && |
|
106 // candidatePane->IsFirstPage() ) |
|
107 // { |
|
108 // return ETrue; |
|
109 // } |
|
110 // else |
|
111 { |
|
112 iOwner->ChangeState(EPredictiveInput); |
|
113 ret = EFalse; //passes to predictive input state to handle the key |
|
114 } |
|
115 } |
|
116 else if (aKey == EKeyRightArrow && aLength != ELongKeyPress) |
|
117 { |
|
118 if (candidatePane->IsLastPage() && |
|
119 (candidatePane->SelectedIndex() == candidatePane->VisibleCandidateCount() - 1)) |
|
120 { |
|
121 return ETrue; |
|
122 } |
|
123 else |
|
124 { |
|
125 iOwner->ChangeState(EPredictiveInput); |
|
126 return EFalse; |
|
127 } |
|
128 } |
|
129 else if ( ( aKey == EKeyOK || aKey == EKeyCBA1 ) && aLength != ELongKeyPress) |
|
130 { |
|
131 iOwner->ChangeState(EPredictiveInput); |
|
132 ret = EFalse; //passes to predictive input state to handle the key |
|
133 } |
|
134 else if(aKey == EKeyBackspace && aLength != ELongKeyPress) |
|
135 { |
|
136 iOwner->FepMan()->TryCloseUiL(); |
|
137 } |
|
138 else if (aKey == EPtiKeyStar && aLength != ELongKeyPress) |
|
139 { |
|
140 ret = TAknFepInputStateCandidateBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
141 } |
|
142 } |
|
143 return ret; |
|
144 } |
|
145 |
|
146 // End of file |