|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Provides the CAknFepUIInputStateMiniQwertyZhuyinPhrase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStateEntryMiniQwertyZhuyinPhrase.h" |
|
31 #include "AknFepUIManagerStateInterface.h" |
|
32 |
|
33 #include "AknFepUICtrlInputPane.h" |
|
34 #include "AknFepUICtrlCandidatePane.h" |
|
35 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
36 #include "AknFepManager.h" //FepMan flag |
|
37 #include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase |
|
38 #include "aknfepuictrleditpane.h" //phrase creation |
|
39 #include "aknfepinputstateminiqwertyzhuyinkeymap.h" //phrase creation |
|
40 #include <PtiEngine.h> |
|
41 #include <e32keys.h> |
|
42 #include <PtiDefs.h> |
|
43 #include <avkon.rsg> //keys |
|
44 #include <AknFep.rsg> |
|
45 |
|
46 const TInt KInputPaneLength = 32; |
|
47 _LIT(KSep, "'"); |
|
48 _LIT(KReplace, ""); |
|
49 _LIT(KLeftBracket, "("); |
|
50 _LIT(KRightBracket, ")"); |
|
51 const TText KPinyinTone4Valid = 0x02D9; |
|
52 const TText KPinyinTone4Invalid = 0x0020; |
|
53 const TInt KMaxKeystrokeCount = 31; |
|
54 const TInt KKeystrokeMaxLength =5; |
|
55 const TInt KKeyBufferMaxLength =150; |
|
56 |
|
57 const TUint16 KSai = 0x311D; |
|
58 const TUint16 KToneMark1 = 0x0020; |
|
59 const TUint16 KToneMark2 = 0x02CA; |
|
60 const TUint16 KToneMark3 = 0x02c7; |
|
61 const TUint16 KToneMark4 = 0x02CB; |
|
62 const TUint16 KToneMark5 = 0x02D9; |
|
63 |
|
64 struct TToneZhuYinMap |
|
65 { |
|
66 TUint16 iValue; |
|
67 TInt iInputTone; |
|
68 }; |
|
69 const TToneZhuYinMap ZhuyinToneMap[] = |
|
70 { |
|
71 { |
|
72 KToneMark1, 1 |
|
73 }, |
|
74 { |
|
75 KToneMark2, 2 |
|
76 }, |
|
77 { |
|
78 KToneMark3, 3 |
|
79 }, |
|
80 { |
|
81 KToneMark4, 4 |
|
82 }, |
|
83 { |
|
84 KToneMark5, 5 |
|
85 } |
|
86 }; |
|
87 |
|
88 const TInt KMaxPhraseCount = 150;//This should be the same as that in pticpicore. |
|
89 |
|
90 _LIT( KZhuyinNote,"\x9020\x65B0\x8BCD" ); |
|
91 |
|
92 TAknFepInputStateEntryMiniQwertyZhuyinPhrase::TAknFepInputStateEntryMiniQwertyZhuyinPhrase( |
|
93 MAknFepUIManagerStateInterface* aOwner, |
|
94 MAknFepUICtrlContainerChinese* aUIContainer ) : |
|
95 TAknFepInputStateEntryQwertyBaseChinesePhrase( aOwner, aUIContainer) |
|
96 { |
|
97 iState = EEntry; |
|
98 |
|
99 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
100 uiContainer->FocusCandidatePane( EFalse ); |
|
101 uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse ); |
|
102 uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutInput ); |
|
103 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
104 uiContainer->ShowVerticalScrollArrows( ETrue ); |
|
105 uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
106 uiContainer->InputPane()->SetOverrideFontId( 0 ); |
|
107 uiContainer->SetFepMan( iOwner->FepMan() ); |
|
108 |
|
109 //For fix bug that the text in input pane could not be shown totally. |
|
110 if ( iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty4x10 || |
|
111 iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty3x11) |
|
112 { |
|
113 uiContainer->PinyinPopupWindow()->SetInputLayoutMiniQwertyZhuyin(); |
|
114 } |
|
115 |
|
116 iOwner->PtiEngine()->SetCandidatePageLength( KMaxPhraseCount ); |
|
117 // in the case that we are coming back to the input pane from the candidate pane, |
|
118 // we need to ensure that the current selection is selected correctly |
|
119 ImplicitlyUpdateSelection(); |
|
120 // however we also need to clear the deliberate selection, in case we are not |
|
121 // coming back to the input pane from the candidate pane |
|
122 ClearDeliberateSelection(); |
|
123 UpdateIndicator(); |
|
124 |
|
125 iOwner->PtiEngine()->SetInputMode( EPtiEngineZhuyinPhraseQwerty ); |
|
126 iOwner->PtiEngine()->SetCase( EPtiCaseLower ); |
|
127 } |
|
128 |
|
129 TBool TAknFepInputStateEntryMiniQwertyZhuyinPhrase::HandleKeyL( TInt aKey, |
|
130 TKeyPressLength aLength ) |
|
131 { |
|
132 if ( iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty4x10 || |
|
133 iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty3x11) |
|
134 { |
|
135 return HandleKeyForMiniQwertyL( aKey, aLength ); |
|
136 } |
|
137 else |
|
138 { |
|
139 return HandleKeyForHalfAndCustomQwertyL( aKey, aLength ); |
|
140 } |
|
141 } |
|
142 |
|
143 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::KeyTimerExpired() |
|
144 { |
|
145 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
146 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
147 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
148 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
149 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
150 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
151 |
|
152 // set container's position |
|
153 TPoint baseLine = TPoint( 0, 0 ); |
|
154 TInt height = 0; |
|
155 TInt ascent = 0; |
|
156 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)) |
|
157 ; |
|
158 if ( ret == KErrNone ) |
|
159 { |
|
160 uiContainer->SetContainerPosition( baseLine, height ); |
|
161 } |
|
162 |
|
163 TInt pinyinCountWithoutToneMarks = ptiengine->PhoneticSpellingCount(); |
|
164 if ( editPane->GetEffictiveLength() < keystroke->Count() |
|
165 || pinyinCountWithoutToneMarks == popup->CurrentSelection() ) |
|
166 { |
|
167 TBuf<KKeyBufferMaxLength> keystrokeBuf; |
|
168 for (TInt i = 0; i < keystroke->Count(); i++ ) |
|
169 { |
|
170 keystrokeBuf.Append( keystroke->MdcaPoint( i ) ); |
|
171 } |
|
172 inputPane->SetText( keystrokeBuf ); |
|
173 } |
|
174 else |
|
175 { |
|
176 TPtrC ptr = ptiengine->GetPhoneticSpelling( 1 ); |
|
177 TBuf<KInputPaneLength> currentText; |
|
178 inputPane->GetText( currentText ); |
|
179 if ( ptr.Length() < currentText.Length() ) |
|
180 { |
|
181 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
182 } |
|
183 inputPane->SetText( ptr ); |
|
184 } |
|
185 } |
|
186 |
|
187 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::DeliberatelyUpdateSelection() |
|
188 { |
|
189 TPtr deliberateSelection = iOwner->GetLatestDeliberateSelection(); |
|
190 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
191 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
192 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
193 |
|
194 TInt selected = popup->CurrentSelection(); |
|
195 ptiengine->EnableToneMarks( EFalse ); |
|
196 TPtrC spelling = ptiengine->GetPhoneticSpelling( selected + 1 ); // our index is zero based, engine index is one based |
|
197 deliberateSelection |
|
198 = spelling.Left( MAknFepUICtrlInputPane::EMaxInputCharsPinyinPopupNotIncludingToneMark ); |
|
199 ptiengine->EnableToneMarks( ETrue ); |
|
200 UIContainer()->PinyinPopupWindow()->SetFlag( MAknFepUICtrlPinyinPopup::ESpellingNavigation ); |
|
201 RefreshUI( popup->CurrentVisibleSelection() ); |
|
202 } |
|
203 |
|
204 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::ImplicitlyUpdateSelection() |
|
205 { |
|
206 TPtr oldDeliberateSelection = iOwner->GetLatestDeliberateSelection(); |
|
207 TInt oldDeliberateSelectionLength = oldDeliberateSelection.Length(); |
|
208 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
209 |
|
210 // previously selected is compared in turn to each of the new candidates |
|
211 ptiengine->EnableToneMarks( EFalse ); |
|
212 TInt pinyinCount = ptiengine->PhoneticSpellingCount(); |
|
213 TInt newSelection = 0; |
|
214 for (TInt i = 0; i < pinyinCount; i++ ) |
|
215 { |
|
216 TPtrC spelling = ptiengine->GetPhoneticSpelling( i + 1 ); // our index is zero based, engine index is one based |
|
217 TInt spellingLength = spelling.Length(); |
|
218 |
|
219 // figure out how many characters we are comparing, this depends on the |
|
220 // direction of the edit |
|
221 TInt compareLength = oldDeliberateSelectionLength <= spellingLength |
|
222 ? oldDeliberateSelectionLength : spellingLength; |
|
223 |
|
224 if ( oldDeliberateSelection.Left( compareLength ) |
|
225 == spelling.Left( compareLength ) ) |
|
226 { |
|
227 // as soon as a substring match is found, the |
|
228 // highlight position is set to that candidate in the new list. |
|
229 // note that in the case of the first character entered, the |
|
230 // oldBuf will be empty so it will always match... which is |
|
231 // fine as we want to select the top one anyway, so we will |
|
232 // quit the loop early. |
|
233 newSelection = i; |
|
234 break; |
|
235 } |
|
236 } |
|
237 ptiengine->EnableToneMarks( ETrue ); |
|
238 UIContainer()->PinyinPopupWindow()->SetFlag( MAknFepUICtrlPinyinPopup::ESpellingChanged ); |
|
239 RefreshUI( newSelection ); |
|
240 } |
|
241 |
|
242 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::ClearDeliberateSelection() |
|
243 { |
|
244 // we must have just deleted the last character, |
|
245 // or we are starting a new zhuyin session, so wipe the last deliberate selection |
|
246 CDesCArrayFlat* keystroke = UIContainer()->EditPaneWindow()->KeystrokeArray(); |
|
247 if ( keystroke->Count() == 0 ) |
|
248 { |
|
249 TPtr oldDeliberateSelection = iOwner->GetLatestDeliberateSelection(); |
|
250 oldDeliberateSelection = KNullDesC; |
|
251 } |
|
252 } |
|
253 |
|
254 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::RefreshUI( TInt aSelection ) |
|
255 { |
|
256 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
257 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
258 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
259 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
260 CDesCArrayFlat* spelling = popup->PhoneticSpellingArray(); |
|
261 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
262 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
263 TBuf<KKeyBufferMaxLength> keystrokeBuf; |
|
264 |
|
265 // get cursor position |
|
266 TPoint baseLine = TPoint( 0, 0 ); |
|
267 TInt height = 0; |
|
268 TInt ascent = 0; |
|
269 |
|
270 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
271 if ( ret == KErrNone ) |
|
272 { |
|
273 uiContainer->SetContainerPosition( baseLine, height ); |
|
274 } |
|
275 |
|
276 TText toneMark; |
|
277 TBool toneMarkEntered = ptiengine->ToneMark( toneMark ); |
|
278 TBuf<1> validToneMarkBuf; |
|
279 if ( toneMarkEntered ) |
|
280 { |
|
281 // override specific invalid tonemark character only, the others are the same character |
|
282 // when both valid and invalid |
|
283 if ( toneMark == KPinyinTone4Invalid ) |
|
284 toneMark = KPinyinTone4Valid; |
|
285 validToneMarkBuf.Append( toneMark ); |
|
286 } |
|
287 |
|
288 // to start with, disable the tone marks so we can get the list of all zhuyin matches |
|
289 // later we will figure out which ones are invalid |
|
290 ptiengine->EnableToneMarks( EFalse ); |
|
291 TInt pinyinCountWithoutToneMarks = ptiengine->PhoneticSpellingCount(); |
|
292 |
|
293 for (TInt i = 0; i < keystroke->Count(); i++ ) |
|
294 { |
|
295 keystrokeBuf.Append( keystroke->MdcaPoint( i ) ); |
|
296 } |
|
297 |
|
298 if ( pinyinCountWithoutToneMarks > 0 ) |
|
299 { |
|
300 if ( popup->IsFlagSet( MAknFepUICtrlPinyinPopup::ESpellingChanged ) ) |
|
301 { |
|
302 if ( editPane->GetEffictiveLength() < keystroke->Count() ) |
|
303 { |
|
304 spelling->Reset(); |
|
305 spelling->Compress(); |
|
306 } |
|
307 else |
|
308 { |
|
309 TRAPD(ignore, ptiengine->GetPhoneticSpellingsL(*spelling)); |
|
310 if ( ignore != KErrNone ) |
|
311 { |
|
312 return; |
|
313 } |
|
314 } |
|
315 |
|
316 TRAPD( retOptimize, spelling->AppendL( keystrokeBuf ) ); |
|
317 if ( KErrNone != retOptimize ) |
|
318 { |
|
319 return; |
|
320 } |
|
321 |
|
322 popup->SplitPhraseSpellingIntoPages(); |
|
323 } |
|
324 |
|
325 // set display page for delibrate selection |
|
326 popup->SetDisplayPage( aSelection ); |
|
327 popup->SetPhraseItemTexts(); |
|
328 |
|
329 // fill in input pane although it's invisible |
|
330 if ( editPane->GetEffictiveLength() < keystroke->Count() |
|
331 || pinyinCountWithoutToneMarks == popup->CurrentSelection() ) |
|
332 { |
|
333 inputPane->SetText( keystrokeBuf ); |
|
334 } |
|
335 else |
|
336 { |
|
337 inputPane->SetText( ptiengine->GetPhoneticSpelling( popup->CurrentSelection() |
|
338 + 1 ) ); |
|
339 } |
|
340 popup->PopupSizeChanged(); // phrase input |
|
341 } |
|
342 // turn tone marks back on so that we know where we are. |
|
343 ptiengine->EnableToneMarks( ETrue ); |
|
344 |
|
345 // this is where we start to figure out whether the tonemarks are valid, |
|
346 // whether the selected tonemark is valid, and what is the index of the |
|
347 // selected candidate in the list of candidates with tonemarks... |
|
348 TBool selectionToneMarkValid = EFalse; |
|
349 TInt selectionIndexAdjustedForToneMarkValidity = |
|
350 popup->CurrentSelection(); |
|
351 |
|
352 // we only need to deal with tone marks if there is one |
|
353 if ( toneMarkEntered ) |
|
354 { |
|
355 if ( pinyinCountWithoutToneMarks > 0 ) |
|
356 { |
|
357 for (TInt i = popup->CurrentSelection() + 1; i < pinyinCountWithoutToneMarks; i++ ) |
|
358 { |
|
359 TBool valid = EFalse; |
|
360 |
|
361 TBuf<MAknFepUICtrlInputPane::EMaxInputCharsPinyinPopupNotIncludingToneMark> |
|
362 nextCandidateWithoutToneMark; |
|
363 nextCandidateWithoutToneMark.Copy( ptiengine->GetPhoneticSpelling(i + 1).Left( MAknFepUICtrlInputPane::EMaxInputCharsPinyinPopupNotIncludingToneMark ) ); |
|
364 |
|
365 ptiengine->EnableToneMarks( EFalse ); |
|
366 ptiengine->SelectPhoneticSpelling( i + 1 ); |
|
367 |
|
368 valid = ptiengine->IsToneMarkValidForSpelling(); |
|
369 if ( valid ) |
|
370 { |
|
371 ptiengine->EnableToneMarks( ETrue ); |
|
372 TInt pinyinCountWithToneMarks = |
|
373 ptiengine->PhoneticSpellingCount(); |
|
374 |
|
375 for (TInt j = popup->CurrentSelection() + 1; j < pinyinCountWithToneMarks; j++ ) |
|
376 { |
|
377 // use j here not i as we are looking at the list with tonemarks |
|
378 TPtrC nextCandidateWithToneMark = |
|
379 ptiengine->GetPhoneticSpelling( j + 1 ); |
|
380 if ( nextCandidateWithToneMark |
|
381 == nextCandidateWithoutToneMark ) |
|
382 { |
|
383 if ( i == aSelection ) |
|
384 { |
|
385 selectionToneMarkValid = ETrue; |
|
386 |
|
387 // fill in input pane even if it can't be seen, for when we have to hide popup window |
|
388 inputPane->SetText( nextCandidateWithoutToneMark ); |
|
389 } |
|
390 break; |
|
391 } |
|
392 } |
|
393 } |
|
394 } |
|
395 } |
|
396 } |
|
397 ptiengine->EnableToneMarks( EFalse ); |
|
398 ptiengine->SelectPhoneticSpelling( popup->CurrentSelection() + 1 ); |
|
399 // next two lines are for tonemark validity |
|
400 ptiengine->EnableToneMarks( selectionToneMarkValid ); |
|
401 ptiengine->SelectPhoneticSpelling( selectionIndexAdjustedForToneMarkValidity |
|
402 + 1 ); // our index is zero based, engine index is one based |
|
403 |
|
404 // update the candidate pane. |
|
405 if ( popup->IsFlagSet( MAknFepUICtrlPinyinPopup::ESpellingChanged ) |
|
406 || popup->IsFlagSet( MAknFepUICtrlPinyinPopup::ESpellingNavigation ) ) |
|
407 { |
|
408 CDesCArrayFlat* phraseCandidates = uiContainer->CandidatePane()->CandidateArray(); |
|
409 if ( editPane->GetEffictiveLength() == keystroke->Count() |
|
410 && pinyinCountWithoutToneMarks > popup->CurrentSelection() ) |
|
411 { |
|
412 TRAPD(ignore, ptiengine->GetChinesePhraseCandidatesL(*phraseCandidates)); |
|
413 if ( ignore != KErrNone ) |
|
414 { |
|
415 return; |
|
416 } |
|
417 } |
|
418 else if ( keystroke->Count() != 0 ) |
|
419 { |
|
420 phraseCandidates->Reset(); |
|
421 phraseCandidates->Compress(); |
|
422 TRAPD( retAddZhuyinNote, phraseCandidates->AppendL( KZhuyinNote ) ); |
|
423 if ( KErrNone != retAddZhuyinNote ) |
|
424 { |
|
425 return; |
|
426 } |
|
427 } |
|
428 |
|
429 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
430 popup->ClearFlag( MAknFepUICtrlPinyinPopup::ESpellingChanged |
|
431 | MAknFepUICtrlPinyinPopup::ESpellingNavigation ); |
|
432 } |
|
433 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
434 uiContainer->Enable( ETrue ); |
|
435 // need to enable the pinyin popup after the container so that it is raised to the front |
|
436 popup->Enable( pinyinCountWithoutToneMarks > 0 ); |
|
437 UpdateIndicator(); |
|
438 } |
|
439 |
|
440 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::InitializeStateL( void ) |
|
441 { |
|
442 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL ); |
|
443 } |
|
444 |
|
445 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::UpdateIndicator() |
|
446 { |
|
447 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
448 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
449 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
450 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
451 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
452 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
453 TInt pinyinCountWithoutToneMarks = ptiengine->PhoneticSpellingCount(); |
|
454 |
|
455 if (candidatePane->IsFirstPage()) |
|
456 { |
|
457 uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse); |
|
458 } |
|
459 else |
|
460 { |
|
461 uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue); |
|
462 } |
|
463 |
|
464 if (candidatePane->IsLastPage()) |
|
465 { |
|
466 uiContainer->CandidatePane()->ShowDownScrollArrows(EFalse); |
|
467 } |
|
468 else |
|
469 { |
|
470 uiContainer->CandidatePane()->ShowDownScrollArrows(ETrue); |
|
471 } |
|
472 |
|
473 if ( editPane->GetEffictiveLength() < keystroke->Count() || |
|
474 pinyinCountWithoutToneMarks == popup->CurrentSelection() ) |
|
475 { |
|
476 uiContainer->ShowVerticalScrollArrows(EFalse); |
|
477 } |
|
478 else |
|
479 { |
|
480 uiContainer->ShowVerticalScrollArrows(ETrue); |
|
481 } |
|
482 } |
|
483 |
|
484 TBool TAknFepInputStateEntryMiniQwertyZhuyinPhrase::CheckToneMarkBorderUpon() |
|
485 { |
|
486 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
487 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
488 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
489 TPtrC ptr = keystroke->MdcaPoint( keystroke->Count() - 1 ); |
|
490 TInt num = sizeof(ZhuyinToneMap )/( sizeof(ZhuyinToneMap[0])); |
|
491 for (TInt i = 0; i< num; i++ ) |
|
492 { |
|
493 //if ( ptr.Compare( ZhuyinToneMap[i].iValue) == 0 ) |
|
494 if ( ptr[0] == ZhuyinToneMap[i].iValue ) |
|
495 { |
|
496 return ETrue; |
|
497 } |
|
498 } |
|
499 |
|
500 return EFalse; |
|
501 } |
|
502 |
|
503 TBool TAknFepInputStateEntryMiniQwertyZhuyinPhrase::HandleKeyForMiniQwertyL( TInt aKey, |
|
504 TKeyPressLength aLength ) |
|
505 { |
|
506 |
|
507 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
508 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
509 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
510 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
511 MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
512 CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
513 RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
514 TInt keystrokeLength = keystroke->Count(); |
|
515 |
|
516 TBool ret = ETrue; |
|
517 |
|
518 if ( (aKey == EPtiKeyQwertyE || aKey == EPtiKeyQwertyR || |
|
519 aKey == EPtiKeyQwertyY || aKey == EPtiKeyQwertyU || aKey == EStdKeySpace) |
|
520 && (aLength == EShortKeyPress) ) |
|
521 { |
|
522 if ( keystrokeLength == 0 ) |
|
523 { |
|
524 iOwner->FepMan()->TryCloseUiL(); |
|
525 CommitToneMarkL( aKey ); |
|
526 return ETrue; |
|
527 } |
|
528 |
|
529 if ( keystrokeLength < KMaxKeystrokeCount && |
|
530 !CheckToneMarkBorderUpon() ) |
|
531 { |
|
532 if ( editPane->GetEffictiveLength() == keystrokeLength ) |
|
533 { |
|
534 TBool isToneValid = ptiengine->SetToneMark(aKey); |
|
535 TInt stringAfterLength = |
|
536 ptiengine->GetPhoneticSpelling(1).Length(); |
|
537 TPtrC ptr = ptiengine->GetPhoneticSpelling(1); |
|
538 TInt spellSepLen = 0; |
|
539 TInt keySepLen = 0; |
|
540 for (TInt i = 0; i < stringAfterLength; i++) |
|
541 { |
|
542 if (ptr.Mid(i, 1).Compare(KSep) == 0) |
|
543 { |
|
544 spellSepLen++; |
|
545 } |
|
546 } |
|
547 for ( TInt j = 0; j < keystrokeLength; j++ ) |
|
548 { |
|
549 if ( keystroke->MdcaPoint( j ).Compare(KSep) == 0 ) |
|
550 { |
|
551 keySepLen++; |
|
552 } |
|
553 } |
|
554 |
|
555 // +1 is for we had add tone mark to engine, perhaps it is legal, but |
|
556 // We had not add it to keystroke array |
|
557 if ((stringAfterLength - spellSepLen) == (keystrokeLength |
|
558 - keySepLen + 1) && isToneValid) |
|
559 { |
|
560 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
561 |
|
562 UIContainer()->ShowHorizontalScrollArrows(EFalse); |
|
563 UIContainer()->ShowVerticalScrollArrows(ETrue); |
|
564 SetInputPaneToneMark(); |
|
565 editPane->AddEffictiveLength(); |
|
566 } |
|
567 } |
|
568 |
|
569 TBuf<KKeystrokeMaxLength> buf; |
|
570 TAknFepInputStateMiniQwertyZhuyinKeyMap::GetKeyStroke( |
|
571 ptiengine, aKey, buf ); |
|
572 keystroke->AppendL( buf ); |
|
573 keycodeArray->AppendL( aKey ); |
|
574 ImplicitlyUpdateSelection(); |
|
575 } |
|
576 else |
|
577 { |
|
578 UpdateIndicator(); |
|
579 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
580 } |
|
581 |
|
582 } |
|
583 else if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyLock |
|
584 == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyDown |
|
585 == iOwner->FepMan()->FnKeyState() ) |
|
586 { |
|
587 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
588 } |
|
589 else if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed ) |
|
590 || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) |
|
591 || ((aKey == EStdKeyLeftFunc) && aLength == EShortKeyPress) ) |
|
592 { |
|
593 iOwner->FepMan()->TryCloseUiL(); |
|
594 ret = EFalse; |
|
595 } |
|
596 else if ( aKey == EKeyLeftShift || aKey ==EKeyLeftCtrl || aKey |
|
597 == EKeyRightCtrl || aKey ==EKeyRightFunc ) |
|
598 { |
|
599 iOwner->FepMan()->TryCloseUiL(); |
|
600 ret = EFalse; |
|
601 } |
|
602 else if ( aKey == EStdKeyBackspace ) |
|
603 { |
|
604 TBool state = ETrue; |
|
605 if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
606 { |
|
607 state = EFalse; |
|
608 } |
|
609 else |
|
610 { |
|
611 editPane->SetChangeState( EFalse ); |
|
612 } |
|
613 if ( state ) |
|
614 { |
|
615 if ( editPane->GetEffictiveLength() == keystrokeLength ) |
|
616 { |
|
617 if ( iOwner->PtiEngine()->DeleteKeyPress().Length() && keystrokeLength != 1 ) |
|
618 { |
|
619 editPane->DecEffictiveLength(); |
|
620 keystroke->Delete( keystrokeLength - 1 ); |
|
621 keycodeArray->Remove( keystrokeLength - 1 ); |
|
622 inputPane->SetFlag( MAknFepUICtrlInputPane::EPhoneticChanged ); |
|
623 ImplicitlyUpdateSelection(); |
|
624 } |
|
625 else |
|
626 { |
|
627 ClearDeliberateSelection(); |
|
628 iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI. |
|
629 if ( aLength == ELongKeyPress ) |
|
630 { |
|
631 iOwner->FepMan()->SetLongClearAfterCloseUI( ETrue ); |
|
632 } |
|
633 } |
|
634 } |
|
635 else |
|
636 { |
|
637 keystroke->Delete( keystrokeLength - 1 ); |
|
638 keycodeArray->Remove( keystrokeLength - 1 ); |
|
639 ImplicitlyUpdateSelection(); |
|
640 } |
|
641 } |
|
642 } |
|
643 else if ( aKey ==EStdKeyDevice1 )//sk2 |
|
644 { |
|
645 iOwner->FepMan()->TryCloseUiL(); |
|
646 } |
|
647 else if ( aKey == EStdKeyRightArrow ) |
|
648 { |
|
649 if ( popup->IsEnabled() ) |
|
650 { |
|
651 if ( popup->SelectNextPhrase() ) |
|
652 { |
|
653 DeliberatelyUpdateSelection(); |
|
654 UpdateIndicator(); |
|
655 } |
|
656 } |
|
657 } |
|
658 else if ( aKey == EStdKeyLeftArrow ) |
|
659 { |
|
660 if ( popup->IsEnabled() ) |
|
661 { |
|
662 if ( popup->SelectPrevPhrase() ) |
|
663 { |
|
664 DeliberatelyUpdateSelection(); |
|
665 UpdateIndicator(); |
|
666 } |
|
667 } |
|
668 } |
|
669 else if ( aKey == EStdKeyDownArrow || aKey == EStdKeyDevice3 || aKey |
|
670 == EStdKeyDevice0 )//selection key |
|
671 { |
|
672 editPane->SetChangeState( ETrue ); |
|
673 if ( editPane->GetEffictiveLength() == keystroke->Count() |
|
674 && ptiengine->PhoneticSpellingCount() |
|
675 > popup->CurrentSelection() ) |
|
676 { |
|
677 if ( popup->IsEnabled() ) |
|
678 { |
|
679 popup->Enable( EFalse ); |
|
680 } |
|
681 iOwner->ChangeState( ECandidate ); |
|
682 } |
|
683 else |
|
684 { |
|
685 if ( keystrokeLength > 0 && keystroke->MdcaPoint( 0 )[0] == KSai ) |
|
686 { |
|
687 UIContainer()->SetControlInVisible( EFalse ); |
|
688 iOwner->ChangeState( EMiniQwertyEdit ); |
|
689 } |
|
690 else |
|
691 { |
|
692 ClearDeliberateSelection(); |
|
693 editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
694 iOwner->ChangeState( EZhuyinSpelling ); |
|
695 } |
|
696 } |
|
697 } |
|
698 else if ( aKey == EStdKeyEnter )//enter the characters in the entry pane into the editor |
|
699 { |
|
700 TInt currentIndex = uiContainer->PinyinPopupWindow()->CurrentSelection(); |
|
701 TBuf<KInputPaneLength> currentText; |
|
702 if ( currentIndex < ptiengine->PhoneticSpellingCount() ) |
|
703 { |
|
704 currentText.Copy(ptiengine->GetPhoneticSpelling( currentIndex + 1 )); |
|
705 } |
|
706 else |
|
707 { |
|
708 inputPane->GetText( currentText ); |
|
709 } |
|
710 |
|
711 |
|
712 while (currentText.Find( KSep )> 0 ) |
|
713 { |
|
714 currentText.Replace( currentText.Find( KSep ), 1, KReplace ); |
|
715 } |
|
716 while (currentText.Find( KLeftBracket ) >= 0 ) |
|
717 { |
|
718 currentText.Replace( currentText.Find( KLeftBracket ), 1, |
|
719 KReplace ); |
|
720 } |
|
721 while (currentText.Find( KRightBracket ) >= 0 ) |
|
722 { |
|
723 currentText.Replace( currentText.Find( KRightBracket ), 1, |
|
724 KReplace ); |
|
725 } |
|
726 |
|
727 if ( currentText.Length() ) |
|
728 { |
|
729 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
730 fepMan->NewTextL( currentText ); |
|
731 fepMan->CommitInlineEditL(); |
|
732 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
|
733 { |
|
734 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
735 } |
|
736 } |
|
737 |
|
738 iOwner->FepMan()->TryCloseUiL(); |
|
739 |
|
740 } |
|
741 else if ( aLength == EShortKeyPress ) // don't want repeats on these keys |
|
742 { |
|
743 iOwner->FepMan()->SetCcpuFlag( CAknFepManager::ECcpuStateIgnoreStarUp ); |
|
744 |
|
745 if ( keystroke->Count() < KMaxKeystrokeCount |
|
746 && (iOwner->IsValidChineseInputKeyQwerty( aKey ) || aKey |
|
747 ==EStdKeySpace ) ) //seperator |
|
748 { |
|
749 TInt stringBeforeLength(0); |
|
750 TInt stringAfterLength(0); |
|
751 |
|
752 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
753 stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length(); |
|
754 |
|
755 if ( stringBeforeLength != stringAfterLength ) |
|
756 { |
|
757 if ( ptiengine->GetPhoneticSpelling(1).Length() == 1 ) |
|
758 { |
|
759 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL ); |
|
760 } |
|
761 editPane->AddEffictiveLength(); |
|
762 } |
|
763 |
|
764 TBuf<KKeystrokeMaxLength> buf; |
|
765 TAknFepInputStateMiniQwertyZhuyinKeyMap::GetKeyStroke( |
|
766 ptiengine, aKey, buf ); |
|
767 keystroke->AppendL( buf ); |
|
768 keycodeArray->AppendL( aKey ); |
|
769 |
|
770 ImplicitlyUpdateSelection(); |
|
771 } |
|
772 else |
|
773 { |
|
774 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
775 } |
|
776 } |
|
777 return ret; |
|
778 } |
|
779 |
|
780 TBool TAknFepInputStateEntryMiniQwertyZhuyinPhrase::HandleKeyForHalfAndCustomQwertyL( TInt aKey, |
|
781 TKeyPressLength aLength ) |
|
782 { |
|
783 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
784 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
785 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
786 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
787 |
|
788 TBool ret = ETrue; |
|
789 |
|
790 if((aKey == EPtiKeyQwertyE || |
|
791 aKey == EPtiKeyQwertyR || |
|
792 aKey == EPtiKeyQwertyY || |
|
793 aKey == EPtiKeyQwertyU || |
|
794 aKey == EStdKeySpace) && |
|
795 (aLength == EShortKeyPress)) |
|
796 { |
|
797 if(ptiengine->SetToneMark(aKey)) |
|
798 { |
|
799 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
800 |
|
801 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
802 uiContainer->CandidatePane()->IsFirstPage()); |
|
803 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
804 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
805 |
|
806 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
807 UIContainer()->ShowVerticalScrollArrows(multiplePages); |
|
808 SetInputPaneToneMark(); |
|
809 ImplicitlyUpdateSelection(); |
|
810 } |
|
811 } |
|
812 if(( aKey == EStdKeyLeftFunc) && aLength == EShortKeyPress) //chr key to tone mark |
|
813 { |
|
814 if(ptiengine->IncrementToneMark(ETrue)) |
|
815 { |
|
816 ImplicitlyUpdateSelection(); |
|
817 } |
|
818 } |
|
819 else if( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || |
|
820 CAknFepFnKeyManager::EFnKeyLock == iOwner->FepMan()->FnKeyState() || |
|
821 CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState()) |
|
822 { |
|
823 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
824 } |
|
825 else if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed)|| |
|
826 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
827 { |
|
828 iOwner->FepMan()->TryCloseUiL(); |
|
829 ret = EFalse; |
|
830 } |
|
831 else if (aKey == EKeyLeftShift || aKey ==EKeyLeftCtrl || aKey == EKeyRightCtrl) |
|
832 { |
|
833 iOwner->FepMan()->TryCloseUiL(); |
|
834 ret = EFalse; |
|
835 } |
|
836 else if (aKey ==EKeyRightFunc)//fn |
|
837 { |
|
838 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
839 } |
|
840 else if(aKey == EStdKeyBackspace ) |
|
841 { |
|
842 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
843 { |
|
844 ImplicitlyUpdateSelection(); |
|
845 } |
|
846 else |
|
847 { |
|
848 ClearDeliberateSelection(); |
|
849 iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI. |
|
850 if (aLength == ELongKeyPress) |
|
851 { |
|
852 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue); |
|
853 } |
|
854 } |
|
855 } |
|
856 else if(aKey ==EStdKeyDevice1)//sk2 |
|
857 { |
|
858 iOwner->FepMan()->TryCloseUiL(); |
|
859 } |
|
860 else if(aKey == EStdKeyRightArrow) |
|
861 { |
|
862 if(popup->IsEnabled()) |
|
863 { |
|
864 if(popup->SelectNextPhrase()) |
|
865 { |
|
866 DeliberatelyUpdateSelection(); |
|
867 } |
|
868 } |
|
869 } |
|
870 else if(aKey == EStdKeyLeftArrow) |
|
871 { |
|
872 if(popup->IsEnabled()) |
|
873 { |
|
874 if(popup->SelectPrevPhrase()) |
|
875 { |
|
876 DeliberatelyUpdateSelection(); |
|
877 } |
|
878 } |
|
879 } |
|
880 else if (aKey == EStdKeyDownArrow || aKey == EStdKeyDevice3 || aKey == EStdKeyDevice0)//selection key |
|
881 { |
|
882 if(popup->IsEnabled()) |
|
883 { |
|
884 popup->Enable(EFalse); |
|
885 } |
|
886 iOwner->ChangeState(ECandidate); |
|
887 } |
|
888 else if (aKey == EStdKeyEnter)//enter the characters in the entry pane into the editor |
|
889 { |
|
890 TBuf<KInputPaneLength> currentText; |
|
891 inputPane->GetText(currentText); |
|
892 |
|
893 while(currentText.Find(KSep)> 0) |
|
894 { |
|
895 currentText.Replace(currentText.Find(KSep), 1,KReplace); |
|
896 } |
|
897 |
|
898 |
|
899 if(currentText.Length()) |
|
900 { |
|
901 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
902 fepMan->NewTextL(currentText); |
|
903 fepMan->CommitInlineEditL(); |
|
904 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
905 { |
|
906 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
907 } |
|
908 } |
|
909 |
|
910 iOwner->FepMan()->TryCloseUiL(); |
|
911 |
|
912 } |
|
913 else if(aLength == EShortKeyPress) // don't want repeats on these keys |
|
914 { |
|
915 iOwner->FepMan()->SetCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp); |
|
916 |
|
917 if(iOwner->IsValidChineseInputKeyQwerty(aKey) || aKey ==EStdKeySpace ) //seperator |
|
918 { |
|
919 TInt stringBeforeLength(0); |
|
920 TInt stringAfterLength(0); |
|
921 |
|
922 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
923 stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length(); |
|
924 |
|
925 if (stringBeforeLength != stringAfterLength) |
|
926 { |
|
927 if (ptiengine->GetPhoneticSpelling(1).Length() == 1) |
|
928 { |
|
929 //iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY); iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL); |
|
930 iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL); |
|
931 } |
|
932 |
|
933 ImplicitlyUpdateSelection(); |
|
934 } |
|
935 |
|
936 else |
|
937 { |
|
938 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
939 } |
|
940 |
|
941 } |
|
942 else |
|
943 { |
|
944 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
945 } |
|
946 } |
|
947 return ret; |
|
948 } |
|
949 |
|
950 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::CommitToneMarkL( TInt aKey ) |
|
951 { |
|
952 TBuf<1> ToneMarkBuf; |
|
953 switch ( aKey ) |
|
954 { |
|
955 case EPtiKeyQwertyE: |
|
956 ToneMarkBuf.Append( KToneMark3 ); |
|
957 break; |
|
958 |
|
959 case EPtiKeyQwertyR: |
|
960 ToneMarkBuf.Append( KToneMark4 ); |
|
961 break; |
|
962 |
|
963 case EPtiKeyQwertyY: |
|
964 ToneMarkBuf.Append( KToneMark2 ); |
|
965 break; |
|
966 |
|
967 case EPtiKeyQwertyU: |
|
968 ToneMarkBuf.Append( KToneMark5 ); |
|
969 break; |
|
970 default: |
|
971 break; |
|
972 } |
|
973 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
974 fepMan->NewCharacterL(ToneMarkBuf); |
|
975 fepMan->CommitInlineEditL(); |
|
976 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
977 { |
|
978 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
979 iOwner->FepMan()->TryCloseUiL(); |
|
980 } |
|
981 } |
|
982 |
|
983 // --------------------------------------------------------------------------- |
|
984 // TAknFepInputStateEntryMiniQwertyZhuyinPhrase::HandleCommandL |
|
985 // Handling Command |
|
986 // --------------------------------------------------------------------------- |
|
987 // |
|
988 void TAknFepInputStateEntryMiniQwertyZhuyinPhrase::HandleCommandL( |
|
989 TInt aCommandId ) |
|
990 { |
|
991 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
992 MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
993 switch ( aCommandId ) |
|
994 { |
|
995 // Handle the event frome command. |
|
996 case EAknSoftkeySelect: |
|
997 // case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
998 if ( popup->IsEnabled() ) |
|
999 { |
|
1000 popup->Enable( EFalse ); |
|
1001 } |
|
1002 iOwner->ChangeState( ECandidate ); |
|
1003 break; |
|
1004 default: |
|
1005 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
1006 break; |
|
1007 } |
|
1008 } |
|
1009 // End of file |
|
1010 |