|
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 <PtiEngine.h> |
|
33 #include <avkon.rsg> |
|
34 #include <aknfep.rsg> |
|
35 #include <PtiUserDicEntry.h> |
|
36 #include <aknnotewrappers.h> //CAknWarningNote |
|
37 |
|
38 // User includes |
|
39 #include "AknFepUIManagerStateInterface.h" |
|
40 #include "AknFepUICtrlInputPane.h" |
|
41 #include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase |
|
42 #include "aknfepuictrleditpane.h" //pinyin phrase creation |
|
43 #include "AknFepUICtrlCandidatePane.h" |
|
44 #include "AknFepManager.h" |
|
45 #include "aknfepuiinputstatestrokephrasebase.h" |
|
46 |
|
47 // Constant definition |
|
48 const TInt KMinCnadidateCount = 1; |
|
49 const TInt KMaxPhraseCount = 50; |
|
50 const TInt KEnginePhoneticIndex = 1; |
|
51 const TInt KMaxPhraseCreationCount = 7; |
|
52 const TInt KMaxKeystrokeCount = 31; |
|
53 const TInt KKey0Code = 48; |
|
54 const TInt KKey1Code = 49; |
|
55 const TInt KKey2Code = 50; |
|
56 const TInt KKey3Code = 51; |
|
57 const TInt KKey4Code = 52; |
|
58 const TInt KKey5Code = 53; |
|
59 const TInt KKey6Code = 54; |
|
60 const TInt KAutoChangeState = 1; |
|
61 const TInt KManualChangeState = 0; |
|
62 const TUint16 KDelimiter = 0x2022; |
|
63 const TUint16 KStrokeKey1 = 0x4E00; |
|
64 const TUint16 KStrokeKey2 = 0x4E28; |
|
65 const TUint16 KStrokeKey3 = 0x4E3F; |
|
66 const TUint16 KStrokeKey4 = 0x4E36; |
|
67 const TUint16 KStrokeKey5 = 0x4E5B; |
|
68 const TUint16 KStrokeKey6 = 0x003F; |
|
69 |
|
70 const TUint16 KSegment = 0x0020; |
|
71 |
|
72 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" ); |
|
73 |
|
74 const TKeyMap StrokeMap[] = |
|
75 { |
|
76 {KDelimiter, KKey0Code}, |
|
77 {KStrokeKey1, KKey1Code}, |
|
78 {KStrokeKey2, KKey2Code}, |
|
79 {KStrokeKey3, KKey3Code}, |
|
80 {KStrokeKey4, KKey4Code}, |
|
81 {KStrokeKey5, KKey5Code}, |
|
82 {KStrokeKey6, KKey6Code} |
|
83 }; |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase |
|
87 // C++ default constructor |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 TAknFepInputStateStrokePhraseBase::TAknFepInputStateStrokePhraseBase( |
|
91 MAknFepUIManagerStateInterface* aOwner, |
|
92 MAknFepUICtrlContainerChinese* aUIContainer) |
|
93 :TAknFepInputStateChineseBase(aOwner, aUIContainer) |
|
94 { |
|
95 if ( iOwner->PtiEngine()->InputMode() != EPtiEngineStrokeByPhrase ) |
|
96 { |
|
97 iOwner->PtiEngine()->SetInputMode( EPtiEngineStrokeByPhrase ); |
|
98 } |
|
99 iOwner->PtiEngine()->SetCandidatePageLength( KMaxPhraseCount ); |
|
100 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
101 uiContainer->SetFepMan( iOwner->FepMan() ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // TAknFepInputStateStrokePhraseBase::HandleKeyL |
|
106 // Handle system key press event. |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 TBool TAknFepInputStateStrokePhraseBase::HandleKeyL( |
|
110 TInt aKey, |
|
111 TKeyPressLength aLength ) |
|
112 { |
|
113 switch( aKey ) |
|
114 { |
|
115 case EKeyBackspace: |
|
116 { |
|
117 if ( CheckKeyNeedRepeat( aLength ) ) |
|
118 { |
|
119 HandleKeyBackspaceL( aLength ); |
|
120 } |
|
121 else |
|
122 { |
|
123 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
124 } |
|
125 break; |
|
126 } |
|
127 case EKeyUpArrow: |
|
128 { |
|
129 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
130 break; |
|
131 } |
|
132 case EKeyDownArrow: |
|
133 { |
|
134 if ( EStrokeSequenceEdit == iState ) |
|
135 { |
|
136 if ( CheckFirstGroupStroke() ) |
|
137 { |
|
138 UIContainer()->PinyinPopupWindow()->SetChangeState( ETrue ); |
|
139 iOwner->ChangeState( EEntry ); |
|
140 } |
|
141 } |
|
142 else |
|
143 { |
|
144 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
145 } |
|
146 break; |
|
147 } |
|
148 case EKeyLeftArrow: |
|
149 { |
|
150 if ( EStrokeSequenceEdit == iState ) |
|
151 { |
|
152 MoveCursorLeft(); |
|
153 } |
|
154 else |
|
155 { |
|
156 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
157 } |
|
158 break; |
|
159 } |
|
160 case EKeyRightArrow: |
|
161 { |
|
162 if ( EStrokeSequenceEdit == iState ) |
|
163 { |
|
164 MoveCursorRight(); |
|
165 } |
|
166 else |
|
167 { |
|
168 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
169 } |
|
170 break; |
|
171 } |
|
172 case EKeyOK: |
|
173 case EKeyCBA1: |
|
174 { |
|
175 if ( CheckKeyNeedRepeat( aLength ) ) |
|
176 { |
|
177 HandleKeyCBA1OrKeyOKL( aLength ); |
|
178 } |
|
179 else |
|
180 { |
|
181 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
182 } |
|
183 break; |
|
184 } |
|
185 case EKeyCBA2: |
|
186 { |
|
187 iOwner->FepMan()->TryCloseUiL(); |
|
188 break; |
|
189 } |
|
190 default: |
|
191 { |
|
192 if ( ( EShortKeyPress == aLength ) && |
|
193 ( iOwner->IsValidChineseInputKey( aKey ) ) ) |
|
194 { |
|
195 HandleDefaultKeyL( aKey ); |
|
196 } |
|
197 else |
|
198 { |
|
199 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
200 } |
|
201 break; |
|
202 } |
|
203 } |
|
204 |
|
205 return ETrue; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // TAknFepInputStateStrokePhraseBase::RefreshUI |
|
210 // Update input window. |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void TAknFepInputStateStrokePhraseBase::RefreshUI( TBool aRefresh ) |
|
214 { |
|
215 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
216 // get cursor position |
|
217 if ( aRefresh ) |
|
218 { |
|
219 TPoint baseLine; |
|
220 TInt height(0); |
|
221 TInt ascent(0); |
|
222 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
223 if (ret == KErrNone) |
|
224 { |
|
225 uiContainer->SetContainerPosition(baseLine, height); |
|
226 } |
|
227 } |
|
228 |
|
229 ShowInfoOnEEPPane(); |
|
230 if ( !CheckAllKeystroke() ) |
|
231 { |
|
232 SetWarningColor(); |
|
233 } |
|
234 ShowInfoOnCandidatePane(); |
|
235 UpdateIndicator(); |
|
236 TRAP_IGNORE( ChangeCbaL() ); |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // TAknFepInputStateStrokePhraseBase::HandleHorizontalNavigation |
|
241 // Handle horizontal navigation. |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 TBool TAknFepInputStateStrokePhraseBase::CheckFirstGroupStroke() |
|
245 { |
|
246 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
247 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
248 CDesCArrayFlat* keystroke = uiContainer-> |
|
249 PinyinPopupWindow()->KeystrokeArrayForStroke(); |
|
250 |
|
251 TInt stringBeforeLength = 0; |
|
252 TInt stringAfterLength = 0; |
|
253 TInt keyCode = 0; |
|
254 TInt pos = 0; |
|
255 if ( 0 == keystroke->Count() ) |
|
256 { |
|
257 return EFalse; |
|
258 } |
|
259 |
|
260 ClearPtiEngineKeystroke(); |
|
261 TBuf<1> delimiter; |
|
262 delimiter.Append( KDelimiter ); |
|
263 if ( 0 == keystroke->Find( delimiter, pos ) ) |
|
264 { |
|
265 if ( 0 == pos ) |
|
266 { |
|
267 return EFalse; |
|
268 } |
|
269 } |
|
270 else |
|
271 { |
|
272 pos = keystroke->Count(); |
|
273 } |
|
274 |
|
275 for ( TInt i = 0; i < pos; ++i ) |
|
276 { |
|
277 GetKeystrokeCode( keyCode, keystroke->MdcaPoint( i ) ); |
|
278 stringBeforeLength = |
|
279 ptiengine->GetPhoneticSpelling(KEnginePhoneticIndex).Length(); |
|
280 stringAfterLength = |
|
281 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
282 //the keystroke is invalid. |
|
283 if ( stringBeforeLength == stringAfterLength ) |
|
284 { |
|
285 ClearPtiEngineKeystroke(); |
|
286 return EFalse; |
|
287 } |
|
288 } |
|
289 return ETrue; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // TAknFepInputStateStrokePhraseBase::HandleKeyBackspaceL |
|
294 // Handle KeyBackspace event. |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 void TAknFepInputStateStrokePhraseBase::HandleKeyBackspaceL( |
|
298 TKeyPressLength aLength ) |
|
299 { |
|
300 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
301 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
302 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
303 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
304 CDesCArrayFlat* keystroke = popup->KeystrokeArrayForStroke(); |
|
305 TInt phraseCount = popup->ChooseChineseCharacterArrayForStroke()->Count(); |
|
306 TBool firstGroup = CheckFirstGroupStroke(); |
|
307 |
|
308 if ( ( 0 == index ) && ( phraseCount != 0 ) ) |
|
309 { |
|
310 RevertPhraseToKeystrokeL(); |
|
311 } |
|
312 else if ( ( 0 == index ) && ( keystroke->Count() > 0 ) ) |
|
313 { |
|
314 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
315 return; |
|
316 } |
|
317 else |
|
318 { |
|
319 if ( !DeleteKeystroke() ) |
|
320 { |
|
321 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
322 return; |
|
323 } |
|
324 } |
|
325 |
|
326 if ( popup->ChooseChineseCharacterArrayForStroke()->Count() == 0 ) |
|
327 { |
|
328 iOwner->FepMan()->PhraseCreation( EFalse ); |
|
329 } |
|
330 |
|
331 //if the keystroke is null and phrase is null then close input window. |
|
332 if ( ( 0 == phraseCount ) && ( keystroke->Count() == 0 ) ) |
|
333 { |
|
334 iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI. |
|
335 if ( aLength == ELongKeyPress ) |
|
336 { |
|
337 iOwner->FepMan()->SetLongClearAfterCloseUI( ETrue ); |
|
338 } |
|
339 return; |
|
340 } |
|
341 |
|
342 //Auto change from EStrokeSequenceEdit state to EEntry state. |
|
343 if ( EStrokeSequenceEdit == iState ) |
|
344 { |
|
345 if ( ( KAutoChangeState == popup->GetState() ) && |
|
346 ( !firstGroup ) && CheckFirstGroupStroke() ) |
|
347 { |
|
348 popup->SetChangeState( EFalse ); |
|
349 iOwner->ChangeState( EEntry ); |
|
350 return; |
|
351 } |
|
352 } |
|
353 |
|
354 //Auto change from EEntry state to EStrokeSequenceEdit state. |
|
355 if ( EEntry == iState ) |
|
356 { |
|
357 if ( ( firstGroup ) && ( !CheckFirstGroupStroke() ) ) |
|
358 { |
|
359 popup->SetChangeState( EFalse ); |
|
360 popup->SetState( KAutoChangeState ); |
|
361 iOwner->ChangeState( EStrokeSequenceEdit ); |
|
362 return; |
|
363 } |
|
364 } |
|
365 |
|
366 RefreshUI(); |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKEntryL |
|
371 // Entry handle CBA1 or OK key press event. |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKEntry( |
|
375 TKeyPressLength aLength ) |
|
376 { |
|
377 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
378 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
379 TBool state = ETrue; |
|
380 if ( popup->IsChangeStatet() && aLength == ELongKeyPress ) |
|
381 { |
|
382 state = EFalse; |
|
383 } |
|
384 else |
|
385 { |
|
386 popup->SetChangeState( EFalse ); |
|
387 } |
|
388 |
|
389 if ( state ) |
|
390 { |
|
391 popup->SetChangeState( ETrue ); |
|
392 iOwner->ChangeState( ECandidate ); |
|
393 } |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKEditL |
|
398 // Edit state handle CBA1 or OK key press event. |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 void TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKEditL() |
|
402 { |
|
403 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
404 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
405 CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke(); |
|
406 CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke(); |
|
407 TBuf<KMaxPhraseCreationCount> phraseCreated; |
|
408 if ( (phrase->Count() >= 2 ) && ( 0 == keystrokeArray->Count() ) ) |
|
409 { |
|
410 //commit the chinese character. |
|
411 for (TInt i = 0; i < phrase->Count(); ++i ) |
|
412 { |
|
413 phraseCreated.Append( phrase->MdcaPoint( i ) ); |
|
414 } |
|
415 AddPhraseToDB( phraseCreated ); |
|
416 iOwner->FepMan()->NewTextL( phraseCreated ); |
|
417 iOwner->FepMan()->CommitInlineEditL(); |
|
418 iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI. |
|
419 } |
|
420 else if ( CheckFirstGroupStroke() ) |
|
421 { |
|
422 popup->SetState( KManualChangeState ); |
|
423 popup->SetChangeState( ETrue ); |
|
424 iOwner->ChangeState( EEntry ); |
|
425 } |
|
426 else |
|
427 { |
|
428 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
429 } |
|
430 |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 // TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKL |
|
435 // Handle CBA1 or OK key press event. |
|
436 // --------------------------------------------------------------------------- |
|
437 // |
|
438 void TAknFepInputStateStrokePhraseBase::HandleKeyCBA1OrKeyOKL( |
|
439 TKeyPressLength aLength ) |
|
440 { |
|
441 if ( EStrokeSequenceEdit == iState ) |
|
442 { |
|
443 HandleKeyCBA1OrKeyOKEditL(); |
|
444 } |
|
445 else if ( EEntry == iState ) |
|
446 { |
|
447 HandleKeyCBA1OrKeyOKEntry( aLength ); |
|
448 } |
|
449 else |
|
450 { |
|
451 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
452 } |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // TAknFepInputStateStrokePhraseBase::HandleDefaultKeyL |
|
457 // Handle default key press event. |
|
458 // --------------------------------------------------------------------------- |
|
459 // |
|
460 void TAknFepInputStateStrokePhraseBase::HandleDefaultKeyL( TInt aKey ) |
|
461 { |
|
462 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
463 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
464 TBool firstGroup = CheckFirstGroupStroke(); |
|
465 |
|
466 if ( !AddKeystrokeL( aKey ) ) |
|
467 { |
|
468 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
469 return; |
|
470 } |
|
471 |
|
472 //Auto change from EStrokeSequenceEdit state to EEntry state. |
|
473 if ( EStrokeSequenceEdit == iState ) |
|
474 { |
|
475 if ( ( KAutoChangeState == popup->GetState() ) && |
|
476 ( !firstGroup ) && CheckFirstGroupStroke() ) |
|
477 { |
|
478 popup->SetChangeState( ETrue ); |
|
479 iOwner->ChangeState( EEntry ); |
|
480 return; |
|
481 } |
|
482 } |
|
483 |
|
484 //Auto change from EEntry state to EStrokeSequenceEdit state. |
|
485 if ( EEntry == iState ) |
|
486 { |
|
487 if ( ( firstGroup ) && ( !CheckFirstGroupStroke() ) ) |
|
488 { |
|
489 popup->SetState( KAutoChangeState ); |
|
490 popup->SetChangeState( ETrue ); |
|
491 iOwner->ChangeState( EStrokeSequenceEdit ); |
|
492 return; |
|
493 } |
|
494 } |
|
495 |
|
496 RefreshUI(); |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // TAknFepInputStateStrokePhraseBase::ShowInfoOnEEP |
|
501 // Show the showinfo on the EEP ctrl. |
|
502 // --------------------------------------------------------------------------- |
|
503 // |
|
504 void TAknFepInputStateStrokePhraseBase::ShowInfoOnEEPPane() |
|
505 { |
|
506 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
507 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
508 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
509 CDesCArrayFlat* keystroke = popup->KeystrokeArrayForStroke(); |
|
510 CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke(); |
|
511 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
512 TBuf<KMaxKeystrokeCount> showInfo; |
|
513 |
|
514 for (TInt i = 0; i < phrase->Count(); ++i ) |
|
515 { |
|
516 showInfo.Append( phrase->MdcaPoint( i ) ); |
|
517 } |
|
518 |
|
519 for (TInt ii = 0; ii < keystroke->Count(); ++ii ) |
|
520 { |
|
521 showInfo.Append( keystroke->MdcaPoint( ii ) ); |
|
522 } |
|
523 |
|
524 editPane->SetText( showInfo, phrase->Count() + index ); |
|
525 if ( EStrokeSequenceEdit == iState ) |
|
526 { |
|
527 editPane->ActiveCursor(); |
|
528 } |
|
529 else if ( EEntry == iState ) |
|
530 { |
|
531 editPane->DeactiveCursor(); |
|
532 } |
|
533 else |
|
534 { |
|
535 editPane->DisableCursor(); |
|
536 } |
|
537 } |
|
538 |
|
539 // --------------------------------------------------------------------------- |
|
540 // TAknFepInputStateStrokePhraseBase::ShowInfoOnEEP |
|
541 // Show the showinfo on the EEP ctrl. |
|
542 // --------------------------------------------------------------------------- |
|
543 // |
|
544 void TAknFepInputStateStrokePhraseBase::ShowInfoOnCandidatePane() |
|
545 { |
|
546 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
547 uiContainer->SetControlInVisible( ETrue ); |
|
548 CDesCArrayFlat* phrase = uiContainer->CandidatePane()->CandidateArray(); |
|
549 if ( KMaxPhraseCreationCount == uiContainer->PinyinPopupWindow()-> |
|
550 ChooseChineseCharacterArrayForStroke()->Count() ) |
|
551 { |
|
552 phrase->Reset(); |
|
553 TRAP_IGNORE( phrase->AppendL( KMaxPhraseNote ) ); |
|
554 uiContainer->SetControlInVisible( ETrue ); |
|
555 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
556 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
557 uiContainer->Enable( ETrue ); |
|
558 uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
559 uiContainer->ShowVerticalScrollArrows( EFalse ); |
|
560 } |
|
561 |
|
562 TRAP_IGNORE( GetCandidateL() ); |
|
563 if ( phrase->Count() > 0 ) |
|
564 { |
|
565 // layout candidate and fill candidate buffer for first display page |
|
566 uiContainer->SetControlInVisible( ETrue ); |
|
567 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
568 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
569 uiContainer->Enable( ETrue ); |
|
570 uiContainer->ShowVerticalScrollArrows( ETrue ); |
|
571 } |
|
572 else |
|
573 { |
|
574 uiContainer->SetControlInVisible( EFalse ); |
|
575 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
576 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
577 uiContainer->Enable( ETrue ); |
|
578 uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
579 uiContainer->ShowVerticalScrollArrows( EFalse ); |
|
580 } |
|
581 } |
|
582 |
|
583 // --------------------------------------------------------------------------- |
|
584 // TAknFepInputStateStrokePhraseBase::GetShowKeystroke |
|
585 //Handle horizontal navigation. |
|
586 // --------------------------------------------------------------------------- |
|
587 // |
|
588 void TAknFepInputStateStrokePhraseBase::GetShowKeystroke( |
|
589 TInt aKey, |
|
590 TDes& aKeystroke ) |
|
591 { |
|
592 TInt count = sizeof( StrokeMap )/sizeof( StrokeMap[0] ); |
|
593 for ( TInt i = 0; i < count ; i++ ) |
|
594 { |
|
595 if (aKey == StrokeMap[i].iKeyCode) |
|
596 { |
|
597 aKeystroke.Append(StrokeMap[i].iValue); |
|
598 break; |
|
599 } |
|
600 } |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // TAknFepInputStateStrokePhraseBase::HandleHorizontalNavigation |
|
605 //Handle horizontal navigation. |
|
606 // --------------------------------------------------------------------------- |
|
607 // |
|
608 TBool TAknFepInputStateStrokePhraseBase::HandleHorizontalNavigation( |
|
609 TInt aKey ) |
|
610 { |
|
611 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
612 TBool response = EFalse; |
|
613 |
|
614 // Do navigation... |
|
615 if (aKey == EKeyLeftArrow) |
|
616 { |
|
617 if(!candidatePane->SelectPrev()) |
|
618 { |
|
619 candidatePane->SetCandidateBuffer(); |
|
620 candidatePane->SelectLastPhrase(); |
|
621 } |
|
622 response = ETrue; |
|
623 } |
|
624 else if (aKey == EKeyRightArrow) |
|
625 { |
|
626 if(!candidatePane->SelectNext()) |
|
627 { |
|
628 candidatePane->SetCandidateBuffer(); |
|
629 candidatePane->SelectFirstPhrase(); |
|
630 } |
|
631 response = ETrue; |
|
632 } |
|
633 |
|
634 if (response) |
|
635 { |
|
636 UpdateIndicator(); |
|
637 } |
|
638 |
|
639 return response; |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------- |
|
643 // TAknFepInputStateStrokePhraseBase::UpdateIndicator |
|
644 // Update Indicator. |
|
645 // --------------------------------------------------------- |
|
646 // |
|
647 void TAknFepInputStateStrokePhraseBase::UpdateIndicator() |
|
648 { |
|
649 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
650 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
651 |
|
652 if ( candidatePane->IsFirstPage() ) |
|
653 { |
|
654 uiContainer->CandidatePane()->ShowUpScrollArrows( EFalse ); |
|
655 } |
|
656 else |
|
657 { |
|
658 uiContainer->CandidatePane()->ShowUpScrollArrows( ETrue ); |
|
659 } |
|
660 |
|
661 if ( candidatePane->IsLastPage() ) |
|
662 { |
|
663 uiContainer->CandidatePane()->ShowDownScrollArrows( EFalse ); |
|
664 } |
|
665 else |
|
666 { |
|
667 uiContainer->CandidatePane()->ShowDownScrollArrows( ETrue ); |
|
668 } |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------- |
|
672 // TAknFepInputStateStrokePhraseBase::DeleteKeystroke |
|
673 // Delete current keystroke. |
|
674 // --------------------------------------------------------- |
|
675 // |
|
676 TBool TAknFepInputStateStrokePhraseBase::DeleteKeystroke() |
|
677 { |
|
678 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
679 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
680 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
681 CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke(); |
|
682 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
683 |
|
684 if ( ( 0 == index ) || ( keystrokeArray->Count() == 0 ) ) |
|
685 { |
|
686 return EFalse; |
|
687 } |
|
688 |
|
689 if ( 1 == index ) |
|
690 { |
|
691 keystrokeArray->Delete( 0 ); |
|
692 editPane->SetCursorIndexOfKeystroke( 0 ); |
|
693 editPane->Reset(); |
|
694 } |
|
695 else if ( index >= keystrokeArray->Count() ) |
|
696 { |
|
697 keystrokeArray->Delete( keystrokeArray->Count() - 1 ); |
|
698 editPane->SetCursorIndexOfKeystroke( keystrokeArray->Count() ); |
|
699 } |
|
700 else |
|
701 { |
|
702 keystrokeArray->Delete( index - 1 ); |
|
703 editPane->SetCursorIndexOfKeystroke( index - 1 ); |
|
704 } |
|
705 return ETrue; |
|
706 } |
|
707 |
|
708 // --------------------------------------------------------- |
|
709 // TAknFepInputStateStrokePhraseBase::AddPhraseToDB |
|
710 // Add phrase to DB. |
|
711 // --------------------------------------------------------- |
|
712 // |
|
713 void TAknFepInputStateStrokePhraseBase::AddPhraseToDB( |
|
714 const TDesC& aPhraseAdd ) |
|
715 { |
|
716 TPtiUserDictionaryEntry addUdbEntry( aPhraseAdd ); |
|
717 //Add the phrase to the DB by PTI Engine |
|
718 iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); |
|
719 } |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // TAknFepInputStateStrokePhraseBase::RefreshCandidate |
|
723 // Refresh candidate |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 void TAknFepInputStateStrokePhraseBase::RefreshCandidate() |
|
727 { |
|
728 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
729 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
730 uiContainer->Enable( ETrue ); |
|
731 |
|
732 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
733 uiContainer->CandidatePane()->IsFirstPage()); |
|
734 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
735 TBool showArrows = multiplePages || bufLength > KMinCnadidateCount; |
|
736 |
|
737 uiContainer->ShowHorizontalScrollArrows( showArrows ); |
|
738 uiContainer->ShowVerticalScrollArrows( multiplePages ); |
|
739 |
|
740 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
741 UpdateIndicator(); |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // TAknFepInputStateStrokePhraseBase::CheckKeyNeedRepeat |
|
746 // Check key whether need repeat. |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 TBool TAknFepInputStateStrokePhraseBase::CheckKeyNeedRepeat( TKeyPressLength aLength ) |
|
750 { |
|
751 MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow(); |
|
752 if ( popup->IsChangeStatet() && aLength == ELongKeyPress ) |
|
753 { |
|
754 return EFalse; |
|
755 } |
|
756 else |
|
757 { |
|
758 popup->SetChangeState( EFalse ); |
|
759 } |
|
760 return ETrue; |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------- |
|
764 // TAknFepInputStateStrokePhraseBase::ClearPtiEngineKeystroke |
|
765 // clear the ptiengine keystroke; |
|
766 // --------------------------------------------------------- |
|
767 // |
|
768 void TAknFepInputStateStrokePhraseBase::ClearPtiEngineKeystroke() |
|
769 { |
|
770 iOwner->PtiEngine()->ClearCurrentWord(); |
|
771 } |
|
772 |
|
773 // --------------------------------------------------------- |
|
774 // TAknFepInputStateStrokePhraseBase::AddKeystrokeL |
|
775 // Add keystroke. |
|
776 // --------------------------------------------------------- |
|
777 // |
|
778 TBool TAknFepInputStateStrokePhraseBase::AddKeystrokeL( TInt aKey ) |
|
779 { |
|
780 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
781 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
782 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
783 CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke(); |
|
784 TInt phraseCount = popup->ChooseChineseCharacterArrayForStroke()->Count(); |
|
785 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
786 |
|
787 if ( phraseCount + keystrokeArray->Count() >= KMaxKeystrokeCount ) |
|
788 { |
|
789 return EFalse; |
|
790 } |
|
791 |
|
792 TBuf<1> keystroke; |
|
793 GetShowKeystroke( aKey, keystroke ); |
|
794 if ( index >= keystrokeArray->Count() ) |
|
795 { |
|
796 keystrokeArray->AppendL( keystroke ); |
|
797 editPane->SetCursorIndexOfKeystroke( keystrokeArray->Count() ); |
|
798 } |
|
799 else |
|
800 { |
|
801 keystrokeArray->InsertL( index, keystroke ); |
|
802 editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
803 } |
|
804 return ETrue; |
|
805 } |
|
806 // --------------------------------------------------------- |
|
807 // TAknFepInputStateStrokePhraseBase::GetCandidateL |
|
808 // Get the candidate info. |
|
809 // --------------------------------------------------------- |
|
810 // |
|
811 void TAknFepInputStateStrokePhraseBase::GetCandidateL() |
|
812 { |
|
813 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
814 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
815 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
816 CDesCArrayFlat* phraseCandidates = |
|
817 uiContainer->CandidatePane()->CandidateArray(); |
|
818 CDesCArrayFlat* keystroke = popup->KeystrokeArrayForStroke(); |
|
819 phraseCandidates->Reset(); |
|
820 TBuf<KMaxKeystrokeCount> buf; |
|
821 TBuf<1> delimiter; |
|
822 delimiter.Append( KDelimiter ); |
|
823 if ( !CheckFirstGroupStroke() ) |
|
824 { |
|
825 return; |
|
826 } |
|
827 else if ( CheckAllKeystroke() ) |
|
828 { |
|
829 for( TInt i = 0; i < keystroke->Count(); ++i ) |
|
830 { |
|
831 buf.Append( keystroke->MdcaPoint( i ) ); |
|
832 } |
|
833 } |
|
834 else |
|
835 { |
|
836 TInt pos = 0; |
|
837 if ( 0 == keystroke->Find( delimiter,pos ) ) |
|
838 { |
|
839 for( TInt i = 0; i < pos; ++i ) |
|
840 { |
|
841 buf.Append( keystroke->MdcaPoint( i ) ); |
|
842 } |
|
843 } |
|
844 else |
|
845 { |
|
846 for( TInt i = 0; i < keystroke->Count(); ++i ) |
|
847 { |
|
848 buf.Append( keystroke->MdcaPoint( i ) ); |
|
849 } |
|
850 } |
|
851 } |
|
852 extern void CleanArray( TAny* aAny ); |
|
853 RPointerArray<HBufC> list; |
|
854 TCleanupItem cleanitem( CleanArray, &list ); |
|
855 CleanupStack::PushL( cleanitem ); |
|
856 HBufC* retString = ptiengine->GetCandidatesByInputString( |
|
857 buf, |
|
858 list, |
|
859 EFalse ); |
|
860 |
|
861 delete retString; |
|
862 retString = NULL; |
|
863 |
|
864 for ( TInt i = 0; i < list.Count(); ++i ) |
|
865 { |
|
866 phraseCandidates->AppendL( *(list[i]) ); |
|
867 } |
|
868 CleanupStack::PopAndDestroy(); |
|
869 } |
|
870 |
|
871 // --------------------------------------------------------- |
|
872 // TAknFepInputStateStrokePhraseBase::GetKeystrokeCode |
|
873 // get Code of the key stroke. |
|
874 // --------------------------------------------------------- |
|
875 // |
|
876 void TAknFepInputStateStrokePhraseBase::GetKeystrokeCode( |
|
877 TInt& aKey, |
|
878 const TDesC& aKeystroke ) |
|
879 { |
|
880 TInt count = sizeof( StrokeMap )/sizeof( StrokeMap[0] ); |
|
881 for ( TInt i = 0; i < count ; i++ ) |
|
882 { |
|
883 TBuf<1> buf; |
|
884 buf.Append(StrokeMap[i].iValue); |
|
885 if (0 == aKeystroke.Compare(buf)) |
|
886 { |
|
887 aKey = StrokeMap[i].iKeyCode; |
|
888 break; |
|
889 } |
|
890 } |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------- |
|
894 // TAknFepInputStateStrokePhraseBase::CheckAllKeystroke |
|
895 // Get the candidate info. |
|
896 // --------------------------------------------------------- |
|
897 // |
|
898 TBool TAknFepInputStateStrokePhraseBase::CheckAllKeystroke() |
|
899 { |
|
900 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
901 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
902 CDesCArrayFlat* keystrokeArray = uiContainer-> |
|
903 PinyinPopupWindow()->KeystrokeArrayForStroke(); |
|
904 |
|
905 TInt chineseCount = uiContainer->PinyinPopupWindow()-> |
|
906 ChooseChineseCharacterArrayForStroke()->Count(); |
|
907 TInt stringBeforeLength = 0; |
|
908 TInt stringAfterLength = 0; |
|
909 TInt keyCode = 0; |
|
910 TInt delimiterCount = 0; |
|
911 TBuf<1> delimiter; |
|
912 delimiter.Append( KDelimiter ); |
|
913 if ( chineseCount > 0 ) |
|
914 { |
|
915 return EFalse; |
|
916 } |
|
917 |
|
918 if ( keystrokeArray->Count() > 0 ) |
|
919 { |
|
920 if ( 0 == keystrokeArray->MdcaPoint( 0 ).Compare( delimiter ) ) |
|
921 { |
|
922 return EFalse; |
|
923 } |
|
924 } |
|
925 ClearPtiEngineKeystroke(); |
|
926 for ( TInt i = 0; i < keystrokeArray->Count(); ++i ) |
|
927 { |
|
928 if ( 0 == keystrokeArray->MdcaPoint( i ).Compare( delimiter ) ) |
|
929 { |
|
930 delimiterCount = delimiterCount + 1; |
|
931 } |
|
932 GetKeystrokeCode( keyCode, keystrokeArray->MdcaPoint( i ) ); |
|
933 stringBeforeLength = |
|
934 ptiengine->GetPhoneticSpelling(KEnginePhoneticIndex).Length(); |
|
935 stringAfterLength = |
|
936 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
937 |
|
938 if ( stringBeforeLength == stringAfterLength ) |
|
939 { |
|
940 ClearPtiEngineKeystroke(); |
|
941 return EFalse; |
|
942 } |
|
943 } |
|
944 if ( delimiterCount >= KMaxPhraseCreationCount ) |
|
945 { |
|
946 return EFalse; |
|
947 } |
|
948 return ETrue; |
|
949 } |
|
950 |
|
951 // --------------------------------------------------------- |
|
952 // TAknFepInputStateStrokePhraseBase::RevertPhraseToKeystrokeL |
|
953 // Revert the phrase to keystroke. |
|
954 // --------------------------------------------------------- |
|
955 // |
|
956 void TAknFepInputStateStrokePhraseBase::RevertPhraseToKeystrokeL() |
|
957 { |
|
958 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
959 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
960 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
961 CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke(); |
|
962 CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke(); |
|
963 CDesCArrayFlat* phraseStroke = |
|
964 popup->ChooseChineseCharacterArrayKeystrokeForStroke(); |
|
965 |
|
966 TBuf<KMaxKeystrokeCount> buf; |
|
967 if ( ( phrase->Count() == 0 ) || ( phraseStroke->Count() == 0 ) ) |
|
968 { |
|
969 return; |
|
970 } |
|
971 |
|
972 buf.Append( phraseStroke->MdcaPoint( phraseStroke->Count() - 1 ) ); |
|
973 |
|
974 for ( TInt i = buf.Length() - 1; i >= 0; --i ) |
|
975 { |
|
976 keystrokeArray->InsertL( 0, buf.Mid( i, 1 ) ); |
|
977 } |
|
978 phrase->Delete( phrase->Count() - 1 ); |
|
979 phraseStroke->Delete( phraseStroke->Count() - 1 ); |
|
980 |
|
981 TInt leng = phrase->Count() + keystrokeArray->Count(); |
|
982 if ( leng > KMaxKeystrokeCount ) |
|
983 { |
|
984 for ( TInt i = 0; i < leng - KMaxKeystrokeCount; ++i ) |
|
985 { |
|
986 keystrokeArray->Delete( keystrokeArray->Count() - 1 ); |
|
987 } |
|
988 } |
|
989 editPane->SetCursorIndexOfKeystroke( buf.Length() ); |
|
990 keystrokeArray->Compress(); |
|
991 phrase->Compress(); |
|
992 phraseStroke->Compress(); |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------- |
|
996 // TAknFepInputStateStrokePhraseBase::SetWarningColor |
|
997 // Set warning color. |
|
998 // --------------------------------------------------------- |
|
999 // |
|
1000 void TAknFepInputStateStrokePhraseBase::SetWarningColor() |
|
1001 { |
|
1002 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
1003 CDesCArrayFlat* keystrokeArray = UIContainer()-> |
|
1004 PinyinPopupWindow()->KeystrokeArrayForStroke(); |
|
1005 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1006 TInt phraseCount = UIContainer()->PinyinPopupWindow()-> |
|
1007 ChooseChineseCharacterArrayForStroke()->Count(); |
|
1008 |
|
1009 TInt indexStart = phraseCount; |
|
1010 TInt keyCode = 0; |
|
1011 TInt stringBeforeLength = 0; |
|
1012 TInt stringAfterLength = 0; |
|
1013 TInt keystrokeCount = 0; |
|
1014 TInt validKeystrokeCountOfPti = 0; |
|
1015 TBool valid = ETrue; |
|
1016 TInt delimiterCount = 0; |
|
1017 TInt delimiterADD = 0; |
|
1018 TBuf<1> delimiter; |
|
1019 delimiter.Append( KDelimiter ); |
|
1020 ClearPtiEngineKeystroke(); |
|
1021 |
|
1022 for ( TInt i = 0; i < keystrokeArray->Count(); ++i ) |
|
1023 { |
|
1024 keystrokeCount = keystrokeCount + 1; |
|
1025 if ( phraseCount + delimiterCount >= KMaxPhraseCreationCount ) |
|
1026 { |
|
1027 break; |
|
1028 } |
|
1029 if ( 0 == keystrokeArray->MdcaPoint( i ).Compare( delimiter ) ) |
|
1030 { |
|
1031 delimiterADD = i; |
|
1032 delimiterCount = delimiterCount + 1; |
|
1033 } |
|
1034 GetKeystrokeCode( keyCode, keystrokeArray->MdcaPoint( i ) ); |
|
1035 stringBeforeLength = ptiengine->GetPhoneticSpelling( |
|
1036 KEnginePhoneticIndex).Length(); |
|
1037 stringAfterLength = |
|
1038 ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); |
|
1039 |
|
1040 if ( stringBeforeLength == stringAfterLength ) |
|
1041 { |
|
1042 valid = EFalse; |
|
1043 } |
|
1044 else if ( valid ) |
|
1045 { |
|
1046 validKeystrokeCountOfPti = validKeystrokeCountOfPti + 1; |
|
1047 } |
|
1048 |
|
1049 if ( ( i == keystrokeArray->Count() - 1 ) && ( KKey0Code != keyCode ) |
|
1050 && ( 1 != keystrokeCount ) && ( !valid ) ) |
|
1051 { |
|
1052 editPane->SetHighlight( indexStart, indexStart + keystrokeCount - 1 ); |
|
1053 validKeystrokeCountOfPti = 0; |
|
1054 keystrokeCount = 0; |
|
1055 valid = ETrue; |
|
1056 } |
|
1057 |
|
1058 if ( KKey0Code == keyCode ) |
|
1059 { |
|
1060 ClearPtiEngineKeystroke(); |
|
1061 if ( 0 == i ) |
|
1062 { |
|
1063 editPane->SetHighlight( indexStart, indexStart |
|
1064 + keystrokeCount - 1 ); |
|
1065 indexStart = phraseCount + i + 1; |
|
1066 validKeystrokeCountOfPti = 0; |
|
1067 keystrokeCount = 0; |
|
1068 valid = ETrue; |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 if ( ( 0 == keystrokeArray->MdcaPoint( i ). |
|
1073 Compare( delimiter ) ) && ( 0 |
|
1074 == keystrokeArray->MdcaPoint( i - 1 ). |
|
1075 Compare( delimiter ) ) ) |
|
1076 { |
|
1077 editPane->SetHighlight( indexStart, indexStart |
|
1078 + keystrokeCount - 1 ); |
|
1079 indexStart = phraseCount + i + 1; |
|
1080 validKeystrokeCountOfPti = 0; |
|
1081 keystrokeCount = 0; |
|
1082 valid = ETrue; |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 if ( ( !valid ) && ( 1 != keystrokeCount ) && |
|
1087 ( validKeystrokeCountOfPti < keystrokeCount - 1 ) ) |
|
1088 { |
|
1089 editPane->SetHighlight( indexStart, indexStart |
|
1090 + keystrokeCount - 1 ); |
|
1091 indexStart = phraseCount + i + 1; |
|
1092 validKeystrokeCountOfPti = 0; |
|
1093 keystrokeCount = 0; |
|
1094 valid = ETrue; |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 indexStart = phraseCount + i + 1; |
|
1099 validKeystrokeCountOfPti = 0; |
|
1100 keystrokeCount = 0; |
|
1101 valid = ETrue; |
|
1102 } |
|
1103 } |
|
1104 } |
|
1105 } |
|
1106 } |
|
1107 |
|
1108 if ( phraseCount + delimiterCount >= KMaxPhraseCreationCount ) |
|
1109 { |
|
1110 editPane->SetHighlight( |
|
1111 phraseCount + delimiterADD, |
|
1112 phraseCount + keystrokeArray->Count() ); |
|
1113 } |
|
1114 |
|
1115 } |
|
1116 |
|
1117 // --------------------------------------------------------- |
|
1118 // TAknFepInputStateStrokePhraseBase::SetWarningColor |
|
1119 // Set warning color. |
|
1120 // --------------------------------------------------------- |
|
1121 // |
|
1122 void TAknFepInputStateStrokePhraseBase::ChangeCbaL() |
|
1123 { |
|
1124 MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow(); |
|
1125 TInt keystrokeCount = popup->KeystrokeArrayForStroke()->Count(); |
|
1126 TInt phraseCount = popup->ChooseChineseCharacterArrayForStroke()->Count(); |
|
1127 TInt lastRes = popup->GetLastResouce(); |
|
1128 |
|
1129 TBool first = CheckFirstGroupStroke(); |
|
1130 CheckAllKeystroke(); |
|
1131 if ( phraseCount == KMaxPhraseCreationCount ) |
|
1132 { |
|
1133 if ( lastRes == R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ) |
|
1134 { |
|
1135 return; |
|
1136 } |
|
1137 //User cba done-done-cancel |
|
1138 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1139 popup->SetLastResouce( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1140 } |
|
1141 else if ( 0 != keystrokeCount && first ) |
|
1142 { |
|
1143 if ( lastRes == R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT ) |
|
1144 { |
|
1145 return; |
|
1146 } |
|
1147 //User cba select-select-cancel |
|
1148 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT ); |
|
1149 popup->SetLastResouce( R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT ); |
|
1150 } |
|
1151 else if ( phraseCount > 1 && 0 == keystrokeCount ) |
|
1152 { |
|
1153 if ( lastRes == R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ) |
|
1154 { |
|
1155 return; |
|
1156 } |
|
1157 //User cba done-done-cancel |
|
1158 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1159 popup->SetLastResouce( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE ); |
|
1160 } |
|
1161 else |
|
1162 { |
|
1163 if ( lastRes == R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY ) |
|
1164 { |
|
1165 return; |
|
1166 } |
|
1167 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY ); |
|
1168 popup->SetLastResouce( R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY ); |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 // --------------------------------------------------------- |
|
1173 // TAknFepInputStateStrokePhraseBase::MoveCursorLeft |
|
1174 // Move the cursor to Left. |
|
1175 // --------------------------------------------------------- |
|
1176 // |
|
1177 void TAknFepInputStateStrokePhraseBase::MoveCursorLeft() |
|
1178 { |
|
1179 MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow(); |
|
1180 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1181 TInt keystrokeCount = popup->KeystrokeArrayForStroke()->Count(); |
|
1182 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
1183 if ( 0 == keystrokeCount ) |
|
1184 { |
|
1185 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
1186 return; |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 popup->SetState( KManualChangeState ); |
|
1191 } |
|
1192 |
|
1193 if ( index > 1 ) |
|
1194 { |
|
1195 editPane->SetCursorIndexOfKeystroke( index - 1 ); |
|
1196 editPane->MoveCursorLeft(); |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 if ( 1 == index ) |
|
1201 { |
|
1202 editPane->SetCursorIndexOfKeystroke( 0 ); |
|
1203 } |
|
1204 else |
|
1205 { |
|
1206 editPane->SetCursorIndexOfKeystroke( keystrokeCount ); |
|
1207 } |
|
1208 ShowInfoOnEEPPane(); |
|
1209 if ( !CheckAllKeystroke() ) |
|
1210 { |
|
1211 SetWarningColor(); |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 // --------------------------------------------------------- |
|
1217 // TAknFepInputStateStrokePhraseBase::MoveCursorRight |
|
1218 // Move the cursor to Right. |
|
1219 // --------------------------------------------------------- |
|
1220 // |
|
1221 void TAknFepInputStateStrokePhraseBase::MoveCursorRight() |
|
1222 { |
|
1223 MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow(); |
|
1224 MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1225 TInt keystrokeCount = popup->KeystrokeArrayForStroke()->Count(); |
|
1226 TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
1227 if ( 0 == keystrokeCount ) |
|
1228 { |
|
1229 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
1230 return; |
|
1231 } |
|
1232 else |
|
1233 { |
|
1234 popup->SetState( KManualChangeState ); |
|
1235 } |
|
1236 |
|
1237 if ( index < keystrokeCount ) |
|
1238 { |
|
1239 editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
1240 editPane->MoveCursorRight(); |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 editPane->SetCursorIndexOfKeystroke( 0 ); |
|
1245 ShowInfoOnEEPPane(); |
|
1246 if ( !CheckAllKeystroke() ) |
|
1247 { |
|
1248 SetWarningColor(); |
|
1249 } |
|
1250 } |
|
1251 } |
|
1252 |
|
1253 // --------------------------------------------------------------------------- |
|
1254 // TAknFepInputStateStrokePhraseBase::GetNewCandidatesL |
|
1255 // Get new candidate |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 void TAknFepInputStateStrokePhraseBase::GetNewCandidatesL(const TDesC& aSource, |
|
1259 RPointerArray<HBufC>& aList) |
|
1260 { |
|
1261 TInt start = 0; |
|
1262 TInt length = 0; |
|
1263 |
|
1264 for (TInt ii = 0; ii < aSource.Length(); ii++) |
|
1265 { |
|
1266 if (aSource[ii] == KSegment) |
|
1267 { |
|
1268 TPtrC segment(aSource.Ptr() + start, length); |
|
1269 aList.AppendL(segment.AllocL()); |
|
1270 start += (length + 1); |
|
1271 length = 0; |
|
1272 } |
|
1273 else |
|
1274 { |
|
1275 length++; |
|
1276 } |
|
1277 } |
|
1278 |
|
1279 if (length) |
|
1280 { |
|
1281 TPtrC segm(aSource.Ptr() + start, length); |
|
1282 aList.AppendL(segm.AllocL()); |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 // End of file |