|
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 Pinyin phrase predictive Qwerty state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // System includes |
|
30 #include <PtiEngine.h> //CPtiEngine |
|
31 |
|
32 // User includes |
|
33 #include "AknFepUiInputStateCandidateChinese.h" |
|
34 #include "AknFepUiCtrlContainerChinese.h" |
|
35 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
36 #include "AknFepUICtrlCandidatePane.h" //MAknFepUICtrlCandidatePane |
|
37 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
38 #include "AknFepManager.h" |
|
39 |
|
40 const TInt KMaxCandidateCountFromCore = 6; |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // TAknFepInputStateCandidateChinese:: |
|
44 // TAknFepInputStateCandidateChinese |
|
45 // (other items were commented in a header). |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 TAknFepInputStateCandidateChinese::TAknFepInputStateCandidateChinese( |
|
49 MAknFepUIManagerStateInterface* aOwner, |
|
50 MAknFepUICtrlContainerChinese* aUIContainer) |
|
51 :TAknFepInputStateCandidateBase(aOwner, aUIContainer) |
|
52 { |
|
53 iState = ECandidate; |
|
54 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
55 uiContainer->CandidatePane()->SelectFirst(); |
|
56 |
|
57 TBool multiplePages = iOwner->PtiEngine()->MoreCandidatePages(); |
|
58 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
59 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
60 |
|
61 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
62 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
63 uiContainer->FocusCandidatePane(ETrue); |
|
64 uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue); |
|
65 UpdateIndicator(); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // TAknFepInputStateCandidateChinese:: |
|
70 // HandleKeyL |
|
71 // (other items were commented in a header). |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 TBool TAknFepInputStateCandidateChinese::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/) |
|
75 { |
|
76 if(aKey==EKeyBackspace) |
|
77 { |
|
78 iOwner->ChangeState(EEntry); |
|
79 return ETrue; |
|
80 } |
|
81 |
|
82 if (aKey == EPtiKeyStar) |
|
83 { |
|
84 iOwner->FepMan()->TryCloseUiL(); |
|
85 return EFalse; |
|
86 } |
|
87 |
|
88 if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) )) |
|
89 { |
|
90 // it may be one of the 'valid' numbers.. |
|
91 TInt index = MapKeyToIndex(aKey); |
|
92 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
93 |
|
94 if(candidatePane->SelectIndex(index) || aKey == EKeyOK) |
|
95 { |
|
96 TPtrC text = candidatePane->CurrentCandidate(); |
|
97 if(text.Length()) |
|
98 { |
|
99 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
100 fepMan->NewCharacterL(text); |
|
101 fepMan->CommitInlineEditL(); |
|
102 |
|
103 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
104 { |
|
105 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
106 iOwner->FepMan()->TryCloseUiL(); |
|
107 } |
|
108 else |
|
109 { |
|
110 iOwner->ChangeState(EPredictiveCandidate); |
|
111 UpdateIndicator(); |
|
112 } |
|
113 } |
|
114 else |
|
115 { |
|
116 // No candidates available. Back to Entry state. |
|
117 iOwner->ChangeState(EEntry); |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 return ETrue; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // TAknFepInputStateCandidateChinese:: |
|
127 // HandleHorizontalNavigation |
|
128 // (other items were commented in a header). |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 TBool TAknFepInputStateCandidateChinese::HandleHorizontalNavigation(TInt aKey) |
|
132 { |
|
133 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
134 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
135 TBool response = EFalse; |
|
136 |
|
137 // Do navigation... |
|
138 if (aKey == EKeyLeftArrow) |
|
139 { |
|
140 if (candidatePane->SelectedIndex() == 0 && |
|
141 ptiengine->NumberOfCandidates() == 0) |
|
142 { |
|
143 return ETrue; |
|
144 } |
|
145 if(!candidatePane->SelectPrev()) |
|
146 { |
|
147 ptiengine->PreviousCandidatePage(); |
|
148 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
149 candidatePane->SelectLast(); |
|
150 } |
|
151 response = ETrue; |
|
152 } |
|
153 else if (aKey == EKeyRightArrow) |
|
154 { |
|
155 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
156 |
|
157 if (bufLength != KMaxCandidateCountFromCore && |
|
158 candidatePane->SelectedIndex() == (bufLength -1)) |
|
159 { |
|
160 return ETrue; |
|
161 } |
|
162 if(!candidatePane->SelectNext()) |
|
163 { |
|
164 ptiengine->NextCandidatePage(); |
|
165 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
166 candidatePane->SelectFirst(); |
|
167 } |
|
168 response = ETrue; |
|
169 } |
|
170 |
|
171 if (response) |
|
172 { |
|
173 UpdateIndicator(); |
|
174 } |
|
175 |
|
176 return response; |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // TAknFepInputStateCandidateChinese:: |
|
181 // HandleVerticalNavigation |
|
182 // (other items were commented in a header). |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 TBool TAknFepInputStateCandidateChinese::HandleVerticalNavigation(TInt aKey) |
|
186 { |
|
187 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
188 |
|
189 if (aKey == EKeyDownArrow) |
|
190 { |
|
191 if (iOwner->PtiEngine()->CandidatePage().Length() != |
|
192 KMaxCandidateCountFromCore) |
|
193 { |
|
194 return ETrue; |
|
195 } |
|
196 ptiengine->NextCandidatePage(); |
|
197 } |
|
198 else if (aKey == EKeyUpArrow) |
|
199 { |
|
200 if (ptiengine->NumberOfCandidates() == 0) |
|
201 { |
|
202 return ETrue; |
|
203 } |
|
204 ptiengine->PreviousCandidatePage(); |
|
205 } |
|
206 else |
|
207 { |
|
208 return EFalse; |
|
209 } |
|
210 |
|
211 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
212 candidatePane->SelectFirst(); |
|
213 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
214 UpdateIndicator(); |
|
215 |
|
216 return ETrue; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // TAknFepInputStateCandidateChinese:: |
|
221 // UpdateIndicator |
|
222 // (other items were commented in a header). |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void TAknFepInputStateCandidateChinese::UpdateIndicator() |
|
226 { |
|
227 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
228 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
229 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
230 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
231 |
|
232 if (ptiengine->NumberOfCandidates() == 0) |
|
233 { |
|
234 uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse); |
|
235 } |
|
236 else |
|
237 { |
|
238 uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue); |
|
239 } |
|
240 |
|
241 uiContainer->CandidatePane()->ShowDownScrollArrows |
|
242 (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse); |
|
243 |
|
244 if (candidatePane->SelectedIndex() == 0 && |
|
245 ptiengine->NumberOfCandidates() == 0) |
|
246 { |
|
247 uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse); |
|
248 } |
|
249 else |
|
250 { |
|
251 uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue); |
|
252 } |
|
253 |
|
254 if (bufLength != KMaxCandidateCountFromCore && |
|
255 candidatePane->SelectedIndex() == (bufLength -1)) |
|
256 { |
|
257 uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse); |
|
258 } |
|
259 else |
|
260 { |
|
261 uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue); |
|
262 } |
|
263 } |
|
264 |
|
265 // End of file |