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 TAknFepInputStateStrokePhraseCreationBase definition.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
// System includes
|
|
31 |
#include <e32cmn.h>
|
|
32 |
#include <PtiEngine.h>
|
|
33 |
#include <PtiDefs.h>
|
|
34 |
#include <avkon.rsg>
|
|
35 |
#include <aknfep.rsg>
|
|
36 |
#include <PtiUserDicEntry.h>
|
|
37 |
#include <aknnotewrappers.h> //CAknWarningNote
|
|
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 "aknfepuiinputminiqwertypinyinphrasebase.h"
|
|
46 |
|
|
47 |
// Constant definition
|
|
48 |
const TInt KMaxPhraseCount = 50;
|
|
49 |
const TInt KMaxPhraseCreationCount = 7;
|
|
50 |
const TInt KMaxSpellLength = 7;//max pinyin length for one chinese Zi
|
|
51 |
const TInt KMaxKeystrokeCount = 31;
|
|
52 |
const TInt KInvalidToneMark = -1;
|
|
53 |
const TUint16 KAutoDLT = 0x002E;
|
|
54 |
const TUint16 KManualDLT = 0x0027;
|
|
55 |
const TUint16 KPYa = 0x0061;
|
|
56 |
const TUint16 KPYb = 0x0062;
|
|
57 |
const TUint16 KPYc = 0x0063;
|
|
58 |
const TUint16 KPYd = 0x0064;
|
|
59 |
const TUint16 KPYe = 0x0065;
|
|
60 |
const TUint16 KPYf = 0x0066;
|
|
61 |
const TUint16 KPYg = 0x0067;
|
|
62 |
const TUint16 KPYh = 0x0068;
|
|
63 |
const TUint16 KPYi = 0x0069;
|
|
64 |
const TUint16 KPYj = 0x006A;
|
|
65 |
const TUint16 KPYk = 0x006B;
|
|
66 |
const TUint16 KPYl = 0x006C;
|
|
67 |
const TUint16 KPYm = 0x006D;
|
|
68 |
const TUint16 KPYn = 0x006E;
|
|
69 |
const TUint16 KPYo = 0x006F;
|
|
70 |
const TUint16 KPYp = 0x0070;
|
|
71 |
const TUint16 KPYq = 0x0071;
|
|
72 |
const TUint16 KPYr = 0x0072;
|
|
73 |
const TUint16 KPYs = 0x0073;
|
|
74 |
const TUint16 KPYt = 0x0074;
|
|
75 |
const TUint16 KPYu = 0x0075;
|
|
76 |
const TUint16 KPYv = 0x0076;
|
|
77 |
const TUint16 KPYw = 0x0077;
|
|
78 |
const TUint16 KPYx = 0x0078;
|
|
79 |
const TUint16 KPYy = 0x0079;
|
|
80 |
const TUint16 KPYz = 0x007A;
|
|
81 |
|
|
82 |
_LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" );
|
|
83 |
|
|
84 |
const TMiniQwertyKeyMap StrokeMap[] =
|
|
85 |
{
|
|
86 |
{KPYa, EPtiKeyQwertyA},
|
|
87 |
{KPYb, EPtiKeyQwertyB},
|
|
88 |
{KPYc, EPtiKeyQwertyC},
|
|
89 |
{KPYd, EPtiKeyQwertyD},
|
|
90 |
{KPYe, EPtiKeyQwertyE},
|
|
91 |
{KPYf, EPtiKeyQwertyF},
|
|
92 |
{KPYg, EPtiKeyQwertyG},
|
|
93 |
{KPYh, EPtiKeyQwertyH},
|
|
94 |
{KPYi, EPtiKeyQwertyI},
|
|
95 |
{KPYj, EPtiKeyQwertyJ},
|
|
96 |
{KPYk, EPtiKeyQwertyK},
|
|
97 |
{KPYl, EPtiKeyQwertyL},
|
|
98 |
{KPYm, EPtiKeyQwertyM},
|
|
99 |
{KPYn, EPtiKeyQwertyN},
|
|
100 |
{KPYo, EPtiKeyQwertyO},
|
|
101 |
{KPYp, EPtiKeyQwertyP},
|
|
102 |
{KPYq, EPtiKeyQwertyQ},
|
|
103 |
{KPYr, EPtiKeyQwertyR},
|
|
104 |
{KPYs, EPtiKeyQwertyS},
|
|
105 |
{KPYt, EPtiKeyQwertyT},
|
|
106 |
{KPYu, EPtiKeyQwertyU},
|
|
107 |
{KPYv, EPtiKeyQwertyV},
|
|
108 |
{KPYw, EPtiKeyQwertyW},
|
|
109 |
{KPYx, EPtiKeyQwertyX},
|
|
110 |
{KPYy, EPtiKeyQwertyY},
|
|
111 |
{KPYz, EPtiKeyQwertyZ},
|
|
112 |
{KManualDLT, EPtiKeyQwertySpace}
|
|
113 |
};
|
|
114 |
|
|
115 |
const TMiniQwertyToneMap PinyinToneMap[] =
|
|
116 |
{
|
|
117 |
{0x02C9, 1},
|
|
118 |
{0x02CA, 2},
|
|
119 |
{0x02C7, 3},
|
|
120 |
{0x02CB, 4},
|
|
121 |
{0x02D9, 5}
|
|
122 |
};
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
// TAknFepInputStateStrokePhraseCreationBase::TAknFepInputStateStrokePhraseCreationBase
|
|
126 |
// C++ default constructor
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TAknFepInputMiniQwertyPinyinPhraseBase::TAknFepInputMiniQwertyPinyinPhraseBase(
|
|
130 |
MAknFepUIManagerStateInterface* aOwner,
|
|
131 |
MAknFepUICtrlContainerChinese* aUIContainer) :
|
|
132 |
TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer)
|
|
133 |
{
|
|
134 |
if (iOwner->PtiEngine()->InputMode() != EPtiEnginePinyinPhraseQwerty)
|
|
135 |
{
|
|
136 |
iOwner->PtiEngine()->SetInputMode(EPtiEnginePinyinPhraseQwerty);
|
|
137 |
}
|
|
138 |
iOwner->PtiEngine()->SetCandidatePageLength(KMaxPhraseCount);
|
|
139 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
140 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage());
|
|
141 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL
|
|
146 |
// Handle system key press event.
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(TInt aKey,
|
|
150 |
TKeyPressLength aLength)
|
|
151 |
{
|
|
152 |
//
|
|
153 |
switch (aKey)
|
|
154 |
{
|
|
155 |
case EKeyLeftShift:
|
|
156 |
case EKeyLeftCtrl:
|
|
157 |
case EKeyRightCtrl:
|
|
158 |
case EStdKeyDevice1:// CBA2
|
|
159 |
{
|
|
160 |
iOwner->FepMan()->TryCloseUiL();
|
|
161 |
break;
|
|
162 |
}
|
|
163 |
case EKeyRightFunc:
|
|
164 |
{
|
|
165 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
case EStdKeyLeftFunc: //tone mark.
|
|
169 |
{
|
|
170 |
HandlToneMarkL();
|
|
171 |
break;
|
|
172 |
}
|
|
173 |
case EStdKeyBackspace:
|
|
174 |
{
|
|
175 |
if (CheckKeyNeedRepeat(aLength) )
|
|
176 |
{
|
|
177 |
HandleKeyBackspaceL(aLength);
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
182 |
}
|
|
183 |
break;
|
|
184 |
}
|
|
185 |
case EStdKeyEnter://Enter keypress.
|
|
186 |
{
|
|
187 |
HandlEnterKeyL();
|
|
188 |
break;
|
|
189 |
}
|
|
190 |
case EStdKeyDevice0:// CBA1
|
|
191 |
case EStdKeyDevice3:// CBASelect
|
|
192 |
{
|
|
193 |
HandleCommitL();
|
|
194 |
break;
|
|
195 |
}
|
|
196 |
case EStdKeyUpArrow:
|
|
197 |
{
|
|
198 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
case EStdKeyDownArrow:
|
|
202 |
{
|
|
203 |
if (EMiniQwertyEdit == iState)
|
|
204 |
{
|
|
205 |
if (CheckFirstGroupStroke() )
|
|
206 |
{
|
|
207 |
iOwner->ChangeState(EEntry);
|
|
208 |
}
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
213 |
}
|
|
214 |
break;
|
|
215 |
}
|
|
216 |
case EStdKeyLeftArrow:
|
|
217 |
{
|
|
218 |
if (EMiniQwertyEdit == iState)
|
|
219 |
{
|
|
220 |
UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EManualChangeState );
|
|
221 |
MoveCursorLeft();
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
226 |
}
|
|
227 |
break;
|
|
228 |
}
|
|
229 |
case EStdKeyRightArrow:
|
|
230 |
{
|
|
231 |
if (EMiniQwertyEdit == iState)
|
|
232 |
{
|
|
233 |
UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EManualChangeState );
|
|
234 |
MoveCursorRight();
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
239 |
}
|
|
240 |
break;
|
|
241 |
}
|
|
242 |
case EStdKeySpace:
|
|
243 |
{
|
|
244 |
if (EShortKeyPress == aLength)
|
|
245 |
{
|
|
246 |
HandlSpaceKeyL();
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
break;
|
|
250 |
}
|
|
251 |
default:
|
|
252 |
{
|
|
253 |
if (CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyLock
|
|
254 |
== iOwner->FepMan()->FnKeyState()
|
|
255 |
|| ( CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState() && iState != ECandidate ))
|
|
256 |
{
|
|
257 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
258 |
return ETrue;
|
|
259 |
}
|
|
260 |
else
|
|
261 |
if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed)
|
|
262 |
|| iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
|
|
263 |
{
|
|
264 |
iOwner->FepMan()->TryCloseUiL();
|
|
265 |
return EFalse;
|
|
266 |
}
|
|
267 |
else
|
|
268 |
if ( (EShortKeyPress == aLength )
|
|
269 |
&& (iOwner->IsValidChineseInputKeyQwerty(aKey) ))
|
|
270 |
{
|
|
271 |
if (iState == ECandidate)
|
|
272 |
{
|
|
273 |
HandleKeyFromCandidateL(aKey, aLength);
|
|
274 |
}
|
|
275 |
else
|
|
276 |
{
|
|
277 |
HandleDefaultKeyL(aKey);
|
|
278 |
}
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
283 |
}
|
|
284 |
break;
|
|
285 |
}
|
|
286 |
}
|
|
287 |
|
|
288 |
return ETrue;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
// TAknFepInputMiniQwertyPinyinPhraseBase::RefreshUI
|
|
293 |
// Update input window.
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
void TAknFepInputMiniQwertyPinyinPhraseBase::RefreshUI(TBool aRefresh)
|
|
297 |
{
|
|
298 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
299 |
// get cursor position
|
|
300 |
if (aRefresh)
|
|
301 |
{
|
|
302 |
TPoint baseLine;
|
|
303 |
TInt height(0);
|
|
304 |
TInt ascent(0);
|
|
305 |
TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent))
|
|
306 |
;
|
|
307 |
if (ret == KErrNone)
|
|
308 |
{
|
|
309 |
uiContainer->SetContainerPosition(baseLine, height);
|
|
310 |
}
|
|
311 |
}
|
|
312 |
if ( (uiContainer->EditPaneWindow()->KeystrokeArray()->Count() > 0 ) ||
|
|
313 |
(uiContainer->EditPaneWindow()->PhraseArray()->Count() > 0 ) )
|
|
314 |
{
|
|
315 |
ShowInfoOnEEPPane();
|
|
316 |
SetWarningColor();
|
|
317 |
ShowInfoOnCandidatePane();
|
|
318 |
UpdateIndicator();
|
|
319 |
TRAP_IGNORE( ChangeCbaL() );
|
|
320 |
}
|
|
321 |
}
|
|
322 |
|
|
323 |
// ---------------------------------------------------------------------------
|
|
324 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckFirstGroupStroke
|
|
325 |
// check the first group stroke of keystroke.
|
|
326 |
// ---------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckFirstGroupStroke()
|
|
329 |
{
|
|
330 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
331 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
332 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
333 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
334 |
TInt stringBeforeLength = 0;
|
|
335 |
TInt stringAfterLength = 0;
|
|
336 |
TInt keyCode = 0;
|
|
337 |
TInt toneMark = 0;
|
|
338 |
if ( 0 == showKeystroke->Count() )
|
|
339 |
{
|
|
340 |
return EFalse;
|
|
341 |
}
|
|
342 |
|
|
343 |
if (KInvalidToneMark != ToneMark(showKeystroke->MdcaPoint( 0) ) )
|
|
344 |
{
|
|
345 |
return EFalse;
|
|
346 |
}
|
|
347 |
|
|
348 |
ClearPtiEngineKeystroke();
|
|
349 |
for (TInt i = 0; i < showKeystroke->Count(); ++i)
|
|
350 |
{
|
|
351 |
if (CheckSpellingDLT(showKeystroke->MdcaPoint(i) ) )
|
|
352 |
{
|
|
353 |
if ( 0 == i)
|
|
354 |
{
|
|
355 |
return EFalse;
|
|
356 |
}
|
|
357 |
else
|
|
358 |
{
|
|
359 |
return ETrue;
|
|
360 |
}
|
|
361 |
}
|
|
362 |
toneMark = ToneMark(showKeystroke->MdcaPoint(i) );
|
|
363 |
if (KInvalidToneMark != toneMark)
|
|
364 |
{
|
|
365 |
for (TInt j = 0; j < toneMark; ++j)
|
|
366 |
{
|
|
367 |
ptiengine->IncrementToneMark(ETrue);
|
|
368 |
TPtrC ptr0 = getCurrentLeastDLTSpell();
|
|
369 |
if (ptr0.Length() > 0)
|
|
370 |
{
|
|
371 |
if ( 0
|
|
372 |
== ptr0.Mid( ptr0.Length() - 1, 1 ).Compare(showKeystroke->MdcaPoint(i) ) )
|
|
373 |
{
|
|
374 |
return ETrue;
|
|
375 |
}
|
|
376 |
}
|
|
377 |
}
|
|
378 |
TPtrC ptr = getCurrentLeastDLTSpell();
|
|
379 |
if ( 0 == ptr.Mid( ptr.Length() - 1, 1 ).Compare(showKeystroke->MdcaPoint(i) ) )
|
|
380 |
{
|
|
381 |
return ETrue;
|
|
382 |
}
|
|
383 |
else
|
|
384 |
{
|
|
385 |
return EFalse;
|
|
386 |
}
|
|
387 |
}
|
|
388 |
GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) );
|
|
389 |
stringBeforeLength = getCurrentLeastDLTSpell().Length();
|
|
390 |
ptiengine->AppendKeyPress((TPtiKey)keyCode).Length();
|
|
391 |
stringAfterLength = getCurrentLeastDLTSpell().Length();
|
|
392 |
//the keystroke is invalid.
|
|
393 |
if (stringBeforeLength == stringAfterLength)
|
|
394 |
{
|
|
395 |
return EFalse;
|
|
396 |
}
|
|
397 |
}
|
|
398 |
return ETrue;
|
|
399 |
}
|
|
400 |
|
|
401 |
// ---------------------------------------------------------------------------
|
|
402 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandlEnterKey
|
|
403 |
// Handle Enter key press
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
TInt TAknFepInputMiniQwertyPinyinPhraseBase::GetCursorPos()
|
|
407 |
{
|
|
408 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
409 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
410 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
411 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
412 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
413 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
414 |
TInt pos = 0;
|
|
415 |
TInt count = 0;
|
|
416 |
TBuf<1> autoDLT;
|
|
417 |
autoDLT.Append(KAutoDLT);
|
|
418 |
|
|
419 |
if ( 0 == index)
|
|
420 |
{
|
|
421 |
pos = phraseCount;
|
|
422 |
}
|
|
423 |
else
|
|
424 |
if (keystroke->Count() == index)
|
|
425 |
{
|
|
426 |
pos = phraseCount + showKeystroke->Count();
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
for (TInt i = 0; i < showKeystroke->Count(); ++i)
|
|
431 |
{
|
|
432 |
if ( 0 != showKeystroke->MdcaPoint( i ).Compare(autoDLT) )
|
|
433 |
{
|
|
434 |
count = count + 1;
|
|
435 |
}
|
|
436 |
if (count == index)
|
|
437 |
{
|
|
438 |
pos = phraseCount + i + 1;
|
|
439 |
break;
|
|
440 |
}
|
|
441 |
}
|
|
442 |
}
|
|
443 |
return pos;
|
|
444 |
}
|
|
445 |
|
|
446 |
// ---------------------------------------------------------------------------
|
|
447 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandlEnterKeyL
|
|
448 |
// Handle Enter key press
|
|
449 |
// ---------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandlEnterKeyL()
|
|
452 |
{
|
|
453 |
TBuf<KMaxKeystrokeCount> currentText;
|
|
454 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
|
|
455 |
CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray();
|
|
456 |
CDesCArrayFlat* phraseArray = editpane->PhraseArray();
|
|
457 |
TInt phraseCount = phraseArray->Count();
|
|
458 |
TInt keyStrokeCount = showkeyStoke->Count();
|
|
459 |
TInt i = 0;
|
|
460 |
TBuf<1> autoDLT;
|
|
461 |
autoDLT.Append(KAutoDLT);
|
|
462 |
|
|
463 |
for (i = 0; i < phraseCount; i++)
|
|
464 |
{
|
|
465 |
currentText.Append(phraseArray->MdcaPoint(i) );
|
|
466 |
}
|
|
467 |
for (i = 0; i < keyStrokeCount; i++)
|
|
468 |
{
|
|
469 |
currentText.Append(showkeyStoke->MdcaPoint(i) );
|
|
470 |
}
|
|
471 |
|
|
472 |
while (currentText.Find(autoDLT)> 0)
|
|
473 |
{
|
|
474 |
currentText.Replace(currentText.Find(autoDLT), 1, KNullDesC);
|
|
475 |
}
|
|
476 |
|
|
477 |
if (currentText.Length() )
|
|
478 |
{
|
|
479 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
480 |
fepMan->NewTextL(currentText);
|
|
481 |
fepMan->CommitInlineEditL();
|
|
482 |
if (keyStrokeCount == 0 && currentText.Length() > 1)
|
|
483 |
{
|
|
484 |
AddPhraseToDB(currentText);
|
|
485 |
}
|
|
486 |
|
|
487 |
UIContainer()->EditPaneWindow()->ResetAllArray();
|
|
488 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
489 |
|
|
490 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
|
|
491 |
{
|
|
492 |
fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
|
|
493 |
iOwner->FepMan()->TryCloseUiL();
|
|
494 |
}
|
|
495 |
else
|
|
496 |
{
|
|
497 |
iOwner->FepMan()->TryCloseUiL();
|
|
498 |
}
|
|
499 |
}
|
|
500 |
}
|
|
501 |
|
|
502 |
// ---------------------------------------------------------------------------
|
|
503 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandlToneMarkL
|
|
504 |
// Handle tone mark key press.
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
//
|
|
507 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandlSpaceKeyL()
|
|
508 |
{
|
|
509 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
510 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
511 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray();
|
|
512 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
513 |
TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count();
|
|
514 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
515 |
TBuf<1> manualDLT;
|
|
516 |
TBuf<1> autoDLT;
|
|
517 |
manualDLT.Append( KManualDLT );
|
|
518 |
autoDLT.Append( KAutoDLT );
|
|
519 |
|
|
520 |
TBool firstGroup = CheckFirstGroupStroke();
|
|
521 |
|
|
522 |
keystrokeArray->InsertL(index, manualDLT);
|
|
523 |
editPane->SetCursorIndexOfKeystroke(index + 1);
|
|
524 |
AnalyseL();
|
|
525 |
|
|
526 |
if ( editPane->ShowKeystrokeArray()->Count() > KMaxKeystrokeCount )
|
|
527 |
{
|
|
528 |
keystrokeArray->Delete( index );
|
|
529 |
editPane->SetCursorIndexOfKeystroke( index );
|
|
530 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
531 |
AnalyseL();
|
|
532 |
return;
|
|
533 |
}
|
|
534 |
|
|
535 |
//Auto change from EMiniQwertyEdit state to EEntry state.
|
|
536 |
if (EMiniQwertyEdit == iState)
|
|
537 |
{
|
|
538 |
if ( ( !firstGroup ) && CheckFirstGroupStroke() )
|
|
539 |
{
|
|
540 |
if ( EAutoChangeStateFromCandidate == editPane->GetAutoChangeStateFlag() )
|
|
541 |
{
|
|
542 |
RefreshUI();
|
|
543 |
editPane->SetChangeState(ETrue);
|
|
544 |
iOwner->ChangeState(ECandidate);
|
|
545 |
}
|
|
546 |
else if ( EAutoChangeStateFromInput == editPane->GetAutoChangeStateFlag() )
|
|
547 |
{
|
|
548 |
editPane->SetChangeState(ETrue);
|
|
549 |
iOwner->ChangeState(EEntry);
|
|
550 |
}
|
|
551 |
else
|
|
552 |
{
|
|
553 |
RefreshUI();
|
|
554 |
}
|
|
555 |
return;
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
//Auto change from EEntry state to EMiniQwertyEdit state.
|
|
560 |
if (EEntry == iState)
|
|
561 |
{
|
|
562 |
if ( !CheckFirstGroupStroke() )
|
|
563 |
{
|
|
564 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromInput);
|
|
565 |
editPane->SetChangeState(ETrue);
|
|
566 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
567 |
return;
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
RefreshUI();
|
|
572 |
}
|
|
573 |
|
|
574 |
// ---------------------------------------------------------------------------
|
|
575 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandlToneMarkL
|
|
576 |
// Handle tone mark key press.
|
|
577 |
// ---------------------------------------------------------------------------
|
|
578 |
//
|
|
579 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandlToneMarkL()
|
|
580 |
{
|
|
581 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
582 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
583 |
TBool firstGroup = CheckFirstGroupStroke();
|
|
584 |
AddToneMarkL();
|
|
585 |
AnalyseL();
|
|
586 |
//Auto change from EMiniQwertyEdit state to EEntry state.
|
|
587 |
if (EMiniQwertyEdit == iState)
|
|
588 |
{
|
|
589 |
if ( ( !firstGroup ) && CheckFirstGroupStroke() )
|
|
590 |
{
|
|
591 |
if ( EAutoChangeStateFromCandidate == editPane->GetAutoChangeStateFlag() )
|
|
592 |
{
|
|
593 |
RefreshUI();
|
|
594 |
editPane->SetChangeState(ETrue);
|
|
595 |
iOwner->ChangeState(ECandidate);
|
|
596 |
}
|
|
597 |
else if ( EAutoChangeStateFromInput == editPane->GetAutoChangeStateFlag() )
|
|
598 |
{
|
|
599 |
editPane->SetChangeState(ETrue);
|
|
600 |
iOwner->ChangeState(EEntry);
|
|
601 |
}
|
|
602 |
else
|
|
603 |
{
|
|
604 |
RefreshUI();
|
|
605 |
}
|
|
606 |
return;
|
|
607 |
}
|
|
608 |
}
|
|
609 |
|
|
610 |
//Auto change from EEntry state to EMiniQwertyEdit state.
|
|
611 |
if (EEntry == iState)
|
|
612 |
{
|
|
613 |
if ( !CheckFirstGroupStroke() )
|
|
614 |
{
|
|
615 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromInput);
|
|
616 |
editPane->SetChangeState(ETrue);
|
|
617 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
618 |
return;
|
|
619 |
}
|
|
620 |
}
|
|
621 |
RefreshUI();
|
|
622 |
}
|
|
623 |
|
|
624 |
// ---------------------------------------------------------------------------
|
|
625 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckManualDelimiter
|
|
626 |
// Check the delimiter that wether is manual delimiter.
|
|
627 |
// ---------------------------------------------------------------------------
|
|
628 |
//
|
|
629 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckManualDelimiter(
|
|
630 |
const TInt aCount, const TDesC& aKeystroke)
|
|
631 |
{
|
|
632 |
TInt keyCount = 0;
|
|
633 |
for (TInt i = 0; i < aKeystroke.Length(); ++i)
|
|
634 |
{
|
|
635 |
if (KManualDLT != aKeystroke[i])
|
|
636 |
{
|
|
637 |
keyCount = keyCount + 1;
|
|
638 |
}
|
|
639 |
if (aCount == keyCount)
|
|
640 |
{
|
|
641 |
break;
|
|
642 |
}
|
|
643 |
}
|
|
644 |
|
|
645 |
if (keyCount != aCount)
|
|
646 |
{
|
|
647 |
return EFalse;
|
|
648 |
}
|
|
649 |
|
|
650 |
if (aKeystroke.Length() == keyCount)
|
|
651 |
{
|
|
652 |
return EFalse;
|
|
653 |
}
|
|
654 |
|
|
655 |
if (KManualDLT != aKeystroke[keyCount])
|
|
656 |
{
|
|
657 |
return EFalse;
|
|
658 |
}
|
|
659 |
|
|
660 |
return ETrue;
|
|
661 |
}
|
|
662 |
|
|
663 |
// ---------------------------------------------------------------------------
|
|
664 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingL
|
|
665 |
// Analyse Pinyin spelling.
|
|
666 |
// ---------------------------------------------------------------------------
|
|
667 |
//
|
|
668 |
void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingL(
|
|
669 |
const TDesC& aKeystroke, const TDesC& aSpelling,
|
|
670 |
CDesCArrayFlat* aShowKeystroke)
|
|
671 |
{
|
|
672 |
TInt count = 0;
|
|
673 |
TBuf<1> manualDLT;
|
|
674 |
TBuf<1> autoDLT;
|
|
675 |
manualDLT.Append(KManualDLT);
|
|
676 |
autoDLT.Append(KAutoDLT);
|
|
677 |
|
|
678 |
if ( 0 == aSpelling.Compare(aKeystroke) )
|
|
679 |
{
|
|
680 |
for (TInt i = 0; i < aKeystroke.Length(); ++i)
|
|
681 |
{
|
|
682 |
aShowKeystroke->AppendL(aKeystroke.Mid(i, 1) );
|
|
683 |
}
|
|
684 |
return;
|
|
685 |
}
|
|
686 |
|
|
687 |
for (TInt i = 0; i < aSpelling.Length(); ++i)
|
|
688 |
{
|
|
689 |
if (KManualDLT == aSpelling[i])
|
|
690 |
{
|
|
691 |
//Manual delimiter
|
|
692 |
if (CheckManualDelimiter(count, aKeystroke) )
|
|
693 |
{
|
|
694 |
aShowKeystroke->AppendL(manualDLT);
|
|
695 |
}
|
|
696 |
else
|
|
697 |
{
|
|
698 |
aShowKeystroke->AppendL(autoDLT);
|
|
699 |
}
|
|
700 |
}
|
|
701 |
else
|
|
702 |
{
|
|
703 |
aShowKeystroke->AppendL(aSpelling.Mid(i, 1) );
|
|
704 |
count = count + 1;
|
|
705 |
}
|
|
706 |
}
|
|
707 |
}
|
|
708 |
|
|
709 |
// ---------------------------------------------------------------------------
|
|
710 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingAddToneMarkL
|
|
711 |
// Analyse spelling after user press tone mark.
|
|
712 |
// ---------------------------------------------------------------------------
|
|
713 |
//
|
|
714 |
void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingAddToneMarkL(
|
|
715 |
TInt aI,
|
|
716 |
TInt aToneMarkCount,
|
|
717 |
CDesCArrayFlat* aKeystroke,
|
|
718 |
CDesCArrayFlat* aShowKeystroke )
|
|
719 |
{
|
|
720 |
TBuf<1> atuoDLT;
|
|
721 |
TBuf<1> manualDLT;
|
|
722 |
atuoDLT.Append(KAutoDLT);
|
|
723 |
manualDLT.Append(KManualDLT);
|
|
724 |
if ( CheckSpellingDLT( aKeystroke->MdcaPoint( aI - 1 ) ) ||
|
|
725 |
( KInvalidToneMark != ToneMark( aKeystroke->MdcaPoint( aI - 1 ) ) ) )
|
|
726 |
{
|
|
727 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
728 |
}
|
|
729 |
else
|
|
730 |
{
|
|
731 |
if ( CheckSpellingAddToneMarkToPTIL( aToneMarkCount ) )
|
|
732 |
{
|
|
733 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI - 1 ) );
|
|
734 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
735 |
}
|
|
736 |
else
|
|
737 |
{
|
|
738 |
if ( aShowKeystroke->Count() == 0 )
|
|
739 |
{
|
|
740 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI - 1 ) );
|
|
741 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
742 |
}
|
|
743 |
else
|
|
744 |
{
|
|
745 |
if ( ( !CheckSpellingDLT(aShowKeystroke->MdcaPoint(
|
|
746 |
aShowKeystroke->Count() - 1 ) ) ) &&
|
|
747 |
( KInvalidToneMark == ToneMark( aShowKeystroke->
|
|
748 |
MdcaPoint( aShowKeystroke->Count() - 1 ) ) ) )
|
|
749 |
{
|
|
750 |
aShowKeystroke->AppendL( atuoDLT );
|
|
751 |
}
|
|
752 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI - 1 ) );
|
|
753 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
754 |
}
|
|
755 |
}
|
|
756 |
}
|
|
757 |
}
|
|
758 |
|
|
759 |
// ---------------------------------------------------------------------------
|
|
760 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingAddKeyL
|
|
761 |
// Analyse spelling after user press key that is not tone mark.
|
|
762 |
// ---------------------------------------------------------------------------
|
|
763 |
//
|
|
764 |
void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseSpellingAddKeyL(
|
|
765 |
TInt& aI,
|
|
766 |
TInt aDelimterPos,
|
|
767 |
CDesCArrayFlat* aKeystroke,
|
|
768 |
CDesCArrayFlat* aShowKeystroke )
|
|
769 |
{
|
|
770 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
771 |
TBuf<1> atuoDLT;
|
|
772 |
TBuf<1> manualDLT;
|
|
773 |
atuoDLT.Append(KAutoDLT);
|
|
774 |
manualDLT.Append(KManualDLT);
|
|
775 |
if ( 0 == aI )
|
|
776 |
{
|
|
777 |
if ( aI + 1 < aKeystroke->Count() )
|
|
778 |
{
|
|
779 |
if ( ( KInvalidToneMark != ToneMark( aKeystroke->MdcaPoint( aI + 1 ) ) ) ||
|
|
780 |
( CheckSpellingDLT( aKeystroke->MdcaPoint( aI + 1 ) ) ) )
|
|
781 |
{
|
|
782 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
783 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI + 1 ) );
|
|
784 |
aI = aI + 1;
|
|
785 |
}
|
|
786 |
else
|
|
787 |
{
|
|
788 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
789 |
aShowKeystroke->AppendL( atuoDLT );
|
|
790 |
}
|
|
791 |
}
|
|
792 |
else
|
|
793 |
{
|
|
794 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
795 |
}
|
|
796 |
}
|
|
797 |
else if ( aI + 1 == aKeystroke->Count() )
|
|
798 |
{
|
|
799 |
if ( ( 1 == aDelimterPos ) || ( -1 == aDelimterPos ) )
|
|
800 |
{
|
|
801 |
if ( ( !CheckSpellingDLT( aShowKeystroke->
|
|
802 |
MdcaPoint( aShowKeystroke->Count() - 1 ) ) &&
|
|
803 |
( KInvalidToneMark == ToneMark( aShowKeystroke->
|
|
804 |
MdcaPoint( aShowKeystroke->Count() - 1 ) ) ) ) )
|
|
805 |
{
|
|
806 |
aShowKeystroke->AppendL( atuoDLT );
|
|
807 |
}
|
|
808 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
809 |
}
|
|
810 |
else
|
|
811 |
{
|
|
812 |
for ( TInt ii = 0; ii < aDelimterPos - 1; ++ii )
|
|
813 |
{
|
|
814 |
aShowKeystroke->Delete( aShowKeystroke->Count() - 1 );
|
|
815 |
}
|
|
816 |
if ( ( !CheckSpellingDLT( aShowKeystroke->
|
|
817 |
MdcaPoint( aShowKeystroke->Count() - 1 ) ) ) &&
|
|
818 |
( KInvalidToneMark == ToneMark( aShowKeystroke->MdcaPoint(
|
|
819 |
aShowKeystroke->Count() - 1 ) ) ) )
|
|
820 |
{
|
|
821 |
aShowKeystroke->AppendL( atuoDLT );
|
|
822 |
}
|
|
823 |
aI = aI - aDelimterPos;
|
|
824 |
}
|
|
825 |
}
|
|
826 |
else
|
|
827 |
{
|
|
828 |
if ( -1 == aDelimterPos )
|
|
829 |
{
|
|
830 |
if ( ( !CheckSpellingDLT( aShowKeystroke->MdcaPoint(
|
|
831 |
aShowKeystroke->Count() - 1 ) ) ) &&
|
|
832 |
( KInvalidToneMark == ToneMark( aShowKeystroke->MdcaPoint(
|
|
833 |
aShowKeystroke->Count() - 1 ) ) ) )
|
|
834 |
{
|
|
835 |
aShowKeystroke->AppendL( atuoDLT );
|
|
836 |
}
|
|
837 |
if ( 0 == getCurrentLeastDLTSpell().Length() )
|
|
838 |
{
|
|
839 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI ) );
|
|
840 |
if ( KInvalidToneMark != ToneMark( aKeystroke->MdcaPoint( aI + 1 ) ) )
|
|
841 |
{
|
|
842 |
aShowKeystroke->AppendL( aKeystroke->MdcaPoint( aI + 1 ) );
|
|
843 |
aI = aI + 1;
|
|
844 |
}
|
|
845 |
}
|
|
846 |
else
|
|
847 |
{
|
|
848 |
aI = aI - 1;
|
|
849 |
}
|
|
850 |
}
|
|
851 |
else
|
|
852 |
{
|
|
853 |
for ( TInt ii = 0; ii < aDelimterPos - 1; ++ii )
|
|
854 |
{
|
|
855 |
aShowKeystroke->Delete( aShowKeystroke->Count() - 1 );
|
|
856 |
}
|
|
857 |
if ( ( !CheckSpellingDLT( aShowKeystroke->MdcaPoint(
|
|
858 |
aShowKeystroke->Count() - 1 ) ) ) &&
|
|
859 |
( KInvalidToneMark == ToneMark( aShowKeystroke->MdcaPoint(
|
|
860 |
aShowKeystroke->Count() - 1 ) ) ) )
|
|
861 |
{
|
|
862 |
aShowKeystroke->AppendL( atuoDLT );
|
|
863 |
}
|
|
864 |
aI = aI - aDelimterPos;
|
|
865 |
}
|
|
866 |
}
|
|
867 |
}
|
|
868 |
|
|
869 |
// ---------------------------------------------------------------------------
|
|
870 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseL
|
|
871 |
// Analyse key storke.
|
|
872 |
// ---------------------------------------------------------------------------
|
|
873 |
//
|
|
874 |
void TAknFepInputMiniQwertyPinyinPhraseBase::AnalyseL()
|
|
875 |
{
|
|
876 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
877 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
878 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
879 |
//user pressed keystroke sequence
|
|
880 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
881 |
//stroke to be shown
|
|
882 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
883 |
TInt start = 0;
|
|
884 |
TInt toneMarkCount = KInvalidToneMark;
|
|
885 |
TInt delimiterPosition = 0;
|
|
886 |
showKeystroke->Reset();
|
|
887 |
TBuf<1> atuoDLT;
|
|
888 |
TBuf<1> manualDLT;
|
|
889 |
atuoDLT.Append(KAutoDLT);
|
|
890 |
manualDLT.Append(KManualDLT);
|
|
891 |
TBuf<KMaxKeystrokeCount> keyTmp;
|
|
892 |
|
|
893 |
if ( keystroke->Count() == 0 )
|
|
894 |
{
|
|
895 |
return;
|
|
896 |
}
|
|
897 |
|
|
898 |
//if the first keystroke is delimiter or ToneMark, analyse frome the next one
|
|
899 |
if ( CheckSpellingDLT( keystroke->MdcaPoint( 0 ) ) ||
|
|
900 |
( KInvalidToneMark != ToneMark( keystroke->MdcaPoint( 0 ) ) ) )
|
|
901 |
{
|
|
902 |
showKeystroke->AppendL(keystroke->MdcaPoint( 0 ) );
|
|
903 |
start = 1;
|
|
904 |
}
|
|
905 |
|
|
906 |
ClearPtiEngineKeystroke();
|
|
907 |
|
|
908 |
for ( TInt i = start; i < keystroke->Count(); ++i )
|
|
909 |
{
|
|
910 |
toneMarkCount = ToneMark( keystroke->MdcaPoint( i ) );
|
|
911 |
// current keystroke is delimiter
|
|
912 |
if ( CheckSpellingDLT( keystroke->MdcaPoint( i ) ) )
|
|
913 |
{
|
|
914 |
showKeystroke->AppendL(keystroke->MdcaPoint( i ) );
|
|
915 |
ClearPtiEngineKeystroke();
|
|
916 |
}
|
|
917 |
// current keystroke is tone mark
|
|
918 |
else if ( KInvalidToneMark != toneMarkCount )
|
|
919 |
{
|
|
920 |
AnalyseSpellingAddToneMarkL( i, toneMarkCount, keystroke, showKeystroke );
|
|
921 |
ClearPtiEngineKeystroke();
|
|
922 |
}
|
|
923 |
// current keystroke is A - Z
|
|
924 |
else
|
|
925 |
{
|
|
926 |
delimiterPosition = CheckSpellingAddKeyToPTIL( keystroke->MdcaPoint( i ) );
|
|
927 |
if ( 0 == delimiterPosition )
|
|
928 |
{
|
|
929 |
if ( ( 0 != i ) &&
|
|
930 |
( 1 == this->getCurrentLeastDLTSpell().Length() ) )
|
|
931 |
{
|
|
932 |
if ( ( !CheckSpellingDLT( showKeystroke->
|
|
933 |
MdcaPoint( showKeystroke->Count() - 1 ) ) ) &&
|
|
934 |
( KInvalidToneMark == ToneMark( showKeystroke->
|
|
935 |
MdcaPoint( showKeystroke->Count() - 1 ) ) ) )
|
|
936 |
{
|
|
937 |
showKeystroke->AppendL( atuoDLT );
|
|
938 |
}
|
|
939 |
}
|
|
940 |
if ( i + 1 < keystroke->Count() )
|
|
941 |
{
|
|
942 |
if ( KInvalidToneMark == ToneMark( keystroke->MdcaPoint( i + 1 ) ) )
|
|
943 |
{
|
|
944 |
showKeystroke->AppendL( keystroke->MdcaPoint( i ) );
|
|
945 |
}
|
|
946 |
}
|
|
947 |
else
|
|
948 |
{
|
|
949 |
showKeystroke->AppendL( keystroke->MdcaPoint( i ) );
|
|
950 |
}
|
|
951 |
}
|
|
952 |
else
|
|
953 |
{
|
|
954 |
AnalyseSpellingAddKeyL( i, delimiterPosition, keystroke, showKeystroke );
|
|
955 |
ClearPtiEngineKeystroke();
|
|
956 |
}
|
|
957 |
}
|
|
958 |
}
|
|
959 |
}
|
|
960 |
|
|
961 |
// ---------------------------------------------------------------------------
|
|
962 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleCommitL
|
|
963 |
// Handle CBA1 or select event.
|
|
964 |
// ---------------------------------------------------------------------------
|
|
965 |
//
|
|
966 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandleCommitL()
|
|
967 |
{
|
|
968 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
969 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
970 |
TInt keyCount = editPane->KeystrokeArray()->Count();
|
|
971 |
TInt showKeyCount = editPane->ShowKeystrokeArray()->Count();
|
|
972 |
CDesCArrayFlat* phrase = editPane->PhraseArray();
|
|
973 |
TInt cdtCount = uiContainer->CandidatePane()->CandidateArray()->Count();
|
|
974 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
975 |
|
|
976 |
if (EMiniQwertyEdit == iState)
|
|
977 |
{
|
|
978 |
if ( ( showKeyCount > 0 ) && (cdtCount > 0 ) )
|
|
979 |
{
|
|
980 |
UIContainer()->EditPaneWindow()->SetChangeState(ETrue);
|
|
981 |
iOwner->ChangeState(ECandidate);
|
|
982 |
return;
|
|
983 |
}
|
|
984 |
|
|
985 |
if ( keyCount > 0 )
|
|
986 |
{
|
|
987 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
988 |
return;
|
|
989 |
}
|
|
990 |
}
|
|
991 |
|
|
992 |
if ( ( 0 == keyCount ) && (phrase->Count() <= 1 ) )
|
|
993 |
{
|
|
994 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
995 |
return;
|
|
996 |
}
|
|
997 |
|
|
998 |
if ( ( 0 == keyCount ) && (phrase->Count() > 1 ) )
|
|
999 |
{
|
|
1000 |
TBuf<KMaxPhraseCreationCount> phraseCreated;
|
|
1001 |
for (TInt i = 0; ( (i < phrase->Count() ) && (i
|
|
1002 |
< KMaxPhraseCreationCount ) ); ++i )
|
|
1003 |
{
|
|
1004 |
phraseCreated.Append(phrase->MdcaPoint( i ) );
|
|
1005 |
AddPhraseToDB(phraseCreated);
|
|
1006 |
}
|
|
1007 |
fepMan->NewTextL(phraseCreated);
|
|
1008 |
fepMan->CommitInlineEditL();
|
|
1009 |
if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag() )
|
|
1010 |
{
|
|
1011 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
1012 |
iOwner->PtiEngine()->SetPredictiveChineseChar(phraseCreated);
|
|
1013 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
1014 |
UIContainer()->EditPaneWindow()->SetChangeState(ETrue);
|
|
1015 |
if (EPtiKeyboardQwerty4x10 == iOwner->FepMan()->KeyboardLayout() ||
|
|
1016 |
EPtiKeyboardQwerty3x11 == iOwner->FepMan()->KeyboardLayout() )
|
|
1017 |
{
|
|
1018 |
iOwner->ChangeState(EPredictiveCandidate);
|
|
1019 |
}
|
|
1020 |
#endif
|
|
1021 |
}
|
|
1022 |
else
|
|
1023 |
{
|
|
1024 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
1025 |
iOwner->FepMan()->TryCloseUiL();
|
|
1026 |
}
|
|
1027 |
return;
|
|
1028 |
}
|
|
1029 |
|
|
1030 |
TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
|
|
1031 |
if (text.Length() == 0)
|
|
1032 |
{
|
|
1033 |
return;
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
if ( !CommitInlineEEPL(text) )
|
|
1037 |
{
|
|
1038 |
DoActionAfterCommit();
|
|
1039 |
}
|
|
1040 |
else
|
|
1041 |
{
|
|
1042 |
if ( !CheckFirstGroupStroke() )
|
|
1043 |
{
|
|
1044 |
if ( iState == EEntry )
|
|
1045 |
{
|
|
1046 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromInput);
|
|
1047 |
}
|
|
1048 |
else
|
|
1049 |
{
|
|
1050 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromCandidate);
|
|
1051 |
}
|
|
1052 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
1053 |
return;
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
if ( iState == EEntry )
|
|
1058 |
{
|
|
1059 |
UIContainer()->EditPaneWindow()->SetChangeState( ETrue );
|
|
1060 |
iOwner->ChangeState( ECandidate );
|
|
1061 |
}
|
|
1062 |
}
|
|
1063 |
AnalyseL();
|
|
1064 |
RefreshUI();
|
|
1065 |
}
|
|
1066 |
}
|
|
1067 |
|
|
1068 |
// ---------------------------------------------------------------------------
|
|
1069 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyBackspaceL
|
|
1070 |
// Handle KeyBackspace event.
|
|
1071 |
// ---------------------------------------------------------------------------
|
|
1072 |
//
|
|
1073 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyBackspaceL(
|
|
1074 |
TKeyPressLength aLength)
|
|
1075 |
{
|
|
1076 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1077 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1078 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
1079 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
1080 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
1081 |
TBool firstGroup = CheckFirstGroupStroke();
|
|
1082 |
|
|
1083 |
if ( ( 0 == index ) && (phraseCount != 0 ) )
|
|
1084 |
{
|
|
1085 |
RevertPhraseToKeystrokeL();
|
|
1086 |
}
|
|
1087 |
else
|
|
1088 |
if ( ( 0 == index ) && (keystroke->Count() > 0 ) )
|
|
1089 |
{
|
|
1090 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
1091 |
}
|
|
1092 |
else
|
|
1093 |
{
|
|
1094 |
if ( !DeleteKeystrokeL() )
|
|
1095 |
{
|
|
1096 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
//if the keystroke is null and phrase is null then close input window.
|
|
1101 |
if ( ( 0 == phraseCount ) && (keystroke->Count() == 0 ))
|
|
1102 |
{
|
|
1103 |
iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
|
|
1104 |
if (aLength == ELongKeyPress)
|
|
1105 |
{
|
|
1106 |
iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue);
|
|
1107 |
}
|
|
1108 |
return;
|
|
1109 |
}
|
|
1110 |
|
|
1111 |
AnalyseL();
|
|
1112 |
//Auto change from EMiniQwertyEdit state to EEntry state.
|
|
1113 |
if (EMiniQwertyEdit == iState)
|
|
1114 |
{
|
|
1115 |
if ( ( !firstGroup ) && CheckFirstGroupStroke() )
|
|
1116 |
{
|
|
1117 |
if ( EAutoChangeStateFromCandidate == editPane->GetAutoChangeStateFlag() )
|
|
1118 |
{
|
|
1119 |
RefreshUI();
|
|
1120 |
editPane->SetChangeState(ETrue);
|
|
1121 |
iOwner->ChangeState(ECandidate);
|
|
1122 |
}
|
|
1123 |
else if ( EAutoChangeStateFromInput == editPane->GetAutoChangeStateFlag() )
|
|
1124 |
{
|
|
1125 |
editPane->SetChangeState(ETrue);
|
|
1126 |
iOwner->ChangeState(EEntry);
|
|
1127 |
}
|
|
1128 |
else
|
|
1129 |
{
|
|
1130 |
RefreshUI();
|
|
1131 |
}
|
|
1132 |
return;
|
|
1133 |
}
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
//Auto change from EEntry state to EMiniQwertyEdit state.
|
|
1137 |
if (EEntry == iState)
|
|
1138 |
{
|
|
1139 |
if ( (firstGroup ) && ( !CheckFirstGroupStroke() ))
|
|
1140 |
{
|
|
1141 |
editPane->SetChangeState(EFalse);
|
|
1142 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromInput);
|
|
1143 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
1144 |
return;
|
|
1145 |
}
|
|
1146 |
}
|
|
1147 |
|
|
1148 |
RefreshUI();
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
// ---------------------------------------------------------------------------
|
|
1152 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleDefaultKeyL
|
|
1153 |
// Handle default key press event.
|
|
1154 |
// ---------------------------------------------------------------------------
|
|
1155 |
//
|
|
1156 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandleDefaultKeyL(TInt aKey)
|
|
1157 |
{
|
|
1158 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1159 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1160 |
TBool firstGroup = CheckFirstGroupStroke();
|
|
1161 |
|
|
1162 |
if ( !AddKeystrokeL(aKey) )
|
|
1163 |
{
|
|
1164 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
1165 |
return;
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
AnalyseL();
|
|
1169 |
|
|
1170 |
//Auto change from EMiniQwertyEdit state to EEntry state.
|
|
1171 |
if (EMiniQwertyEdit == iState)
|
|
1172 |
{
|
|
1173 |
if ( ( !firstGroup ) && CheckFirstGroupStroke() )
|
|
1174 |
{
|
|
1175 |
if ( EAutoChangeStateFromCandidate == editPane->GetAutoChangeStateFlag() )
|
|
1176 |
{
|
|
1177 |
RefreshUI();
|
|
1178 |
editPane->SetChangeState(ETrue);
|
|
1179 |
iOwner->ChangeState(ECandidate);
|
|
1180 |
}
|
|
1181 |
else if ( EAutoChangeStateFromInput == editPane->GetAutoChangeStateFlag() )
|
|
1182 |
{
|
|
1183 |
editPane->SetChangeState(ETrue);
|
|
1184 |
iOwner->ChangeState(EEntry);
|
|
1185 |
}
|
|
1186 |
else
|
|
1187 |
{
|
|
1188 |
RefreshUI();
|
|
1189 |
}
|
|
1190 |
return;
|
|
1191 |
}
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
//Auto change from EEntry state to EMiniQwertyEdit state.
|
|
1195 |
if (EEntry == iState)
|
|
1196 |
{
|
|
1197 |
if ( !CheckFirstGroupStroke() )
|
|
1198 |
{
|
|
1199 |
editPane->SetAutoChangeStateFlag(EAutoChangeStateFromInput);
|
|
1200 |
editPane->SetChangeState(ETrue);
|
|
1201 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
1202 |
return;
|
|
1203 |
}
|
|
1204 |
}
|
|
1205 |
|
|
1206 |
RefreshUI();
|
|
1207 |
}
|
|
1208 |
|
|
1209 |
// ---------------------------------------------------------------------------
|
|
1210 |
// TAknFepInputMiniQwertyPinyinPhraseBase::ShowInfoOnEEP
|
|
1211 |
// Show the showinfo on the EEP ctrl.
|
|
1212 |
// ---------------------------------------------------------------------------
|
|
1213 |
//
|
|
1214 |
void TAknFepInputMiniQwertyPinyinPhraseBase::ShowInfoOnEEPPane()
|
|
1215 |
{
|
|
1216 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1217 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1218 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
1219 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray();
|
|
1220 |
CDesCArrayFlat* phrase = editPane->PhraseArray();
|
|
1221 |
TBuf<KMaxKeystrokeCount> showInfo;
|
|
1222 |
TBuf<KMaxKeystrokeCount> keyBuf;
|
|
1223 |
for (TInt i = 0; i < phrase->Count(); ++i)
|
|
1224 |
{
|
|
1225 |
showInfo.Append(phrase->MdcaPoint(i) );
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
for (TInt ii = 0; ii < showKeystroke->Count(); ++ii)
|
|
1229 |
{
|
|
1230 |
showInfo.Append(showKeystroke->MdcaPoint(ii) );
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
for (TInt j = 0; j < keystrokeArray->Count(); ++j)
|
|
1234 |
{
|
|
1235 |
keyBuf.Append(keystrokeArray->MdcaPoint(j) );
|
|
1236 |
}
|
|
1237 |
|
|
1238 |
editPane->SetTextForZhuyin(showInfo, GetCursorPos(), phrase->Count(),
|
|
1239 |
keyBuf, editPane->GetCursorIndexOfKeystroke() );
|
|
1240 |
|
|
1241 |
if (iState == ECandidate)
|
|
1242 |
{
|
|
1243 |
editPane->DisableCursor();
|
|
1244 |
}
|
|
1245 |
else
|
|
1246 |
if (iState == EEntry)
|
|
1247 |
{
|
|
1248 |
editPane->EnableCursor();
|
|
1249 |
editPane->DeactiveCursor();
|
|
1250 |
}
|
|
1251 |
else
|
|
1252 |
if (iState == EMiniQwertyEdit)
|
|
1253 |
{
|
|
1254 |
editPane->EnableCursor();
|
|
1255 |
editPane->ActiveCursor();
|
|
1256 |
}
|
|
1257 |
}
|
|
1258 |
|
|
1259 |
// ---------------------------------------------------------------------------
|
|
1260 |
// TAknFepInputMiniQwertyPinyinPhraseBase::ShowInfoOnEEP
|
|
1261 |
// Show the showinfo on the EEP ctrl.
|
|
1262 |
// ---------------------------------------------------------------------------
|
|
1263 |
//
|
|
1264 |
void TAknFepInputMiniQwertyPinyinPhraseBase::ShowInfoOnCandidatePane()
|
|
1265 |
{
|
|
1266 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1267 |
CDesCArrayFlat* phrase = uiContainer->CandidatePane()->CandidateArray();
|
|
1268 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1269 |
if (KMaxPhraseCreationCount == editPane->PhraseArray()->Count() )
|
|
1270 |
{
|
|
1271 |
phrase->Reset();
|
|
1272 |
TRAP_IGNORE( phrase->AppendL( KMaxPhraseNote ) );
|
|
1273 |
uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages();
|
|
1274 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
1275 |
uiContainer->Enable(ETrue);
|
|
1276 |
uiContainer->ShowHorizontalScrollArrows(EFalse);
|
|
1277 |
uiContainer->ShowVerticalScrollArrows(EFalse);
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
TRAP_IGNORE( GetCandidateL() );
|
|
1281 |
if (phrase->Count() > 0)
|
|
1282 |
{
|
|
1283 |
// layout candidate and fill candidate buffer for first display page
|
|
1284 |
uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages();
|
|
1285 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
1286 |
uiContainer->Enable(ETrue);
|
|
1287 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage());
|
|
1288 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
1289 |
if (iState == EMiniQwertyEdit)
|
|
1290 |
{
|
|
1291 |
UIContainer()->FocusCandidatePane(EFalse);
|
|
1292 |
}
|
|
1293 |
else
|
|
1294 |
{
|
|
1295 |
UIContainer()->FocusCandidatePane(ETrue);
|
|
1296 |
UIContainer()->CandidatePane()->SelectFirstPhrase();
|
|
1297 |
}
|
|
1298 |
}
|
|
1299 |
else
|
|
1300 |
{
|
|
1301 |
uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages();
|
|
1302 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
1303 |
uiContainer->Enable(ETrue);
|
|
1304 |
uiContainer->ShowHorizontalScrollArrows(EFalse);
|
|
1305 |
uiContainer->ShowVerticalScrollArrows(EFalse);
|
|
1306 |
uiContainer->SetControlInVisible( EFalse );
|
|
1307 |
}
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
// ---------------------------------------------------------------------------
|
|
1311 |
// TAknFepInputMiniQwertyPinyinPhraseBase::GetShowKeystroke
|
|
1312 |
//Handle horizontal navigation.
|
|
1313 |
// ---------------------------------------------------------------------------
|
|
1314 |
//
|
|
1315 |
void TAknFepInputMiniQwertyPinyinPhraseBase::GetShowKeystroke(TInt aKey,
|
|
1316 |
TDes& aKeystroke)
|
|
1317 |
{
|
|
1318 |
TInt count = sizeof(StrokeMap )/sizeof(StrokeMap[0] );
|
|
1319 |
for (TInt i = 0; i < count; i++)
|
|
1320 |
{
|
|
1321 |
if (aKey == StrokeMap[i].iKeyCode)
|
|
1322 |
{
|
|
1323 |
aKeystroke.Append(StrokeMap[i].iValue);
|
|
1324 |
break;
|
|
1325 |
}
|
|
1326 |
}
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
// ---------------------------------------------------------------------------
|
|
1330 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleHorizontalNavigation
|
|
1331 |
//Handle horizontal navigation.
|
|
1332 |
// ---------------------------------------------------------------------------
|
|
1333 |
//
|
|
1334 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::HandleHorizontalNavigation(
|
|
1335 |
TInt aKey)
|
|
1336 |
{
|
|
1337 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
1338 |
TBool response = EFalse;
|
|
1339 |
|
|
1340 |
// Do navigation...
|
|
1341 |
if (aKey == EStdKeyLeftArrow)
|
|
1342 |
{
|
|
1343 |
if (!candidatePane->SelectPrev())
|
|
1344 |
{
|
|
1345 |
candidatePane->SetCandidateBuffer();
|
|
1346 |
candidatePane->SelectLastPhrase();
|
|
1347 |
}
|
|
1348 |
response = ETrue;
|
|
1349 |
}
|
|
1350 |
else
|
|
1351 |
if (aKey == EStdKeyRightArrow)
|
|
1352 |
{
|
|
1353 |
if (!candidatePane->SelectNext())
|
|
1354 |
{
|
|
1355 |
candidatePane->SetCandidateBuffer();
|
|
1356 |
candidatePane->SelectFirstPhrase();
|
|
1357 |
}
|
|
1358 |
response = ETrue;
|
|
1359 |
}
|
|
1360 |
|
|
1361 |
if (response)
|
|
1362 |
{
|
|
1363 |
UpdateIndicator();
|
|
1364 |
}
|
|
1365 |
|
|
1366 |
return response;
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
// ---------------------------------------------------------
|
|
1370 |
// TAknFepInputMiniQwertyPinyinPhraseBase::UpdateIndicator
|
|
1371 |
// Update Indicator.
|
|
1372 |
// ---------------------------------------------------------
|
|
1373 |
//
|
|
1374 |
void TAknFepInputMiniQwertyPinyinPhraseBase::UpdateIndicator()
|
|
1375 |
{
|
|
1376 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1377 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
1378 |
|
|
1379 |
if (candidatePane->IsFirstPage())
|
|
1380 |
{
|
|
1381 |
uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);
|
|
1382 |
}
|
|
1383 |
else
|
|
1384 |
{
|
|
1385 |
uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);
|
|
1386 |
}
|
|
1387 |
|
|
1388 |
if (candidatePane->IsLastPage())
|
|
1389 |
{
|
|
1390 |
uiContainer->CandidatePane()->ShowDownScrollArrows(EFalse);
|
|
1391 |
}
|
|
1392 |
else
|
|
1393 |
{
|
|
1394 |
uiContainer->CandidatePane()->ShowDownScrollArrows(ETrue);
|
|
1395 |
}
|
|
1396 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
1397 |
if (iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty4x10)
|
|
1398 |
{
|
|
1399 |
if (candidatePane->VisibleCandidateCount()==1)
|
|
1400 |
{
|
|
1401 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
|
|
1402 |
uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse);
|
|
1403 |
}
|
|
1404 |
else
|
|
1405 |
{
|
|
1406 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue);
|
|
1407 |
uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue);
|
|
1408 |
}
|
|
1409 |
}
|
|
1410 |
else
|
|
1411 |
{
|
|
1412 |
#endif
|
|
1413 |
if (candidatePane->SelectedIndex() == 0
|
|
1414 |
&& candidatePane->IsFirstPage() )
|
|
1415 |
{
|
|
1416 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
|
|
1417 |
}
|
|
1418 |
else
|
|
1419 |
{
|
|
1420 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue);
|
|
1421 |
}
|
|
1422 |
|
|
1423 |
if (candidatePane->IsLastPage() && (candidatePane->SelectedIndex()
|
|
1424 |
== candidatePane->VisibleCandidateCount() - 1))
|
|
1425 |
{
|
|
1426 |
uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse);
|
|
1427 |
}
|
|
1428 |
else
|
|
1429 |
{
|
|
1430 |
uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue);
|
|
1431 |
}
|
|
1432 |
}
|
|
1433 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
1434 |
}
|
|
1435 |
#endif
|
|
1436 |
|
|
1437 |
// ---------------------------------------------------------
|
|
1438 |
// TAknFepInputMiniQwertyPinyinPhraseBase::DeleteMoreKeystrokeL
|
|
1439 |
// Delete more keystroke than max leng.
|
|
1440 |
// ---------------------------------------------------------
|
|
1441 |
//
|
|
1442 |
void TAknFepInputMiniQwertyPinyinPhraseBase::DeleteMoreKeystrokeL()
|
|
1443 |
{
|
|
1444 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1445 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1446 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
1447 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
1448 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
1449 |
TBuf<1> autoDLT;
|
|
1450 |
autoDLT.Append( KAutoDLT );
|
|
1451 |
AnalyseL();
|
|
1452 |
// the count keystroke more than max length.
|
|
1453 |
TInt count = showKeystroke->Count() - KMaxKeystrokeCount;
|
|
1454 |
|
|
1455 |
for ( TInt i = 0; i < count; ++i )
|
|
1456 |
{
|
|
1457 |
if ( 0 != showKeystroke->MdcaPoint( showKeystroke->Count() - 1 ).Compare( autoDLT ) )
|
|
1458 |
{
|
|
1459 |
showKeystroke->Delete( showKeystroke->Count() - 1 );
|
|
1460 |
keystroke->Delete( keystroke->Count() - 1 );
|
|
1461 |
}
|
|
1462 |
}
|
|
1463 |
|
|
1464 |
if ( index > keystroke->Count() )
|
|
1465 |
{
|
|
1466 |
editPane->SetCursorIndexOfKeystroke( keystroke->Count() );
|
|
1467 |
}
|
|
1468 |
}
|
|
1469 |
// ---------------------------------------------------------
|
|
1470 |
// TAknFepInputMiniQwertyPinyinPhraseBase::DeleteKeystrokeL
|
|
1471 |
// Delete current keystroke.
|
|
1472 |
// ---------------------------------------------------------
|
|
1473 |
//
|
|
1474 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::DeleteKeystrokeL()
|
|
1475 |
{
|
|
1476 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1477 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1478 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
1479 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
1480 |
TInt showKeyCount = editPane->ShowKeystrokeArray()->Count();
|
|
1481 |
|
|
1482 |
if ( ( 0 == index ) || (keystroke->Count() == 0 ))
|
|
1483 |
{
|
|
1484 |
return EFalse;
|
|
1485 |
}
|
|
1486 |
if ( 1 == index )
|
|
1487 |
{
|
|
1488 |
editPane->Reset();
|
|
1489 |
}
|
|
1490 |
if (index >= keystroke->Count() )
|
|
1491 |
{
|
|
1492 |
keystroke->Delete(keystroke->Count() - 1);
|
|
1493 |
editPane->SetCursorIndexOfKeystroke(keystroke->Count() );
|
|
1494 |
}
|
|
1495 |
else
|
|
1496 |
{
|
|
1497 |
keystroke->Delete(index - 1);
|
|
1498 |
editPane->SetCursorIndexOfKeystroke(index - 1);
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
if ( showKeyCount >= KMaxKeystrokeCount - 1 )
|
|
1502 |
{
|
|
1503 |
DeleteMoreKeystrokeL();
|
|
1504 |
}
|
|
1505 |
|
|
1506 |
return ETrue;
|
|
1507 |
}
|
|
1508 |
|
|
1509 |
// ---------------------------------------------------------
|
|
1510 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AddPhraseToDB
|
|
1511 |
// Add phrase to DB.
|
|
1512 |
// ---------------------------------------------------------
|
|
1513 |
//
|
|
1514 |
void TAknFepInputMiniQwertyPinyinPhraseBase::AddPhraseToDB(
|
|
1515 |
const TDesC& aPhraseAdd)
|
|
1516 |
{
|
|
1517 |
TPtiUserDictionaryEntry addUdbEntry(aPhraseAdd);
|
|
1518 |
//Add the phrase to the DB by PTI Engine
|
|
1519 |
iOwner->PtiEngine()->AddUserDictionaryEntry(addUdbEntry);
|
|
1520 |
}
|
|
1521 |
|
|
1522 |
// ---------------------------------------------------------------------------
|
|
1523 |
// TAknFepInputMiniQwertyPinyinPhraseBase::RefreshCandidate
|
|
1524 |
// Refresh candidate
|
|
1525 |
// ---------------------------------------------------------------------------
|
|
1526 |
//
|
|
1527 |
void TAknFepInputMiniQwertyPinyinPhraseBase::RefreshCandidate()
|
|
1528 |
{
|
|
1529 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1530 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
1531 |
uiContainer->Enable(ETrue);
|
|
1532 |
|
|
1533 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
|
|
1534 |
uiContainer->CandidatePane()->IsFirstPage());
|
|
1535 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
1536 |
|
|
1537 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
1538 |
UpdateIndicator();
|
|
1539 |
}
|
|
1540 |
|
|
1541 |
// ---------------------------------------------------------------------------
|
|
1542 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckKeyNeedRepeat
|
|
1543 |
// Check key whether need repeat.
|
|
1544 |
// ---------------------------------------------------------------------------
|
|
1545 |
//
|
|
1546 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckKeyNeedRepeat(
|
|
1547 |
TKeyPressLength aLength)
|
|
1548 |
{
|
|
1549 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
1550 |
if (editPane->IsChangeState() && aLength == ELongKeyPress)
|
|
1551 |
{
|
|
1552 |
return EFalse;
|
|
1553 |
}
|
|
1554 |
else
|
|
1555 |
{
|
|
1556 |
editPane->SetChangeState(EFalse);
|
|
1557 |
}
|
|
1558 |
return ETrue;
|
|
1559 |
}
|
|
1560 |
|
|
1561 |
// ---------------------------------------------------------------------------
|
|
1562 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CommitInlineEEPL
|
|
1563 |
// Commint text to EEP or editor
|
|
1564 |
// ---------------------------------------------------------------------------
|
|
1565 |
//
|
|
1566 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CommitInlineEEPL(
|
|
1567 |
const TDesC& aDes)
|
|
1568 |
{
|
|
1569 |
TInt charCount = aDes.Length();
|
|
1570 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
1571 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
|
|
1572 |
CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray();
|
|
1573 |
CDesCArrayFlat* keyStoke = editpane->KeystrokeArray();
|
|
1574 |
CDesCArrayFlat* phraseArray = editpane->PhraseArray();
|
|
1575 |
CDesCArrayFlat* phraseShowKeyStroke = editpane->PhraseShowKeyStrokeArray();
|
|
1576 |
TBuf<KMaxKeystrokeCount> buf;
|
|
1577 |
TBuf<1> autoDLT;
|
|
1578 |
autoDLT.Append(KAutoDLT);
|
|
1579 |
|
|
1580 |
if (phraseArray->Count() == 0)
|
|
1581 |
{
|
|
1582 |
editpane->SetPhraseCreationFlag(EFalse);
|
|
1583 |
}
|
|
1584 |
phraseArray->AppendL(aDes);
|
|
1585 |
|
|
1586 |
TInt delCount = 0;
|
|
1587 |
for (TInt i = 0; i < showkeyStoke->Count() && charCount
|
|
1588 |
&& keyStoke->Count() != 0; i++)
|
|
1589 |
{
|
|
1590 |
TPtrC showptr = showkeyStoke->MdcaPoint(i);
|
|
1591 |
TPtrC ptr = keyStoke->MdcaPoint( 0);
|
|
1592 |
if (CheckSpellingDLT(showptr) || (KInvalidToneMark
|
|
1593 |
!= ToneMark(showptr) ))
|
|
1594 |
{
|
|
1595 |
charCount--;
|
|
1596 |
}
|
|
1597 |
if (showptr.Compare(autoDLT) != 0)
|
|
1598 |
{
|
|
1599 |
buf.Append(ptr);
|
|
1600 |
keyStoke->Delete( 0);
|
|
1601 |
}
|
|
1602 |
delCount++;
|
|
1603 |
}
|
|
1604 |
|
|
1605 |
for (TInt j = 0; j < delCount; j++)
|
|
1606 |
{
|
|
1607 |
showkeyStoke->Delete( 0);
|
|
1608 |
}
|
|
1609 |
phraseShowKeyStroke->AppendL(buf);
|
|
1610 |
|
|
1611 |
TInt phraseCount = phraseArray->Count();
|
|
1612 |
if (phraseCount > KMaxPhraseCreationCount)
|
|
1613 |
{
|
|
1614 |
phraseCount = KMaxPhraseCreationCount;
|
|
1615 |
}
|
|
1616 |
|
|
1617 |
if (keyStoke->Count() == 0 || phraseCount == KMaxPhraseCreationCount)
|
|
1618 |
{
|
|
1619 |
//here,we pass pinyin-spelling to db together with phrase.
|
|
1620 |
TBuf<KMaxPhraseCreationCount> phraseCreated;
|
|
1621 |
phraseCreated.FillZ();
|
|
1622 |
TBuf<(1+KMaxSpellLength)*KMaxPhraseCreationCount> phraseCreatedWithPinYin;//(Zi+pinyin)* max_Zi
|
|
1623 |
phraseCreatedWithPinYin.FillZ();
|
|
1624 |
for (TInt ii = 0; ii < phraseCount; ++ii)
|
|
1625 |
{
|
|
1626 |
TPtrC ptrZi = phraseArray->MdcaPoint(ii);
|
|
1627 |
phraseCreatedWithPinYin.Append(ptrZi);
|
|
1628 |
phraseCreated.Append(ptrZi);
|
|
1629 |
|
|
1630 |
TPtrC ptrPinYin = phraseShowKeyStroke->MdcaPoint(ii);//it mabe include KManualDLT,but no matter
|
|
1631 |
phraseCreatedWithPinYin.Append(ptrPinYin);
|
|
1632 |
|
|
1633 |
TInt zeroTail = (1+KMaxSpellLength)-(ptrZi.Length()+ptrPinYin.Length());
|
|
1634 |
phraseCreatedWithPinYin.AppendFill(0,zeroTail);
|
|
1635 |
|
|
1636 |
}
|
|
1637 |
fepMan->NewTextL(phraseCreated);
|
|
1638 |
fepMan->CommitInlineEditL();
|
|
1639 |
iOwner->PtiEngine()->SetPredictiveChineseChar(phraseCreated);
|
|
1640 |
AddPhraseToDB(phraseCreatedWithPinYin);
|
|
1641 |
return EFalse;
|
|
1642 |
}
|
|
1643 |
|
|
1644 |
|
|
1645 |
|
|
1646 |
editpane->SetCursorIndexOfKeystroke( 0);
|
|
1647 |
editpane->DisableCursor();
|
|
1648 |
editpane->SetPhraseCreationFlag(ETrue);
|
|
1649 |
return ETrue;
|
|
1650 |
}
|
|
1651 |
// ---------------------------------------------------------
|
|
1652 |
// TAknFepInputMiniQwertyPinyinPhraseBase::ClearPtiEngineKeystroke
|
|
1653 |
// clear the ptiengine keystroke;
|
|
1654 |
// ---------------------------------------------------------
|
|
1655 |
//
|
|
1656 |
void TAknFepInputMiniQwertyPinyinPhraseBase::ClearPtiEngineKeystroke()
|
|
1657 |
{
|
|
1658 |
iOwner->PtiEngine()->ClearCurrentWord();
|
|
1659 |
}
|
|
1660 |
|
|
1661 |
// ---------------------------------------------------------
|
|
1662 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AddKeystrokeL
|
|
1663 |
// Add keystroke.
|
|
1664 |
// ---------------------------------------------------------
|
|
1665 |
//
|
|
1666 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::AddKeystrokeL(TInt aKey)
|
|
1667 |
{
|
|
1668 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1669 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1670 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray();
|
|
1671 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
1672 |
TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count();
|
|
1673 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
1674 |
TBuf<1> keystroke;
|
|
1675 |
|
|
1676 |
if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount )
|
|
1677 |
{
|
|
1678 |
return EFalse;
|
|
1679 |
}
|
|
1680 |
|
|
1681 |
GetShowKeystroke(aKey, keystroke);
|
|
1682 |
if ( index >= keystrokeArray->Count() )
|
|
1683 |
{
|
|
1684 |
keystrokeArray->AppendL(keystroke);
|
|
1685 |
editPane->SetCursorIndexOfKeystroke(keystrokeArray->Count() );
|
|
1686 |
}
|
|
1687 |
else
|
|
1688 |
{
|
|
1689 |
keystrokeArray->InsertL(index, keystroke);
|
|
1690 |
editPane->SetCursorIndexOfKeystroke(index + 1);
|
|
1691 |
}
|
|
1692 |
|
|
1693 |
if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount - 1 )
|
|
1694 |
{
|
|
1695 |
AnalyseL();
|
|
1696 |
if ( phraseCount + editPane->ShowKeystrokeArray()->Count() <= KMaxKeystrokeCount )
|
|
1697 |
{
|
|
1698 |
return ETrue;
|
|
1699 |
}
|
|
1700 |
else
|
|
1701 |
{
|
|
1702 |
keystrokeArray->Delete( index );
|
|
1703 |
editPane->SetCursorIndexOfKeystroke( index );
|
|
1704 |
AnalyseL();
|
|
1705 |
return EFalse;
|
|
1706 |
}
|
|
1707 |
}
|
|
1708 |
|
|
1709 |
|
|
1710 |
return ETrue;
|
|
1711 |
}
|
|
1712 |
|
|
1713 |
// ---------------------------------------------------------
|
|
1714 |
// TAknFepInputMiniQwertyPinyinPhraseBase::AddToneMarkL
|
|
1715 |
// Add tone mark.
|
|
1716 |
// ---------------------------------------------------------
|
|
1717 |
//
|
|
1718 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::AddToneMarkL()
|
|
1719 |
{
|
|
1720 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1721 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1722 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray();
|
|
1723 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
1724 |
TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count();
|
|
1725 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
1726 |
TInt i = 0;
|
|
1727 |
const TInt MaxToneMark = 4;
|
|
1728 |
if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount )
|
|
1729 |
{
|
|
1730 |
if ( 0 == index )
|
|
1731 |
{
|
|
1732 |
return EFalse;
|
|
1733 |
}
|
|
1734 |
else
|
|
1735 |
{
|
|
1736 |
if ( KInvalidToneMark == ToneMark( keystrokeArray->MdcaPoint( index - 1 ) ) )
|
|
1737 |
{
|
|
1738 |
return EFalse;
|
|
1739 |
}
|
|
1740 |
}
|
|
1741 |
}
|
|
1742 |
|
|
1743 |
TBuf<1> toneMark;
|
|
1744 |
|
|
1745 |
if ( 0 == index )
|
|
1746 |
{
|
|
1747 |
toneMark.Append(PinyinToneMap[0].iValue);
|
|
1748 |
keystrokeArray->InsertL( 0, toneMark);
|
|
1749 |
editPane->SetCursorIndexOfKeystroke( 1);
|
|
1750 |
return ETrue;
|
|
1751 |
}
|
|
1752 |
|
|
1753 |
TInt num = sizeof(PinyinToneMap )/( sizeof(PinyinToneMap[0]));
|
|
1754 |
for ( i = 0; i < num; ++i )
|
|
1755 |
{
|
|
1756 |
if (PinyinToneMap[i].iValue == keystrokeArray->MdcaPoint( index - 1 )[0])
|
|
1757 |
{
|
|
1758 |
break;
|
|
1759 |
}
|
|
1760 |
}
|
|
1761 |
|
|
1762 |
if ( i > MaxToneMark )
|
|
1763 |
{
|
|
1764 |
toneMark.Append(PinyinToneMap[0].iValue);
|
|
1765 |
keystrokeArray->InsertL(index, toneMark);
|
|
1766 |
editPane->SetCursorIndexOfKeystroke( index + 1 );
|
|
1767 |
}
|
|
1768 |
else
|
|
1769 |
{
|
|
1770 |
if ( MaxToneMark == i )
|
|
1771 |
{
|
|
1772 |
toneMark.Append(PinyinToneMap[0].iValue);
|
|
1773 |
}
|
|
1774 |
else
|
|
1775 |
{
|
|
1776 |
toneMark.Append(PinyinToneMap[ i + 1 ].iValue);
|
|
1777 |
}
|
|
1778 |
keystrokeArray->Delete(index - 1);
|
|
1779 |
keystrokeArray->InsertL(index - 1, toneMark);
|
|
1780 |
}
|
|
1781 |
|
|
1782 |
if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount - 1 )
|
|
1783 |
{
|
|
1784 |
AnalyseL();
|
|
1785 |
if ( phraseCount + editPane->ShowKeystrokeArray()->Count() > KMaxKeystrokeCount )
|
|
1786 |
{
|
|
1787 |
if ( i > MaxToneMark )
|
|
1788 |
{
|
|
1789 |
keystrokeArray->Delete( index );
|
|
1790 |
editPane->SetCursorIndexOfKeystroke( index );
|
|
1791 |
}
|
|
1792 |
else
|
|
1793 |
{
|
|
1794 |
toneMark.Zero();
|
|
1795 |
toneMark.Append( PinyinToneMap[i].iValue );
|
|
1796 |
keystrokeArray->Delete( index - 1 );
|
|
1797 |
keystrokeArray->InsertL( index - 1, toneMark );
|
|
1798 |
}
|
|
1799 |
AnalyseL();
|
|
1800 |
return EFalse;
|
|
1801 |
}
|
|
1802 |
}
|
|
1803 |
|
|
1804 |
return ETrue;
|
|
1805 |
}
|
|
1806 |
|
|
1807 |
// ---------------------------------------------------------
|
|
1808 |
// TAknFepInputMiniQwertyPinyinPhraseBase::GetCandidateL
|
|
1809 |
// Get the candidate info.
|
|
1810 |
// ---------------------------------------------------------
|
|
1811 |
//
|
|
1812 |
void TAknFepInputMiniQwertyPinyinPhraseBase::GetCandidateL()
|
|
1813 |
{
|
|
1814 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
1815 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1816 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1817 |
CDesCArrayFlat* phraseCandidates =
|
|
1818 |
uiContainer->CandidatePane()->CandidateArray();
|
|
1819 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
1820 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
1821 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
1822 |
phraseCandidates->Reset();
|
|
1823 |
TBuf<KMaxKeystrokeCount> buf;
|
|
1824 |
TBuf<1> delimiter;
|
|
1825 |
delimiter.Append( KManualDLT );
|
|
1826 |
TInt keyCode;
|
|
1827 |
TInt count = KInvalidToneMark;
|
|
1828 |
ClearPtiEngineKeystroke();
|
|
1829 |
|
|
1830 |
if ( showKeystroke->Count() == 0 )
|
|
1831 |
{
|
|
1832 |
return;
|
|
1833 |
}
|
|
1834 |
|
|
1835 |
if ( CheckAllGroupStroke() && ( phraseCount == 0 ) )
|
|
1836 |
{
|
|
1837 |
getCurrentLeastDLTSpell();
|
|
1838 |
ptiengine->GetChinesePhraseCandidatesL( *phraseCandidates );
|
|
1839 |
return;
|
|
1840 |
}
|
|
1841 |
|
|
1842 |
if ( CheckFirstGroupStroke() )
|
|
1843 |
{
|
|
1844 |
ClearPtiEngineKeystroke();
|
|
1845 |
for ( TInt i = 0; i < showKeystroke->Count(); ++i )
|
|
1846 |
{
|
|
1847 |
count = ToneMark( keystroke->MdcaPoint( i ) );
|
|
1848 |
if ( CheckSpellingDLT( showKeystroke->MdcaPoint( i ) ) )
|
|
1849 |
{
|
|
1850 |
break;
|
|
1851 |
}
|
|
1852 |
else if ( KInvalidToneMark != count )
|
|
1853 |
{
|
|
1854 |
for ( TInt j = 0; j < count; ++j )
|
|
1855 |
{
|
|
1856 |
ptiengine->IncrementToneMark( ETrue );
|
|
1857 |
}
|
|
1858 |
break;
|
|
1859 |
}
|
|
1860 |
else
|
|
1861 |
{
|
|
1862 |
GetKeystrokeCode( keyCode, keystroke->MdcaPoint( i ) );
|
|
1863 |
ptiengine->AppendKeyPress((TPtiKey)keyCode);
|
|
1864 |
}
|
|
1865 |
}
|
|
1866 |
}
|
|
1867 |
else
|
|
1868 |
{
|
|
1869 |
return;
|
|
1870 |
}
|
|
1871 |
getCurrentLeastDLTSpell();
|
|
1872 |
ptiengine->GetChinesePhraseCandidatesL( *phraseCandidates );
|
|
1873 |
}
|
|
1874 |
|
|
1875 |
// ---------------------------------------------------------
|
|
1876 |
// TAknFepInputMiniQwertyPinyinPhraseBase::GetKeystrokeCode
|
|
1877 |
// get Code of the key stroke.
|
|
1878 |
// ---------------------------------------------------------
|
|
1879 |
//
|
|
1880 |
void TAknFepInputMiniQwertyPinyinPhraseBase::GetKeystrokeCode(TInt& aKey,
|
|
1881 |
const TDesC& aKeystroke)
|
|
1882 |
{
|
|
1883 |
TInt count = sizeof(StrokeMap )/sizeof(StrokeMap[0] );
|
|
1884 |
for (TInt i = 0; i < count; i++)
|
|
1885 |
{
|
|
1886 |
TBuf<1> buf;
|
|
1887 |
buf.Append(StrokeMap[i].iValue);
|
|
1888 |
if (0 == aKeystroke.Compare(buf))
|
|
1889 |
{
|
|
1890 |
aKey = StrokeMap[i].iKeyCode;
|
|
1891 |
break;
|
|
1892 |
}
|
|
1893 |
}
|
|
1894 |
}
|
|
1895 |
|
|
1896 |
// ---------------------------------------------------------
|
|
1897 |
// TAknFepInputMiniQwertyPinyinPhraseBase::RevertPhraseToKeystrokeL
|
|
1898 |
// Revert the phrase to keystroke.
|
|
1899 |
// ---------------------------------------------------------
|
|
1900 |
//
|
|
1901 |
void TAknFepInputMiniQwertyPinyinPhraseBase::RevertPhraseToKeystrokeL()
|
|
1902 |
{
|
|
1903 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1904 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
1905 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray();
|
|
1906 |
CDesCArrayFlat* shownKeystrokeArray = editPane->ShowKeystrokeArray();
|
|
1907 |
CDesCArrayFlat* phrase = editPane->PhraseArray();
|
|
1908 |
CDesCArrayFlat* phraseStroke = editPane->PhraseShowKeyStrokeArray();
|
|
1909 |
TBuf<KMaxKeystrokeCount> buf;
|
|
1910 |
if ( (phrase->Count() == 0 ) || (phraseStroke->Count() == 0 ))
|
|
1911 |
{
|
|
1912 |
return;
|
|
1913 |
}
|
|
1914 |
|
|
1915 |
buf.Append(phraseStroke->MdcaPoint(phraseStroke->Count() - 1) );
|
|
1916 |
for (TInt i = buf.Length() - 1; i >= 0; --i)
|
|
1917 |
{
|
|
1918 |
keystrokeArray->InsertL( 0, buf.Mid(i, 1) );
|
|
1919 |
}
|
|
1920 |
phrase->Delete(phrase->Count() - 1);
|
|
1921 |
phraseStroke->Delete(phraseStroke->Count() - 1);
|
|
1922 |
AnalyseL();
|
|
1923 |
TInt showCount = editPane->ShowKeystrokeArray()->Count();
|
|
1924 |
TInt leng = phrase->Count() + showCount;
|
|
1925 |
TInt deleteCount = 0;
|
|
1926 |
if (leng > KMaxKeystrokeCount)
|
|
1927 |
{
|
|
1928 |
for (TInt i = 0; i < leng - KMaxKeystrokeCount; ++i)
|
|
1929 |
{
|
|
1930 |
if (KAutoDLT != shownKeystrokeArray->MdcaPoint( shownKeystrokeArray->Count() - 1 )[0])
|
|
1931 |
{
|
|
1932 |
deleteCount = deleteCount + 1;
|
|
1933 |
}
|
|
1934 |
shownKeystrokeArray->Delete(shownKeystrokeArray->Count() - 1);
|
|
1935 |
}
|
|
1936 |
if (KAutoDLT == shownKeystrokeArray->MdcaPoint( shownKeystrokeArray->Count() - 1 )[0])
|
|
1937 |
{
|
|
1938 |
shownKeystrokeArray->Delete(shownKeystrokeArray->Count() - 1);
|
|
1939 |
}
|
|
1940 |
}
|
|
1941 |
for (TInt i = 0; i < deleteCount; ++i)
|
|
1942 |
{
|
|
1943 |
keystrokeArray->Delete(keystrokeArray->Count() - 1);
|
|
1944 |
}
|
|
1945 |
|
|
1946 |
editPane->SetCursorIndexOfKeystroke(buf.Length() );
|
|
1947 |
keystrokeArray->Compress();
|
|
1948 |
phrase->Compress();
|
|
1949 |
phraseStroke->Compress();
|
|
1950 |
|
|
1951 |
}
|
|
1952 |
|
|
1953 |
// ---------------------------------------------------------
|
|
1954 |
// TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor
|
|
1955 |
// Set warning color.
|
|
1956 |
// ---------------------------------------------------------
|
|
1957 |
//
|
|
1958 |
void TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor(
|
|
1959 |
TInt aCount,
|
|
1960 |
TInt aIndex,
|
|
1961 |
TInt aI,
|
|
1962 |
TInt aPhraseCount,
|
|
1963 |
TInt aToneMark,
|
|
1964 |
TBool aValid,
|
|
1965 |
CDesCArrayFlat* aShowKeystroke
|
|
1966 |
)
|
|
1967 |
{
|
|
1968 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
1969 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
1970 |
if ( ( !aValid ) || CheckSpellingDLT(aShowKeystroke->MdcaPoint(aI
|
|
1971 |
- 1) ) || (KInvalidToneMark
|
|
1972 |
!= ToneMark( aShowKeystroke->MdcaPoint( aI - 1 ) ) ))
|
|
1973 |
{
|
|
1974 |
editPane->SetHighlight(aPhraseCount + aIndex, aPhraseCount
|
|
1975 |
+ aIndex + aCount - 1 );
|
|
1976 |
}
|
|
1977 |
else
|
|
1978 |
{
|
|
1979 |
TPtrC ptr1 = getCurrentLeastDLTSpell();
|
|
1980 |
for (TInt j = 0; j < aToneMark; ++j)
|
|
1981 |
{
|
|
1982 |
ptiengine->IncrementToneMark(ETrue);
|
|
1983 |
TPtrC ptr0 = getCurrentLeastDLTSpell();
|
|
1984 |
if (ptr0.Length() > 0)
|
|
1985 |
{
|
|
1986 |
if ( 0 == ptr0.Mid( ptr0.Length() - 1, 1 ).
|
|
1987 |
Compare(aShowKeystroke->MdcaPoint( aI ) ) )
|
|
1988 |
{
|
|
1989 |
break;
|
|
1990 |
}
|
|
1991 |
}
|
|
1992 |
}
|
|
1993 |
TPtrC ptr2 = getCurrentLeastDLTSpell();
|
|
1994 |
if ( ( ( 1 + ptr1.Length() ) != ptr2.Length() ) || ( 0
|
|
1995 |
!= ptr2.Mid( ptr2.Length() - 1, 1 ).
|
|
1996 |
CompareC( aShowKeystroke->MdcaPoint( aI ) ) ))
|
|
1997 |
{
|
|
1998 |
editPane->SetHighlight( aPhraseCount + aIndex, aPhraseCount
|
|
1999 |
+ aIndex + aCount - 1);
|
|
2000 |
}
|
|
2001 |
}
|
|
2002 |
ClearPtiEngineKeystroke();
|
|
2003 |
}
|
|
2004 |
|
|
2005 |
// ---------------------------------------------------------
|
|
2006 |
// TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor
|
|
2007 |
// Set warning color.
|
|
2008 |
// ---------------------------------------------------------
|
|
2009 |
//
|
|
2010 |
void TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor()
|
|
2011 |
{
|
|
2012 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2013 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
2014 |
CDesCArrayFlat* showKeystroke = editPane->ShowKeystrokeArray();
|
|
2015 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
2016 |
TBool valid = ETrue;
|
|
2017 |
TInt index = 0;
|
|
2018 |
TInt count = 0;
|
|
2019 |
TInt stringBeforeLength = 0;
|
|
2020 |
TInt stringAfterLength = 0;
|
|
2021 |
TInt start = 0;
|
|
2022 |
TInt keyCode = 0;
|
|
2023 |
TInt toneMark = KInvalidToneMark;
|
|
2024 |
|
|
2025 |
if (showKeystroke->Count() == 0)
|
|
2026 |
{
|
|
2027 |
return;
|
|
2028 |
}
|
|
2029 |
|
|
2030 |
if (CheckAllGroupStroke() )
|
|
2031 |
{
|
|
2032 |
return;
|
|
2033 |
}
|
|
2034 |
ClearPtiEngineKeystroke();
|
|
2035 |
if (CheckSpellingDLT(showKeystroke->MdcaPoint( 0) ) || (KInvalidToneMark
|
|
2036 |
!= ToneMark(showKeystroke->MdcaPoint( 0) ) ))
|
|
2037 |
{
|
|
2038 |
start = 1;
|
|
2039 |
editPane->SetHighlight(phraseCount, phraseCount);
|
|
2040 |
index = 1;
|
|
2041 |
}
|
|
2042 |
|
|
2043 |
for ( TInt i = start; i < showKeystroke->Count(); ++i )
|
|
2044 |
{
|
|
2045 |
count = count + 1;
|
|
2046 |
// tone mark
|
|
2047 |
toneMark = ToneMark(showKeystroke->MdcaPoint(i) );
|
|
2048 |
if ( KInvalidToneMark != toneMark )
|
|
2049 |
{
|
|
2050 |
SetWarningColor( count,
|
|
2051 |
index,
|
|
2052 |
i,
|
|
2053 |
phraseCount,
|
|
2054 |
toneMark,
|
|
2055 |
valid,
|
|
2056 |
showKeystroke );
|
|
2057 |
index = i + 1;
|
|
2058 |
count = 0;
|
|
2059 |
valid = ETrue;
|
|
2060 |
}
|
|
2061 |
else
|
|
2062 |
if ( CheckSpellingDLT(showKeystroke->MdcaPoint(i) ) )
|
|
2063 |
{
|
|
2064 |
if ( ( !valid )
|
|
2065 |
|| CheckSpellingDLT(showKeystroke->MdcaPoint(i - 1) )
|
|
2066 |
|| (KInvalidToneMark
|
|
2067 |
!= ToneMark(showKeystroke->MdcaPoint(i - 1) ) ))
|
|
2068 |
{
|
|
2069 |
editPane->SetHighlight(phraseCount + index, phraseCount
|
|
2070 |
+ index + count - 1);
|
|
2071 |
}
|
|
2072 |
ClearPtiEngineKeystroke();
|
|
2073 |
index = i + 1;
|
|
2074 |
count = 0;
|
|
2075 |
valid = ETrue;
|
|
2076 |
}
|
|
2077 |
else
|
|
2078 |
{
|
|
2079 |
if ( valid )
|
|
2080 |
{
|
|
2081 |
GetKeystrokeCode(keyCode, showKeystroke->MdcaPoint(i) );
|
|
2082 |
stringBeforeLength = getCurrentLeastDLTSpell().Length();
|
|
2083 |
ptiengine->AppendKeyPress((TPtiKey)keyCode).Length();
|
|
2084 |
stringAfterLength = getCurrentLeastDLTSpell().Length();
|
|
2085 |
if ( stringBeforeLength == stringAfterLength )//the keystroke is invalid
|
|
2086 |
{
|
|
2087 |
ClearPtiEngineKeystroke();
|
|
2088 |
valid = EFalse;
|
|
2089 |
}
|
|
2090 |
}
|
|
2091 |
}
|
|
2092 |
|
|
2093 |
if ( ( showKeystroke->Count() == i + 1 ) && ( !valid ) )
|
|
2094 |
{
|
|
2095 |
editPane->SetHighlight(
|
|
2096 |
phraseCount + index,
|
|
2097 |
phraseCount + index + count - 1 );
|
|
2098 |
ClearPtiEngineKeystroke();
|
|
2099 |
}
|
|
2100 |
}
|
|
2101 |
}
|
|
2102 |
|
|
2103 |
// ---------------------------------------------------------
|
|
2104 |
// TAknFepInputMiniQwertyPinyinPhraseBase::SetWarningColor
|
|
2105 |
// Set warning color.
|
|
2106 |
// ---------------------------------------------------------
|
|
2107 |
//
|
|
2108 |
void TAknFepInputMiniQwertyPinyinPhraseBase::ChangeCbaL()
|
|
2109 |
{
|
|
2110 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan( );
|
|
2111 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow( );
|
|
2112 |
TInt candidateCount = UIContainer()->CandidatePane()->CandidateArray()->Count( );
|
|
2113 |
TInt keyStrokeCount = editPane->KeystrokeArray()->Count( );
|
|
2114 |
TInt phraseCount = editPane->PhraseArray()->Count( );
|
|
2115 |
TInt currentCBAResId = editPane->GetCurrentCBAResID( );
|
|
2116 |
if ( (candidateCount == 0 && keyStrokeCount != 0 ) || (phraseCount == 1
|
|
2117 |
&& keyStrokeCount == 0 ) )
|
|
2118 |
{
|
|
2119 |
if ( R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY != currentCBAResId )
|
|
2120 |
{
|
|
2121 |
fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY );
|
|
2122 |
editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_EMPTY );
|
|
2123 |
}
|
|
2124 |
|
|
2125 |
}
|
|
2126 |
else if ( keyStrokeCount == 0 )
|
|
2127 |
{
|
|
2128 |
if ( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE != currentCBAResId )
|
|
2129 |
{
|
|
2130 |
fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
2131 |
editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
2132 |
}
|
|
2133 |
}
|
|
2134 |
else if ( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL != currentCBAResId )
|
|
2135 |
{
|
|
2136 |
fepMan->UpdateCbaL( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL );
|
|
2137 |
editPane->SetCurrentCBAResID( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL );
|
|
2138 |
}
|
|
2139 |
}
|
|
2140 |
|
|
2141 |
// ---------------------------------------------------------
|
|
2142 |
// TAknFepInputMiniQwertyPinyinPhraseBase::MoveCursorLeft
|
|
2143 |
// Move the cursor to Left.
|
|
2144 |
// ---------------------------------------------------------
|
|
2145 |
//
|
|
2146 |
void TAknFepInputMiniQwertyPinyinPhraseBase::MoveCursorLeft()
|
|
2147 |
{
|
|
2148 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
2149 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
2150 |
CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray();
|
|
2151 |
TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count();
|
|
2152 |
TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke();
|
|
2153 |
TInt cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count();
|
|
2154 |
|
|
2155 |
TBuf<1> autoDLT;
|
|
2156 |
autoDLT.Append(KAutoDLT);
|
|
2157 |
const TInt offset = 2;
|
|
2158 |
if (cursorPos <= 0)
|
|
2159 |
{
|
|
2160 |
cursorPos = 0;
|
|
2161 |
}
|
|
2162 |
else
|
|
2163 |
if (cursorPos >= showKeyStokeCount)
|
|
2164 |
{
|
|
2165 |
cursorPos = showKeyStokeCount;
|
|
2166 |
}
|
|
2167 |
|
|
2168 |
if (cursorPos == 0)
|
|
2169 |
{
|
|
2170 |
editPane->SetCursorIndexOfKeystroke(editPane->KeystrokeArray()->Count() );
|
|
2171 |
ShowInfoOnEEPPane();
|
|
2172 |
SetWarningColor();
|
|
2173 |
}
|
|
2174 |
else
|
|
2175 |
if (cursorPos == 1)
|
|
2176 |
{
|
|
2177 |
editPane->SetCursorIndexOfKeystroke( 0);
|
|
2178 |
ShowInfoOnEEPPane();
|
|
2179 |
SetWarningColor();
|
|
2180 |
}
|
|
2181 |
else
|
|
2182 |
{
|
|
2183 |
if (showKeyStoke->MdcaPoint( cursorPos - 2 ).Compare(autoDLT) == 0)
|
|
2184 |
{
|
|
2185 |
editPane->MoveCursorLeft(offset);
|
|
2186 |
editPane->SetCursorIndexOfKeystroke(indexOfKeystroke - 1);
|
|
2187 |
}
|
|
2188 |
else
|
|
2189 |
{
|
|
2190 |
editPane->MoveCursorLeft();
|
|
2191 |
editPane->SetCursorIndexOfKeystroke(indexOfKeystroke - 1);
|
|
2192 |
}
|
|
2193 |
}
|
|
2194 |
}
|
|
2195 |
|
|
2196 |
// ---------------------------------------------------------
|
|
2197 |
// TAknFepInputMiniQwertyPinyinPhraseBase::MoveCursorRight
|
|
2198 |
// Move the cursor to Right.
|
|
2199 |
// ---------------------------------------------------------
|
|
2200 |
//
|
|
2201 |
void TAknFepInputMiniQwertyPinyinPhraseBase::MoveCursorRight()
|
|
2202 |
{
|
|
2203 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
2204 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
2205 |
CDesCArrayFlat* showKeyStoke = editPane->ShowKeystrokeArray();
|
|
2206 |
TInt showKeyStokeCount = editPane->ShowKeystrokeArray()->Count();
|
|
2207 |
TInt indexOfKeystroke = editPane->GetCursorIndexOfKeystroke();
|
|
2208 |
TInt cursorPos = editPane->GetCursor() - editPane->PhraseArray()->Count();
|
|
2209 |
TBuf<1> autoDLT;
|
|
2210 |
autoDLT.Append(KAutoDLT);
|
|
2211 |
const TInt offset = 2;
|
|
2212 |
|
|
2213 |
if (cursorPos <= 0)
|
|
2214 |
{
|
|
2215 |
cursorPos = 0;
|
|
2216 |
}
|
|
2217 |
else
|
|
2218 |
if (cursorPos >= showKeyStokeCount)
|
|
2219 |
{
|
|
2220 |
cursorPos = showKeyStokeCount;
|
|
2221 |
}
|
|
2222 |
|
|
2223 |
if (cursorPos == showKeyStokeCount)
|
|
2224 |
{
|
|
2225 |
editPane->SetCursorIndexOfKeystroke( 0);
|
|
2226 |
ShowInfoOnEEPPane();
|
|
2227 |
SetWarningColor();
|
|
2228 |
}
|
|
2229 |
else
|
|
2230 |
if (cursorPos == showKeyStokeCount - 1)
|
|
2231 |
{
|
|
2232 |
editPane->MoveCursorRight();
|
|
2233 |
editPane->SetCursorIndexOfKeystroke(editPane->KeystrokeArray()->Count() );
|
|
2234 |
ShowInfoOnEEPPane();
|
|
2235 |
SetWarningColor();
|
|
2236 |
}
|
|
2237 |
else
|
|
2238 |
{
|
|
2239 |
if (showKeyStoke->MdcaPoint( cursorPos ).Compare(autoDLT) == 0)
|
|
2240 |
{
|
|
2241 |
editPane->MoveCursorRight(offset);
|
|
2242 |
editPane->SetCursorIndexOfKeystroke(indexOfKeystroke + 1);
|
|
2243 |
}
|
|
2244 |
else
|
|
2245 |
{
|
|
2246 |
editPane->MoveCursorRight();
|
|
2247 |
editPane->SetCursorIndexOfKeystroke(indexOfKeystroke + 1);
|
|
2248 |
}
|
|
2249 |
}
|
|
2250 |
}
|
|
2251 |
|
|
2252 |
// ---------------------------------------------------------
|
|
2253 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpecialKey
|
|
2254 |
// Check the special keystroke( i,u,v ).
|
|
2255 |
// ---------------------------------------------------------
|
|
2256 |
//
|
|
2257 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpecialKey(const TInt aKey)
|
|
2258 |
{
|
|
2259 |
if ( (aKey == EPtiKeyQwertyI ) || (aKey == EPtiKeyQwertyU ) || (aKey
|
|
2260 |
== EPtiKeyQwertyV ))
|
|
2261 |
{
|
|
2262 |
return ETrue;
|
|
2263 |
}
|
|
2264 |
return EFalse;
|
|
2265 |
}
|
|
2266 |
|
|
2267 |
// ---------------------------------------------------------
|
|
2268 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpellingDLT
|
|
2269 |
// Check the delimiter of spelling.
|
|
2270 |
// ---------------------------------------------------------
|
|
2271 |
//
|
|
2272 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpellingDLT(
|
|
2273 |
const TDesC& aKeystroke)
|
|
2274 |
{
|
|
2275 |
if ( aKeystroke.Length() == 0 )
|
|
2276 |
{
|
|
2277 |
return EFalse;
|
|
2278 |
}
|
|
2279 |
|
|
2280 |
if ( ( KAutoDLT == aKeystroke[0] ) || ( KManualDLT == aKeystroke[0] ) )
|
|
2281 |
{
|
|
2282 |
return ETrue;
|
|
2283 |
}
|
|
2284 |
|
|
2285 |
return EFalse;
|
|
2286 |
}
|
|
2287 |
|
|
2288 |
// ---------------------------------------------------------
|
|
2289 |
// TAknFepInputMiniQwertyPinyinPhraseBase::ToneMark
|
|
2290 |
// Get pinyin tone mark.
|
|
2291 |
// ---------------------------------------------------------
|
|
2292 |
//
|
|
2293 |
TInt TAknFepInputMiniQwertyPinyinPhraseBase::ToneMark(const TDesC& aKeystroke)
|
|
2294 |
{
|
|
2295 |
TInt numOfToneMark = sizeof (PinyinToneMap)/sizeof(PinyinToneMap[0]);
|
|
2296 |
for (TInt i = 0; i < numOfToneMark; i++)
|
|
2297 |
{
|
|
2298 |
if (PinyinToneMap[i].iValue == aKeystroke[0])
|
|
2299 |
return PinyinToneMap[i].iInputTone;
|
|
2300 |
}
|
|
2301 |
return KInvalidToneMark;
|
|
2302 |
}
|
|
2303 |
|
|
2304 |
// ---------------------------------------------------------
|
|
2305 |
// TAknFepInputMiniQwertyPinyinPhraseBase::ToneMark
|
|
2306 |
// Get pinyin tone mark.
|
|
2307 |
// ---------------------------------------------------------
|
|
2308 |
//
|
|
2309 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpellingAddToneMarkToPTIL(
|
|
2310 |
const TInt aToneMark )
|
|
2311 |
{
|
|
2312 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2313 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
2314 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
2315 |
TBuf<1> toneMark;
|
|
2316 |
TBuf<1> delimiter;
|
|
2317 |
|
|
2318 |
toneMark.Append( PinyinToneMap[aToneMark - 1].iValue );
|
|
2319 |
delimiter.Append( KManualDLT );
|
|
2320 |
|
|
2321 |
for ( TInt i = 0; i < aToneMark; ++i )
|
|
2322 |
{
|
|
2323 |
ptiengine->IncrementToneMark(ETrue);
|
|
2324 |
TPtrC ptr = getCurrentLeastDLTSpell();
|
|
2325 |
if ( ( 0 == ptr.Mid( ptr.Length() - 1, 1 ).Compare( toneMark ) ) &&
|
|
2326 |
( KErrNotFound == ptr.Find( delimiter ) )
|
|
2327 |
)
|
|
2328 |
{
|
|
2329 |
return ETrue;
|
|
2330 |
}
|
|
2331 |
}
|
|
2332 |
|
|
2333 |
|
|
2334 |
return EFalse;
|
|
2335 |
}
|
|
2336 |
TPtrC TAknFepInputMiniQwertyPinyinPhraseBase::getCurrentLeastDLTSpell()
|
|
2337 |
{
|
|
2338 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2339 |
CDesC16ArrayFlat* allSpell = new CDesC16ArrayFlat(1);
|
|
2340 |
TPtrC currentSpell;
|
|
2341 |
TBuf<1> delimiter;
|
|
2342 |
TBuf<KMaxKeystrokeCount> preDltPosizeArr;
|
|
2343 |
TBuf<KMaxKeystrokeCount> curDltPosizeArr;
|
|
2344 |
preDltPosizeArr.FillZ(KMaxKeystrokeCount);
|
|
2345 |
preDltPosizeArr.SetLength(KMaxKeystrokeCount);
|
|
2346 |
curDltPosizeArr.FillZ(KMaxKeystrokeCount);
|
|
2347 |
curDltPosizeArr.SetLength(KMaxKeystrokeCount);
|
|
2348 |
|
|
2349 |
TInt index = 1;
|
|
2350 |
delimiter.Append( KManualDLT );
|
|
2351 |
TRAP_IGNORE( ptiengine->GetPhoneticSpellingsL(*allSpell));
|
|
2352 |
TInt allCount = ptiengine->PhoneticSpellingCount();
|
|
2353 |
|
|
2354 |
|
|
2355 |
for( TInt i = 0; i < allCount; i++)
|
|
2356 |
{
|
|
2357 |
|
|
2358 |
currentSpell.Set(allSpell->MdcaPoint(i));
|
|
2359 |
TInt dltIndex = 0;
|
|
2360 |
curDltPosizeArr.FillZ(KMaxKeystrokeCount);
|
|
2361 |
curDltPosizeArr.SetLength(KMaxKeystrokeCount);
|
|
2362 |
TInt preIndex = 0;
|
|
2363 |
for (TInt j = 0; j < currentSpell.Length(); j++)
|
|
2364 |
{
|
|
2365 |
|
|
2366 |
if (currentSpell.Mid(j, 1).Compare(delimiter) == 0 )
|
|
2367 |
{
|
|
2368 |
curDltPosizeArr[dltIndex] = j - preIndex - 1;
|
|
2369 |
preIndex = j;
|
|
2370 |
dltIndex++;
|
|
2371 |
}
|
|
2372 |
else if ((j+1) == currentSpell.Length())
|
|
2373 |
{
|
|
2374 |
curDltPosizeArr[dltIndex] = j - preIndex;
|
|
2375 |
}
|
|
2376 |
|
|
2377 |
}
|
|
2378 |
|
|
2379 |
for (TInt k = 0; k < KMaxKeystrokeCount; k++)
|
|
2380 |
{
|
|
2381 |
|
|
2382 |
if (preDltPosizeArr[k] < curDltPosizeArr[k] )
|
|
2383 |
{
|
|
2384 |
preDltPosizeArr.Copy(curDltPosizeArr);
|
|
2385 |
index = i + 1;
|
|
2386 |
break;
|
|
2387 |
}
|
|
2388 |
else if (preDltPosizeArr[k] > curDltPosizeArr[k] )
|
|
2389 |
{
|
|
2390 |
break;
|
|
2391 |
}
|
|
2392 |
}
|
|
2393 |
|
|
2394 |
}
|
|
2395 |
|
|
2396 |
if (allSpell)
|
|
2397 |
{
|
|
2398 |
delete allSpell;
|
|
2399 |
}
|
|
2400 |
ptiengine->SelectPhoneticSpelling( index );
|
|
2401 |
return ptiengine->GetPhoneticSpelling(index);
|
|
2402 |
|
|
2403 |
}
|
|
2404 |
// ---------------------------------------------------------
|
|
2405 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpellingAddKeyToPTIL
|
|
2406 |
// Check the spelling after add key to the PTI.
|
|
2407 |
// ---------------------------------------------------------
|
|
2408 |
//
|
|
2409 |
TInt TAknFepInputMiniQwertyPinyinPhraseBase::CheckSpellingAddKeyToPTIL(
|
|
2410 |
const TDesC& aKeystroke )
|
|
2411 |
{
|
|
2412 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2413 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
2414 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
2415 |
|
|
2416 |
TBuf<1> delimiter;
|
|
2417 |
TInt keyCode = 0;
|
|
2418 |
TInt stringBeforeLength = 0;
|
|
2419 |
TInt stringAfterLength = 0;
|
|
2420 |
TInt delimiterIndex = 0;
|
|
2421 |
delimiter.Append( KManualDLT );
|
|
2422 |
|
|
2423 |
GetKeystrokeCode( keyCode, aKeystroke );
|
|
2424 |
//get the string before append this keystroke
|
|
2425 |
TPtrC ptr = getCurrentLeastDLTSpell();
|
|
2426 |
stringBeforeLength = ptr.Length();
|
|
2427 |
//get the string after append this keystroke
|
|
2428 |
ptiengine->AppendKeyPress((TPtiKey)keyCode);
|
|
2429 |
TPtrC ptr1 = getCurrentLeastDLTSpell();
|
|
2430 |
stringAfterLength = ptr1.Length();
|
|
2431 |
|
|
2432 |
if ( stringBeforeLength != stringAfterLength )
|
|
2433 |
{
|
|
2434 |
TPtrC ptr = getCurrentLeastDLTSpell();
|
|
2435 |
if ( KErrNotFound == ptr.Find( delimiter ) )
|
|
2436 |
{
|
|
2437 |
return 0;
|
|
2438 |
}
|
|
2439 |
else
|
|
2440 |
{
|
|
2441 |
delimiterIndex = ptr.Length() - ptr.Find( delimiter ) - 1;
|
|
2442 |
return delimiterIndex;
|
|
2443 |
}
|
|
2444 |
}
|
|
2445 |
else
|
|
2446 |
{
|
|
2447 |
return -1;
|
|
2448 |
}
|
|
2449 |
}
|
|
2450 |
|
|
2451 |
// ---------------------------------------------------------
|
|
2452 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyFromCandidateL
|
|
2453 |
// Handle key from candidate.
|
|
2454 |
// ---------------------------------------------------------
|
|
2455 |
//
|
|
2456 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyFromCandidateL(
|
|
2457 |
TInt aKey, TKeyPressLength /*aLength*/)
|
|
2458 |
{
|
|
2459 |
TInt index = 0;
|
|
2460 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
2461 |
// it may be one of the 'valid' numbers..
|
|
2462 |
TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout();
|
|
2463 |
if (EPtiKeyboardQwerty4x10 == keyboardtype || EPtiKeyboardQwerty3x11
|
|
2464 |
== keyboardtype || EPtiKeyboardHalfQwerty == keyboardtype
|
|
2465 |
|| EPtiKeyboardCustomQwerty == keyboardtype)
|
|
2466 |
{
|
|
2467 |
MPtiLanguage *lang= NULL;
|
|
2468 |
RArray <TPtiNumericKeyBinding> keybinding;
|
|
2469 |
TBool validnumkey = EFalse;
|
|
2470 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2471 |
|
|
2472 |
if( ptiengine != NULL )
|
|
2473 |
{
|
|
2474 |
lang = ptiengine->CurrentLanguage();
|
|
2475 |
}
|
|
2476 |
if (ptiengine && lang)
|
|
2477 |
{
|
|
2478 |
TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardtype));
|
|
2479 |
TInt numericKeysCount = keybinding.Count();
|
|
2480 |
while (numericKeysCount--)
|
|
2481 |
{
|
|
2482 |
TPtiNumericKeyBinding numKeyBind =
|
|
2483 |
keybinding[numericKeysCount];
|
|
2484 |
if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36)
|
|
2485 |
&&(aKey == numKeyBind.iKey))
|
|
2486 |
{
|
|
2487 |
index = numKeyBind.iChar - EPtiKey0 -1;
|
|
2488 |
validnumkey = ETrue;
|
|
2489 |
break;
|
|
2490 |
}
|
|
2491 |
}
|
|
2492 |
}
|
|
2493 |
keybinding.Reset();
|
|
2494 |
keybinding.Close();
|
|
2495 |
if ( !validnumkey)
|
|
2496 |
{
|
|
2497 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
2498 |
return;
|
|
2499 |
}
|
|
2500 |
}
|
|
2501 |
else
|
|
2502 |
{
|
|
2503 |
#endif
|
|
2504 |
index = MapKeyToIndex(aKey);
|
|
2505 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
2506 |
}
|
|
2507 |
#endif
|
|
2508 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
2509 |
|
|
2510 |
if (candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey
|
|
2511 |
== EStdKeyEnter)
|
|
2512 |
{
|
|
2513 |
TPtrC text = candidatePane->CurrentPhraseCandidate();
|
|
2514 |
if (text.Length() )
|
|
2515 |
{
|
|
2516 |
if ( !CommitInlineEEPL(text) )
|
|
2517 |
{
|
|
2518 |
DoActionAfterCommit();
|
|
2519 |
}
|
|
2520 |
else
|
|
2521 |
{
|
|
2522 |
if (CheckFirstGroupStroke() )
|
|
2523 |
{
|
|
2524 |
RefreshUI(EFalse);
|
|
2525 |
UIContainer()->CandidatePane()->SelectFirstPhrase();
|
|
2526 |
}
|
|
2527 |
else
|
|
2528 |
{
|
|
2529 |
UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag(EAutoChangeStateFromCandidate);
|
|
2530 |
iOwner->ChangeState(EMiniQwertyEdit);
|
|
2531 |
}
|
|
2532 |
}
|
|
2533 |
}
|
|
2534 |
}
|
|
2535 |
}
|
|
2536 |
|
|
2537 |
// ---------------------------------------------------------
|
|
2538 |
// TAknFepInputMiniQwertyPinyinPhraseBase::CheckAllGroupStroke
|
|
2539 |
// check the all group stroke of keystroke.
|
|
2540 |
// ---------------------------------------------------------
|
|
2541 |
//
|
|
2542 |
TBool TAknFepInputMiniQwertyPinyinPhraseBase::CheckAllGroupStroke()
|
|
2543 |
{
|
|
2544 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
2545 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
2546 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
2547 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
2548 |
TInt phraseCount = editPane->PhraseArray()->Count();
|
|
2549 |
TInt keyCode = 0;
|
|
2550 |
TInt stringBeforeLength = 0;
|
|
2551 |
TInt stringAfterLength = 0;
|
|
2552 |
TInt toneMarkCount = KInvalidToneMark;
|
|
2553 |
|
|
2554 |
ClearPtiEngineKeystroke();
|
|
2555 |
|
|
2556 |
//If there is phrase on the entry pane then the all keystroke is invalid.
|
|
2557 |
if ( phraseCount > 0 )
|
|
2558 |
{
|
|
2559 |
return EFalse;
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
//If the first keystroke is delimiter or tone mark
|
|
2563 |
//then all keystroke is invalid.
|
|
2564 |
if ( ( keystroke->Count() == 0 )
|
|
2565 |
|| (CheckSpellingDLT(keystroke->MdcaPoint( 0 ) ) )
|
|
2566 |
|| (KInvalidToneMark != ToneMark(keystroke->MdcaPoint( 0 ) ) ) )
|
|
2567 |
{
|
|
2568 |
return EFalse;
|
|
2569 |
}
|
|
2570 |
|
|
2571 |
for (TInt i = 0; i < keystroke->Count(); ++i )
|
|
2572 |
{
|
|
2573 |
toneMarkCount = ToneMark(keystroke->MdcaPoint( i ) );
|
|
2574 |
if ( KInvalidToneMark != toneMarkCount )
|
|
2575 |
{
|
|
2576 |
if ( (CheckSpellingDLT(keystroke->MdcaPoint( i - 1 ) ) )
|
|
2577 |
|| (KInvalidToneMark != ToneMark(keystroke->MdcaPoint( i - 1 ) ) ) )
|
|
2578 |
{
|
|
2579 |
return EFalse;
|
|
2580 |
}
|
|
2581 |
for (TInt j =0; j < toneMarkCount; ++j)
|
|
2582 |
{
|
|
2583 |
ptiengine->IncrementToneMark(ETrue);
|
|
2584 |
TPtrC ptr1 = getCurrentLeastDLTSpell();
|
|
2585 |
if (ptr1.Length() > 0)
|
|
2586 |
{
|
|
2587 |
if ( 0 == ptr1.Mid( ptr1.Length() - 1 ).Compare(keystroke->MdcaPoint( i ) ) )
|
|
2588 |
{
|
|
2589 |
break;
|
|
2590 |
}
|
|
2591 |
}
|
|
2592 |
}
|
|
2593 |
TPtrC ptr = getCurrentLeastDLTSpell();
|
|
2594 |
if ( 0 != ptr.Mid( ptr.Length() - 1, 1 ).Compare(keystroke->MdcaPoint( i ) ) )
|
|
2595 |
{
|
|
2596 |
return EFalse;
|
|
2597 |
}
|
|
2598 |
}
|
|
2599 |
else
|
|
2600 |
{
|
|
2601 |
if ( (CheckSpellingDLT(keystroke->MdcaPoint( i ) ) )
|
|
2602 |
&& (KInvalidToneMark != ToneMark(keystroke->MdcaPoint( i - 1 ) ) ) )
|
|
2603 |
{
|
|
2604 |
return EFalse;
|
|
2605 |
}
|
|
2606 |
GetKeystrokeCode(keyCode, keystroke->MdcaPoint(i) );
|
|
2607 |
stringBeforeLength = getCurrentLeastDLTSpell().Length();
|
|
2608 |
ptiengine->AppendKeyPress((TPtiKey)keyCode).Length();
|
|
2609 |
stringAfterLength = getCurrentLeastDLTSpell().Length();
|
|
2610 |
if ( stringBeforeLength == stringAfterLength )
|
|
2611 |
{
|
|
2612 |
return EFalse;
|
|
2613 |
}
|
|
2614 |
}
|
|
2615 |
}
|
|
2616 |
|
|
2617 |
return ETrue;
|
|
2618 |
}
|
|
2619 |
|
|
2620 |
// ---------------------------------------------------------
|
|
2621 |
// TAknFepInputMiniQwertyPinyinPhraseBase::DoActionAfterCommit
|
|
2622 |
// Do action afer commit, change state to predictive or not.
|
|
2623 |
// ---------------------------------------------------------
|
|
2624 |
//
|
|
2625 |
void TAknFepInputMiniQwertyPinyinPhraseBase::DoActionAfterCommit()
|
|
2626 |
{
|
|
2627 |
TRAP_IGNORE( DoActionAfterCommitL() );
|
|
2628 |
}
|
|
2629 |
|
|
2630 |
// ---------------------------------------------------------
|
|
2631 |
// TAknFepInputMiniQwertyPinyinPhraseBase::DoActionAfterCommitL
|
|
2632 |
// Do action afer commit, change state to predictive or not.
|
|
2633 |
// ---------------------------------------------------------
|
|
2634 |
//
|
|
2635 |
void TAknFepInputMiniQwertyPinyinPhraseBase::DoActionAfterCommitL()
|
|
2636 |
{
|
|
2637 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
2638 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull) )
|
|
2639 |
{
|
|
2640 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2641 |
fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
|
|
2642 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2643 |
if (UIContainer()->EditPaneWindow()->KeystrokeArray()->Count() != 0)
|
|
2644 |
{
|
|
2645 |
UIContainer()->EditPaneWindow()->ResetAllArray();
|
|
2646 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2647 |
CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
|
|
2648 |
errnote->SetTone(CAknNoteDialog::EWarningTone);
|
|
2649 |
errnote->ExecuteLD(KMaxPhraseNote);
|
|
2650 |
}
|
|
2651 |
iOwner->FepMan()->TryCloseUiL();
|
|
2652 |
}
|
|
2653 |
else
|
|
2654 |
{
|
|
2655 |
if (UIContainer()->EditPaneWindow()->KeystrokeArray()->Count() != 0)
|
|
2656 |
{
|
|
2657 |
UIContainer()->EditPaneWindow()->ResetAllArray();
|
|
2658 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2659 |
CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
|
|
2660 |
errnote->SetTone(CAknNoteDialog::EWarningTone);
|
|
2661 |
errnote->ExecuteLD(KMaxPhraseNote);
|
|
2662 |
}
|
|
2663 |
else
|
|
2664 |
{
|
|
2665 |
UIContainer()->EditPaneWindow()->ResetAllArray();
|
|
2666 |
if ( !UIContainer()->EditPaneWindow()->GetPhraseCreationFlag() )
|
|
2667 |
{
|
|
2668 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2669 |
UIContainer()->EditPaneWindow()->SetChangeState(ETrue);
|
|
2670 |
iOwner->ChangeState(EPredictiveCandidate);
|
|
2671 |
}
|
|
2672 |
else
|
|
2673 |
{
|
|
2674 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag(EFalse);
|
|
2675 |
iOwner->FepMan()->TryCloseUiL();
|
|
2676 |
}
|
|
2677 |
}
|
|
2678 |
}
|
|
2679 |
}
|
|
2680 |
// ---------------------------------------------------------------------------
|
|
2681 |
// TAknFepInputMiniQwertyPinyinPhraseBase::HandleCommandL
|
|
2682 |
// Handling Command
|
|
2683 |
// ---------------------------------------------------------------------------
|
|
2684 |
//
|
|
2685 |
void TAknFepInputMiniQwertyPinyinPhraseBase::HandleCommandL( TInt aCommandId )
|
|
2686 |
{
|
|
2687 |
switch ( aCommandId )
|
|
2688 |
{
|
|
2689 |
// Handle the event frome command.
|
|
2690 |
case EAknSoftkeySelect:
|
|
2691 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
|
|
2692 |
HandleCommitL( );
|
|
2693 |
break;
|
|
2694 |
default:
|
|
2695 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
2696 |
break;
|
|
2697 |
}
|
|
2698 |
}
|
|
2699 |
// End of file
|