|
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: |
|
15 * Provides the TAknFepUiInputStateEntryVietnamesePredictive methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStateEntryVietnamesePredictive.h" |
|
31 #include "AknFepUIInputStateInitialVietnameseMultitap.h" |
|
32 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
33 #include "AknFepCaseManager.h" |
|
34 #include "AknFepVietnameseToneManager.h" |
|
35 #include "AknFepPluginManager.h" |
|
36 |
|
37 #include <uikon.hrh> |
|
38 #include <PtiEngine.h> //CPtiEngine |
|
39 #include <PtiDefs.h> //keys |
|
40 #include <aknSctDialog.h> |
|
41 #include <avkon.rsg> |
|
42 #include <aknfep.rsg> |
|
43 |
|
44 #include "AknFepUiManagerWestern.h" |
|
45 TAknFepInputStateEntryVietnamesePredictive:: |
|
46 TAknFepInputStateEntryVietnamesePredictive(MAknFepUIManagerStateInterface* aOwner) |
|
47 : TAknFepInputStateEntryWesternPredictive(aOwner) |
|
48 { |
|
49 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
50 if (ptiengine->CurrentLanguage()->LanguageCode() != ELangVietnamese) |
|
51 { |
|
52 TRAP_IGNORE(ptiengine->ActivateLanguageL(ELangVietnamese)); |
|
53 } |
|
54 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
55 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
56 if(fepMan->IsAutoCompleteOn()) |
|
57 { |
|
58 ptiengine->SetInputMode(EPtiEngineWordCompletion); |
|
59 } |
|
60 else |
|
61 #endif |
|
62 { |
|
63 ptiengine->SetInputMode(EPtiEnginePredictive); |
|
64 } |
|
65 } |
|
66 |
|
67 TBool TAknFepInputStateEntryVietnamesePredictive::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
68 { |
|
69 |
|
70 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
71 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
72 |
|
73 TBool response = ETrue; |
|
74 |
|
75 switch (aKey) |
|
76 { |
|
77 case EPtiKey1: //fall through |
|
78 case EPtiKey2: |
|
79 case EPtiKey3: |
|
80 case EPtiKey4: |
|
81 case EPtiKey5: |
|
82 case EPtiKey6: |
|
83 case EPtiKey7: |
|
84 case EPtiKey8: |
|
85 case EPtiKey9: |
|
86 response = HandleStandardNumericKeysL(aKey, aLength); |
|
87 break; |
|
88 case EPtiKey0: |
|
89 if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) ) |
|
90 { |
|
91 fepMan->TryRemoveNoMatchesIndicatorL(); |
|
92 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
93 if(fepMan->IsAutoCompleteOn()) |
|
94 { |
|
95 fepMan->RemoveSuggestedCompletionL(); |
|
96 } |
|
97 #endif |
|
98 } |
|
99 fepMan->UpdateCbaL(NULL); |
|
100 if (fepMan->IsFlagSet(CAknFepManager::EFlagCompoundWord)) |
|
101 { |
|
102 if (fepMan->IsCursorAtEndOfWord()) |
|
103 { |
|
104 fepMan->AddCompoundWordToUdbL(); |
|
105 } |
|
106 fepMan->ClearFlag(CAknFepManager::EFlagCompoundWord); |
|
107 } |
|
108 ptiengine->CommitCurrentWord(); // commit word after calling TryCloseUiL(). |
|
109 fepMan->TryCloseUiL(); |
|
110 response = EFalse; //pass to initial state to handle key |
|
111 break; |
|
112 case EKeyLeftArrow: // fall through |
|
113 case EKeyRightArrow: |
|
114 response = HandleNaviKeysL(aKey, aLength); |
|
115 break; |
|
116 case EKeyBackspace: |
|
117 response = HandleDeleteKeysL(aKey, aLength); |
|
118 break; |
|
119 case EPtiKeyStar: |
|
120 response = HandleStarKeyL(aLength); |
|
121 break; |
|
122 case EKeyDownArrow: // Japanese input required |
|
123 if (fepMan->IsAbleScrollLatinPredictive()) |
|
124 { |
|
125 if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
126 { |
|
127 DoNextMatch(); |
|
128 } |
|
129 else |
|
130 { |
|
131 response = EFalse; |
|
132 } |
|
133 } |
|
134 else |
|
135 { |
|
136 response = EFalse; |
|
137 } |
|
138 break; |
|
139 case EKeyUpArrow: // Japanese input required |
|
140 if (fepMan->IsAbleScrollLatinPredictive()) |
|
141 { |
|
142 if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
143 { |
|
144 DoPreviousMatchL(); |
|
145 } |
|
146 else |
|
147 { |
|
148 response = EFalse; |
|
149 } |
|
150 } |
|
151 else |
|
152 { |
|
153 response = EFalse; |
|
154 } |
|
155 break; |
|
156 default: |
|
157 response = EFalse; |
|
158 break; |
|
159 } |
|
160 return response; |
|
161 } |
|
162 |
|
163 TBool TAknFepInputStateEntryVietnamesePredictive::HandleStarKeyL(TKeyPressLength aLength) |
|
164 { |
|
165 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
166 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
167 |
|
168 if (aLength == ELongKeyPress) |
|
169 { |
|
170 if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
171 { |
|
172 // replace with previous match |
|
173 fepMan->TryRemoveNoMatchesIndicatorL(); |
|
174 iMatchState = EWordMatchStd; |
|
175 TPtrC newText = ptiengine->PreviousCandidate(); |
|
176 fepMan->UpdateInlineEditL(newText, newText.Length()); |
|
177 } |
|
178 |
|
179 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
180 // to rip off suggested completion when SCT is launched |
|
181 if(fepMan->IsAutoCompleteOn()) |
|
182 { |
|
183 fepMan->RemoveSuggestedCompletionL(); |
|
184 } |
|
185 #endif |
|
186 if (!fepMan->EditSubmenuInUse()) |
|
187 { |
|
188 fepMan->LaunchSpecialCharacterTableL(); |
|
189 } |
|
190 } |
|
191 else |
|
192 { |
|
193 if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
194 { |
|
195 #ifdef RD_SCALABLE_UI_V2 |
|
196 if ( (iIsLastWord || ptiengine->NumberOfCandidates() == 1) |
|
197 && ( fepMan->PluginUIManager()->PluginInputMode() == EPluginInputModeItut ) ) |
|
198 { |
|
199 fepMan->PluginUIManager()->SetFingerMatchSelectionState(ETrue); |
|
200 fepMan->PluginUIManager()->ShowAllCandidates(); |
|
201 iMatchState = EWordMatchNone; |
|
202 iIsLastWord = EFalse; |
|
203 return ETrue; |
|
204 } |
|
205 #endif //RD_SCALABLE_UI_V2 |
|
206 if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches)) |
|
207 { |
|
208 //no more matches |
|
209 fepMan->PlaySound(EAvkonSIDWarningTone); |
|
210 } |
|
211 else if (ptiengine->NumberOfCandidates()<=1) |
|
212 { |
|
213 // only one match |
|
214 if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone) |
|
215 { |
|
216 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY); |
|
217 iMatchState = EWordMatchLast; |
|
218 } |
|
219 } |
|
220 else |
|
221 { |
|
222 // > 1 match |
|
223 if (iMatchState == EWordMatchLast && !(ptiengine->LastEnteredKey() == EPtiKey1)) |
|
224 { |
|
225 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_PREVIOUS); |
|
226 } |
|
227 else if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone) |
|
228 { |
|
229 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_EMPTY_PREVIOUS); |
|
230 iMatchState = EWordMatchStd; |
|
231 } |
|
232 TPtrC newText = ptiengine->NextCandidate(); |
|
233 if(newText.Length() == 1) |
|
234 { |
|
235 TDigitType digittype = fepMan->LocalDigit(); |
|
236 TChar chchar(newText[0]); |
|
237 if(!chchar.IsDigit() || (chchar.IsDigit() && !digittype)) |
|
238 { |
|
239 fepMan->UpdateInlineEditL(newText, newText.Length()); |
|
240 } |
|
241 else |
|
242 { |
|
243 TBuf<1> tempbuf; |
|
244 switch(digittype) |
|
245 { |
|
246 case EDigitTypeDevanagari: |
|
247 { |
|
248 chchar = (newText[0] + KLatinToDevanagariDigitsDelta); |
|
249 } |
|
250 break; |
|
251 case EDigitTypeArabicIndic: |
|
252 { |
|
253 chchar = (newText[0] + KLatinToArabicIndicDigitsDelta); |
|
254 } |
|
255 break; |
|
256 case EDigitTypeEasternArabicIndic: |
|
257 { |
|
258 chchar = (newText[0] + KLatinToEasternArabicIndicDigitsDelta); |
|
259 } |
|
260 } |
|
261 tempbuf.Append(chchar); |
|
262 fepMan->UpdateInlineEditL(tempbuf, tempbuf.Length()); |
|
263 } |
|
264 } |
|
265 else |
|
266 { |
|
267 fepMan->UpdateInlineEditL(newText, newText.Length()); |
|
268 } |
|
269 } |
|
270 } |
|
271 else |
|
272 { |
|
273 if (!fepMan->EditSubmenuInUse()) |
|
274 { |
|
275 fepMan->LaunchSpecialCharacterTableL(); |
|
276 } |
|
277 } |
|
278 } |
|
279 return ETrue; |
|
280 } |
|
281 |
|
282 TBool TAknFepInputStateEntryVietnamesePredictive::HandleDeleteKeysL(TInt aKey, TKeyPressLength /*aLength*/) |
|
283 { |
|
284 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
285 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
286 |
|
287 if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))) |
|
288 { |
|
289 if(fepMan->PreviousChar() == TText(0x0020)) // 0x0020 is space |
|
290 { |
|
291 return EFalse; |
|
292 } |
|
293 TBuf<CAknFepManager::EMaximumFepWordLength> textToUncommit; |
|
294 TBool comsumeKey; |
|
295 if (!(fepMan->TryGetTextToUncommitL(textToUncommit, aKey, comsumeKey))) |
|
296 { |
|
297 // If T9 word length > 32, the navi key is consumed without action. |
|
298 // Maybe should navigate inside word. |
|
299 return comsumeKey; |
|
300 } |
|
301 ptiengine->SetCurrentWord(textToUncommit); |
|
302 fepMan->ClearFlag(CAknFepManager::EFlagRemoveMatchesMenuItem); |
|
303 if (ptiengine->NumberOfCandidates() <= 1) |
|
304 { |
|
305 fepMan->SetFlag(CAknFepManager::EFlagRemoveMatchesMenuItem); |
|
306 } |
|
307 fepMan->StartInlineEditL(fepMan->UncommittedText(), textToUncommit, |
|
308 textToUncommit.Length(), EFalse); |
|
309 } |
|
310 |
|
311 if (aKey == EKeyBackspace) |
|
312 { |
|
313 if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches)) |
|
314 { |
|
315 fepMan->TryRemoveNoMatchesIndicatorL(); |
|
316 fepMan->UpdateCbaL(NULL); |
|
317 return ETrue; |
|
318 } |
|
319 else if (iMatchState != EWordMatchFirst) |
|
320 { |
|
321 //let FirstWordInSelectionList() reset the CBA |
|
322 iMatchState = EWordMatchNone; |
|
323 } |
|
324 |
|
325 TBuf<2> newText; |
|
326 // Get the last character from the current editor |
|
327 TText prevChar = fepMan->PreviousChar(); |
|
328 TBool vowelList = EFalse; |
|
329 for (TInt index = 0; index < KNumberOfToneMarks; index ++) |
|
330 { |
|
331 if (VietToneMatrix[0][index] == prevChar) |
|
332 { |
|
333 vowelList = ETrue; |
|
334 break; |
|
335 } |
|
336 } |
|
337 |
|
338 if (vowelList) |
|
339 { |
|
340 ((CAknFepManager*)fepMan)->RemovePreviousCharacterL(); |
|
341 } |
|
342 else |
|
343 { |
|
344 if (prevChar <= 0) |
|
345 { |
|
346 return EFalse; |
|
347 } |
|
348 |
|
349 // Judge if the last character needs to be converted |
|
350 if ( TAknFepInputStateInitialVietnameseMultitap::NeedsVietnameseBkDelSupport(prevChar, |
|
351 newText) ) |
|
352 { |
|
353 ((CAknFepManager*)fepMan)->RemovePreviousCharacterL(); |
|
354 } |
|
355 else |
|
356 { |
|
357 TPtrC updatedText = ptiengine->DeleteKeyPress(); |
|
358 if(ptiengine->InputMode() != EPtiEngineWordCompletion && newText.Length()) |
|
359 { |
|
360 fepMan->UpdateInlineEditL(updatedText, newText.Length()); |
|
361 } |
|
362 else |
|
363 { |
|
364 fepMan->UpdateInlineEditL(updatedText, updatedText.Length()); |
|
365 } |
|
366 } |
|
367 } |
|
368 |
|
369 fepMan->ClearFlag(CAknFepManager::EFlagRemoveMatchesMenuItem); |
|
370 if (ptiengine->NumberOfCandidates() <= 1) |
|
371 { |
|
372 fepMan->SetFlag(CAknFepManager::EFlagRemoveMatchesMenuItem); |
|
373 } |
|
374 |
|
375 iOwner->CaseMan()->UpdateCase(EBackspaceEvent); |
|
376 fepMan->CloseUiIfWordDeletedL(); |
|
377 } |
|
378 |
|
379 return ETrue; |
|
380 } |
|
381 |
|
382 // End of file |