44
|
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 TAknFepInputStateEntryPinyinPhraseCreation methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include <PtiEngine.h> //CPtiEngine
|
|
31 |
#include <PtiUserDicEntry.h>
|
|
32 |
|
|
33 |
#include <PtiDefs.h> //keys
|
|
34 |
#include <avkon.rsg>
|
|
35 |
#include <aknfep.rsg>
|
|
36 |
#include <aknnotewrappers.h>
|
|
37 |
|
|
38 |
#include "AknFepPanic.h"
|
|
39 |
#include "aknfepuiinputstateentrypinyinphrasecreation.h"
|
|
40 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
41 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface
|
|
42 |
#include "AknFepUiCtrlContainerChinese.h"
|
|
43 |
#include "AknFepUICtrlInputPane.h"
|
|
44 |
#include "AknFepUICtrlCandidatePane.h"
|
|
45 |
#include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase
|
|
46 |
#include "aknfepuictrleditpane.h" //pinyin phrase creation
|
|
47 |
#include "AknFepManager.h"
|
|
48 |
|
|
49 |
const TInt KMaxPhraseCreationCount = 7;
|
|
50 |
const TInt KMaxPinYinSpellLength = 7;
|
|
51 |
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
// C++ construct.
|
|
54 |
// ---------------------------------------------------------
|
|
55 |
//
|
|
56 |
TAknFepInputStateEntryPinyinPhraseCreation::TAknFepInputStateEntryPinyinPhraseCreation(
|
|
57 |
MAknFepUIManagerStateInterface* aOwner,
|
|
58 |
MAknFepUICtrlContainerChinese* aUIContainer ) :
|
|
59 |
TAknFepInputStatePinyinPhraseCreationBase( aOwner, aUIContainer)
|
|
60 |
{
|
|
61 |
iState = EKeySequenceEdit;
|
|
62 |
|
|
63 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
64 |
uiContainer->FocusCandidatePane( EFalse );
|
|
65 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse );
|
|
66 |
uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutPhraseCreation );
|
|
67 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
68 |
uiContainer->ShowVerticalScrollArrows( ETrue );
|
|
69 |
uiContainer->ShowHorizontalScrollArrows( EFalse );
|
|
70 |
uiContainer->InputPane()->SetOverrideFontId( 0 );
|
|
71 |
uiContainer->PinyinPopupWindow()->SetPhraseCreationEditingState( EFalse );
|
|
72 |
// in the case that we are coming back to the input pane from the candidate pane,
|
|
73 |
// we need to ensure that the current selection is selected correctly
|
|
74 |
if ( uiContainer->PinyinPopupWindow()->GetFromEditToSpellingFlag() )
|
|
75 |
{
|
|
76 |
uiContainer->PinyinPopupWindow()->SetFromEditToSpellingFlag();
|
|
77 |
TInt validCount = uiContainer->
|
|
78 |
PinyinPopupWindow()->InEffectKeystrokeArray()->Count();
|
|
79 |
uiContainer->EditPaneWindow()->SetCursorIndexOfKeystroke( validCount );
|
|
80 |
ShowInfo();
|
|
81 |
uiContainer->PinyinPopupWindow()->SetNoneHighlighted();
|
|
82 |
uiContainer->EditPaneWindow()->ActiveCursor();
|
|
83 |
uiContainer->EditPaneWindow()->EnableCursor();
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
ImplicityShowInfo( ETrue );
|
|
88 |
}
|
|
89 |
// however we also need to clear the deliberate selection, in case we are not
|
|
90 |
// coming back to the input pane from the candidate pane
|
|
91 |
ChangeCba();
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------
|
|
95 |
// HandleKeyL
|
|
96 |
// ---------------------------------------------------------
|
|
97 |
//
|
|
98 |
TBool TAknFepInputStateEntryPinyinPhraseCreation::HandleKeyL( TInt aKey,
|
|
99 |
TKeyPressLength aLength )
|
|
100 |
{
|
|
101 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
102 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
103 |
CDesCArrayFlat* inEffectKeystrokeArray = popup->InEffectKeystrokeArray();
|
|
104 |
CDesCArrayFlat* showKeystrokeArray = popup->ShowKeystrokeArray();
|
|
105 |
|
|
106 |
switch( aKey )
|
|
107 |
{
|
|
108 |
case EKeyBackspace:
|
|
109 |
{
|
|
110 |
TBool state = ETrue;
|
|
111 |
if ( popup->IsChangeStatet() && aLength == ELongKeyPress )
|
|
112 |
{
|
|
113 |
state = EFalse;
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
popup->SetChangeState( EFalse );
|
|
118 |
}
|
|
119 |
if ( state )
|
|
120 |
{
|
|
121 |
HandleKeyBackspace( aLength );
|
|
122 |
}
|
|
123 |
break;
|
|
124 |
}
|
|
125 |
case EKeyRightArrow:
|
|
126 |
if ( !IsMoveCursor() )
|
|
127 |
{
|
|
128 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
MoveCursorToRight();
|
|
133 |
}
|
|
134 |
break;
|
|
135 |
case EKeyLeftArrow:
|
|
136 |
if ( !IsMoveCursor() )
|
|
137 |
{
|
|
138 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
139 |
}
|
|
140 |
else
|
|
141 |
{
|
|
142 |
MoveCursorToLeft();
|
|
143 |
}
|
|
144 |
break;
|
|
145 |
case EKeyOK:
|
|
146 |
case EKeyCBA1:
|
|
147 |
if ( !( popup->IsChangeStatet() && aLength == ELongKeyPress ) )
|
|
148 |
{
|
|
149 |
popup->SetChangeState( EFalse );
|
|
150 |
HandleKeyOKAndKeyCBA1L();
|
|
151 |
}
|
|
152 |
break;
|
|
153 |
case EKeyCBA2:
|
|
154 |
iOwner->FepMan()->TryCloseUiL();
|
|
155 |
break;
|
|
156 |
case EKeyDownArrow:
|
|
157 |
if ( ( 0 == showKeystrokeArray->Count() ) ||
|
|
158 |
( 0 == inEffectKeystrokeArray->Count() ) )
|
|
159 |
{
|
|
160 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
popup->SetChangeState( ETrue );
|
|
165 |
popup->SetFromEditToSpellingFlag( ETrue );
|
|
166 |
iOwner->ChangeState( ESpellingSelection );
|
|
167 |
}
|
|
168 |
break;
|
|
169 |
case EKeyUpArrow:
|
|
170 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
171 |
break;
|
|
172 |
default:
|
|
173 |
if ( EShortKeyPress == aLength )
|
|
174 |
{
|
|
175 |
HandleOthersKey( aKey );
|
|
176 |
}
|
|
177 |
else
|
|
178 |
{
|
|
179 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
}
|
|
183 |
|
|
184 |
return ETrue;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
// Init the show info
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
//
|
|
191 |
void TAknFepInputStateEntryPinyinPhraseCreation::ImplicityShowInfo(
|
|
192 |
TBool aGetScreenCoordinates )
|
|
193 |
{
|
|
194 |
TRAP_IGNORE( ImplicityShowInfoL( aGetScreenCoordinates ) );
|
|
195 |
}
|
|
196 |
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
// Init the show info
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
//
|
|
201 |
void TAknFepInputStateEntryPinyinPhraseCreation::ImplicityShowInfoL(
|
|
202 |
TBool aGetScreenCoordinates )
|
|
203 |
{
|
|
204 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
205 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
206 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
207 |
TInt showKeystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
208 |
TInt chineseCount = popup->ChooseChineseCharacterArray()->Count();
|
|
209 |
// get cursor position
|
|
210 |
TPoint baseLine = TPoint( 0, 0 );
|
|
211 |
TInt height = 0;
|
|
212 |
TInt ascent = 0;
|
|
213 |
TBool validChange = EFalse;
|
|
214 |
TBool isSpellingValid = EFalse;
|
|
215 |
if ( aGetScreenCoordinates )
|
|
216 |
{
|
|
217 |
iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent);
|
|
218 |
uiContainer->SetContainerPosition( baseLine, height );
|
|
219 |
}
|
|
220 |
if ( popup->GetPhraseCreationEditingState() )
|
|
221 |
{
|
|
222 |
isSpellingValid = GetValidKeystroke();
|
|
223 |
}
|
|
224 |
else if ( popup->GetPhraseCreationState() )
|
|
225 |
{
|
|
226 |
isSpellingValid = GetValidKeystroke();
|
|
227 |
if ( 0 == chineseCount )
|
|
228 |
{
|
|
229 |
editPane->SetCursorIndexOfKeystroke( showKeystrokeCount );
|
|
230 |
}
|
|
231 |
else
|
|
232 |
{
|
|
233 |
editPane->SetCursorIndexOfKeystroke( 0 );
|
|
234 |
}
|
|
235 |
|
|
236 |
}
|
|
237 |
|
|
238 |
if ( !isSpellingValid )
|
|
239 |
{
|
|
240 |
UIContainer()->SetControlInVisible( EFalse );
|
|
241 |
}
|
|
242 |
|
|
243 |
validChange = popup->GetValidKeystrokeChange();
|
|
244 |
|
|
245 |
ShowInfo();
|
|
246 |
SetWarningColor();
|
|
247 |
editPane->ActiveCursor();
|
|
248 |
if ( ( popup->GetPhraseCreationState() ) ||
|
|
249 |
( popup->GetPhraseCreationEditingState() ) )
|
|
250 |
{
|
|
251 |
if ( validChange ||
|
|
252 |
( 0 != popup->CurrentPageStartIndex() ) )
|
|
253 |
{
|
|
254 |
popup->SetPhraseCreationEditingState( EFalse );
|
|
255 |
popup->SetPhraseCreationState( EFalse );
|
|
256 |
RefreshUI();
|
|
257 |
}
|
|
258 |
else
|
|
259 |
{
|
|
260 |
if ( 0 != popup->CurrentSelection() )
|
|
261 |
{
|
|
262 |
RefreshCandidate();
|
|
263 |
}
|
|
264 |
}
|
|
265 |
}
|
|
266 |
else
|
|
267 |
{
|
|
268 |
if ( validChange )
|
|
269 |
{
|
|
270 |
RefreshUI( popup->CurrentSelection() );
|
|
271 |
}
|
|
272 |
}
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------
|
|
276 |
// EKeyBackspace
|
|
277 |
// ---------------------------------------------------------
|
|
278 |
//
|
|
279 |
void TAknFepInputStateEntryPinyinPhraseCreation::HandleKeyBackspace( TKeyPressLength aLength )
|
|
280 |
{
|
|
281 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
282 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
283 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
284 |
|
|
285 |
TInt validKeystrokeCount = popup->InEffectKeystrokeArray()->Count();
|
|
286 |
TInt chineseCount = popup->ChooseChineseCharacterArray()->Count();
|
|
287 |
TInt cursorOfkeystrokeIndex = editPane->GetCursorIndexOfKeystroke();
|
|
288 |
|
|
289 |
if ( 0 == cursorOfkeystrokeIndex )
|
|
290 |
{
|
|
291 |
if ( !TryCloseUI( aLength ) )
|
|
292 |
{
|
|
293 |
if ( ( 0 == chineseCount ) && ( 0 != validKeystrokeCount ) )
|
|
294 |
{
|
|
295 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
if ( ChineseRevertKeystroke() )
|
|
300 |
{
|
|
301 |
ClearDeliberateSelection();
|
|
302 |
popup->SetPhraseCreationEditingState( ETrue );
|
|
303 |
ImplicityShowInfo();
|
|
304 |
ChangeCba();
|
|
305 |
}
|
|
306 |
else
|
|
307 |
{
|
|
308 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
309 |
}
|
|
310 |
}
|
|
311 |
}
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
if ( 1 == cursorOfkeystrokeIndex )
|
|
316 |
{
|
|
317 |
editPane->Reset();
|
|
318 |
editPane->SetCursorIndexOfKeystroke( 1 );
|
|
319 |
}
|
|
320 |
//delete the current keystroke
|
|
321 |
if ( DeleteCurrentKeystroke() )
|
|
322 |
{
|
|
323 |
if ( !TryCloseUI( aLength ) )
|
|
324 |
{
|
|
325 |
ClearDeliberateSelection();
|
|
326 |
popup->SetPhraseCreationEditingState( ETrue );
|
|
327 |
ImplicityShowInfo();
|
|
328 |
ChangeCba();
|
|
329 |
}
|
|
330 |
}
|
|
331 |
else
|
|
332 |
{
|
|
333 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------
|
|
339 |
// EKeyOK And EKeyCBA1L.
|
|
340 |
// ---------------------------------------------------------
|
|
341 |
//
|
|
342 |
void TAknFepInputStateEntryPinyinPhraseCreation::HandleKeyOKAndKeyCBA1L()
|
|
343 |
{
|
|
344 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
345 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
346 |
|
|
347 |
TInt validKeystrokeCount = popup->InEffectKeystrokeArray()->Count();
|
|
348 |
TInt keystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
349 |
CDesCArrayFlat* chinese = popup->ChooseChineseCharacterArray();
|
|
350 |
TBuf<KMaxPhraseCreationCount> phraseCreated;
|
|
351 |
|
|
352 |
CDesCArrayFlat* spellingArray = popup->PhoneticSpellingArray();
|
|
353 |
TBuf<100> spellingBuf;
|
|
354 |
for(TInt i=0;i<spellingArray->Count();i++)
|
|
355 |
{
|
|
356 |
spellingBuf.Append(spellingArray->MdcaPoint( i ));
|
|
357 |
}
|
|
358 |
|
|
359 |
if ( ( chinese->Count() >= 2 ) && ( 0 == keystrokeCount ) )
|
|
360 |
{
|
|
361 |
//commit the chinese character.
|
|
362 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
363 |
for (TInt i = 0; i < chinese->Count(); ++i )
|
|
364 |
{
|
|
365 |
phraseCreated.Append( chinese->MdcaPoint( i ) );
|
|
366 |
}
|
|
367 |
|
|
368 |
fepMan->PinyinPhraseCreation( EFalse );
|
|
369 |
fepMan->NewTextL( phraseCreated );
|
|
370 |
|
|
371 |
//here,pass spelling to db
|
|
372 |
CDesCArrayFlat* chooseChineseCharacterArraySpelling = popup->ChooseChineseCharacterArraySpelling();
|
|
373 |
TBuf<(1+KMaxPinYinSpellLength)*KMaxPhraseCreationCount> phraseCreatedWithPinYin;//(Zi+pinyin)* max_Zi
|
|
374 |
phraseCreatedWithPinYin.FillZ();
|
|
375 |
for (TInt i = 0; i < chinese->Count(); i++)
|
|
376 |
{
|
|
377 |
TPtrC ptrZi = chinese->MdcaPoint(i);
|
|
378 |
phraseCreatedWithPinYin.Append(ptrZi);
|
|
379 |
|
|
380 |
TPtrC ptrPinYin = chooseChineseCharacterArraySpelling->MdcaPoint(i);
|
|
381 |
phraseCreatedWithPinYin.Append(ptrPinYin);
|
|
382 |
|
|
383 |
TInt zeroTail = (1+KMaxPinYinSpellLength)-(ptrZi.Length()+ptrPinYin.Length());
|
|
384 |
phraseCreatedWithPinYin.AppendFill(0,zeroTail);
|
|
385 |
|
|
386 |
}
|
|
387 |
|
|
388 |
AddPhraseToDB( phraseCreatedWithPinYin );//pinyin
|
|
389 |
fepMan->CommitInlineEditL();
|
|
390 |
iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
|
|
391 |
}
|
|
392 |
else if ( 0 != validKeystrokeCount )
|
|
393 |
{
|
|
394 |
popup->SetChangeState( ETrue );
|
|
395 |
popup->SetFromEditToSpellingFlag( ETrue );
|
|
396 |
iOwner->ChangeState( ESpellingSelection );
|
|
397 |
}
|
|
398 |
else
|
|
399 |
{
|
|
400 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
401 |
}
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
// others key input.
|
|
406 |
// ---------------------------------------------------------
|
|
407 |
//
|
|
408 |
void TAknFepInputStateEntryPinyinPhraseCreation::HandleOthersKey( TInt aKey )
|
|
409 |
{
|
|
410 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
411 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
412 |
iOwner->FepMan()->SetCcpuFlag( CAknFepManager::ECcpuStateIgnoreStarUp );
|
|
413 |
if ( iOwner->IsValidChineseInputKey( aKey ) )
|
|
414 |
{
|
|
415 |
if ( AddKeystroke( aKey ) )
|
|
416 |
{
|
|
417 |
ClearDeliberateSelection();
|
|
418 |
popup->SetPhraseCreationEditingState( ETrue );
|
|
419 |
ImplicityShowInfo();
|
|
420 |
ChangeCba();
|
|
421 |
}
|
|
422 |
else
|
|
423 |
{
|
|
424 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
425 |
}
|
|
426 |
}
|
|
427 |
else if ( aKey == EPtiKeyStar ) // we increment the tone mark.
|
|
428 |
{
|
|
429 |
if ( AddToneMark() )
|
|
430 |
{
|
|
431 |
ClearDeliberateSelection();
|
|
432 |
popup->SetPhraseCreationEditingState( ETrue );
|
|
433 |
ImplicityShowInfo();
|
|
434 |
ChangeCba();
|
|
435 |
}
|
|
436 |
else
|
|
437 |
{
|
|
438 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
439 |
}
|
|
440 |
}
|
|
441 |
else
|
|
442 |
{
|
|
443 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
444 |
}
|
|
445 |
}
|
|
446 |
|
|
447 |
// ---------------------------------------------------------
|
|
448 |
// move cursor to left.
|
|
449 |
// ---------------------------------------------------------
|
|
450 |
//
|
|
451 |
TBool TAknFepInputStateEntryPinyinPhraseCreation::IsMoveCursor()
|
|
452 |
{
|
|
453 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
454 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
455 |
TInt keystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
456 |
TInt chineseCount = popup->ChooseChineseCharacterArray()->Count();
|
|
457 |
if ( ( 0 == keystrokeCount ) || ( KMaxPhraseCreationCount == chineseCount ) )
|
|
458 |
{
|
|
459 |
return EFalse;
|
|
460 |
}
|
|
461 |
return ETrue;
|
|
462 |
}
|
|
463 |
|
|
464 |
// ---------------------------------------------------------
|
|
465 |
// move cursor to left.
|
|
466 |
// ---------------------------------------------------------
|
|
467 |
//
|
|
468 |
void TAknFepInputStateEntryPinyinPhraseCreation::MoveCursorToLeft()
|
|
469 |
{
|
|
470 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
471 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
472 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
473 |
TInt keystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
474 |
TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke();
|
|
475 |
|
|
476 |
if ( 0 == indexOfKeystroke )
|
|
477 |
{
|
|
478 |
editPane->SetCursorIndexOfKeystroke( keystrokeCount );
|
|
479 |
// for fix bug when press left, spelling pane will flash
|
|
480 |
// ImplicityShowInfo();
|
|
481 |
ShowInfo();
|
|
482 |
SetWarningColor();
|
|
483 |
}
|
|
484 |
else if ( 1 == indexOfKeystroke )
|
|
485 |
{
|
|
486 |
editPane->SetCursorIndexOfKeystroke( 0 );
|
|
487 |
// for fix bug when press left, spelling pane will flash
|
|
488 |
// ImplicityShowInfo();
|
|
489 |
ShowInfo();
|
|
490 |
SetWarningColor();
|
|
491 |
}
|
|
492 |
else
|
|
493 |
{
|
|
494 |
editPane->SetCursorIndexOfKeystroke( indexOfKeystroke - 1 );
|
|
495 |
editPane->MoveCursorLeft();
|
|
496 |
}
|
|
497 |
}
|
|
498 |
|
|
499 |
|
|
500 |
// ---------------------------------------------------------
|
|
501 |
// move cursor to left.
|
|
502 |
// ---------------------------------------------------------
|
|
503 |
//
|
|
504 |
void TAknFepInputStateEntryPinyinPhraseCreation::MoveCursorToRight()
|
|
505 |
{
|
|
506 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
507 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
508 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
509 |
TInt keystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
510 |
TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke();
|
|
511 |
|
|
512 |
if ( indexOfKeystroke == keystrokeCount )
|
|
513 |
{
|
|
514 |
editPane->SetCursorIndexOfKeystroke( 0 );
|
|
515 |
// for fix bug when press right, spelling pane will flash
|
|
516 |
// ImplicityShowInfo();
|
|
517 |
ShowInfo();
|
|
518 |
SetWarningColor();
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
editPane->SetCursorIndexOfKeystroke( indexOfKeystroke + 1 );
|
|
523 |
editPane->MoveCursorRight();
|
|
524 |
}
|
|
525 |
}
|
|
526 |
|
|
527 |
// ---------------------------------------------------------
|
|
528 |
// Initialize State.
|
|
529 |
// ---------------------------------------------------------
|
|
530 |
//
|
|
531 |
void TAknFepInputStateEntryPinyinPhraseCreation::InitializeState()
|
|
532 |
{
|
|
533 |
ChangeCba();
|
|
534 |
}
|
|
535 |
|
|
536 |
// ---------------------------------------------------------
|
|
537 |
// Add phrase to DB.
|
|
538 |
// ---------------------------------------------------------
|
|
539 |
//
|
|
540 |
TBool TAknFepInputStateEntryPinyinPhraseCreation::AddPhraseToDB(
|
|
541 |
const TDesC& aPhraseAdd )
|
|
542 |
{
|
|
543 |
TInt retCode;
|
|
544 |
TPtiUserDictionaryEntry addUdbEntry(aPhraseAdd);
|
|
545 |
//Add the phrase to the DB by PTI Engine
|
|
546 |
retCode = iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry );
|
|
547 |
if ( KErrNone != retCode )
|
|
548 |
{
|
|
549 |
return EFalse;
|
|
550 |
}
|
|
551 |
|
|
552 |
return ETrue;
|
|
553 |
}
|
|
554 |
|
|
555 |
// ---------------------------------------------------------
|
|
556 |
// Try to close UI.
|
|
557 |
// ---------------------------------------------------------
|
|
558 |
//
|
|
559 |
TBool TAknFepInputStateEntryPinyinPhraseCreation::TryCloseUI( TKeyPressLength aLength )
|
|
560 |
{
|
|
561 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
562 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
563 |
TInt keystrokeCount = popup->ShowKeystrokeArray()->Count();
|
|
564 |
TInt chineseCount = popup->ChooseChineseCharacterArray()->Count();
|
|
565 |
|
|
566 |
if ( ( 0 == chineseCount ) && ( 0 == keystrokeCount ) )
|
|
567 |
{
|
|
568 |
TRAP_IGNORE( iOwner->FepMan()->TryCloseUiL() ); //no more keys, close the UI.
|
|
569 |
if ( aLength == ELongKeyPress )
|
|
570 |
{
|
|
571 |
iOwner->FepMan()->SetLongClearAfterCloseUI( ETrue );
|
|
572 |
}
|
|
573 |
return ETrue;
|
|
574 |
}
|
|
575 |
|
|
576 |
return EFalse;
|
|
577 |
}
|
|
578 |
|
|
579 |
// End of file
|