|
1 /* |
|
2 * Copyright (c) 2008 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 TAknFepInputStateStrokePhraseCreationBase definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 // System includes |
|
32 #include <e32cmn.h> |
|
33 #include <PtiEngine.h> |
|
34 #include <PtiDefs.h> |
|
35 #include <avkon.rsg> |
|
36 #include <AknFep.rsg> |
|
37 #include <PtiUserDicEntry.h> |
|
38 #include <aknnotewrappers.h> //CAknWarningNote |
|
39 |
|
40 // User includes |
|
41 #include "AknFepUIManagerStateInterface.h" |
|
42 #include "AknFepUICtrlInputPane.h" |
|
43 #include "aknfepuictrleditpane.h" //Stroke phrase creation |
|
44 #include "AknFepUICtrlCandidatePane.h" |
|
45 #include "AknFepManager.h" |
|
46 #include "aknfepuiinputminiqwertystrokephrasebase.h" |
|
47 |
|
48 // CONSTANTS |
|
49 |
|
50 const TInt KMaxPhraseCount = 50; |
|
51 const TInt KMaxPhraseCreationCount = 7; |
|
52 const TInt KMaxKeystrokeCount = 31; |
|
53 const TInt16 KStrokeDelimiter = 0x2022; |
|
54 const TInt16 KStrokeUnicode = 0x2461; |
|
55 const TInt16 KKey1 = 0x31; |
|
56 const TInt16 KKey6 = 0x36; |
|
57 |
|
58 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" ); |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
|
62 // C++ default constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 TAknFepInputMiniQwertyStrokePhraseBase::TAknFepInputMiniQwertyStrokePhraseBase( |
|
66 MAknFepUIManagerStateInterface* aOwner, |
|
67 MAknFepUICtrlContainerChinese* aUIContainer) |
|
68 :TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer) |
|
69 { |
|
70 iOwner->PtiEngine()->SetInputMode(EPtiEngineStrokePhraseQwerty); |
|
71 iOwner->PtiEngine()->SetCase(EPtiCaseLower); |
|
72 iOwner->PtiEngine()->SetCandidatePageLength( KMaxPhraseCount ); |
|
73 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
74 |
|
75 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
76 TBool multiplePages = !(candidatePane->IsLastPage() && |
|
77 candidatePane->IsFirstPage()); |
|
78 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyL |
|
83 // Handle system key press event. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 TBool TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyL( |
|
87 TInt aKey, |
|
88 TKeyPressLength aLength ) |
|
89 { |
|
90 TBool ret = ETrue; |
|
91 const TPtiKeyboardType keyboardType = iOwner->PtiEngine()->KeyboardType(); |
|
92 |
|
93 switch( aKey ) |
|
94 { |
|
95 case EKeyLeftShift: |
|
96 case EKeyLeftCtrl: |
|
97 case EKeyRightCtrl: |
|
98 case EStdKeyLeftFunc: |
|
99 { |
|
100 iOwner->FepMan()->TryCloseUiL(); |
|
101 ret = EFalse; |
|
102 break; |
|
103 } |
|
104 case EStdKeyDevice1:// CBA2 |
|
105 { |
|
106 iOwner->FepMan()->TryCloseUiL(); |
|
107 break; |
|
108 } |
|
109 case EStdKeyUpArrow: |
|
110 case EStdKeyDownArrow: |
|
111 case EKeyRightFunc: |
|
112 case EStdKeyEnter: |
|
113 { |
|
114 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
115 break; |
|
116 } |
|
117 case EStdKeyBackspace: |
|
118 { |
|
119 HandleKeyBackspaceL( aLength ); |
|
120 break; |
|
121 } |
|
122 case EStdKeyDevice0:// CBA1 |
|
123 case EStdKeyDevice3:// CBASelect |
|
124 { |
|
125 HandleCommitL( aLength ); |
|
126 break; |
|
127 } |
|
128 case EStdKeyLeftArrow: |
|
129 { |
|
130 if ( !MoveCursorLeft() ) |
|
131 { |
|
132 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
133 } |
|
134 break; |
|
135 } |
|
136 case EStdKeyRightArrow: |
|
137 { |
|
138 if ( !MoveCursorRight() ) |
|
139 { |
|
140 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
141 } |
|
142 break; |
|
143 } |
|
144 default: |
|
145 { |
|
146 ret = HandleDefaultL( aKey, aLength ); |
|
147 break; |
|
148 } |
|
149 } |
|
150 |
|
151 return ret; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // TAknFepInputMiniQwertyStrokePhraseBase::RefreshUI |
|
156 // Update input window. |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void TAknFepInputMiniQwertyStrokePhraseBase::RefreshUI() |
|
160 { |
|
161 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
162 // get cursor position |
|
163 if ( ( uiContainer->EditPaneWindow()->KeystrokeArray()->Count() == 0 ) && |
|
164 ( uiContainer->EditPaneWindow()->PhraseArray()->Count() == 0 ) ) |
|
165 { |
|
166 TPoint baseLine; |
|
167 TInt height(0); |
|
168 TInt ascent(0); |
|
169 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
170 if (ret == KErrNone) |
|
171 { |
|
172 uiContainer->SetContainerPosition(baseLine, height); |
|
173 } |
|
174 } |
|
175 if ( ( uiContainer->EditPaneWindow()->KeystrokeArray()->Count() > 0 ) || |
|
176 ( uiContainer->EditPaneWindow()->PhraseArray()->Count() > 0 ) ) |
|
177 { |
|
178 ShowInfoOnEEPPane(); |
|
179 SetWarningColor(); |
|
180 ShowInfoOnCandidatePane(); |
|
181 UpdateIndicator(); |
|
182 TRAP_IGNORE( ChangeCbaL() ); |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // TAknFepInputMiniQwertyStrokePhraseBase::CheckFirstGroupStroke |
|
188 // check the first group stroke of keystroke. |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 TBool TAknFepInputMiniQwertyStrokePhraseBase::CheckFirstGroupStroke() |
|
192 { |
|
193 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
194 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
195 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
196 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
197 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
198 TInt stringBeforeLength = 0; |
|
199 TInt stringAfterLength = 0; |
|
200 TInt keyCode = 0; |
|
201 TInt pos = 0; |
|
202 TBuf<1> delimiter; |
|
203 |
|
204 if ( 0 == keystroke->Count() ) |
|
205 { |
|
206 return EFalse; |
|
207 } |
|
208 |
|
209 delimiter.Append( KStrokeDelimiter ); |
|
210 |
|
211 //the keystroke is not delimiter the all keystroke is first group keystroke. |
|
212 if ( 0 != keystroke->Find( delimiter, pos ) ) |
|
213 { |
|
214 pos = keystroke->Count(); |
|
215 } |
|
216 //first keystroke is delimiter then first group keystroke is invalid. |
|
217 if ( 0 == pos ) |
|
218 { |
|
219 return EFalse; |
|
220 } |
|
221 |
|
222 ClearPtiEngineKeystroke(); |
|
223 |
|
224 for ( TInt i = 0; i < pos; ++i ) |
|
225 { |
|
226 //GetKeystrokeCode( keyCode, keystroke->MdcaPoint( i ) ); |
|
227 keyCode = (*keycodeArray)[i]; |
|
228 stringBeforeLength = |
|
229 ptiengine->GetPhoneticSpelling(1).Length(); |
|
230 stringAfterLength = |
|
231 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
232 //the keystroke is invalid. |
|
233 if ( stringBeforeLength == stringAfterLength ) |
|
234 { |
|
235 return EFalse; |
|
236 } |
|
237 } |
|
238 return ETrue; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // TAknFepInputMiniQwertyStrokePhraseBase::HandleCommitL |
|
243 // Handle CBA1 or select event. |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void TAknFepInputMiniQwertyStrokePhraseBase::HandleCommitL( |
|
247 TKeyPressLength aLength ) |
|
248 { |
|
249 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
250 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
251 TInt keyCount = editPane->KeystrokeArray()->Count(); |
|
252 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
253 TInt cdtCount = uiContainer->CandidatePane()->CandidateArray()->Count(); |
|
254 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
255 |
|
256 if ( !CheckKeyNeedRepeat( aLength ) ) |
|
257 { |
|
258 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
259 return; |
|
260 } |
|
261 |
|
262 if ( EMiniQwertyEdit == iState ) |
|
263 { |
|
264 if ( cdtCount > 0 ) |
|
265 { |
|
266 UIContainer()->EditPaneWindow()->SetChangeState( ETrue ); |
|
267 iOwner->ChangeState( ECandidate ); |
|
268 return; |
|
269 } |
|
270 |
|
271 if ( keyCount > 0 ) |
|
272 { |
|
273 fepMan->PlaySound( EAvkonSIDErrorTone ); |
|
274 return; |
|
275 } |
|
276 } |
|
277 |
|
278 if ( phrase->Count( ) <= 1 ) |
|
279 { |
|
280 fepMan->PlaySound( EAvkonSIDErrorTone ); |
|
281 return; |
|
282 } |
|
283 |
|
284 TBuf<KMaxPhraseCreationCount> phraseCreated; |
|
285 for (TInt i = 0; i < phrase->Count( ); ++i ) |
|
286 { |
|
287 phraseCreated.Append( phrase->MdcaPoint( i ) ); |
|
288 } |
|
289 fepMan->NewTextL( phraseCreated ); |
|
290 fepMan->CommitInlineEditL( ); |
|
291 AddPhraseToDB( phraseCreated ); |
|
292 fepMan->TryCloseUiL( ); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // TAknFepInputMiniQwertyStrokePhraseBase::HandleAutoChangeState |
|
297 // Auto change state. |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 TBool TAknFepInputMiniQwertyStrokePhraseBase::HandleAutoChangeState() |
|
301 { |
|
302 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
303 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
304 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
305 TBool FirstStrokeValid = CheckFirstGroupStroke(); |
|
306 //Auto change from EMiniQwertyEdit state to EEntry state. |
|
307 if ( EMiniQwertyEdit == iState ) |
|
308 { |
|
309 if ( FirstStrokeValid ) |
|
310 { |
|
311 if ( EAutoChangeStateFromInput == editPane->GetAutoChangeStateFlag() ) |
|
312 { |
|
313 editPane->SetChangeState( EFalse ); |
|
314 iOwner->ChangeState( EEntry ); |
|
315 return ETrue; |
|
316 } |
|
317 else if ( EAutoChangeStateFromCandidate == editPane->GetAutoChangeStateFlag() ) |
|
318 { |
|
319 editPane->SetChangeState( ETrue ); |
|
320 iOwner->ChangeState( ECandidate ); |
|
321 return ETrue; |
|
322 } |
|
323 } |
|
324 } |
|
325 |
|
326 //Auto change from EEntry state to EMiniQwertyEdit state. |
|
327 if ( EEntry == iState ) |
|
328 { |
|
329 if ( ( 0 <= index ) && ( !FirstStrokeValid ) ) |
|
330 { |
|
331 editPane->SetChangeState( EFalse ); |
|
332 editPane->SetAutoChangeStateFlag( EAutoChangeStateFromInput ); |
|
333 iOwner->ChangeState( EMiniQwertyEdit ); |
|
334 return ETrue; |
|
335 } |
|
336 } |
|
337 return EFalse; |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyBackspaceL |
|
342 // Handle KeyBackspace event. |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 void TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyBackspaceL( |
|
346 TKeyPressLength aLength ) |
|
347 { |
|
348 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
349 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
350 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
351 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
352 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
353 |
|
354 if ( !CheckKeyNeedRepeat( aLength ) ) |
|
355 { |
|
356 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
357 return; |
|
358 } |
|
359 |
|
360 if ( ( 0 == index ) && ( phraseCount != 0 ) ) |
|
361 { |
|
362 RevertPhraseToKeystrokeL(); |
|
363 } |
|
364 else if ( ( 0 == index ) && ( keystroke->Count() > 0 ) ) |
|
365 { |
|
366 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
367 return; |
|
368 } |
|
369 else |
|
370 { |
|
371 if ( !DeleteKeystroke() ) |
|
372 { |
|
373 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
374 return; |
|
375 } |
|
376 } |
|
377 |
|
378 //if the keystroke is null and phrase is null then close input window. |
|
379 if ( ( 0 == phraseCount ) && ( keystroke->Count() == 0 ) ) |
|
380 { |
|
381 iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI. |
|
382 if ( aLength == ELongKeyPress ) |
|
383 { |
|
384 iOwner->FepMan()->SetLongClearAfterCloseUI( ETrue ); |
|
385 } |
|
386 return; |
|
387 } |
|
388 |
|
389 if ( !HandleAutoChangeState() ) |
|
390 { |
|
391 RefreshUI(); |
|
392 } |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // TAknFepInputMiniQwertyStrokePhraseBase::HandleDefaultL |
|
397 // Handle default event. |
|
398 // --------------------------------------------------------------------------- |
|
399 // |
|
400 TBool TAknFepInputMiniQwertyStrokePhraseBase::HandleDefaultL( |
|
401 TInt aKey, |
|
402 TKeyPressLength aLength ) |
|
403 { |
|
404 TBool ret = ETrue; |
|
405 if( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || |
|
406 CAknFepFnKeyManager::EFnKeyLock == iOwner->FepMan()->FnKeyState() || |
|
407 ( CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState() && iState != ECandidate )) |
|
408 { |
|
409 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
410 } |
|
411 else if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed) || |
|
412 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
413 { |
|
414 iOwner->FepMan()->TryCloseUiL(); |
|
415 ret = EFalse; |
|
416 } |
|
417 else if ( ( EShortKeyPress == aLength ) && |
|
418 ( iOwner->IsValidChineseInputKeyQwerty( aKey ) ) ) |
|
419 { |
|
420 if ( iState == ECandidate ) |
|
421 { |
|
422 HandleKeyFromCandidateL( aKey, aLength ); |
|
423 } |
|
424 else |
|
425 { |
|
426 HandleDefaultKeyL( aKey ); |
|
427 } |
|
428 } |
|
429 else |
|
430 { |
|
431 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
432 } |
|
433 |
|
434 return ret; |
|
435 } |
|
436 |
|
437 // --------------------------------------------------------------------------- |
|
438 // TAknFepInputMiniQwertyStrokePhraseBase::HandleDefaultKeyL |
|
439 // Handle default key press event. |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 void TAknFepInputMiniQwertyStrokePhraseBase::HandleDefaultKeyL( TInt aKey ) |
|
443 { |
|
444 if ( !AddKeystrokeL( aKey ) ) |
|
445 { |
|
446 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
447 return; |
|
448 } |
|
449 |
|
450 if ( !HandleAutoChangeState() ) |
|
451 { |
|
452 RefreshUI(); |
|
453 } |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // TAknFepInputMiniQwertyStrokePhraseBase::ShowInfoOnEEP |
|
458 // Show the showinfo on the EEP ctrl. |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void TAknFepInputMiniQwertyStrokePhraseBase::ShowInfoOnEEPPane() |
|
462 { |
|
463 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
464 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
465 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
466 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
467 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
468 TBuf<KMaxKeystrokeCount> showInfo; |
|
469 |
|
470 for ( TInt i = 0; i < phrase->Count(); ++i ) |
|
471 { |
|
472 showInfo.Append( phrase->MdcaPoint( i ) ); |
|
473 } |
|
474 |
|
475 for ( TInt ii = 0; ii < keystroke->Count(); ++ii ) |
|
476 { |
|
477 showInfo.Append( keystroke->MdcaPoint( ii ) ); |
|
478 } |
|
479 |
|
480 editPane->SetText( showInfo, index + phrase->Count() ); |
|
481 |
|
482 switch ( iState ) |
|
483 { |
|
484 case ECandidate: |
|
485 editPane->DisableCursor(); |
|
486 break; |
|
487 case EEntry: |
|
488 editPane->EnableCursor(); |
|
489 editPane->DeactiveCursor(); |
|
490 break; |
|
491 case EMiniQwertyEdit: |
|
492 editPane->EnableCursor(); |
|
493 editPane->ActiveCursor(); |
|
494 break; |
|
495 default: |
|
496 break; |
|
497 } |
|
498 } |
|
499 |
|
500 // --------------------------------------------------------------------------- |
|
501 // TAknFepInputMiniQwertyStrokePhraseBase::ShowInfoOnEEP |
|
502 // Show the showinfo on the EEP ctrl. |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 void TAknFepInputMiniQwertyStrokePhraseBase::ShowInfoOnCandidatePane() |
|
506 { |
|
507 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
508 CDesCArrayFlat* phrase = uiContainer->CandidatePane()->CandidateArray(); |
|
509 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
510 if ( KMaxPhraseCreationCount == editPane->PhraseArray()->Count() ) |
|
511 { |
|
512 phrase->Reset(); |
|
513 TRAP_IGNORE( phrase->AppendL( KMaxPhraseNote ) ); |
|
514 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
515 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
516 uiContainer->Enable( ETrue ); |
|
517 uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
518 uiContainer->ShowVerticalScrollArrows( EFalse ); |
|
519 } |
|
520 |
|
521 TRAP_IGNORE( GetCandidateL() ); |
|
522 if ( phrase->Count() > 0 ) |
|
523 { |
|
524 // layout candidate and fill candidate buffer for first display page |
|
525 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
526 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
527 uiContainer->Enable( ETrue ); |
|
528 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
529 uiContainer->CandidatePane()->IsFirstPage()); |
|
530 uiContainer->ShowVerticalScrollArrows( multiplePages ); |
|
531 if ( iState == EMiniQwertyEdit ) |
|
532 { |
|
533 UIContainer()->FocusCandidatePane( EFalse ); |
|
534 } |
|
535 else |
|
536 { |
|
537 UIContainer()->FocusCandidatePane( ETrue ); |
|
538 UIContainer()->CandidatePane()->SelectFirstPhrase(); |
|
539 } |
|
540 } |
|
541 else |
|
542 { |
|
543 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
544 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
545 uiContainer->Enable( ETrue ); |
|
546 uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
547 uiContainer->ShowVerticalScrollArrows( EFalse ); |
|
548 uiContainer->SetControlInVisible( EFalse ); |
|
549 } |
|
550 } |
|
551 |
|
552 // --------------------------------------------------------------------------- |
|
553 // TAknFepInputMiniQwertyStrokePhraseBase::HandleHorizontalNavigation |
|
554 //Handle horizontal navigation. |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 TBool TAknFepInputMiniQwertyStrokePhraseBase::HandleHorizontalNavigation( |
|
558 TInt aKey ) |
|
559 { |
|
560 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
561 TBool response = EFalse; |
|
562 |
|
563 // Do navigation... |
|
564 if ( aKey == EStdKeyLeftArrow ) |
|
565 { |
|
566 if(!candidatePane->SelectPrev()) |
|
567 { |
|
568 candidatePane->SetCandidateBuffer(); |
|
569 candidatePane->SelectLastPhrase(); |
|
570 } |
|
571 response = ETrue; |
|
572 } |
|
573 else if ( aKey == EStdKeyRightArrow ) |
|
574 { |
|
575 if(!candidatePane->SelectNext()) |
|
576 { |
|
577 candidatePane->SetCandidateBuffer(); |
|
578 candidatePane->SelectFirstPhrase(); |
|
579 } |
|
580 response = ETrue; |
|
581 } |
|
582 |
|
583 if (response) |
|
584 { |
|
585 UpdateIndicator(); |
|
586 } |
|
587 |
|
588 return response; |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // TAknFepInputMiniQwertyStrokePhraseBase::UpdateIndicator |
|
593 // Update Indicator. |
|
594 // --------------------------------------------------------- |
|
595 // |
|
596 void TAknFepInputMiniQwertyStrokePhraseBase::UpdateIndicator() |
|
597 { |
|
598 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
599 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
600 |
|
601 if (candidatePane->IsFirstPage()) |
|
602 { |
|
603 uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse); |
|
604 } |
|
605 else |
|
606 { |
|
607 uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue); |
|
608 } |
|
609 |
|
610 if (candidatePane->IsLastPage()) |
|
611 { |
|
612 uiContainer->CandidatePane()->ShowDownScrollArrows(EFalse); |
|
613 } |
|
614 else |
|
615 { |
|
616 uiContainer->CandidatePane()->ShowDownScrollArrows(ETrue); |
|
617 } |
|
618 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
619 if (iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty4x10) |
|
620 { |
|
621 if (candidatePane->VisibleCandidateCount()==1) |
|
622 { |
|
623 uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse); |
|
624 uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse); |
|
625 } |
|
626 else |
|
627 { |
|
628 uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue); |
|
629 uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue); |
|
630 } |
|
631 } |
|
632 else |
|
633 { |
|
634 #endif |
|
635 if (candidatePane->SelectedIndex() == 0 |
|
636 && candidatePane->IsFirstPage() ) |
|
637 { |
|
638 uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse); |
|
639 } |
|
640 else |
|
641 { |
|
642 uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue); |
|
643 } |
|
644 |
|
645 if (candidatePane->IsLastPage() && (candidatePane->SelectedIndex() |
|
646 == candidatePane->VisibleCandidateCount() - 1)) |
|
647 { |
|
648 uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse); |
|
649 } |
|
650 else |
|
651 { |
|
652 uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue); |
|
653 } |
|
654 } |
|
655 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
656 } |
|
657 #endif |
|
658 |
|
659 // --------------------------------------------------------- |
|
660 // TAknFepInputMiniQwertyStrokePhraseBase::DeleteKeystroke |
|
661 // Delete current keystroke. |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 TBool TAknFepInputMiniQwertyStrokePhraseBase::DeleteKeystroke() |
|
665 { |
|
666 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
667 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
668 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
669 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
670 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
671 |
|
672 if ( ( 0 == index ) || ( keystroke->Count() == 0 ) ) |
|
673 { |
|
674 return EFalse; |
|
675 } |
|
676 |
|
677 if ( 1 == index ) |
|
678 { |
|
679 editPane->Reset(); |
|
680 } |
|
681 |
|
682 if ( index >= keystroke->Count() ) |
|
683 { |
|
684 keystroke->Delete( keystroke->Count() - 1 ); |
|
685 keycodeArray->Remove( keycodeArray->Count() - 1 ); |
|
686 editPane->SetCursorIndexOfKeystroke( keystroke->Count() ); |
|
687 } |
|
688 else |
|
689 { |
|
690 keystroke->Delete( index - 1 ); |
|
691 keycodeArray->Remove( index - 1 ); |
|
692 editPane->SetCursorIndexOfKeystroke( index - 1 ); |
|
693 } |
|
694 return ETrue; |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------- |
|
698 // TAknFepInputMiniQwertyStrokePhraseBase::AddPhraseToDB |
|
699 // Add phrase to DB. |
|
700 // --------------------------------------------------------- |
|
701 // |
|
702 void TAknFepInputMiniQwertyStrokePhraseBase::AddPhraseToDB( |
|
703 const TDesC& aPhraseAdd ) |
|
704 { |
|
705 TPtiUserDictionaryEntry addUdbEntry( aPhraseAdd ); |
|
706 //Add the phrase to the DB by PTI Engine |
|
707 iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); |
|
708 } |
|
709 |
|
710 // --------------------------------------------------------------------------- |
|
711 // TAknFepInputMiniQwertyStrokePhraseBase::RefreshCandidate |
|
712 // Refresh candidate |
|
713 // --------------------------------------------------------------------------- |
|
714 // |
|
715 void TAknFepInputMiniQwertyStrokePhraseBase::RefreshCandidate() |
|
716 { |
|
717 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
718 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
719 uiContainer->Enable( ETrue ); |
|
720 |
|
721 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
722 uiContainer->CandidatePane()->IsFirstPage()); |
|
723 uiContainer->ShowVerticalScrollArrows( multiplePages ); |
|
724 |
|
725 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
726 UpdateIndicator(); |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 // TAknFepInputMiniQwertyStrokePhraseBase::CheckKeyNeedRepeat |
|
731 // Check key whether need repeat. |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 TBool TAknFepInputMiniQwertyStrokePhraseBase::CheckKeyNeedRepeat( TKeyPressLength aLength ) |
|
735 { |
|
736 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
737 if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
738 { |
|
739 return EFalse; |
|
740 } |
|
741 else |
|
742 { |
|
743 editPane->SetChangeState( EFalse ); |
|
744 } |
|
745 return ETrue; |
|
746 } |
|
747 |
|
748 // --------------------------------------------------------------------------- |
|
749 // TAknFepInputMiniQwertyStrokePhraseBase::CommitInlineEEPL |
|
750 // Commint text to EEP or editor |
|
751 // --------------------------------------------------------------------------- |
|
752 // |
|
753 TBool TAknFepInputMiniQwertyStrokePhraseBase::CommitInlineEEPL( const TDesC& aDes ) |
|
754 { |
|
755 TInt charCount = aDes.Length(); |
|
756 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
757 MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
|
758 CDesCArrayFlat* keyStoke = editpane->KeystrokeArray(); |
|
759 RArray<TInt>* keycode = editpane->KeycodeArray(); |
|
760 CDesCArrayFlat* phraseArray = editpane->PhraseArray(); |
|
761 CDesCArrayFlat* phraseShowKeyStroke = editpane->PhraseShowKeyStrokeArray(); |
|
762 RArray<TInt>* phraseKeycode = editpane->PhraseKeycodeArray(); |
|
763 TBuf<KMaxKeystrokeCount> buf; |
|
764 TBuf<1> strokeDLT; |
|
765 strokeDLT.Append( KStrokeDelimiter ); |
|
766 |
|
767 phraseArray->AppendL( aDes ); |
|
768 |
|
769 TInt phraseCount = phraseArray->Count(); |
|
770 TInt index = 0; |
|
771 TInt isFound = keyStoke->Find( strokeDLT, index ); |
|
772 |
|
773 //phrase creation state |
|
774 if ( phraseCount > 1 || ( 0 == isFound && charCount <= 1 )) |
|
775 { |
|
776 editpane->SetPhraseCreationFlag( ETrue ); |
|
777 if ( 0 == isFound && phraseCount < 7 && index < keyStoke->Count() - 1 ) |
|
778 { |
|
779 for ( TInt i = 0; i <= index; i++ ) |
|
780 { |
|
781 TPtrC ptr = keyStoke->MdcaPoint( 0 ); |
|
782 buf.Append( ptr ); |
|
783 keyStoke->Delete( 0); |
|
784 phraseKeycode->AppendL( (*keycode)[0]); |
|
785 keycode->Remove( 0 ); |
|
786 } |
|
787 phraseShowKeyStroke->AppendL( buf ); |
|
788 editpane->SetCursorIndexOfKeystroke( 0 ); |
|
789 editpane->DisableCursor(); |
|
790 return ETrue; |
|
791 } |
|
792 else |
|
793 { |
|
794 TBuf<KMaxPhraseCreationCount> phraseCreated; |
|
795 for ( TInt ii = 0; ii < phraseCount; ++ii ) |
|
796 { |
|
797 phraseCreated.Append( phraseArray->MdcaPoint(ii) ); |
|
798 } |
|
799 if ( 0 != isFound || ( 0 == isFound && index == keyStoke->Count() - 1 ) ) |
|
800 { |
|
801 editpane->ResetAllArray(); |
|
802 } |
|
803 fepMan->NewTextL( phraseCreated ); |
|
804 fepMan->CommitInlineEditL(); |
|
805 AddPhraseToDB( phraseCreated ); |
|
806 return EFalse; |
|
807 } |
|
808 } |
|
809 else |
|
810 { |
|
811 TBuf<KMaxPhraseCreationCount> phraseCreated; |
|
812 for ( TInt ii = 0; ii < phraseCount; ++ii ) |
|
813 { |
|
814 phraseCreated.Append( phraseArray->MdcaPoint( ii ) ); |
|
815 } |
|
816 editpane->ResetAllArray(); |
|
817 editpane->SetPhraseCreationFlag( EFalse ); |
|
818 fepMan->NewTextL( phraseCreated ); |
|
819 fepMan->CommitInlineEditL(); |
|
820 iOwner->PtiEngine()->SetPredictiveChineseChar( phraseCreated ); |
|
821 return EFalse; |
|
822 } |
|
823 } |
|
824 |
|
825 // --------------------------------------------------------- |
|
826 // TAknFepInputMiniQwertyStrokePhraseBase::ClearPtiEngineKeystroke |
|
827 // clear the ptiengine keystroke; |
|
828 // --------------------------------------------------------- |
|
829 // |
|
830 void TAknFepInputMiniQwertyStrokePhraseBase::ClearPtiEngineKeystroke() |
|
831 { |
|
832 iOwner->PtiEngine()->ClearCurrentWord(); |
|
833 } |
|
834 |
|
835 // --------------------------------------------------------- |
|
836 // TAknFepInputMiniQwertyStrokePhraseBase::AddKeystrokeL |
|
837 // Add keystroke. |
|
838 // --------------------------------------------------------- |
|
839 // |
|
840 TBool TAknFepInputMiniQwertyStrokePhraseBase::AddKeystrokeL( TInt aKey ) |
|
841 { |
|
842 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
843 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
844 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
845 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
846 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
847 TInt keystrokeCount = keystrokeArray->Count(); |
|
848 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
849 |
|
850 if ( phraseCount + keystrokeCount >= KMaxKeystrokeCount ) |
|
851 { |
|
852 return EFalse; |
|
853 } |
|
854 |
|
855 |
|
856 TBuf<1> keystroke; |
|
857 GetShowKeystroke( aKey, keystroke ); |
|
858 if ( index >= keystrokeCount ) |
|
859 { |
|
860 keystrokeArray->AppendL( keystroke ); |
|
861 keycodeArray->AppendL( aKey ); |
|
862 editPane->SetCursorIndexOfKeystroke( keystrokeCount + 1 ); |
|
863 } |
|
864 else |
|
865 { |
|
866 keystrokeArray->InsertL( index, keystroke ); |
|
867 keycodeArray->InsertL( aKey, index ); |
|
868 editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
869 } |
|
870 |
|
871 return ETrue; |
|
872 } |
|
873 |
|
874 // --------------------------------------------------------- |
|
875 // TAknFepInputMiniQwertyStrokePhraseBase::GetCandidateL |
|
876 // Get the candidate info. |
|
877 // --------------------------------------------------------- |
|
878 // |
|
879 void TAknFepInputMiniQwertyStrokePhraseBase::GetCandidateL() |
|
880 { |
|
881 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
882 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
883 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
884 CDesCArrayFlat* phraseCandidates = |
|
885 uiContainer->CandidatePane()->CandidateArray(); |
|
886 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
887 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
888 phraseCandidates->Reset(); |
|
889 |
|
890 if ( keystrokeArray->Count() == 0 ) |
|
891 { |
|
892 return; |
|
893 } |
|
894 |
|
895 if ( ( 0 == phraseCount ) && editPane->GetAllValidFlag() ) |
|
896 { |
|
897 ptiengine->GetChinesePhraseCandidatesL( *phraseCandidates ); |
|
898 return; |
|
899 } |
|
900 |
|
901 if ( !CheckFirstGroupStroke() ) |
|
902 { |
|
903 return; |
|
904 } |
|
905 |
|
906 ptiengine->GetChinesePhraseCandidatesL( *phraseCandidates ); |
|
907 } |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // TAknFepInputMiniQwertyStrokePhraseBase::GetShowKeystroke |
|
911 // get the show keystroke. |
|
912 // --------------------------------------------------------------------------- |
|
913 // |
|
914 void TAknFepInputMiniQwertyStrokePhraseBase::GetShowKeystroke( |
|
915 TInt aKey, |
|
916 TDes& aKeystroke |
|
917 ) |
|
918 { |
|
919 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
920 TBuf<KMaxName> lowerdata; |
|
921 ptiEngine->MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); |
|
922 TInt StrokeUnicodePosition =0; |
|
923 |
|
924 if(lowerdata.Length()>0) |
|
925 { |
|
926 for(TInt i=0;i<lowerdata.Length()-1;i++) |
|
927 { |
|
928 if(lowerdata[i]==KStrokeUnicode) |
|
929 { |
|
930 StrokeUnicodePosition = i+1; |
|
931 break; |
|
932 } |
|
933 } |
|
934 if ( StrokeUnicodePosition < lowerdata.Length() ) |
|
935 { |
|
936 aKeystroke.Copy( lowerdata.Mid( StrokeUnicodePosition, 1 ) ); |
|
937 } |
|
938 } |
|
939 |
|
940 } |
|
941 |
|
942 // --------------------------------------------------------- |
|
943 // TAknFepInputMiniQwertyStrokePhraseBase::RevertPhraseToKeystrokeL |
|
944 // Revert the phrase to keystroke. |
|
945 // --------------------------------------------------------- |
|
946 // |
|
947 void TAknFepInputMiniQwertyStrokePhraseBase::RevertPhraseToKeystrokeL() |
|
948 { |
|
949 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
950 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
951 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
952 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
953 RArray<TInt>* phraseKeycodeArray = editPane->PhraseKeycodeArray(); |
|
954 CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
955 CDesCArrayFlat* phraseStroke = editPane->PhraseShowKeyStrokeArray(); |
|
956 |
|
957 TBuf<KMaxKeystrokeCount> buf; |
|
958 |
|
959 if ( ( phrase->Count() == 0 ) || ( phraseStroke->Count() == 0 ) ) |
|
960 { |
|
961 return; |
|
962 } |
|
963 |
|
964 buf.Append( phraseStroke->MdcaPoint( phraseStroke->Count() - 1 ) ); |
|
965 |
|
966 for ( TInt i = buf.Length() - 1; i >= 0; --i ) |
|
967 { |
|
968 keystrokeArray->InsertL( 0, buf.Mid( i, 1 ) ); |
|
969 keycodeArray->Insert( (*phraseKeycodeArray)[phraseKeycodeArray->Count()-1], 0 ); |
|
970 phraseKeycodeArray->Remove( phraseKeycodeArray->Count()-1 ); |
|
971 } |
|
972 phrase->Delete( phrase->Count() - 1 ); |
|
973 phraseStroke->Delete( phraseStroke->Count() - 1 ); |
|
974 |
|
975 TInt leng = phrase->Count() + keystrokeArray->Count(); |
|
976 if ( leng > KMaxKeystrokeCount ) |
|
977 { |
|
978 for ( TInt i = 0; i < leng - KMaxKeystrokeCount; ++i ) |
|
979 { |
|
980 if ( keystrokeArray->Count() == 0 ) |
|
981 { |
|
982 break; |
|
983 } |
|
984 keystrokeArray->Delete( keystrokeArray->Count() - 1 ); |
|
985 keycodeArray->Remove( keycodeArray->Count() - 1 ); |
|
986 } |
|
987 } |
|
988 |
|
989 editPane->SetCursorIndexOfKeystroke( buf.Length() ); |
|
990 keystrokeArray->Compress(); |
|
991 phrase->Compress(); |
|
992 phraseStroke->Compress(); |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------- |
|
996 // TAknFepInputMiniQwertyStrokePhraseBase::SetWarningColor |
|
997 // Set warning color. |
|
998 // --------------------------------------------------------- |
|
999 // |
|
1000 void TAknFepInputMiniQwertyStrokePhraseBase::SetWarningColor() |
|
1001 { |
|
1002 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
1003 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1004 CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
1005 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
1006 TInt keystrokeCount = keystrokeArray->Count(); |
|
1007 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
1008 TBool valid = ETrue; |
|
1009 TInt index = 0; |
|
1010 TInt count = 0; |
|
1011 TInt stringBeforeLength = 0; |
|
1012 TInt stringAfterLength = 0; |
|
1013 TInt keyCode = 0; |
|
1014 TInt invalidPos = 0; |
|
1015 TBuf<1> delimiter; |
|
1016 delimiter.Append( KStrokeDelimiter ); |
|
1017 |
|
1018 //set warning color stroke after 7th group when it's more than 7 groups. |
|
1019 if ( 0 == keystrokeCount ) |
|
1020 { |
|
1021 return; |
|
1022 } |
|
1023 |
|
1024 if ( CheckAllGroupStroke() ) |
|
1025 { |
|
1026 return; |
|
1027 } |
|
1028 |
|
1029 TInt delimiterCount = phraseCount + editPane->GetDelimiterCount(); |
|
1030 invalidPos = editPane->GetInvalidIndex(); |
|
1031 index = invalidPos; |
|
1032 ClearPtiEngineKeystroke(); |
|
1033 for ( TInt i = invalidPos; i < keystrokeCount; ++i ) |
|
1034 { |
|
1035 count = count + 1; |
|
1036 //GetKeystrokeCode( keyCode, keystrokeArray->MdcaPoint( i ) ); |
|
1037 keyCode = (*keycodeArray)[i]; |
|
1038 if ( EPtiKeyQwertySpace == keyCode ) |
|
1039 { |
|
1040 delimiterCount = delimiterCount + 1; |
|
1041 if ( delimiterCount == KMaxPhraseCreationCount ) |
|
1042 { |
|
1043 if ( !valid ) |
|
1044 { |
|
1045 editPane->SetHighlight( |
|
1046 phraseCount + index, |
|
1047 phraseCount + keystrokeCount - 1 ); |
|
1048 } |
|
1049 else |
|
1050 { |
|
1051 editPane->SetHighlight( |
|
1052 phraseCount + i, |
|
1053 phraseCount + keystrokeCount - 1 ); |
|
1054 } |
|
1055 break; |
|
1056 } |
|
1057 if ( ( !valid ) || ( 0 == i ) ) |
|
1058 { |
|
1059 editPane->SetHighlight( |
|
1060 phraseCount + index, |
|
1061 phraseCount + index + count - 1 ); |
|
1062 } |
|
1063 else if ( i > 0 ) |
|
1064 { |
|
1065 if ( 0 == keystrokeArray->MdcaPoint( i - 1 ).Compare( delimiter ) ) |
|
1066 { |
|
1067 editPane->SetHighlight( |
|
1068 phraseCount + index, |
|
1069 phraseCount + index + count - 1 ); |
|
1070 } |
|
1071 } |
|
1072 valid = ETrue; |
|
1073 index = i + 1; |
|
1074 count = 0; |
|
1075 ClearPtiEngineKeystroke(); |
|
1076 } |
|
1077 else if ( valid ) |
|
1078 { |
|
1079 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
1080 stringAfterLength = |
|
1081 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
1082 if ( stringBeforeLength == stringAfterLength ) |
|
1083 { |
|
1084 valid = EFalse; |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 if ( ( !valid ) && |
|
1089 ( keystrokeCount == i + 1 ) && |
|
1090 ( EPtiKeyQwertySpace != keyCode ) ) |
|
1091 { |
|
1092 editPane->SetHighlight( |
|
1093 phraseCount + index, |
|
1094 phraseCount + index + count - 1 ); |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 } |
|
1099 |
|
1100 // --------------------------------------------------------- |
|
1101 // TAknFepInputMiniQwertyStrokePhraseBase::SetWarningColor |
|
1102 // Set warning color. |
|
1103 // --------------------------------------------------------- |
|
1104 // |
|
1105 void TAknFepInputMiniQwertyStrokePhraseBase::ChangeCbaL() |
|
1106 { |
|
1107 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
1108 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1109 TInt candidateCount = UIContainer()->CandidatePane()->CandidateArray()->Count(); |
|
1110 TInt keyStrokeCount = editPane->KeystrokeArray()->Count(); |
|
1111 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
1112 TInt currentCBAResId = editPane->GetCurrentCBAResID(); |
|
1113 if ( ( candidateCount == 0 && keyStrokeCount != 0 ) || |
|
1114 ( phraseCount == 1 && keyStrokeCount == 0 ) ) |
|
1115 { |
|
1116 if (R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY != currentCBAResId ) |
|
1117 { |
|
1118 fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY ); |
|
1119 editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY ); |
|
1120 } |
|
1121 |
|
1122 } |
|
1123 else if ( keyStrokeCount == 0 ) |
|
1124 { |
|
1125 if ( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE != currentCBAResId ) |
|
1126 { |
|
1127 fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1128 editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1129 } |
|
1130 } |
|
1131 else if ( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL != currentCBAResId ) |
|
1132 { |
|
1133 fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL ); |
|
1134 editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL ); |
|
1135 } |
|
1136 } |
|
1137 |
|
1138 // --------------------------------------------------------- |
|
1139 // TAknFepInputMiniQwertyStrokePhraseBase::MoveCursorLeft |
|
1140 // Move the cursor to Left. |
|
1141 // --------------------------------------------------------- |
|
1142 // |
|
1143 TBool TAknFepInputMiniQwertyStrokePhraseBase::MoveCursorLeft() |
|
1144 { |
|
1145 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1146 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
1147 TInt keystrokeCount = editPane->KeystrokeArray()->Count(); |
|
1148 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
1149 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
1150 |
|
1151 if ( EMiniQwertyEdit != iState ) |
|
1152 { |
|
1153 return EFalse; |
|
1154 } |
|
1155 if ( 0 == keystrokeCount ) |
|
1156 { |
|
1157 return EFalse; |
|
1158 } |
|
1159 |
|
1160 if ( 0 == index ) |
|
1161 { |
|
1162 editPane->SetCursorIndexOfKeystroke( keystrokeCount ); |
|
1163 ShowInfoOnEEPPane(); |
|
1164 SetWarningColor(); |
|
1165 } |
|
1166 else if ( ( phraseCount > 0 ) && ( 1 == index ) ) |
|
1167 { |
|
1168 editPane->SetCursorIndexOfKeystroke( 0 ); |
|
1169 ShowInfoOnEEPPane(); |
|
1170 SetWarningColor(); |
|
1171 } |
|
1172 else |
|
1173 { |
|
1174 editPane->MoveCursorLeft(); |
|
1175 editPane->SetCursorIndexOfKeystroke( index - 1 ); |
|
1176 } |
|
1177 |
|
1178 editPane->SetAutoChangeStateFlag( EManualChangeState ); |
|
1179 |
|
1180 return ETrue; |
|
1181 } |
|
1182 |
|
1183 // --------------------------------------------------------- |
|
1184 // TAknFepInputMiniQwertyStrokePhraseBase::MoveCursorRight |
|
1185 // Move the cursor to Right. |
|
1186 // --------------------------------------------------------- |
|
1187 // |
|
1188 TBool TAknFepInputMiniQwertyStrokePhraseBase::MoveCursorRight() |
|
1189 { |
|
1190 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1191 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
1192 TInt keystrokeCount = editPane->KeystrokeArray()->Count(); |
|
1193 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
1194 |
|
1195 if ( EMiniQwertyEdit != iState ) |
|
1196 { |
|
1197 return EFalse; |
|
1198 } |
|
1199 if ( 0 == keystrokeCount ) |
|
1200 { |
|
1201 return EFalse; |
|
1202 } |
|
1203 if ( index >= keystrokeCount ) |
|
1204 { |
|
1205 editPane->SetCursorIndexOfKeystroke( 0 ); |
|
1206 ShowInfoOnEEPPane(); |
|
1207 SetWarningColor(); |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 editPane->MoveCursorRight(); |
|
1212 editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
1213 } |
|
1214 |
|
1215 editPane->SetAutoChangeStateFlag( EManualChangeState ); |
|
1216 |
|
1217 return ETrue; |
|
1218 } |
|
1219 |
|
1220 // --------------------------------------------------------- |
|
1221 // TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyFromCandidateL |
|
1222 // Handle key from candidate. |
|
1223 // --------------------------------------------------------- |
|
1224 // |
|
1225 void TAknFepInputMiniQwertyStrokePhraseBase::HandleKeyFromCandidateL( |
|
1226 TInt aKey, TKeyPressLength /*aLength*/ ) |
|
1227 { |
|
1228 TInt index = 0; |
|
1229 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
1230 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1231 // it may be one of the 'valid' numbers.. |
|
1232 TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout(); |
|
1233 if ( EPtiKeyboardQwerty4x10 == keyboardtype || EPtiKeyboardQwerty3x11 |
|
1234 == keyboardtype || EPtiKeyboardHalfQwerty == keyboardtype |
|
1235 || EPtiKeyboardCustomQwerty == keyboardtype ) |
|
1236 { |
|
1237 MPtiLanguage *lang= NULL; |
|
1238 RArray < TPtiNumericKeyBinding > keybinding; |
|
1239 TBool validnumkey = EFalse; |
|
1240 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
1241 lang = ptiengine->CurrentLanguage(); |
|
1242 if ( ptiengine && lang ) |
|
1243 { |
|
1244 TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardtype)); |
|
1245 TInt numericKeysCount = keybinding.Count(); |
|
1246 while (numericKeysCount-- ) |
|
1247 { |
|
1248 TPtiNumericKeyBinding numKeyBind = |
|
1249 keybinding[numericKeysCount]; |
|
1250 if ( (numKeyBind.iChar >= KKey1 && numKeyBind.iChar <= KKey6) |
|
1251 &&(aKey == numKeyBind.iKey) ) |
|
1252 { |
|
1253 index = numKeyBind.iChar - EPtiKey0 -1; |
|
1254 if ( candidatePane->SelectIndex( index ) ) |
|
1255 { |
|
1256 validnumkey = ETrue; |
|
1257 } |
|
1258 break; |
|
1259 } |
|
1260 } |
|
1261 } |
|
1262 keybinding.Reset(); |
|
1263 keybinding.Close(); |
|
1264 if ( !validnumkey ) |
|
1265 { |
|
1266 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
1267 return; |
|
1268 } |
|
1269 } |
|
1270 else |
|
1271 { |
|
1272 #endif |
|
1273 index = MapKeyToIndex( aKey ); |
|
1274 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1275 } |
|
1276 #endif |
|
1277 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
1278 if ( text.Length( ) ) |
|
1279 { |
|
1280 if ( !CommitInlineEEPL( text ) ) |
|
1281 { |
|
1282 DoActionAfterCommit( ); |
|
1283 } |
|
1284 else |
|
1285 { |
|
1286 if ( CheckFirstGroupStroke( ) ) |
|
1287 { |
|
1288 RefreshUI( ); |
|
1289 UIContainer()->CandidatePane()->SelectFirstPhrase( ); |
|
1290 } |
|
1291 else |
|
1292 { |
|
1293 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EAutoChangeStateFromCandidate ); |
|
1294 iOwner->ChangeState( EMiniQwertyEdit ); |
|
1295 } |
|
1296 } |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 // --------------------------------------------------------- |
|
1301 // TAknFepInputMiniQwertyStrokePhraseBase::CheckAllGroupStroke |
|
1302 // check the all group stroke of keystroke. |
|
1303 // --------------------------------------------------------- |
|
1304 // |
|
1305 TBool TAknFepInputMiniQwertyStrokePhraseBase::CheckAllGroupStroke() |
|
1306 { |
|
1307 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
1308 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1309 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
1310 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
1311 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
1312 TInt phraseCount = editPane->PhraseArray()->Count(); |
|
1313 TInt keystrokeCount = keystroke->Count(); |
|
1314 TInt keyCode = 0; |
|
1315 TInt stringBeforeLength = 0; |
|
1316 TInt stringAfterLength = 0; |
|
1317 TInt lastDLTPos = 0; |
|
1318 TBool check = ETrue; |
|
1319 TInt delimiterCount = 0; |
|
1320 //If has phrase on the entry pane then the all keystroke is invalid. |
|
1321 if ( ( phraseCount > 0 ) || ( 0 == keystrokeCount ) ) |
|
1322 { |
|
1323 editPane->SetAllValidFlag( EFalse ); |
|
1324 editPane->SetDelimiterCount( 0 ); |
|
1325 editPane->SetInvalidIndex( 0 ); |
|
1326 return EFalse; |
|
1327 } |
|
1328 |
|
1329 ClearPtiEngineKeystroke(); |
|
1330 for ( TInt i = 0; i < keystrokeCount; ++i ) |
|
1331 { |
|
1332 //GetKeystrokeCode( keyCode, keystroke->MdcaPoint( i ) ); |
|
1333 keyCode = (*keycodeArray)[i]; |
|
1334 if ( EPtiKeyQwertySpace == keyCode ) |
|
1335 { |
|
1336 //If first keystroke is delimiter then all keystroke is not valid. |
|
1337 if ( i == 0 ) |
|
1338 { |
|
1339 editPane->SetAllValidFlag( EFalse ); |
|
1340 editPane->SetDelimiterCount( 0 ); |
|
1341 editPane->SetInvalidIndex( 0 ); |
|
1342 return EFalse; |
|
1343 } |
|
1344 //If two delimiter is border upon then the check evaluate EFalse. |
|
1345 else if ( lastDLTPos == ( i - 1 ) ) |
|
1346 { |
|
1347 check = EFalse; |
|
1348 } |
|
1349 //lastDLTPos evaluate last delimiter that has not border upon deliminter. |
|
1350 else if ( check ) |
|
1351 { |
|
1352 delimiterCount = delimiterCount + 1; |
|
1353 lastDLTPos = i; |
|
1354 } |
|
1355 } |
|
1356 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
1357 stringAfterLength = |
|
1358 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
1359 if ( stringBeforeLength == stringAfterLength ) |
|
1360 { |
|
1361 editPane->SetAllValidFlag( EFalse ); |
|
1362 if ( 0 == lastDLTPos ) |
|
1363 { |
|
1364 editPane->SetDelimiterCount( 0 ); |
|
1365 editPane->SetInvalidIndex( 0 ); |
|
1366 } |
|
1367 else |
|
1368 { |
|
1369 editPane->SetDelimiterCount( delimiterCount ); |
|
1370 editPane->SetInvalidIndex( lastDLTPos + 1 ); |
|
1371 } |
|
1372 return EFalse; |
|
1373 } |
|
1374 } |
|
1375 |
|
1376 editPane->SetAllValidFlag( ETrue ); |
|
1377 editPane->SetDelimiterCount( 0 ); |
|
1378 editPane->SetInvalidIndex( 0 ); |
|
1379 return ETrue; |
|
1380 } |
|
1381 |
|
1382 |
|
1383 // --------------------------------------------------------- |
|
1384 // TAknFepInputMiniQwertyStrokePhraseBase::DoActionAfterCommit |
|
1385 // Do action afer commit, change state to predictive or not. |
|
1386 // --------------------------------------------------------- |
|
1387 // |
|
1388 void TAknFepInputMiniQwertyStrokePhraseBase::DoActionAfterCommit() |
|
1389 { |
|
1390 TRAP_IGNORE( DoActionAfterCommitL() ); |
|
1391 } |
|
1392 |
|
1393 // --------------------------------------------------------- |
|
1394 // TAknFepInputMiniQwertyStrokePhraseBase::DoActionAfterCommitL |
|
1395 // Do action afer commit, change state to predictive or not. |
|
1396 // --------------------------------------------------------- |
|
1397 // |
|
1398 void TAknFepInputMiniQwertyStrokePhraseBase::DoActionAfterCommitL( ) |
|
1399 { |
|
1400 if ( UIContainer()->EditPaneWindow()->KeystrokeArray()->Count( ) != 0 ) |
|
1401 { |
|
1402 UIContainer()->EditPaneWindow()->ResetAllArray( ); |
|
1403 CAknWarningNote* errnote = new( ELeave ) CAknWarningNote(); |
|
1404 errnote->SetTone( CAknNoteDialog::EWarningTone ); |
|
1405 errnote->ExecuteLD( KMaxPhraseNote ); |
|
1406 } |
|
1407 else if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag( ) ) |
|
1408 { |
|
1409 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1410 TBool isEditorFull = iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagEditorFull); |
|
1411 if ( !isEditorFull ) |
|
1412 { |
|
1413 iOwner->ChangeState( EPredictiveCandidate ); |
|
1414 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 iOwner->FepMan()->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
1419 iOwner->FepMan()->TryCloseUiL(); |
|
1420 } |
|
1421 #endif |
|
1422 } |
|
1423 else |
|
1424 { |
|
1425 iOwner->FepMan()->TryCloseUiL( ); |
|
1426 } |
|
1427 } |
|
1428 // --------------------------------------------------------- |
|
1429 // TAknFepInputMiniQwertyStrokePhraseBase::CheckSpellingDLT |
|
1430 // Check the delimiter of spelling. |
|
1431 // --------------------------------------------------------- |
|
1432 // |
|
1433 TBool TAknFepInputMiniQwertyStrokePhraseBase::CheckSpellingDLT( const TDesC& aKeystroke ) |
|
1434 { |
|
1435 if ( aKeystroke.Length() == 0 ) |
|
1436 { |
|
1437 return EFalse; |
|
1438 } |
|
1439 if ( KStrokeDelimiter == aKeystroke[0] ) |
|
1440 { |
|
1441 return ETrue; |
|
1442 } |
|
1443 return EFalse; |
|
1444 } |
|
1445 |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // TAknFepInputMiniQwertyStrokePhraseBase::HandleCommandL |
|
1448 // Handling Command |
|
1449 // --------------------------------------------------------------------------- |
|
1450 // |
|
1451 void TAknFepInputMiniQwertyStrokePhraseBase::HandleCommandL( TInt aCommandId ) |
|
1452 { |
|
1453 switch ( aCommandId ) |
|
1454 { |
|
1455 // Handle the event frome command. |
|
1456 case EAknSoftkeySelect: |
|
1457 //case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
1458 HandleCommitL( EShortKeyPress ); |
|
1459 break; |
|
1460 default: |
|
1461 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
1462 break; |
|
1463 } |
|
1464 } |
|
1465 // End of file |