|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepHashKeyManager.h" |
|
30 #include "AknFepManager.h" |
|
31 #include "AknFepCaseManager.h" |
|
32 #include "AknFepUiIndicInputManager.h" |
|
33 |
|
34 #include <aknedsts.h> |
|
35 #include <uikon.hrh> |
|
36 #include <coedef.h> |
|
37 |
|
38 #include <PtiEngine.h> |
|
39 |
|
40 //move to class definition |
|
41 #define EHashKeyTimeout 700000 // 0.7s |
|
42 |
|
43 CAknFepHashKeyManager* CAknFepHashKeyManager::NewL(CAknFepManager& aFepMan, |
|
44 CAknFepCaseManager* aCaseMan) |
|
45 { |
|
46 CAknFepHashKeyManager* self = new(ELeave) CAknFepHashKeyManager(aFepMan, aCaseMan); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 CAknFepHashKeyManager::~CAknFepHashKeyManager() |
|
54 { |
|
55 delete iHashKeyTimer; |
|
56 } |
|
57 |
|
58 TKeyResponse CAknFepHashKeyManager::HandleKeyEventL(TKeyPressLength aLength) |
|
59 { |
|
60 TKeyResponse response = EKeyWasNotConsumed; |
|
61 |
|
62 switch (iHashKeyStyle) |
|
63 { |
|
64 case EHashKeyStyleWestern: |
|
65 response = HandleKeyWesternL(aLength); |
|
66 break; |
|
67 case EHashKeyStyleChineseWithWestern: |
|
68 response = HandleKeyWesternWithChineseL(aLength); |
|
69 break; |
|
70 case EHashKeyStyleJapanese: |
|
71 response = HandleKeyJapaneseL(aLength); |
|
72 break; |
|
73 case EHashKeyStyleKoreanWithWestern: |
|
74 response = HandleKeyWesternWithKoreanL(aLength); |
|
75 break; |
|
76 default: |
|
77 break; |
|
78 } |
|
79 return response; |
|
80 } |
|
81 |
|
82 void CAknFepHashKeyManager::SetMode(TInt aMode, TBool aWesternPredictive) |
|
83 { |
|
84 iMode = aMode; |
|
85 iWesternPredictive = aWesternPredictive; |
|
86 } |
|
87 |
|
88 void CAknFepHashKeyManager::SetHashKeyStyle(THashKeyStyle aHashKeyStyle) |
|
89 { |
|
90 iHashKeyStyle = aHashKeyStyle; |
|
91 } |
|
92 |
|
93 void CAknFepHashKeyManager::CancelHashKeyTimer() |
|
94 { |
|
95 if (iHashKeyTimer->IsActive()) |
|
96 { |
|
97 iHashKeyTimer->Cancel(); |
|
98 } |
|
99 } |
|
100 |
|
101 CAknFepHashKeyManager::CAknFepHashKeyManager(CAknFepManager& aFepMan, CAknFepCaseManager* aCaseMan) |
|
102 :iHashKeyStyle(EHashKeyStyleWestern), |
|
103 iFepMan(aFepMan), |
|
104 iCaseMan(aCaseMan) |
|
105 { |
|
106 iLanguageChangedOrChangeFromNumberMode = EFalse; |
|
107 iIndicSelectionLoopIndex = -1; // Cannot use 'iFepMan.WesternPredictive(ELatin);' since FepMan is not completely constructed at the construction of this |
|
108 } |
|
109 |
|
110 void CAknFepHashKeyManager::ConstructL() |
|
111 { |
|
112 iHashKeyTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
113 } |
|
114 |
|
115 TInt CAknFepHashKeyManager::HashKeyTimerTimeoutCallback(TAny* aObj) |
|
116 { |
|
117 STATIC_CAST(CAknFepHashKeyManager*, aObj)->HashKeyTimerTimeout(); |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 void CAknFepHashKeyManager::HashKeyTimerTimeout() |
|
122 { |
|
123 iHashKeyTimer->Cancel(); |
|
124 } |
|
125 |
|
126 void CAknFepHashKeyManager::RevertPredictiveTextSettingChangeL() |
|
127 { |
|
128 if ( !iFepMan.InputLanguageSupportsCaseChanges() && iFepMan.EditorState()&& |
|
129 !( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9) ) |
|
130 { |
|
131 // Reverts predictive text settings change made with short key press. |
|
132 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
133 iFepMan.TryChangeModeL(ELatin); |
|
134 } |
|
135 } |
|
136 |
|
137 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternL(TKeyPressLength aLength) |
|
138 { |
|
139 TKeyResponse response = EKeyWasNotConsumed; |
|
140 TBool phoneIdle = (iFepMan.EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); |
|
141 if(phoneIdle) |
|
142 { |
|
143 return response; |
|
144 } |
|
145 iLastModeNumber = (iMode == ENumber || iMode == ENativeNumber); |
|
146 |
|
147 if ( (iMode == ENumber || iMode == ENativeNumber) && !iFepMan.HashKeySelectionInUse()) |
|
148 { |
|
149 if (aLength == ELongKeyPress) |
|
150 { |
|
151 // Clear the EExtendedFlagShortPressHashKey, only for non numeric only editors |
|
152 // so as to indicate we are in a long press of hash key event. |
|
153 // In case of numeric only editor, we should re-simulate hash and let application |
|
154 // handle it. |
|
155 |
|
156 if ( !iFepMan.IsOnlyNumericPermitted() ) |
|
157 { |
|
158 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
159 |
|
160 // Long press of hash key switches to alpha mode |
|
161 // if it is permitted mode in the editor. |
|
162 iFepMan.TryChangeToModeBeforeL(); |
|
163 ResetIndicHashKeyStateL(); |
|
164 } |
|
165 response = EKeyWasConsumed; |
|
166 } |
|
167 else if (!iFepMan.IsExtendedFlagSet(CAknFepManager::EExtendedFlagShortPressHashKey)) |
|
168 { |
|
169 // Set the flag to indicate its a short press of key event |
|
170 iFepMan.SetExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
171 response = EKeyWasConsumed; |
|
172 } |
|
173 else |
|
174 { |
|
175 // We are not suppose to be here. Just a fail safe check to guard us against |
|
176 // erroneous situations. |
|
177 |
|
178 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
179 } |
|
180 } |
|
181 else |
|
182 { |
|
183 if ( aLength == EShortKeyPress ) |
|
184 { |
|
185 if (iFepMan.HashKeySelectionInUse()) |
|
186 { |
|
187 // New style hash key loop when long hash-key press is used for text selection. |
|
188 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
189 // To rip off suggested word completion when user wants to |
|
190 // switch to number or multitap mode |
|
191 if(iFepMan.IsAutoCompleteOn()) |
|
192 { |
|
193 iFepMan.RemoveSuggestedCompletionL(); |
|
194 } |
|
195 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
196 return HandleKeyWesternSelectionStyleL(aLength); |
|
197 } |
|
198 |
|
199 if ( iLastModeNumber ) |
|
200 { |
|
201 // The key should not be consumed in number mode? FEP Manager may |
|
202 // put special chars into the editor or the key event |
|
203 // is passed to the editor. |
|
204 |
|
205 // But now the event is consumed. Same happens also in |
|
206 // Chinese languages because # key is reserved for |
|
207 // other purpose. |
|
208 response = EKeyWasConsumed; |
|
209 } |
|
210 |
|
211 if(IsIndicHashKeyStyleRequired()) |
|
212 { |
|
213 return (SetIndicStateL()); |
|
214 } |
|
215 // Traditional hash key loop |
|
216 if ( iFepMan.InputLanguageSupportsCaseChanges() ) |
|
217 { |
|
218 if (iHashKeyTimer->IsActive()) |
|
219 { |
|
220 iHashKeyTimer->Cancel(); |
|
221 iCaseMan->RevertCaseChange(); |
|
222 // Toggle predictive setting. |
|
223 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
224 // To rip off suggested word completion when user wants to |
|
225 // switch to number or multitap mode |
|
226 if(iFepMan.IsAutoCompleteOn()) |
|
227 { |
|
228 iFepMan.RemoveSuggestedCompletionL(); |
|
229 } |
|
230 |
|
231 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
232 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStataCommitPredictiveWord); |
|
233 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
234 iFepMan.TryChangeModeL(ELatin); |
|
235 } |
|
236 else |
|
237 { |
|
238 iCaseMan->ManualCaseUpdate(); |
|
239 iHashKeyTimer->Start(EHashKeyTimeout, EHashKeyTimeout, |
|
240 TCallBack(HashKeyTimerTimeoutCallback, this)); |
|
241 } |
|
242 } |
|
243 else // Case changes are not allowed. |
|
244 { |
|
245 if (iHashKeyTimer->IsActive()) |
|
246 { |
|
247 iHashKeyTimer->Cancel(); |
|
248 // Double press of hash key does not have functionality. |
|
249 } |
|
250 else |
|
251 { |
|
252 // Toggle predictive setting. |
|
253 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
254 // AutoComplete - Fix - Begin |
|
255 if(iFepMan.IsAutoCompleteOn()) |
|
256 { |
|
257 iFepMan.RemoveSuggestedCompletionL(); |
|
258 } |
|
259 // AutoComplete - Fix - End |
|
260 |
|
261 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
262 iFepMan.SetWesternPredictive( !iFepMan.WesternPredictive(ELatin) ); |
|
263 iFepMan.TryChangeModeL(ELatin); |
|
264 iHashKeyTimer->Start(EHashKeyTimeout, EHashKeyTimeout, |
|
265 TCallBack(HashKeyTimerTimeoutCallback, this)); |
|
266 } |
|
267 } |
|
268 response = EKeyWasConsumed; |
|
269 } |
|
270 else // Long key press of hash key |
|
271 { |
|
272 // Clear EExtendedFlagShortPressHashKey flag as soon as long press happens |
|
273 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
274 |
|
275 // Toggle number mode / alpha mode |
|
276 if (iLastModeNumber && !IsIndicHashKeyStyleRequired() && |
|
277 !iFepMan.HashKeySelectionInUse()) // For Indic it is handled in SetIndicPreviousStateL() |
|
278 { |
|
279 // If short hash key press event is passed to the editor, it |
|
280 // needs to be removed here from the editor. |
|
281 |
|
282 iFepMan.TryChangeToModeBeforeL(); |
|
283 } |
|
284 else |
|
285 { |
|
286 // Input mode is incremented. |
|
287 if (!iFepMan.HashKeySelectionInUse()) |
|
288 { |
|
289 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
290 // To rip off suggested word completion when user wants to switch to number mode |
|
291 if(iFepMan.IsAutoCompleteOn()) |
|
292 { |
|
293 iFepMan.RemoveSuggestedCompletionL(); |
|
294 } |
|
295 |
|
296 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
297 if(IsIndicHashKeyStyleRequired()) |
|
298 { |
|
299 SetIndicPreviousStateL(); |
|
300 } |
|
301 else |
|
302 { |
|
303 RevertPredictiveTextSettingChangeL(); |
|
304 } |
|
305 if( iFepMan.IsSupportNativeNumber()) |
|
306 { |
|
307 iFepMan.TryChangeModeL( ENativeNumber ); |
|
308 } |
|
309 else |
|
310 { |
|
311 iFepMan.TryChangeModeL( ENumber ); |
|
312 } |
|
313 } |
|
314 else if (!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) && |
|
315 iFepMan.OkToActivateSelectionMode()) |
|
316 { |
|
317 // User wants to select and not to change mode, so cancel the mode change |
|
318 // caused by initial hash key press. |
|
319 if(iLastModeNumber && !IsIndicHashKeyStyleRequired()) |
|
320 { |
|
321 iFepMan.TryChangeToModeBeforeL(); |
|
322 } |
|
323 else |
|
324 { |
|
325 SetPreviousSelectionStyleModeL(); |
|
326 } |
|
327 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
328 CAknFepManager::ECcpuStateEdwinInSelectionMode | |
|
329 CAknFepManager::ECcpuStateHashKeyDeleteDone ); |
|
330 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
331 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
332 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
333 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
334 } |
|
335 } |
|
336 response = EKeyWasConsumed; |
|
337 } |
|
338 } |
|
339 return response; |
|
340 } |
|
341 |
|
342 |
|
343 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternWithChineseL(TKeyPressLength aLength) |
|
344 { |
|
345 TKeyResponse response = EKeyWasNotConsumed; |
|
346 if ( iFepMan.IsOnlyNumericPermitted() ) |
|
347 { |
|
348 if ( aLength == ELongKeyPress ) |
|
349 { |
|
350 response = EKeyWasConsumed; |
|
351 if ( iFepMan.HashKeySelectionInUse() ) |
|
352 { |
|
353 TText prevCh = iFepMan.PreviousChar(); |
|
354 if (prevCh == '#') |
|
355 { |
|
356 iFepMan.RemovePreviousCharacterL(); |
|
357 } |
|
358 } |
|
359 |
|
360 iFepMan.SetCcpuFlag( CAknFepManager::ECcpuStateHashDown | |
|
361 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
362 TKeyEvent ccpuStart = { EKeyF21, EStdKeyF21, 0, 0 }; |
|
363 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
364 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
365 CCoeEnv::Static()->SimulateKeyEventL( ccpuStart, EEventKey ); |
|
366 } |
|
367 //else let the FEP Man put special chars into the editor |
|
368 } |
|
369 else |
|
370 { |
|
371 if (aLength == EShortKeyPress) |
|
372 { |
|
373 if (iMode == ENumber || iMode == ENativeNumber) |
|
374 { |
|
375 iLastModeNumber = ETrue; |
|
376 } |
|
377 else |
|
378 { |
|
379 iLastModeNumber = EFalse; |
|
380 } |
|
381 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
382 TInt permittedCases = editorState->PermittedCases(); |
|
383 permittedCases = permittedCases == 0 ? |
|
384 EAknEditorLowerCase | EAknEditorUpperCase : permittedCases; |
|
385 if ( iMode == ELatin && (permittedCases & EAknEditorTextCase)) |
|
386 { |
|
387 // Latin case update is changed back to automatic if latin |
|
388 // text case is allowed and the case is changed manually from #-key. |
|
389 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
390 } |
|
391 TInt currentCase = iCaseMan->CurrentCase(); |
|
392 |
|
393 // Is current latin case last available case. |
|
394 TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase) && |
|
395 (( currentCase == EAknEditorLowerCase) || |
|
396 ( currentCase == EAknEditorUpperCase && |
|
397 !(permittedCases & EAknEditorLowerCase)) ) || |
|
398 ( editorState->Flags() & EAknEditorFlagFixedCase) ) || |
|
399 ( editorState->Flags() & EAknEditorFlagForceTransparentFepModes) ); |
|
400 |
|
401 if (iMode == ELatin && |
|
402 !iFepMan.IsFlagSet(CAknFepManager::EFlagChangeInputMode) && |
|
403 !lastCase ) |
|
404 { |
|
405 // Input mode is still Latin. Only case is updated. |
|
406 if (permittedCases & EAknEditorTextCase) |
|
407 { |
|
408 iCaseMan->ManualCaseUpdate(); |
|
409 } |
|
410 else |
|
411 { |
|
412 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
413 } |
|
414 |
|
415 // Next time input mode is changed if any text is not entered before. |
|
416 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
417 } |
|
418 else |
|
419 { |
|
420 // Input mode is incremented. |
|
421 iFepMan.TryIncrementModeL(iMode); |
|
422 |
|
423 iFepMan.ClearFlag(CAknFepManager::EFlagChangeInputMode); |
|
424 |
|
425 if (iMode == ELatin) // New mode after Increment. |
|
426 { |
|
427 if (editorState->Flags() & EAknEditorFlagFixedCase) |
|
428 { |
|
429 // Only one fixed case is available. Use it. |
|
430 iCaseMan->ConfigureCaseStateFromEditorState(); |
|
431 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
432 } |
|
433 else if (editorState->Flags() & EAknEditorFlagForceTransparentFepModes) |
|
434 { |
|
435 // Only lower case is used with find pane. |
|
436 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
437 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
438 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
439 } |
|
440 else if (permittedCases & EAknEditorTextCase) |
|
441 { |
|
442 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
443 iCaseMan->UpdateCase(ENullNaviEvent); |
|
444 } |
|
445 else |
|
446 { |
|
447 if (permittedCases & EAknEditorUpperCase) |
|
448 { |
|
449 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
450 if ( !(permittedCases & EAknEditorLowerCase)) |
|
451 { |
|
452 // We need to move to next input mode since only upper case |
|
453 // is permitted in Latin input mode. |
|
454 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
455 } |
|
456 } |
|
457 else |
|
458 { |
|
459 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
460 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
461 } |
|
462 } |
|
463 } |
|
464 } |
|
465 } |
|
466 else // Long keypress |
|
467 { |
|
468 if (!iFepMan.HashKeySelectionInUse()) |
|
469 { |
|
470 if (iLastModeNumber) |
|
471 { |
|
472 iFepMan.TryChangeToModeBeforeL(); |
|
473 } |
|
474 else |
|
475 { |
|
476 if( iFepMan.IsSupportNativeNumber()) |
|
477 { |
|
478 iFepMan.TryChangeModeL( ENativeNumber ); |
|
479 } |
|
480 else |
|
481 { |
|
482 iFepMan.TryChangeModeL(ENumber); |
|
483 } |
|
484 } |
|
485 } |
|
486 else if (!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) && |
|
487 iFepMan.OkToActivateSelectionMode()) |
|
488 { |
|
489 // User wants to select and not to change mode, so cancel the mode change |
|
490 // caused by initial hash key press. |
|
491 MPtiLanguage* lang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
492 TInt inputLang = ELangTest; |
|
493 if (lang) |
|
494 { |
|
495 inputLang = lang->LanguageCode(); |
|
496 } |
|
497 const TInt inputMode = iFepMan.InputMode(); |
|
498 |
|
499 if ((inputLang == ELangPrcChinese && inputMode == EPinyin) || |
|
500 (inputLang == ELangTaiwanChinese && inputMode == EZhuyin) || |
|
501 (inputLang == ELangHongKongChinese && inputMode == EStroke)) |
|
502 { |
|
503 // Hash key selection was initiated from number mode, |
|
504 // return there. |
|
505 iFepMan.TryChangeModeL(ENumber); |
|
506 } |
|
507 else |
|
508 { |
|
509 iFepMan.TryChangeToModeBeforeL(); |
|
510 } |
|
511 |
|
512 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
513 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
514 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
515 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
516 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
517 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
518 } |
|
519 } |
|
520 response = EKeyWasConsumed; |
|
521 } |
|
522 return response; |
|
523 } |
|
524 |
|
525 |
|
526 TKeyResponse CAknFepHashKeyManager::HandleKeyJapaneseL(TKeyPressLength aLength) |
|
527 { |
|
528 TKeyResponse response = EKeyWasNotConsumed; |
|
529 if (aLength == ELongKeyPress) |
|
530 { |
|
531 response = HandleLongKeypressJapaneseL(); |
|
532 } |
|
533 else |
|
534 { |
|
535 response = HandleSortKeypressJapaneseL(); |
|
536 } |
|
537 return response; |
|
538 } |
|
539 |
|
540 TKeyResponse CAknFepHashKeyManager::HandleLongKeypressJapaneseL() |
|
541 { |
|
542 TKeyResponse response = EKeyWasConsumed; |
|
543 |
|
544 if (iFepMan.IsOnlyNumericPermitted()) |
|
545 { |
|
546 if (iFepMan.HashKeySelectionInUse()) |
|
547 { |
|
548 TText prevCh = iFepMan.PreviousChar(); |
|
549 if (prevCh == '#') |
|
550 { |
|
551 iFepMan.RemovePreviousCharacterL(); |
|
552 } |
|
553 } |
|
554 } |
|
555 |
|
556 if (iMode == EHiraganaKanji || iMode == ELatin) |
|
557 { |
|
558 // predictive input is turned on/off |
|
559 // Commit string on transitory input |
|
560 iFepMan.TryCloseUiL(); |
|
561 |
|
562 if(iWesternPredictive) |
|
563 { |
|
564 iFepMan.TryChangePredictiveInputModeL(EFalse); |
|
565 } |
|
566 else |
|
567 { |
|
568 iFepMan.TryChangePredictiveInputModeL(ETrue); |
|
569 } |
|
570 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateChangeToPredictionMode); |
|
571 } |
|
572 else if (iMode == EHiragana) |
|
573 { |
|
574 // nothing to do |
|
575 } |
|
576 else |
|
577 { |
|
578 // Input mode is incremented. |
|
579 iFepMan.TryIncrementModeL(iMode); |
|
580 if ( iMode == ELatin ) |
|
581 { |
|
582 if (iCaseMan->IsAbleChangeCase()) |
|
583 { |
|
584 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
585 TInt permittedCases = editorState->PermittedCases(); |
|
586 if (permittedCases & EAknEditorTextCase) |
|
587 { |
|
588 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
589 iCaseMan->UpdateCase(ENullNaviEvent); |
|
590 } |
|
591 else |
|
592 { |
|
593 if ( iFepMan.CaseBefore() ) |
|
594 { |
|
595 iCaseMan->SetCurrentCase(iFepMan.CaseBefore()); |
|
596 } |
|
597 else if (permittedCases & EAknEditorUpperCase) |
|
598 { |
|
599 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
600 if ( !(permittedCases & EAknEditorLowerCase)) |
|
601 { |
|
602 // We need to move to next input mode since only upper case |
|
603 // is permitted in Latin input mode. |
|
604 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
605 } |
|
606 } |
|
607 else |
|
608 { |
|
609 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
610 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
611 } |
|
612 } |
|
613 } |
|
614 } |
|
615 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateChangeToPredictionMode); |
|
616 } |
|
617 |
|
618 if (iFepMan.HashKeySelectionInUse() |
|
619 && !iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode) |
|
620 && iFepMan.OkToActivateSelectionMode()) |
|
621 { |
|
622 // User wants to select and not to change mode, so cancel the mode change |
|
623 // caused by initial hash key press. |
|
624 SetPreviousSelectionStyleModeL(); |
|
625 |
|
626 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStateHashDown | |
|
627 CAknFepManager::ECcpuStateEdwinInSelectionMode ); |
|
628 TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0}; |
|
629 // to enable copy/paste support on cba. We simulate via CCoeEnv |
|
630 // to avoid fep SimulateKeyEventL adding shift modifiers |
|
631 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); |
|
632 } |
|
633 |
|
634 return response; |
|
635 } |
|
636 |
|
637 TKeyResponse CAknFepHashKeyManager::HandleSortKeypressJapaneseL() |
|
638 { |
|
639 TKeyResponse response = EKeyWasConsumed; |
|
640 if (iFepMan.IsOnlyNumericPermitted()) |
|
641 { |
|
642 response = EKeyWasNotConsumed; |
|
643 } |
|
644 else if (iMode == EHiragana) |
|
645 { |
|
646 response = EKeyWasConsumed; |
|
647 } |
|
648 else if (iFepMan.HashKeySelectionInUse() |
|
649 && iPreviousSelection) |
|
650 { |
|
651 // User wants to select and not to change mode, so not change to input mode |
|
652 response = EKeyWasConsumed; |
|
653 iPreviousSelection = EFalse; |
|
654 } |
|
655 else |
|
656 { |
|
657 CancelHashKeyTimer(); |
|
658 if ( iMode == ELatin && iCaseMan->IsAbleChangeCase()) |
|
659 { |
|
660 // Input mode is incremented. |
|
661 iFepMan.TryIncrementModeL(iMode); |
|
662 if (iFepMan.IsQwerty()) |
|
663 { |
|
664 if ( iMode == ELatin ) |
|
665 { |
|
666 iFepMan.TryIncrementModeL(ENumber); |
|
667 } |
|
668 } |
|
669 } |
|
670 else if ( iMode == ELatin && !iCaseMan->IsAbleChangeCase() && iFepMan.IsQwerty()) |
|
671 { |
|
672 // In Qwerty input and not be able to change case mode, |
|
673 // Number mode must be skipped. |
|
674 iFepMan.TryIncrementModeL(ENumber); |
|
675 } |
|
676 else |
|
677 { |
|
678 // Input mode is incremented. |
|
679 iFepMan.TryIncrementModeL(iMode); |
|
680 if ( iMode == ELatin ) |
|
681 { |
|
682 if (iCaseMan->IsAbleChangeCase()) |
|
683 { |
|
684 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
685 TInt permittedCases = editorState->PermittedCases(); |
|
686 if (permittedCases & EAknEditorTextCase) |
|
687 { |
|
688 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
689 iCaseMan->UpdateCase(ENullNaviEvent); |
|
690 } |
|
691 else |
|
692 { |
|
693 if ( iFepMan.CaseBefore() ) |
|
694 { |
|
695 iCaseMan->SetCurrentCase(iFepMan.CaseBefore()); |
|
696 } |
|
697 else if (permittedCases & EAknEditorUpperCase) |
|
698 { |
|
699 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
700 if ( !(permittedCases & EAknEditorLowerCase)) |
|
701 { |
|
702 // We need to move to next input mode since only upper case |
|
703 // is permitted in Latin input mode. |
|
704 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
705 } |
|
706 } |
|
707 else |
|
708 { |
|
709 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
710 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
711 } |
|
712 } |
|
713 } |
|
714 } |
|
715 } |
|
716 } |
|
717 |
|
718 return response; |
|
719 } |
|
720 |
|
721 |
|
722 enum |
|
723 { |
|
724 EHashPredictionBit = 0x01, |
|
725 EHashTextCaseBit = 0x02, |
|
726 EHashUpperCaseBit = 0x04, |
|
727 EHashLowerCaseBit = 0x08, |
|
728 EHashNumberModeBit = 0x10, |
|
729 }; |
|
730 |
|
731 enum |
|
732 { |
|
733 EHashLatinLowerMode = EHashLowerCaseBit, |
|
734 EHashLatinUpperMode = EHashUpperCaseBit, |
|
735 EHashLatinTextMode = EHashTextCaseBit, |
|
736 EHashPredLowerMode = EHashLowerCaseBit | EHashPredictionBit, |
|
737 EHashPredUpperMode = EHashUpperCaseBit | EHashPredictionBit, |
|
738 EHashPredTextMode = EHashTextCaseBit | EHashPredictionBit |
|
739 }; |
|
740 |
|
741 enum |
|
742 { |
|
743 EHashIndicMultitapMode, |
|
744 EHashIndicPredictiveMode, |
|
745 #ifdef RD_HINDI_PHONETIC_INPUT |
|
746 EHashIndicPhoneticLowerMode, |
|
747 EHashIndicPhoneticUpperMode, |
|
748 #endif |
|
749 EHashIndicLatinTextMode, |
|
750 EHashIndicLatinLowerMode, |
|
751 EHashIndicLatinUpperMode, |
|
752 EHashNumberMode |
|
753 |
|
754 }; |
|
755 // Here we enumerate possible mode sequences for selection style has key loop. |
|
756 // Number mode is handled as a special case. This only consumes 24 bytes. |
|
757 const TInt KNumModesInLoop = 4; |
|
758 const TUint8 allHashKeyLoops[] = |
|
759 { |
|
760 EHashLatinLowerMode, EHashLatinUpperMode, EHashPredLowerMode, EHashPredUpperMode, |
|
761 EHashLatinUpperMode, EHashLatinLowerMode, EHashPredUpperMode, EHashPredLowerMode, |
|
762 EHashLatinTextMode, EHashLatinLowerMode, EHashPredTextMode, EHashPredLowerMode, |
|
763 EHashPredLowerMode, EHashPredUpperMode, EHashLatinLowerMode, EHashLatinUpperMode, |
|
764 EHashPredUpperMode, EHashPredLowerMode, EHashLatinUpperMode, EHashLatinLowerMode, |
|
765 EHashPredTextMode, EHashPredLowerMode, EHashLatinTextMode, EHashLatinLowerMode |
|
766 }; |
|
767 |
|
768 |
|
769 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternSelectionStyleL(TKeyPressLength aLength) |
|
770 { |
|
771 TKeyResponse response = EKeyWasNotConsumed; |
|
772 |
|
773 if (aLength == EShortKeyPress) |
|
774 { |
|
775 if (iFepMan.IsOnlyNumericPermitted()) |
|
776 { |
|
777 if (!iFepMan.IsExtendedFlagSet(CAknFepManager::EExtendedFlagShortPressHashKey)) |
|
778 { |
|
779 // Set the flag to indicate its a short press of key event |
|
780 iFepMan.SetExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
781 response = EKeyWasConsumed; |
|
782 } |
|
783 else |
|
784 { |
|
785 iFepMan.ClearExtendedFlag(CAknFepManager::EExtendedFlagShortPressHashKey); |
|
786 } |
|
787 return response; |
|
788 } |
|
789 |
|
790 if(IsIndicHashKeyStyleRequired()) |
|
791 { |
|
792 return (SetIndicStateL()); |
|
793 } |
|
794 |
|
795 if (!iSelectionLoop) |
|
796 { |
|
797 TInt index = 0; |
|
798 if (iFepMan.WesternPredictive(ELatin)) |
|
799 { |
|
800 index += (3 * KNumModesInLoop); |
|
801 } |
|
802 |
|
803 switch (iCaseMan->CurrentCase()) |
|
804 { |
|
805 case EAknEditorUpperCase: |
|
806 index += KNumModesInLoop; |
|
807 break; |
|
808 case EAknEditorTextCase: |
|
809 index += (2 * KNumModesInLoop); |
|
810 break; |
|
811 default: |
|
812 break; |
|
813 } |
|
814 |
|
815 iSelectionLoop = &allHashKeyLoops[index]; |
|
816 |
|
817 if (iMode == ENumber || iMode == ENativeNumber) |
|
818 { |
|
819 iSelectionLoopIndex = -1; |
|
820 } |
|
821 } |
|
822 |
|
823 if (!iFepMan.InputLanguageSupportsCaseChanges()) |
|
824 { |
|
825 // Jumping by 2 always ignores case change. |
|
826 iSelectionLoopIndex += 2; |
|
827 } |
|
828 else |
|
829 { |
|
830 iSelectionLoopIndex++; |
|
831 } |
|
832 |
|
833 if (iSelectionLoopIndex >= 0 && (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0) |
|
834 { |
|
835 MPtiLanguage* curLang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
836 if(!iFepMan.InputLanguageSupportsCaseChanges()) |
|
837 { |
|
838 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
839 if(edit && edit->DocumentLengthForFep() > 0) |
|
840 { |
|
841 edit->GetCursorSelectionForFep(iPreviousIndicCursorPosition); |
|
842 } |
|
843 |
|
844 } |
|
845 if ((curLang && curLang->HasInputMode(EPtiEnginePredictive) == EFalse) || |
|
846 (iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
847 { |
|
848 // If next one would be prediction, but prediction is not allowed, |
|
849 // skip modes. |
|
850 iSelectionLoopIndex += 2; |
|
851 } |
|
852 } |
|
853 |
|
854 if (iSelectionLoopIndex >= KNumModesInLoop) |
|
855 { |
|
856 iSelectionLoopIndex = -1; |
|
857 } |
|
858 |
|
859 SetSelectionStyleModeL(); |
|
860 |
|
861 response = EKeyWasConsumed; |
|
862 } |
|
863 |
|
864 return response; |
|
865 } |
|
866 |
|
867 |
|
868 void CAknFepHashKeyManager::SetPreviousSelectionStyleModeL() |
|
869 { |
|
870 if(IsIndicHashKeyStyleRequired()) |
|
871 { |
|
872 SetIndicPreviousStateL(); |
|
873 return; |
|
874 } |
|
875 if (iFepMan.IsOnlyNumericPermitted() || !iSelectionLoop) |
|
876 { |
|
877 // iSelectionLoop is not used in Japanese variant, |
|
878 // so, it keeps previous selection. |
|
879 if (!iSelectionLoop) |
|
880 { |
|
881 iPreviousSelection = ETrue; |
|
882 } |
|
883 return; |
|
884 } |
|
885 |
|
886 if (!iFepMan.InputLanguageSupportsCaseChanges()) |
|
887 { |
|
888 // Jumping by 2 always ignores case change. |
|
889 iSelectionLoopIndex -= 2; |
|
890 if (iSelectionLoopIndex >= 0 && |
|
891 (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) == 0 ) |
|
892 { |
|
893 |
|
894 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
895 if(edit && edit->DocumentLengthForFep() > 0) |
|
896 { |
|
897 edit->SetCursorSelectionForFepL(iPreviousIndicCursorPosition); |
|
898 } |
|
899 } |
|
900 } |
|
901 else |
|
902 { |
|
903 iSelectionLoopIndex--; |
|
904 } |
|
905 |
|
906 if (iSelectionLoopIndex >= 0 && |
|
907 (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0 && |
|
908 (iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
909 { |
|
910 // If next one would be prediction, but prediction is not allowed, |
|
911 // skip modes. |
|
912 iSelectionLoopIndex -= 2; |
|
913 } |
|
914 |
|
915 if (iSelectionLoopIndex < -1) |
|
916 { |
|
917 // Jump over to the end of list |
|
918 iSelectionLoopIndex = KNumModesInLoop - 1; |
|
919 } |
|
920 |
|
921 SetSelectionStyleModeL(); |
|
922 } |
|
923 |
|
924 |
|
925 |
|
926 void CAknFepHashKeyManager::SetSelectionStyleModeL() |
|
927 { |
|
928 TBool wasPredictive = iFepMan.WesternPredictive(); |
|
929 TBool willBePredictive = EFalse; |
|
930 |
|
931 if (iSelectionLoopIndex == -1) |
|
932 { |
|
933 // Set number mode. |
|
934 if( iFepMan.IsSupportNativeNumber()) |
|
935 { |
|
936 iFepMan.TryChangeModeL( ENativeNumber ); |
|
937 } |
|
938 else |
|
939 { |
|
940 iFepMan.TryChangeModeL(ENumber); |
|
941 } |
|
942 } |
|
943 else |
|
944 { |
|
945 willBePredictive = (iSelectionLoop[iSelectionLoopIndex] & EHashPredictionBit) != 0; |
|
946 iFepMan.SetWesternPredictive(willBePredictive); |
|
947 if (iSelectionLoop[iSelectionLoopIndex] & EHashLowerCaseBit) |
|
948 { |
|
949 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
950 } |
|
951 else if (iSelectionLoop[iSelectionLoopIndex] & EHashUpperCaseBit) |
|
952 { |
|
953 // Let case manager to decide whether we use text case or |
|
954 // upper case. |
|
955 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
956 TInt permittedCases = EAknEditorAllCaseModes; |
|
957 if(editorState) |
|
958 permittedCases = editorState->PermittedCases(); |
|
959 if (!(permittedCases&EAknEditorTextCase ) || |
|
960 iCaseMan->CapsLockRequired(EAknEditorLowerCase)) |
|
961 { |
|
962 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
963 } |
|
964 else |
|
965 { |
|
966 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
967 } |
|
968 } |
|
969 else |
|
970 { |
|
971 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
972 } |
|
973 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
974 if (!(wasPredictive && willBePredictive)) |
|
975 { |
|
976 // Do not do this if this is just case change inside predictive mode, |
|
977 // otherwise active word will be committed. |
|
978 iFepMan.SetCcpuFlag(CAknFepManager::ECcpuStataCommitPredictiveWord); |
|
979 iFepMan.TryChangeModeL(ELatin); |
|
980 } |
|
981 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
982 } |
|
983 } |
|
984 void CAknFepHashKeyManager::UpdateCaseForIndicHashLoop() |
|
985 { |
|
986 switch (iCaseMan->CurrentCase()) |
|
987 { |
|
988 case EAknEditorUpperCase: |
|
989 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
990 break; |
|
991 case EAknEditorTextCase: |
|
992 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
993 break; |
|
994 case EAknEditorLowerCase: |
|
995 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
996 break; |
|
997 default: |
|
998 break; |
|
999 } |
|
1000 } |
|
1001 |
|
1002 |
|
1003 TBool CAknFepHashKeyManager::IsIndicHashKeyStyleRequired() |
|
1004 { |
|
1005 if(TAknFepUiIndicInputManager::IsIndicLangauge(iFepMan.GetInputLanguageFromSharedDataInterface()) |
|
1006 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1007 || TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1008 iFepMan.GetInputLanguageFromSharedDataInterface()) |
|
1009 #endif |
|
1010 ) |
|
1011 { |
|
1012 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
1013 if (editorState && !(editorState->Flags() & EAknEditorFlagLatinInputModesOnly)) |
|
1014 { |
|
1015 return ETrue; |
|
1016 } |
|
1017 } |
|
1018 return EFalse; |
|
1019 } |
|
1020 |
|
1021 |
|
1022 TKeyResponse CAknFepHashKeyManager::SetIndicPreviousStateL() |
|
1023 { |
|
1024 TKeyResponse response = EKeyWasNotConsumed; |
|
1025 if (iFepMan.IsOnlyNumericPermitted()) |
|
1026 { |
|
1027 return response; |
|
1028 } |
|
1029 switch(iIndicSelectionLoopIndex) |
|
1030 { |
|
1031 case EHashIndicMultitapMode: |
|
1032 case EHashIndicPredictiveMode: // fall through |
|
1033 if(iLanguageChangedOrChangeFromNumberMode) |
|
1034 { |
|
1035 if(iFepMan.HashKeySelectionInUse()) |
|
1036 { |
|
1037 iIndicSelectionLoopIndex = EHashNumberMode; |
|
1038 } |
|
1039 else |
|
1040 { |
|
1041 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1042 if(iIndicSelectionLoopIndex) // if hindi predictive is on, turn off for english |
|
1043 { |
|
1044 iFepMan.SetWesternPredictive(EFalse); |
|
1045 iFepMan.TryChangeModeL(ELatin); |
|
1046 } |
|
1047 UpdateCaseForIndicHashLoop(); |
|
1048 } |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 // Reverts predictive text settings change made with short key press. |
|
1053 if(iIndicSelectionLoopIndex) // Meaning predictive state |
|
1054 { |
|
1055 iIndicSelectionLoopIndex = EHashIndicMultitapMode; // change to multitap |
|
1056 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
1057 if(edit && edit->DocumentLengthForFep() > 0) |
|
1058 { |
|
1059 edit->SetCursorSelectionForFepL(iPreviousIndicCursorPosition); |
|
1060 } |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 iIndicSelectionLoopIndex = EHashIndicPredictiveMode; // change to predictive |
|
1065 } |
|
1066 } |
|
1067 break; |
|
1068 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1069 case EHashIndicPhoneticLowerMode: |
|
1070 case EHashIndicPhoneticUpperMode: |
|
1071 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1072 { |
|
1073 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1074 iFepMan.SetWesternPredictive(EFalse); |
|
1075 iFepMan.TryChangeModeL(ELatin); |
|
1076 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1077 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1082 { |
|
1083 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1084 } |
|
1085 else if(iIndicSelectionLoopIndex == EHashIndicPhoneticLowerMode) |
|
1086 { |
|
1087 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1088 } |
|
1089 } |
|
1090 break; |
|
1091 #endif |
|
1092 case EHashIndicLatinTextMode: // Text Case |
|
1093 case EHashIndicLatinUpperMode: // Upper Case |
|
1094 case EHashIndicLatinLowerMode: // Lower Case |
|
1095 if(iLanguageChangedOrChangeFromNumberMode) |
|
1096 { |
|
1097 iFepMan.ChangeInputLanguageL(iFepMan.GetInputLanguageFromSharedDataInterface()); |
|
1098 iIndicSelectionLoopIndex = iIndicPredictiveState; |
|
1099 } |
|
1100 else |
|
1101 { |
|
1102 if (iIndicSelectionLoopIndex == EHashIndicLatinLowerMode) |
|
1103 { |
|
1104 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1109 } |
|
1110 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1111 if(iCaseMan->CurrentCase() == EAknEditorTextCase) |
|
1112 { |
|
1113 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
1114 } |
|
1115 else |
|
1116 { |
|
1117 iCaseMan->RevertCaseChange(); |
|
1118 } |
|
1119 } |
|
1120 break; |
|
1121 |
|
1122 case EHashNumberMode: |
|
1123 if(iFepMan.HashKeySelectionInUse()) |
|
1124 { |
|
1125 iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1126 iFepMan.SetWesternPredictive(EFalse); |
|
1127 iFepMan.TryChangeModeL(ELatin); |
|
1128 UpdateCaseForIndicHashLoop(); |
|
1129 } |
|
1130 break; |
|
1131 } |
|
1132 SetIndicSelectionStateL(); |
|
1133 return EKeyWasConsumed; |
|
1134 } |
|
1135 |
|
1136 void CAknFepHashKeyManager::ResetIndicHashKeyStateL() |
|
1137 { |
|
1138 if(IsIndicHashKeyStyleRequired()) |
|
1139 { |
|
1140 TInt editorMode = iFepMan.EditorState()->CurrentInputMode(); |
|
1141 if(editorMode == EAknEditorNumericInputMode) |
|
1142 { |
|
1143 iIndicSelectionLoopIndex = EHashNumberMode; |
|
1144 } |
|
1145 else |
|
1146 { |
|
1147 MPtiLanguage* curLang = iFepMan.PtiEngine()->CurrentLanguage(); |
|
1148 if(curLang && curLang->LanguageCode()!=ELangEnglish ) |
|
1149 { |
|
1150 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1151 if(iFepMan.IsIndicPhoneticInputLanguage()) |
|
1152 { |
|
1153 if(iCaseMan->CurrentCase() == EAknEditorUpperCase) |
|
1154 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1155 else |
|
1156 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1157 } |
|
1158 else |
|
1159 { |
|
1160 #endif |
|
1161 iIndicPredictiveState = iIndicSelectionLoopIndex = iFepMan.WesternPredictive(ELatin); |
|
1162 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1163 } |
|
1164 #endif |
|
1165 } |
|
1166 else |
|
1167 { |
|
1168 UpdateCaseForIndicHashLoop(); |
|
1169 } |
|
1170 } |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 TKeyResponse CAknFepHashKeyManager::SetIndicStateL() |
|
1175 { |
|
1176 TKeyResponse response = EKeyWasNotConsumed; |
|
1177 |
|
1178 if (iFepMan.IsOnlyNumericPermitted()) |
|
1179 { |
|
1180 return response; |
|
1181 } |
|
1182 |
|
1183 iLanguageChangedOrChangeFromNumberMode = EFalse; |
|
1184 if(iIndicSelectionLoopIndex == -1) |
|
1185 { |
|
1186 iIndicPredictiveState = iIndicSelectionLoopIndex = |
|
1187 (iFepMan.WesternPredictive(ELatin) && |
|
1188 (!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9))); |
|
1189 // Cannot be done in constructor as FepMan is not completely initialized |
|
1190 } |
|
1191 |
|
1192 switch(iIndicSelectionLoopIndex) |
|
1193 { |
|
1194 case EHashIndicMultitapMode: |
|
1195 case EHashIndicPredictiveMode: //fall through |
|
1196 |
|
1197 iIndicPredictiveState = iIndicSelectionLoopIndex; // 0 for multitap and 1 for predictive |
|
1198 if(iFepMan.WasLastKeyPressAHashKey() || |
|
1199 ( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
1200 { |
|
1201 //iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1202 iFepMan.SetWesternPredictive(EFalse); |
|
1203 iFepMan.TryChangeModeL(ELatin); |
|
1204 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1205 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1206 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1207 if(iCaseMan->CurrentCase() == EAknEditorTextCase) |
|
1208 { |
|
1209 iIndicSelectionLoopIndex = EHashIndicLatinTextMode; |
|
1210 } |
|
1211 else |
|
1212 { |
|
1213 iCaseMan->RevertCaseChange(); |
|
1214 } |
|
1215 } |
|
1216 else |
|
1217 { |
|
1218 if(iIndicSelectionLoopIndex) // Meaning predictive state |
|
1219 { |
|
1220 iIndicSelectionLoopIndex = EHashIndicMultitapMode; // change to multitap |
|
1221 } |
|
1222 else |
|
1223 { |
|
1224 if(!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) |
|
1225 { |
|
1226 iIndicSelectionLoopIndex = EHashIndicPredictiveMode; // change to predictive |
|
1227 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); |
|
1228 if(edit && edit->DocumentLengthForFep() > 0) |
|
1229 { |
|
1230 edit->GetCursorSelectionForFep(iPreviousIndicCursorPosition); |
|
1231 } |
|
1232 } |
|
1233 } |
|
1234 } |
|
1235 break; |
|
1236 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1237 case EHashIndicPhoneticLowerMode: |
|
1238 case EHashIndicPhoneticUpperMode: |
|
1239 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1240 { |
|
1241 //iFepMan.ChangeInputLanguageL(ELangEnglish); |
|
1242 iFepMan.SetWesternPredictive(EFalse); |
|
1243 iFepMan.TryChangeModeL(ELatin); |
|
1244 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1245 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1246 } |
|
1247 else |
|
1248 { |
|
1249 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1250 { |
|
1251 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1252 } |
|
1253 else if(iIndicSelectionLoopIndex == EHashIndicPhoneticLowerMode) |
|
1254 { |
|
1255 iIndicSelectionLoopIndex = EHashIndicPhoneticUpperMode; |
|
1256 } |
|
1257 } |
|
1258 break; |
|
1259 #endif |
|
1260 case EHashIndicLatinTextMode: // Text Case |
|
1261 case EHashIndicLatinLowerMode: // Lower Case |
|
1262 case EHashIndicLatinUpperMode: // Upper Case |
|
1263 if(iFepMan.WasLastKeyPressAHashKey()) |
|
1264 { |
|
1265 //iFepMan.ChangeInputLanguageL(iFepMan.GetInputLanguageFromSharedDataInterface()); |
|
1266 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1267 if(iFepMan.HashKeySelectionInUse()) |
|
1268 { |
|
1269 iIndicSelectionLoopIndex = EHashNumberMode; // change to number |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1274 if(TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1275 iFepMan.GetInputLanguageFromSharedDataInterface())) |
|
1276 { |
|
1277 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1278 } |
|
1279 else |
|
1280 { |
|
1281 #endif |
|
1282 iIndicSelectionLoopIndex = iIndicPredictiveState; // change to hindi [multitap or predictive based on previous setting] |
|
1283 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1284 } |
|
1285 #endif |
|
1286 } |
|
1287 } |
|
1288 else |
|
1289 { |
|
1290 switch (iCaseMan->CurrentCase()) |
|
1291 { |
|
1292 case EAknEditorUpperCase: |
|
1293 case EAknEditorTextCase: //fall through |
|
1294 iIndicSelectionLoopIndex = EHashIndicLatinLowerMode; |
|
1295 break; |
|
1296 case EAknEditorLowerCase: |
|
1297 iIndicSelectionLoopIndex = EHashIndicLatinUpperMode; |
|
1298 break; |
|
1299 default: |
|
1300 break; |
|
1301 } |
|
1302 } |
|
1303 break; |
|
1304 |
|
1305 case EHashNumberMode: |
|
1306 if(iFepMan.HashKeySelectionInUse()) |
|
1307 { |
|
1308 iLanguageChangedOrChangeFromNumberMode = ETrue; |
|
1309 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1310 if(TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage( |
|
1311 iFepMan.GetInputLanguageFromSharedDataInterface())) |
|
1312 { |
|
1313 iIndicSelectionLoopIndex = EHashIndicPhoneticLowerMode; |
|
1314 iFepMan.TryChangeModeL(ELatin); |
|
1315 } |
|
1316 else |
|
1317 { |
|
1318 #endif |
|
1319 iIndicSelectionLoopIndex = iIndicPredictiveState; // change to hindi [multitap or predictive based on previous setting] |
|
1320 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1321 } |
|
1322 #endif |
|
1323 } |
|
1324 break; |
|
1325 |
|
1326 default: |
|
1327 break; |
|
1328 } |
|
1329 |
|
1330 SetIndicSelectionStateL(); |
|
1331 return EKeyWasConsumed; |
|
1332 } |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 void CAknFepHashKeyManager::SetIndicSelectionStateL() |
|
1338 { |
|
1339 switch(iIndicSelectionLoopIndex) |
|
1340 { |
|
1341 |
|
1342 case EHashIndicMultitapMode: |
|
1343 { |
|
1344 iFepMan.SetWesternPredictive(EFalse); |
|
1345 iFepMan.TryChangeModeL(EHindi); |
|
1346 } |
|
1347 break; |
|
1348 |
|
1349 case EHashIndicPredictiveMode: |
|
1350 if(!( iFepMan.EditorState()->Flags() & EAknEditorFlagNoT9)) // make sure predictive is supported for editor |
|
1351 { |
|
1352 iFepMan.SetWesternPredictive(ETrue); |
|
1353 iFepMan.TryChangeModeL(EHindi); |
|
1354 } |
|
1355 break; |
|
1356 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1357 case EHashIndicPhoneticLowerMode: |
|
1358 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
1359 break; |
|
1360 |
|
1361 case EHashIndicPhoneticUpperMode: |
|
1362 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
1363 break; |
|
1364 #endif |
|
1365 case EHashIndicLatinTextMode: |
|
1366 iCaseMan->SetCurrentCase(EAknEditorTextCase, ETrue); |
|
1367 break; |
|
1368 |
|
1369 case EHashIndicLatinUpperMode: |
|
1370 iCaseMan->SetCurrentCase(EAknEditorUpperCase, ETrue); |
|
1371 break; |
|
1372 |
|
1373 case EHashIndicLatinLowerMode: |
|
1374 iCaseMan->SetCurrentCase(EAknEditorLowerCase, ETrue); |
|
1375 break; |
|
1376 |
|
1377 case EHashNumberMode: |
|
1378 if( iFepMan.IsSupportNativeNumber()) |
|
1379 { |
|
1380 iFepMan.TryChangeModeL(ENativeNumber); |
|
1381 } |
|
1382 else |
|
1383 { |
|
1384 iFepMan.TryChangeModeL(ENumber); |
|
1385 } |
|
1386 break; |
|
1387 default: |
|
1388 break; |
|
1389 } |
|
1390 } |
|
1391 |
|
1392 void CAknFepHashKeyManager::ResetPreviousSelectionStyleMode() |
|
1393 { |
|
1394 iPreviousSelection = EFalse; |
|
1395 } |
|
1396 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1397 void CAknFepHashKeyManager::HandleSetIndicStateL() |
|
1398 { |
|
1399 //calling SetIndicStateL only if currently it is in upper mode |
|
1400 if(iIndicSelectionLoopIndex == EHashIndicPhoneticUpperMode) |
|
1401 SetIndicStateL(); |
|
1402 } |
|
1403 #endif |
|
1404 |
|
1405 TKeyResponse CAknFepHashKeyManager::HandleKeyWesternWithKoreanL(TKeyPressLength aLength) |
|
1406 { |
|
1407 TKeyResponse response = EKeyWasNotConsumed; |
|
1408 |
|
1409 if(iMode == ELatin) |
|
1410 { |
|
1411 iFepMan.SetWesternPredictive(EFalse); |
|
1412 } |
|
1413 |
|
1414 if (iFepMan.IsOnlyNumericPermitted()) |
|
1415 { |
|
1416 if (aLength == ELongKeyPress) |
|
1417 { |
|
1418 TText prevCh = iFepMan.PreviousChar(); |
|
1419 if (prevCh == '#') |
|
1420 { |
|
1421 iFepMan.RemovePreviousCharacterL(); |
|
1422 } |
|
1423 |
|
1424 response = EKeyWasConsumed; |
|
1425 } |
|
1426 //else let the FEP Man put special chars into the editor |
|
1427 } |
|
1428 else |
|
1429 { |
|
1430 if (aLength == EShortKeyPress) |
|
1431 { |
|
1432 if (iMode == ENumber) |
|
1433 { |
|
1434 response = EKeyWasNotConsumed; |
|
1435 return response; |
|
1436 } |
|
1437 } |
|
1438 else // Long keypress |
|
1439 { |
|
1440 if (iMode == ENumber) |
|
1441 { |
|
1442 iLastModeNumber = ETrue; |
|
1443 |
|
1444 TText prevCh = iFepMan.PreviousChar(); |
|
1445 if (prevCh == '#') |
|
1446 { |
|
1447 iFepMan.RemovePreviousCharacterL(); |
|
1448 } |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 iLastModeNumber = EFalse; |
|
1453 } |
|
1454 |
|
1455 CAknEdwinState* editorState = iFepMan.EditorState(); |
|
1456 TInt permittedCases = editorState->PermittedCases(); |
|
1457 permittedCases = permittedCases == 0 ? |
|
1458 EAknEditorLowerCase | EAknEditorUpperCase : permittedCases; |
|
1459 if ( iMode == ELatin && (permittedCases & EAknEditorTextCase)) |
|
1460 { |
|
1461 // Latin case update is changed back to automatic if latin |
|
1462 // text case is allowed and the case is changed manually from #-key. |
|
1463 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
1464 } |
|
1465 TInt currentCase = iCaseMan->CurrentCase(); |
|
1466 |
|
1467 // Is current latin case last available case. |
|
1468 TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase) && |
|
1469 (( currentCase == EAknEditorLowerCase) || |
|
1470 ( currentCase == EAknEditorUpperCase && |
|
1471 !(permittedCases & EAknEditorLowerCase)) ) || |
|
1472 ( editorState->Flags() & EAknEditorFlagFixedCase) ) || |
|
1473 ( editorState->Flags() & EAknEditorFlagForceTransparentFepModes) ); |
|
1474 |
|
1475 if (iMode == ELatin && |
|
1476 !iFepMan.IsFlagSet(CAknFepManager::EFlagChangeInputMode) && |
|
1477 !lastCase ) |
|
1478 { |
|
1479 // Input mode is still Latin. Only case is updated. |
|
1480 if (permittedCases & EAknEditorTextCase) |
|
1481 { |
|
1482 iCaseMan->ManualCaseUpdate(); |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1487 } |
|
1488 |
|
1489 // Next time input mode is changed if any text is not entered before. |
|
1490 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1491 } |
|
1492 else |
|
1493 { |
|
1494 // Do not change mode, if text selection is ongoing. |
|
1495 if(!iFepMan.IsCcpuFlagSet(CAknFepManager::ECcpuStateEdwinInSelectionMode)) |
|
1496 { |
|
1497 // Input mode is incremented. |
|
1498 iFepMan.TryIncrementModeL(iMode); |
|
1499 |
|
1500 |
|
1501 iFepMan.ClearFlag(CAknFepManager::EFlagChangeInputMode); |
|
1502 |
|
1503 if (iMode == ELatin) // New mode after Increment. |
|
1504 { |
|
1505 if (editorState->Flags() & EAknEditorFlagFixedCase) |
|
1506 { |
|
1507 // Only one fixed case is available. Use it. |
|
1508 iCaseMan->ConfigureCaseStateFromEditorState(); |
|
1509 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1510 } |
|
1511 else if (editorState->Flags() & EAknEditorFlagForceTransparentFepModes) |
|
1512 { |
|
1513 // Only lower case is used with find pane. |
|
1514 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1515 iFepMan.SetFlag(CAknFepManager::EFlagSupressAutoUpdate); |
|
1516 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1517 } |
|
1518 else if (permittedCases & EAknEditorTextCase) |
|
1519 { |
|
1520 iCaseMan->SetCurrentCase(EAknEditorTextCase); |
|
1521 iCaseMan->UpdateCase(ENullNaviEvent); |
|
1522 } |
|
1523 else |
|
1524 { |
|
1525 if (permittedCases & EAknEditorUpperCase) |
|
1526 { |
|
1527 iCaseMan->SetCurrentCase(EAknEditorUpperCase); |
|
1528 if ( !(permittedCases & EAknEditorLowerCase)) |
|
1529 { |
|
1530 // We need to move to next input mode since only upper case |
|
1531 // is permitted in Latin input mode. |
|
1532 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1533 } |
|
1534 } |
|
1535 else |
|
1536 { |
|
1537 iCaseMan->SetCurrentCase(EAknEditorLowerCase); |
|
1538 iFepMan.SetFlag(CAknFepManager::EFlagChangeInputMode); |
|
1539 } |
|
1540 } |
|
1541 } |
|
1542 } |
|
1543 } |
|
1544 } |
|
1545 response = EKeyWasConsumed; |
|
1546 } |
|
1547 return response; |
|
1548 } |
|
1549 // End of File |