author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:59:06 +0300 | |
branch | RCL_3 |
changeset 46 | bd83ceabce89 |
parent 44 | ecbabf52600f |
child 50 | 5a1685599b76 |
permissions | -rw-r--r-- |
44 | 1 |
/* |
2 |
* Copyright (c) 2007 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 TAknFepInputStateEntryMiniQwertyZhuyinPhrase, |
|
16 |
* TAknFepInputStateEditingMiniQwertyZhuyinPhrase, |
|
17 |
* TAknFepUiInputStateCandidateMiniQwertyZhuyinPhrase methods. |
|
18 |
* |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
||
23 |
||
24 |
||
25 |
||
26 |
||
27 |
||
28 |
||
29 |
||
30 |
||
31 |
||
32 |
// System includes |
|
33 |
#include <PtiEngine.h> |
|
34 |
#include <PtiUserDicEntry.h> |
|
35 |
#include <aknnotewrappers.h> //CAknWarningNote |
|
36 |
#include <aknfep.rsg> |
|
37 |
||
38 |
// User includes |
|
39 |
#include "AknFepUiCtrlContainerChinese.h" |
|
40 |
#include "AknFepUICtrlCandidatePane.h" |
|
41 |
#include "AknFepUICtrlInputPane.h" |
|
42 |
#include "aknfepuictrleditpane.h" //phrase creation |
|
43 |
#include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase |
|
44 |
#include "AknFepUIManagerStateInterface.h" |
|
45 |
#include "AknFepManager.h" |
|
46 |
#include "aknfepuiinputstateminiqwertyzhuyinphrase.h" |
|
47 |
#include "aknfepinputstateminiqwertyzhuyinkeymap.h" |
|
48 |
||
49 |
const TInt KMaxKeystrokeCount = 31; |
|
50 |
const TInt KMaxKeystrokeSize = 130; |
|
51 |
const TInt KMaxPhraseLength = 7; |
|
52 |
const TInt KMinCandidateCount = 1; |
|
53 |
const TInt KKeystrokeMaxLength = 4; |
|
54 |
const TInt KMaxSpellLength = 7;//max zhuyin length for one chinese Zi |
|
55 |
const TInt KMaxPhraseCreationCount = 7; |
|
56 |
//const TInt KTonemarkCount = 5; |
|
57 |
||
58 |
const TUint16 KToneMark1 = 0x0020; |
|
59 |
const TUint16 KToneMark2 = 0x02CA; |
|
60 |
const TUint16 KToneMark3 = 0x02c7; |
|
61 |
const TUint16 KToneMark4 = 0x02CB; |
|
62 |
const TUint16 KToneMark5 = 0x02D9; |
|
63 |
||
64 |
_LIT(KLeftBracket, "("); |
|
65 |
_LIT(KRightBracket, ")"); |
|
66 |
_LIT(KReplace, ""); |
|
67 |
||
68 |
_LIT( KDelimiter, "'"); |
|
69 |
struct TToneZhuYinMap |
|
70 |
{ |
|
71 |
TUint16 iValue; |
|
72 |
TInt iInputTone; |
|
73 |
}; |
|
74 |
const TToneZhuYinMap ZhuyinToneMap[] = |
|
75 |
{ |
|
76 |
{KToneMark1, 1}, |
|
77 |
{KToneMark2, 2}, |
|
78 |
{KToneMark3, 3}, |
|
79 |
{KToneMark4, 4}, |
|
80 |
{KToneMark5, 5} |
|
81 |
}; |
|
82 |
// --------------------------------------------------------------------------- |
|
83 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::TAknFepInputStateEditingMiniQwertyZhuyinPhrase |
|
84 |
// C++ default constructor |
|
85 |
// --------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
TAknFepInputStateEditingMiniQwertyZhuyinPhrase::TAknFepInputStateEditingMiniQwertyZhuyinPhrase( |
|
88 |
MAknFepUIManagerStateInterface* aOwner, |
|
89 |
MAknFepUICtrlContainerChinese* aUIContainer ) : |
|
90 |
TAknFepInputMiniQwertyZhuyinPhraseBase( aOwner, aUIContainer) |
|
91 |
{ |
|
92 |
iState = EMiniQwertyEdit; |
|
93 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
94 |
uiContainer->FocusCandidatePane( EFalse ); |
|
95 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse ); |
|
96 |
uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutPhraseCreation ); |
|
97 |
uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
98 |
uiContainer->ShowVerticalScrollArrows( ETrue ); |
|
99 |
uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
100 |
uiContainer->InputPane()->SetOverrideFontId( 0 ); |
|
101 |
// in the case that we are coming back to the input pane from the candidate pane, |
|
102 |
// we need to ensure that the current selection is selected correctly |
|
103 |
ImplicityShowInfo( ETrue ); |
|
104 |
// so that it could handle EKeyCBA1 |
|
105 |
iOwner->FepMan()->EntryPhrase( ETrue ); |
|
106 |
RefreshEditPane(); |
|
107 |
uiContainer->PinyinPopupWindow()->SetNoneHighlighted(); |
|
108 |
TRAP_IGNORE( ChangeCbaL() ); |
|
109 |
} |
|
110 |
||
111 |
// --------------------------------------------------------------------------- |
|
112 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleKeyL |
|
113 |
// Handle system key press event. |
|
114 |
// --------------------------------------------------------------------------- |
|
115 |
// |
|
116 |
TBool TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleKeyL( TInt aKey, |
|
117 |
TKeyPressLength aLength ) |
|
118 |
{ |
|
119 |
TBool ret = ETrue; |
|
120 |
TBool state = ETrue; |
|
121 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
122 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
123 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
124 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
125 |
CDesCArrayFlat* phraseArray = editPane->PhraseArray(); |
|
126 |
||
127 |
if ( iOwner->FepMan()->GetComposChrFlag() && aKey == EStdKeyLeftFunc ) |
|
128 |
{ |
|
129 |
iOwner->FepMan()->SetComposChrFlag( EFalse ); |
|
130 |
return ret; |
|
131 |
} |
|
132 |
||
133 |
switch ( aKey ) |
|
134 |
{ |
|
135 |
case EStdKeyLeftShift: |
|
136 |
case EStdKeyRightShift: |
|
137 |
case EStdKeyLeftCtrl: |
|
138 |
case EStdKeyRightCtrl: |
|
139 |
case EStdKeyRightFunc://fn |
|
140 |
case EStdKeyLeftFunc: //chr key |
|
141 |
case EStdKeyUpArrow: |
|
142 |
case EKeyRightFunc: |
|
143 |
case EKeyLeftFunc: |
|
144 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
145 |
break; |
|
146 |
//if the canidate is empty ,inactive;else candiniate selecting state |
|
147 |
case EStdKeyDownArrow: |
|
148 |
{ |
|
149 |
if ( 0 != candidatePane->VisibleCandidateCount() && phraseArray->Count() < 7 ) |
|
150 |
{ |
|
151 |
uiContainer->EditPaneWindow()->SetChangeState( ETrue ); |
|
152 |
iOwner->ChangeState( EZhuyinSpelling ); |
|
153 |
} |
|
154 |
} |
|
155 |
break; |
|
156 |
case EStdKeyRightArrow: |
|
157 |
MoveCursorRight(); |
|
158 |
break; |
|
159 |
case EStdKeyLeftArrow: |
|
160 |
MoveCursorLeft(); |
|
161 |
break; |
|
162 |
case EStdKeyDevice1: //"cancle" key |
|
163 |
iOwner->FepMan()->TryCloseUiL(); |
|
164 |
break; |
|
165 |
case EStdKeyEnter: |
|
166 |
CommitContentL( EFalse ); |
|
167 |
break; |
|
168 |
case EStdKeyDevice0: |
|
169 |
case EStdKeyDevice3: |
|
170 |
||
171 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
172 |
{ |
|
173 |
state = EFalse; |
|
174 |
} |
|
175 |
else |
|
176 |
{ |
|
177 |
editPane->SetChangeState( EFalse ); |
|
178 |
} |
|
179 |
if ( state ) |
|
180 |
{ |
|
181 |
HandleCommitL(); |
|
182 |
} |
|
183 |
break; |
|
184 |
case EStdKeyBackspace: |
|
185 |
{ |
|
186 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
187 |
{ |
|
188 |
state = EFalse; |
|
189 |
} |
|
190 |
else |
|
191 |
{ |
|
192 |
editPane->SetChangeState( EFalse ); |
|
193 |
} |
|
194 |
if ( state ) |
|
195 |
{ |
|
196 |
HandleKeyBackspaceL( aLength ); |
|
197 |
} |
|
198 |
} |
|
199 |
break; |
|
200 |
default: |
|
201 |
{ |
|
202 |
if ( aLength == EShortKeyPress && keystrokeArray->Count() < KMaxKeystrokeCount && |
|
203 |
!iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) && |
|
204 |
phraseArray->Count() < KMaxPhraseLength && |
|
205 |
( iOwner->IsValidChineseInputKeyQwerty( aKey ) || aKey == EStdKeySpace ) ) |
|
206 |
{ |
|
207 |
AddKeystrokeL( aKey ); |
|
208 |
RefreshUI(); |
|
209 |
ShowEEPInfo(); |
|
210 |
ChangeCbaL(); |
|
211 |
} |
|
212 |
else |
|
213 |
{ |
|
214 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
215 |
} |
|
216 |
} |
|
217 |
break; |
|
218 |
} |
|
219 |
return ret; |
|
220 |
} |
|
221 |
||
222 |
// --------------------------------------------------------------------------- |
|
223 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::AddKeystrokeL |
|
224 |
// Add key stroke. |
|
225 |
// --------------------------------------------------------------------------- |
|
226 |
// |
|
227 |
TBool TAknFepInputStateEditingMiniQwertyZhuyinPhrase::AddKeystrokeL( TInt aKey ) |
|
228 |
{ |
|
229 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
230 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
231 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
232 |
RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
233 |
TInt phraseCount = editPane->PhraseArray()->Count(); |
|
234 |
TInt showKeystrokeCount = editPane->ShowKeystrokeArray()->Count(); |
|
235 |
TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
236 |
||
237 |
if ( phraseCount + showKeystrokeCount >= KMaxKeystrokeCount - 1 ) |
|
238 |
{ |
|
239 |
return EFalse; |
|
240 |
} |
|
241 |
TBuf<KKeystrokeMaxLength> keystroke; |
|
242 |
||
243 |
TAknFepInputStateMiniQwertyZhuyinKeyMap::GetKeyStroke( |
|
244 |
iOwner->PtiEngine(), aKey, keystroke ); |
|
245 |
||
246 |
if ( index >= keystrokeArray->Count() ) |
|
247 |
{ |
|
248 |
keycodeArray->Append( aKey ); |
|
249 |
keystrokeArray->AppendL( keystroke ); |
|
250 |
editPane->SetCursorIndexOfKeystroke( keystrokeArray->Count() ); |
|
251 |
} |
|
252 |
else |
|
253 |
{ |
|
254 |
keycodeArray->Insert( aKey, index ); |
|
255 |
keystrokeArray->InsertL( index, keystroke ); |
|
256 |
editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
257 |
} |
|
258 |
editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
259 |
return ETrue; |
|
260 |
} |
|
261 |
||
262 |
// --------------------------------------------------------- |
|
263 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RevertPhraseToKeystrokeL |
|
264 |
// Revert the phrase to keystroke. |
|
265 |
// --------------------------------------------------------- |
|
266 |
// |
|
267 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RevertPhraseToKeystrokeL() |
|
268 |
{ |
|
269 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
270 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
271 |
CDesCArrayFlat* keystrokeArray = editPane->KeystrokeArray(); |
|
272 |
CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
273 |
RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
274 |
RArray<TInt>* phraseKeycode = editPane->PhraseKeycodeArray(); |
|
275 |
CDesCArrayFlat* phraseStroke = editPane->PhraseShowKeyStrokeArray(); |
|
276 |
TBuf<KMaxKeystrokeCount> buf; |
|
277 |
||
278 |
if ( (phrase->Count() == 0 ) || (phraseStroke->Count() == 0 ) ) |
|
279 |
{ |
|
280 |
return; |
|
281 |
} |
|
282 |
||
283 |
buf.Append( phraseStroke->MdcaPoint( phraseStroke->Count() - 1 ) ); |
|
284 |
||
285 |
TInt insertIndex = 0; |
|
286 |
while ( buf.Length() != 0 ) |
|
287 |
{ |
|
288 |
TBuf<KKeystrokeMaxLength> strokeBuf; |
|
289 |
TInt index = buf.Find( KRightBracket ); |
|
290 |
if ( index != KErrNotFound ) |
|
291 |
{ |
|
292 |
strokeBuf.Copy( buf.Left( index + 1 ) ); |
|
293 |
keystrokeArray->InsertL( insertIndex, strokeBuf ); |
|
294 |
buf.Replace( 0, index + 1, KNullDesC ); |
|
295 |
} |
|
296 |
else |
|
297 |
{ |
|
298 |
keystrokeArray->InsertL( insertIndex, buf ); |
|
299 |
insertIndex = insertIndex + 1; |
|
300 |
break; |
|
301 |
} |
|
302 |
insertIndex = insertIndex + 1; |
|
303 |
} |
|
304 |
phrase->Delete( phrase->Count() - 1 ); |
|
305 |
phraseStroke->Delete( phraseStroke->Count() - 1 ); |
|
306 |
||
307 |
if ( insertIndex > phraseKeycode->Count() ) |
|
308 |
{ |
|
309 |
insertIndex = keycodeArray->Count(); |
|
310 |
} |
|
311 |
||
312 |
for ( TInt i = 0; i < insertIndex ; ++i ) |
|
313 |
{ |
|
314 |
keycodeArray->Insert( (*phraseKeycode)[phraseKeycode->Count() - 1 ],0 ); |
|
315 |
phraseKeycode->Remove( phraseKeycode->Count() - 1 ); |
|
316 |
} |
|
317 |
||
318 |
TInt keystrokeCount = keystrokeArray->Count(); |
|
319 |
TInt lenth = phrase->Count() + keystrokeCount; |
|
320 |
TInt deleteCount = lenth - KMaxKeystrokeCount; |
|
321 |
||
322 |
for (TInt i = 0; i < deleteCount; ++i ) |
|
323 |
{ |
|
324 |
keycodeArray->Remove( keycodeArray->Count() - 1 ); |
|
325 |
keystrokeArray->Delete( keystrokeArray->Count() - 1 ); |
|
326 |
} |
|
327 |
editPane->SetCursorIndexOfKeystroke( insertIndex ); |
|
328 |
keystrokeArray->Compress(); |
|
329 |
phrase->Compress(); |
|
330 |
phraseStroke->Compress(); |
|
331 |
} |
|
332 |
||
333 |
// --------------------------------------------------------- |
|
334 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::AddPhraseToDB |
|
335 |
// Add phrase to DB. |
|
336 |
// --------------------------------------------------------- |
|
337 |
// |
|
338 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::AddPhraseToDB( |
|
339 |
const TDesC& aPhraseAdd ) |
|
340 |
{ |
|
341 |
TPtiUserDictionaryEntry addUdbEntry(aPhraseAdd); |
|
342 |
//Add the phrase to the DB by PTI Engine |
|
343 |
iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); |
|
344 |
} |
|
345 |
||
346 |
// --------------------------------------------------------- |
|
347 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::MoveCursorLeft |
|
348 |
// Move the cursor to Left. |
|
349 |
// --------------------------------------------------------- |
|
350 |
// |
|
351 |
TBool TAknFepInputStateEditingMiniQwertyZhuyinPhrase::MoveCursorLeft() |
|
352 |
{ |
|
353 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
354 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
355 |
CDesCArrayFlat* keyStrokeArray = editPane->KeystrokeArray(); |
|
356 |
TInt keystrokeCount = keyStrokeArray->Count(); |
|
357 |
TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
358 |
TInt phraseCount = editPane->PhraseArray()->Count(); |
|
359 |
||
360 |
if ( EMiniQwertyEdit != iState ) |
|
361 |
{ |
|
362 |
return EFalse; |
|
363 |
} |
|
364 |
if ( 0 == keystrokeCount ) |
|
365 |
{ |
|
366 |
return EFalse; |
|
367 |
} |
|
368 |
||
369 |
if ( 0 == index ) |
|
370 |
{ |
|
371 |
editPane->SetCursorIndexOfKeystroke( keystrokeCount ); |
|
372 |
ShowEEPInfo(); |
|
373 |
} |
|
374 |
else if ( phraseCount > 0 && 1 == index ) |
|
375 |
{ |
|
376 |
editPane->SetCursorIndexOfKeystroke( 0 ); |
|
377 |
ShowEEPInfo(); |
|
378 |
} |
|
379 |
else |
|
380 |
{ |
|
381 |
TInt stride = keyStrokeArray->MdcaPoint( index - 1 ).Length(); |
|
382 |
editPane->MoveCursorLeft( stride ); |
|
383 |
editPane->SetCursorIndexOfKeystroke( index - 1 ); |
|
384 |
} |
|
385 |
return ETrue; |
|
386 |
} |
|
387 |
||
388 |
// --------------------------------------------------------- |
|
389 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::MoveCursorRight |
|
390 |
// Move the cursor to Right. |
|
391 |
// --------------------------------------------------------- |
|
392 |
// |
|
393 |
TBool TAknFepInputStateEditingMiniQwertyZhuyinPhrase::MoveCursorRight() |
|
394 |
{ |
|
395 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
396 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
397 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
398 |
TInt keystrokeCount = keystroke->Count(); |
|
399 |
TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
400 |
||
401 |
if ( EMiniQwertyEdit != iState ) |
|
402 |
{ |
|
403 |
return EFalse; |
|
404 |
} |
|
405 |
if ( 0 == keystrokeCount ) |
|
406 |
{ |
|
407 |
return EFalse; |
|
408 |
} |
|
409 |
if ( index >= keystrokeCount ) |
|
410 |
{ |
|
411 |
editPane->SetCursorIndexOfKeystroke( 0 ); |
|
412 |
ShowEEPInfo(); |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
TInt stride = editPane->KeystrokeArray()->MdcaPoint( index ).Length(); |
|
417 |
editPane->MoveCursorRight( stride ); |
|
418 |
editPane->SetCursorIndexOfKeystroke( index + 1 ); |
|
419 |
} |
|
420 |
return ETrue; |
|
421 |
} |
|
422 |
||
423 |
// --------------------------------------------------------- |
|
424 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleKeyBackspace |
|
425 |
// Handle Key Backspace |
|
426 |
// --------------------------------------------------------- |
|
427 |
// |
|
428 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleKeyBackspaceL( |
|
429 |
TKeyPressLength aLength ) |
|
430 |
{ |
|
431 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
432 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
433 |
||
434 |
CDesCArrayFlat* keyStrokeArray = editPane->KeystrokeArray(); |
|
435 |
RArray<TInt>* keycodeArray = editPane->KeycodeArray(); |
|
436 |
TInt keystrokeCount = keyStrokeArray->Count(); |
|
437 |
TInt phraseCount = editPane->PhraseArray()->Count(); |
|
438 |
||
439 |
TInt cursorOfkeystrokeIndex = editPane->GetCursorIndexOfKeystroke(); |
|
440 |
||
441 |
if ( 1 == cursorOfkeystrokeIndex ) |
|
442 |
{ |
|
443 |
editPane->Reset(); |
|
444 |
} |
|
445 |
||
446 |
if ( cursorOfkeystrokeIndex > 0 && |
|
447 |
( keystrokeCount > 1 || phraseCount > 0 ) ) |
|
448 |
{ |
|
449 |
keycodeArray->Remove( cursorOfkeystrokeIndex - 1 ); |
|
450 |
keyStrokeArray->Delete( cursorOfkeystrokeIndex - 1 ); |
|
451 |
editPane->SetCursorIndexOfKeystroke( cursorOfkeystrokeIndex - 1 ); |
|
452 |
} |
|
453 |
else if ( phraseCount > 0 && 0 == cursorOfkeystrokeIndex ) |
|
454 |
{ |
|
455 |
RevertPhraseToKeystrokeL(); |
|
456 |
} |
|
457 |
else if ( 1 == cursorOfkeystrokeIndex ) |
|
458 |
{ |
|
459 |
iOwner->FepMan()->TryCloseUiL(); |
|
460 |
if ( aLength == ELongKeyPress ) |
|
461 |
{ |
|
462 |
iOwner->FepMan()->SetLongClearAfterCloseUI( ETrue ); |
|
463 |
} |
|
464 |
return; |
|
465 |
} |
|
466 |
else |
|
467 |
{ |
|
468 |
return; |
|
469 |
} |
|
470 |
editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
471 |
RefreshUI(); |
|
472 |
ShowEEPInfo(); |
|
473 |
ChangeCbaL(); |
|
474 |
} |
|
475 |
||
476 |
// --------------------------------------------------------- |
|
477 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::CommitContentL |
|
478 |
// Commit content |
|
479 |
// --------------------------------------------------------- |
|
480 |
// |
|
481 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::CommitContentL( |
|
482 |
TBool aAddUDB ) |
|
483 |
{ |
|
484 |
TBuf<KMaxKeystrokeSize> currentText; |
|
485 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
486 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
|
487 |
CDesCArrayFlat* phraseArray = editpane->PhraseArray(); |
|
488 |
CDesCArrayFlat* keystrokeArray = editpane->KeystrokeArray(); |
|
489 |
TInt phraseCount = phraseArray->Count(); |
|
490 |
TInt keyStrokeCount = keystrokeArray->Count(); |
|
491 |
||
492 |
for (TInt i = 0; i < phraseCount; i++ ) |
|
493 |
{ |
|
494 |
currentText.Append( phraseArray->MdcaPoint( i ) ); |
|
495 |
} |
|
496 |
for (TInt i = 0; i < keyStrokeCount; i++ ) |
|
497 |
{ |
|
498 |
currentText.Append( keystrokeArray->MdcaPoint( i ) ); |
|
499 |
} |
|
500 |
||
501 |
if ( currentText.Length() ) |
|
502 |
{ |
|
503 |
while (currentText.Find( KLeftBracket ) >= 0 ) |
|
504 |
{ |
|
505 |
currentText.Replace( currentText.Find( KLeftBracket ), 1, |
|
506 |
KReplace ); |
|
507 |
} |
|
508 |
while (currentText.Find( KRightBracket ) > 0 ) |
|
509 |
{ |
|
510 |
currentText.Replace( currentText.Find( KRightBracket ), 1, |
|
511 |
KReplace ); |
|
512 |
} |
|
513 |
fepMan->NewTextL( currentText ); |
|
514 |
fepMan->CommitInlineEditL(); |
|
515 |
} |
|
46
bd83ceabce89
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
516 |
|
44 | 517 |
if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
518 |
{ |
|
519 |
fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
520 |
} |
|
521 |
if ( aAddUDB ) |
|
522 |
{ |
|
523 |
//here,we pass zhuyin-spelling to db together with phrase. |
|
524 |
CDesCArrayFlat* phraseZhuYinSpellingArray = UIContainer()->EditPaneWindow()->PhraseZhuYinSpellingArray(); |
|
525 |
TBuf<(1+KMaxSpellLength)*KMaxPhraseCreationCount> phraseCreatedWithZhuYin;//(Zi+Zhuyin)* max_Zi |
|
526 |
phraseCreatedWithZhuYin.FillZ(); |
|
527 |
for (TInt ii = 0; ii < phraseCount; ++ii) |
|
528 |
{ |
|
529 |
TPtrC ptrZi = phraseArray->MdcaPoint(ii); |
|
530 |
phraseCreatedWithZhuYin.Append(ptrZi); |
|
531 |
||
532 |
TPtrC ptrZhuYin = phraseZhuYinSpellingArray->MdcaPoint(ii); |
|
533 |
phraseCreatedWithZhuYin.Append(ptrZhuYin); |
|
534 |
||
535 |
TInt zeroTail = (1+KMaxSpellLength)-(ptrZi.Length()+ptrZhuYin.Length()); |
|
536 |
phraseCreatedWithZhuYin.AppendFill(0,zeroTail); |
|
537 |
||
538 |
} |
|
539 |
AddPhraseToDB( phraseCreatedWithZhuYin ); |
|
540 |
} |
|
46
bd83ceabce89
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
541 |
UIContainer()->EditPaneWindow()->ResetAllArray(); |
bd83ceabce89
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
542 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag( EFalse ); |
44 | 543 |
fepMan->TryCloseUiL(); |
544 |
} |
|
545 |
||
546 |
// --------------------------------------------------------- |
|
547 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommitL |
|
548 |
// Handle commit action |
|
549 |
// --------------------------------------------------------- |
|
550 |
// |
|
551 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommitL() |
|
552 |
{ |
|
553 |
TBuf<KMaxKeystrokeSize> currentText; |
|
554 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
|
555 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
556 |
CDesCArrayFlat* phraseArray = editpane->PhraseArray(); |
|
557 |
CDesCArrayFlat* keystrokeArray = editpane->KeystrokeArray(); |
|
558 |
TInt phraseCount = phraseArray->Count(); |
|
559 |
TInt keyStrokeCount = keystrokeArray->Count(); |
|
560 |
||
561 |
if ( 0 == candidatePane->VisibleCandidateCount() && ( 1 == phraseCount |
|
562 |
|| keyStrokeCount > 0 ) ) |
|
563 |
{ |
|
564 |
return; |
|
565 |
} |
|
566 |
if ( 0 != candidatePane->VisibleCandidateCount() && phraseCount < KMaxPhraseLength ) |
|
567 |
{ |
|
568 |
UIContainer()->EditPaneWindow()->SetChangeState( ETrue ); |
|
569 |
iOwner->ChangeState( EZhuyinSpelling ); |
|
570 |
return; |
|
571 |
} |
|
572 |
CommitContentL( ETrue ); |
|
573 |
} |
|
574 |
||
575 |
// --------------------------------------------------------- |
|
576 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RefreshUI |
|
577 |
// Refresh UI if necessary |
|
578 |
// --------------------------------------------------------- |
|
579 |
// |
|
580 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RefreshUI() |
|
581 |
{ |
|
582 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); |
|
583 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow(); |
|
584 |
CDesCArrayFlat* showKeystroke = editpane->ShowKeystrokeArray(); |
|
585 |
TBuf<KMaxKeystrokeCount> preValidKeystroke; |
|
586 |
TInt preValidKeystrokeCount = showKeystroke->Count(); |
|
587 |
for (TInt i=0; i < preValidKeystrokeCount; i++ ) |
|
588 |
{ |
|
589 |
preValidKeystroke.Append( showKeystroke->MdcaPoint( i ) ); |
|
590 |
} |
|
591 |
GetValidKeystroke(); |
|
592 |
TBuf<KMaxKeystrokeCount> validKeystroke; |
|
593 |
TInt validKeystrokeCount = showKeystroke->Count(); |
|
594 |
for (TInt i=0; i < validKeystrokeCount; i++ ) |
|
595 |
{ |
|
596 |
validKeystroke.Append( showKeystroke->MdcaPoint( i ) ); |
|
597 |
} |
|
598 |
if ( preValidKeystroke.Compare( validKeystroke ) != 0 ) |
|
599 |
{ |
|
600 |
RefreshSpellingPane( ETrue ); |
|
601 |
RefreshCandidatePane(); |
|
602 |
} |
|
603 |
else if ( popup->CurrentSelection() != 0 ) |
|
604 |
{ |
|
605 |
RefreshCandidatePane(); |
|
606 |
} |
|
607 |
UpdateIndicator(); |
|
608 |
} |
|
609 |
||
610 |
// --------------------------------------------------------- |
|
611 |
// Init the show info |
|
612 |
// --------------------------------------------------------- |
|
613 |
// |
|
614 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ImplicityShowInfo( |
|
615 |
TBool aGetScreenCoordinates ) |
|
616 |
{ |
|
617 |
TRAP_IGNORE( ImplicityShowInfoL( aGetScreenCoordinates ) ); |
|
618 |
} |
|
619 |
||
620 |
// --------------------------------------------------------- |
|
621 |
// Init the show info |
|
622 |
// --------------------------------------------------------- |
|
623 |
// |
|
624 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ImplicityShowInfoL( |
|
625 |
TBool aGetScreenCoordinates ) |
|
626 |
{ |
|
627 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
628 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
629 |
// get cursor position |
|
630 |
TPoint baseLine = TPoint( 0, 0 ); |
|
631 |
TInt height = 0; |
|
632 |
TInt ascent = 0; |
|
633 |
if ( aGetScreenCoordinates ) |
|
634 |
{ |
|
635 |
iOwner->FepMan()->GetScreenCoordinatesL( baseLine, height, ascent ); |
|
636 |
uiContainer->SetContainerPosition( baseLine, height ); |
|
637 |
} |
|
638 |
editPane->ActiveCursor(); |
|
639 |
} |
|
640 |
||
641 |
// --------------------------------------------------------- |
|
642 |
// Init the show info |
|
643 |
// --------------------------------------------------------- |
|
644 |
// |
|
645 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ShowEEPInfo() |
|
646 |
{ |
|
647 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
648 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
649 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray(); |
|
650 |
CDesCArrayFlat* phrase = editPane->PhraseArray(); |
|
651 |
TInt index = editPane->GetCursorIndexOfKeystroke(); |
|
652 |
TInt cursorPosInKeystroke = 0; |
|
653 |
||
654 |
TBuf<KMaxKeystrokeSize> buf; |
|
655 |
||
656 |
for (TInt i = 0; i < phrase->Count(); ++i ) |
|
657 |
{ |
|
658 |
buf.Append( phrase->MdcaPoint( i ) ); |
|
659 |
} |
|
660 |
||
661 |
for (TInt i = 0; i < keystroke->Count(); ++i ) |
|
662 |
{ |
|
663 |
buf.Append( keystroke->MdcaPoint( i ) ); |
|
664 |
} |
|
665 |
||
666 |
for (TInt i = 0; i < index; ++i ) |
|
667 |
{ |
|
668 |
cursorPosInKeystroke = cursorPosInKeystroke + keystroke->MdcaPoint( i ).Length(); |
|
669 |
} |
|
670 |
||
671 |
editPane->SetText( buf, phrase->Count() + cursorPosInKeystroke, ETrue ); |
|
672 |
if ( editPane->GetEffictiveLength() == 0 ) |
|
673 |
{ |
|
674 |
editPane->SetHighlight( phrase->Count(), buf.Length() ); |
|
675 |
} |
|
676 |
} |
|
677 |
||
678 |
// --------------------------------------------------------------------------- |
|
679 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::TAknFepInputStateSpellingMiniQwertyZhuyin |
|
680 |
// C++ default constructor |
|
681 |
// --------------------------------------------------------------------------- |
|
682 |
// |
|
683 |
TAknFepInputStateSpellingMiniQwertyZhuyin::TAknFepInputStateSpellingMiniQwertyZhuyin( |
|
684 |
MAknFepUIManagerStateInterface* aOwner, |
|
685 |
MAknFepUICtrlContainerChinese* aUIContainer ) : |
|
686 |
TAknFepInputMiniQwertyZhuyinPhraseBase( aOwner, aUIContainer) |
|
687 |
{ |
|
688 |
iState = EZhuyinSpelling; |
|
689 |
||
690 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
691 |
uiContainer->FocusCandidatePane( EFalse ); |
|
692 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse ); |
|
693 |
uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
694 |
uiContainer->ShowVerticalScrollArrows( ETrue ); |
|
695 |
uiContainer->ShowHorizontalScrollArrows( EFalse ); |
|
696 |
uiContainer->InputPane()->SetOverrideFontId( 0 ); |
|
697 |
uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutPhraseCreation ); |
|
698 |
uiContainer->EditPaneWindow()->DeactiveCursor(); |
|
699 |
RefreshUI(); |
|
700 |
// however we also need to clear the deliberate selection, in case we are not |
|
701 |
// coming back to the input pane from the candidate pane |
|
702 |
ClearDeliberateSelection(); |
|
703 |
UpdateIndicator(); |
|
704 |
||
705 |
iOwner->PtiEngine()->SetInputMode( EPtiEngineZhuyinPhraseQwerty ); |
|
706 |
iOwner->PtiEngine()->SetCase( EPtiCaseLower ); |
|
707 |
} |
|
708 |
||
709 |
// --------------------------------------------------------------------------- |
|
710 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::HandleKeyL |
|
711 |
// Handle system key press event. |
|
712 |
// --------------------------------------------------------------------------- |
|
713 |
// |
|
714 |
TBool TAknFepInputStateSpellingMiniQwertyZhuyin::HandleKeyL( TInt aKey, |
|
715 |
TKeyPressLength aLength ) |
|
716 |
{ |
|
717 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
718 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
719 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
720 |
TBool ret = ETrue; |
|
721 |
||
722 |
if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyLock |
|
723 |
== iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyDown |
|
724 |
== iOwner->FepMan()->FnKeyState() ) |
|
725 |
{ |
|
726 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
727 |
return ETrue; |
|
728 |
} |
|
729 |
else if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed ) |
|
730 |
|| iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) ) |
|
731 |
{ |
|
732 |
return ETrue; |
|
733 |
} |
|
734 |
||
735 |
switch ( aKey ) |
|
736 |
{ |
|
737 |
case EPtiKeyQwertyE: |
|
738 |
case EPtiKeyQwertyR: |
|
739 |
case EPtiKeyQwertyY: |
|
740 |
case EPtiKeyQwertyU: |
|
741 |
case EStdKeyLeftFunc: |
|
742 |
{ |
|
743 |
if ( aLength == EShortKeyPress ) |
|
744 |
{ |
|
745 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
746 |
} |
|
747 |
} |
|
748 |
break; |
|
749 |
case EKeyRightFunc: |
|
750 |
case EKeyLeftShift: |
|
751 |
case EKeyLeftCtrl: |
|
752 |
case EKeyRightCtrl: |
|
753 |
case EStdKeyEnter: |
|
754 |
{ |
|
755 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
756 |
} |
|
757 |
break; |
|
758 |
case EStdKeyBackspace: |
|
759 |
case EStdKeyUpArrow: |
|
760 |
{ |
|
761 |
TBool state = ETrue; |
|
762 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
763 |
{ |
|
764 |
state = EFalse; |
|
765 |
} |
|
766 |
else |
|
767 |
{ |
|
768 |
editPane->SetChangeState( EFalse ); |
|
769 |
} |
|
770 |
if ( state ) |
|
771 |
{ |
|
772 |
editPane->SetChangeState( ETrue ); |
|
773 |
iOwner->ChangeState( EMiniQwertyEdit ); |
|
774 |
} |
|
775 |
} |
|
776 |
break; |
|
777 |
case EStdKeyDevice1: |
|
778 |
{ |
|
779 |
iOwner->FepMan()->TryCloseUiL(); |
|
780 |
} |
|
781 |
break; |
|
782 |
case EStdKeyRightArrow: |
|
783 |
{ |
|
784 |
if ( popup->IsEnabled() ) |
|
785 |
{ |
|
786 |
if ( popup->SelectNextPhrase() ) |
|
787 |
{ |
|
788 |
RefreshVaildKeyStroke(); |
|
789 |
RefreshCandidatePane(); |
|
790 |
RefreshSpellingPane(); |
|
791 |
RefreshEditPane(); |
|
792 |
UpdateIndicator(); |
|
793 |
} |
|
794 |
} |
|
795 |
} |
|
796 |
break; |
|
797 |
case EStdKeyLeftArrow: |
|
798 |
{ |
|
799 |
if ( popup->IsEnabled() ) |
|
800 |
{ |
|
801 |
if ( popup->SelectPrevPhrase() ) |
|
802 |
{ |
|
803 |
RefreshVaildKeyStroke(); |
|
804 |
RefreshCandidatePane(); |
|
805 |
RefreshSpellingPane(); |
|
806 |
RefreshEditPane(); |
|
807 |
UpdateIndicator(); |
|
808 |
} |
|
809 |
} |
|
810 |
} |
|
811 |
break; |
|
812 |
case EStdKeyDownArrow: |
|
813 |
case EStdKeyDevice3: |
|
814 |
case EStdKeyDevice0: |
|
815 |
{ |
|
816 |
TBool state = ETrue; |
|
817 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
818 |
{ |
|
819 |
state = EFalse; |
|
820 |
} |
|
821 |
else |
|
822 |
{ |
|
823 |
editPane->SetChangeState( EFalse ); |
|
824 |
} |
|
825 |
if ( state ) |
|
826 |
{ |
|
827 |
if ( popup->IsEnabled() ) |
|
828 |
{ |
|
829 |
popup->Enable( EFalse ); |
|
830 |
} |
|
831 |
editPane->SetChangeState( ETrue ); |
|
832 |
iOwner->ChangeState( EZhuyinCandidate ); |
|
833 |
} |
|
834 |
} |
|
835 |
break; |
|
836 |
default: |
|
837 |
{ |
|
838 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
839 |
return TAknFepInputMiniQwertyZhuyinPhraseBase::HandleKeyL( |
|
840 |
aKey, aLength ); |
|
841 |
} |
|
842 |
// break; |
|
843 |
} |
|
844 |
return ret; |
|
845 |
} |
|
846 |
||
847 |
// --------------------------------------------------------- |
|
848 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI |
|
849 |
// Refresh UI if necessary |
|
850 |
// --------------------------------------------------------- |
|
851 |
// |
|
852 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI() |
|
853 |
{ |
|
854 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
855 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
856 |
// get cursor position |
|
857 |
TPoint baseLine = TPoint( 0, 0 ); |
|
858 |
TInt height = 0; |
|
859 |
TInt ascent = 0; |
|
860 |
||
861 |
TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
862 |
if ( ret == KErrNone ) |
|
863 |
{ |
|
864 |
uiContainer->SetContainerPosition( baseLine, height ); |
|
865 |
} |
|
866 |
||
867 |
GetValidKeystroke( ); |
|
868 |
TBool needClearDeliberateSelection = editPane->NeedClearDeliberateSelection(); |
|
869 |
if ( needClearDeliberateSelection ) |
|
870 |
{ |
|
871 |
editPane->SetNeedClearDeliberateSelection( EFalse ); |
|
872 |
} |
|
873 |
else |
|
874 |
{ |
|
875 |
RefreshVaildKeyStroke(); |
|
876 |
} |
|
877 |
RefreshEditPane(); |
|
878 |
RefreshCandidatePane( needClearDeliberateSelection ); |
|
879 |
RefreshSpellingPane( needClearDeliberateSelection ); |
|
880 |
} |
|
881 |
||
882 |
// --------------------------------------------------------- |
|
883 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI |
|
884 |
// Refresh vaild key stroke length |
|
885 |
// --------------------------------------------------------- |
|
886 |
// |
|
887 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshVaildKeyStroke() |
|
888 |
{ |
|
889 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
890 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
891 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
892 |
CDesCArrayFlat* spelling = popup->PhoneticSpellingArray(); |
|
893 |
TInt currentSel = popup->CurrentSelection(); |
|
894 |
if ( currentSel >= spelling->Count() ) |
|
895 |
{ |
|
896 |
currentSel = 0; |
|
897 |
} |
|
898 |
TPtrC ptr = spelling->MdcaPoint( currentSel ); |
|
899 |
TInt currentLength = ptr.Length(); |
|
900 |
editPane->SetEffictiveLength( currentLength ); |
|
901 |
} |
|
902 |
// --------------------------------------------------------------------------- |
|
903 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::TAknFepInputStateCanindateSelectingMiniQwertyZhuyin |
|
904 |
// C++ default constructor |
|
905 |
// --------------------------------------------------------------------------- |
|
906 |
// |
|
907 |
TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::TAknFepInputStateCanindateSelectingMiniQwertyZhuyin( |
|
908 |
MAknFepUIManagerStateInterface* aOwner, |
|
909 |
MAknFepUICtrlContainerChinese* aUIContainer ) : |
|
910 |
TAknFepInputMiniQwertyZhuyinPhraseBase( aOwner, aUIContainer) |
|
911 |
{ |
|
912 |
iState = EZhuyinCandidate; |
|
913 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
914 |
||
915 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage()); |
|
916 |
TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
917 |
TBool showHorizontalScrollArrows = multiplePages || bufLength |
|
918 |
> KMinCandidateCount; |
|
919 |
||
920 |
uiContainer->ShowHorizontalScrollArrows( showHorizontalScrollArrows ); |
|
921 |
uiContainer->ShowVerticalScrollArrows( multiplePages ); |
|
922 |
uiContainer->FocusCandidatePane( ETrue ); |
|
923 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( ETrue ); |
|
924 |
uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
925 |
UpdateIndicator(); |
|
926 |
} |
|
927 |
// --------------------------------------------------------------------------- |
|
928 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleKeyL |
|
929 |
// Handle system key press event. |
|
930 |
// --------------------------------------------------------------------------- |
|
931 |
// |
|
932 |
TBool TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleKeyL( |
|
933 |
TInt aKey, TKeyPressLength aLength ) |
|
934 |
{ |
|
935 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
936 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow(); |
|
937 |
TInt selected = uiContainer->CandidatePane()->SelectedIndex(); |
|
938 |
TInt numbertotal = uiContainer->CandidatePane()->VisibleCandidateCount(); |
|
939 |
TBool ret = ETrue; |
|
940 |
||
941 |
if (iOwner->FepMan()->GetComposChrFlag() ) |
|
942 |
{ |
|
943 |
iOwner->FepMan()->SetComposChrFlag(EFalse); |
|
944 |
return ETrue; |
|
945 |
} |
|
946 |
switch ( aKey ) |
|
947 |
{ |
|
948 |
case EStdKeySpace: |
|
949 |
case EStdKeyEnter: |
|
950 |
{ |
|
951 |
iOwner->FepMan()->PlaySound( EAvkonSIDDefaultSound ); |
|
952 |
} |
|
953 |
break; |
|
954 |
case EStdKeyLeftArrow: |
|
955 |
{ |
|
956 |
if ( selected == 0 ) |
|
957 |
{ |
|
958 |
UIContainer()->CandidatePane()->SelectIndex( numbertotal-1 ); |
|
959 |
} |
|
960 |
else |
|
961 |
{ |
|
962 |
UIContainer()->CandidatePane()->SelectIndex( selected - 1 ); |
|
963 |
} |
|
964 |
} |
|
965 |
break; |
|
966 |
case EStdKeyRightArrow: |
|
967 |
{ |
|
968 |
if ( selected == numbertotal-1 ) |
|
969 |
{ |
|
970 |
UIContainer()->CandidatePane()->SelectIndex( 0 ); |
|
971 |
} |
|
972 |
else |
|
973 |
{ |
|
974 |
UIContainer()->CandidatePane()->SelectIndex( selected + 1 ); |
|
975 |
} |
|
976 |
break; |
|
977 |
} |
|
978 |
case EStdKeyDevice1: // cancel key |
|
979 |
{ |
|
980 |
iOwner->FepMan()->TryCloseUiL(); |
|
981 |
break; |
|
982 |
} |
|
983 |
case EStdKeyUpArrow: |
|
984 |
{ |
|
985 |
if ( uiContainer->CandidatePane()->IsFirstPage() ) // same as the backspace |
|
986 |
{ |
|
987 |
editPane->SetChangeState( ETrue ); |
|
988 |
iOwner->ChangeState( EZhuyinSpelling ); |
|
989 |
} |
|
990 |
else // just move to the last page |
|
991 |
{ |
|
992 |
uiContainer->CandidatePane()->PreviousCandidatePage(); |
|
993 |
uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
994 |
uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
995 |
UpdateIndicator(); |
|
996 |
} |
|
997 |
break; |
|
998 |
} |
|
999 |
case EStdKeyDownArrow: |
|
1000 |
{ |
|
1001 |
ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL( aKey, aLength ); |
|
1002 |
} |
|
1003 |
break; |
|
1004 |
case EStdKeyBackspace: // |
|
1005 |
{ |
|
1006 |
TBool state = ETrue; |
|
1007 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
1008 |
{ |
|
1009 |
state = EFalse; |
|
1010 |
} |
|
1011 |
else |
|
1012 |
{ |
|
1013 |
editPane->SetChangeState( EFalse ); |
|
1014 |
} |
|
1015 |
if ( state ) |
|
1016 |
{ |
|
1017 |
editPane->SetChangeState( ETrue ); |
|
1018 |
iOwner->ChangeState( EZhuyinSpelling ); |
|
1019 |
} |
|
1020 |
} |
|
1021 |
break; |
|
1022 |
case EStdKeyDevice0: //commit to editor |
|
1023 |
case EStdKeyDevice3: |
|
1024 |
{ |
|
1025 |
TBool state = ETrue; |
|
1026 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress ) |
|
1027 |
{ |
|
1028 |
state = EFalse; |
|
1029 |
} |
|
1030 |
else |
|
1031 |
{ |
|
1032 |
editPane->SetChangeState( EFalse ); |
|
1033 |
} |
|
1034 |
if ( state ) |
|
1035 |
{ |
|
1036 |
editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
1037 |
CommitCandidateL(); |
|
1038 |
} |
|
1039 |
} |
|
1040 |
break; |
|
1041 |
default: |
|
1042 |
if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
1043 |
{ |
|
1044 |
iOwner->FepMan()->PlaySound(EAvkonSIDDefaultSound); |
|
1045 |
break; |
|
1046 |
} |
|
1047 |
if ( SelectCandidate( aKey ) ) // is 1-6 key |
|
1048 |
{ |
|
1049 |
editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
1050 |
CommitCandidateL(); |
|
1051 |
} |
|
1052 |
else |
|
1053 |
{ |
|
1054 |
return TAknFepInputMiniQwertyZhuyinPhraseBase::HandleKeyL( |
|
1055 |
aKey, aLength ); |
|
1056 |
} |
|
1057 |
break; |
|
1058 |
} |
|
1059 |
return ret; |
|
1060 |
} |
|
1061 |
// --------------------------------------------------------------------------- |
|
1062 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate |
|
1063 |
// commint the charater to the editor pane |
|
1064 |
// --------------------------------------------------------------------------- |
|
1065 |
||
1066 |
TInt TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::GetIndexOfToneMark( const TDesC& aText) |
|
1067 |
{ |
|
1068 |
TInt indexOfToneMark = -1; |
|
1069 |
TInt num = sizeof(ZhuyinToneMap )/( sizeof(ZhuyinToneMap[0])); |
|
1070 |
TInt len = aText.Length(); |
|
1071 |
for( TInt j = 0; j< len ;j++ ) |
|
1072 |
{ |
|
1073 |
indexOfToneMark = j; |
|
1074 |
TBuf<1> keyStorkeBuf = aText.Mid( j ,1 ); |
|
1075 |
for (TInt i = 0; i<num; i++ ) |
|
1076 |
{ |
|
1077 |
if ( keyStorkeBuf[0] == ZhuyinToneMap[i].iValue ) |
|
1078 |
{ |
|
1079 |
return indexOfToneMark; |
|
1080 |
} |
|
1081 |
} |
|
1082 |
} |
|
1083 |
return -1; |
|
1084 |
} |
|
1085 |
// --------------------------------------------------------------------------- |
|
1086 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate |
|
1087 |
// commint the charater to the editor pane |
|
1088 |
// --------------------------------------------------------------------------- |
|
1089 |
// |
|
1090 |
void TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidateL() |
|
1091 |
{ |
|
1092 |
CDesCArrayFlat* keyStrokeArray = UIContainer()->EditPaneWindow()->KeystrokeArray(); |
|
1093 |
CDesCArrayFlat* phraseKeyStrokeArray = UIContainer()->EditPaneWindow()->PhraseShowKeyStrokeArray(); |
|
1094 |
CDesCArrayFlat* phraseArray = UIContainer()->EditPaneWindow()->PhraseArray(); |
|
1095 |
CDesCArrayFlat* phraseZhuYinSpellingArray = UIContainer()->EditPaneWindow()->PhraseZhuYinSpellingArray(); |
|
1096 |
TPtrC candidate = UIContainer()->CandidatePane()->CurrentPhraseCandidate(); |
|
1097 |
||
1098 |
RArray<TInt>* keyCodeArray = UIContainer()->EditPaneWindow()->KeycodeArray(); |
|
1099 |
RArray<TInt>* keyCodePhraseArray = UIContainer()->EditPaneWindow()->PhraseKeycodeArray(); |
|
1100 |
TBuf<KMaxKeystrokeCount> spellingText; |
|
1101 |
||
1102 |
UIContainer()->InputPane()->GetText( spellingText ); |
|
1103 |
||
1104 |
//phraseZhuYinSpellingArray must keep same count with phraseArray |
|
1105 |
TInt delCount = phraseZhuYinSpellingArray->Count()-phraseArray->Count();//we can sure delCount>=0,impossible <0 |
|
1106 |
if(delCount>0) |
|
1107 |
{ |
|
1108 |
phraseZhuYinSpellingArray->Delete(phraseArray->Count(),delCount);//delete from tail |
|
1109 |
} |
|
1110 |
phraseZhuYinSpellingArray->AppendL(spellingText); |
|
1111 |
phraseArray->AppendL( candidate ); |
|
1112 |
||
1113 |
TBuf<KMaxKeystrokeCount> keyStoke; |
|
1114 |
TInt replaceCount = 0; |
|
1115 |
TInt delimiterIndex = spellingText.Find( KDelimiter ); |
|
1116 |
if ( KErrNotFound ==delimiterIndex ) |
|
1117 |
{ |
|
1118 |
delimiterIndex = -1; |
|
1119 |
} |
|
1120 |
TInt indexOfToneMark = GetIndexOfToneMark( spellingText ); |
|
1121 |
if ( delimiterIndex != KErrNotFound && indexOfToneMark >= 0 ) |
|
1122 |
{ |
|
1123 |
replaceCount = Min( delimiterIndex, indexOfToneMark ); |
|
1124 |
if ( delimiterIndex > indexOfToneMark ) |
|
1125 |
{ |
|
1126 |
replaceCount++; |
|
1127 |
} |
|
1128 |
} |
|
1129 |
else if ( delimiterIndex != KErrNotFound && indexOfToneMark == -1 ) |
|
1130 |
{ |
|
1131 |
replaceCount = delimiterIndex; |
|
1132 |
} |
|
1133 |
else if ( delimiterIndex == KErrNotFound && indexOfToneMark != -1 ) |
|
1134 |
{ |
|
1135 |
replaceCount = indexOfToneMark + 1; |
|
1136 |
} |
|
1137 |
else |
|
1138 |
{ |
|
1139 |
replaceCount = spellingText.Length(); |
|
1140 |
} |
|
1141 |
for (TInt i = 0; i < replaceCount; i++ ) |
|
1142 |
{ |
|
1143 |
TPtrC ptr = keyStrokeArray->MdcaPoint( 0 ); |
|
1144 |
keyStoke.Append( ptr ); |
|
1145 |
keyStrokeArray->Delete( 0 ); |
|
1146 |
// added for the keycode |
|
1147 |
TInt keyCodeValue = ( *keyCodeArray )[0]; |
|
1148 |
keyCodePhraseArray->AppendL( keyCodeValue ); |
|
1149 |
keyCodeArray->Remove( 0 ); |
|
1150 |
} |
|
1151 |
phraseKeyStrokeArray->AppendL( keyStoke ); |
|
1152 |
||
1153 |
if ( GetValidKeystroke() ) |
|
1154 |
{ |
|
1155 |
iOwner->ChangeState( EZhuyinSpelling ); |
|
1156 |
} |
|
1157 |
else |
|
1158 |
{ |
|
1159 |
iOwner->ChangeState( EMiniQwertyEdit ); |
|
1160 |
} |
|
1161 |
UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
|
1162 |
RefreshSpellingPane(); |
|
1163 |
RefreshCandidatePane(); |
|
1164 |
ChangeCbaL(); |
|
1165 |
} |
|
1166 |
||
1167 |
// --------------------------------------------------------------------------- |
|
1168 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate |
|
1169 |
// to check the select number is valid or not |
|
1170 |
// --------------------------------------------------------------------------- |
|
1171 |
// |
|
1172 |
TBool TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::SelectCandidate( |
|
1173 |
TInt aKey ) |
|
1174 |
{ |
|
1175 |
TInt index = 0; |
|
1176 |
MPtiLanguage *lang= NULL; |
|
1177 |
RArray <TPtiNumericKeyBinding> keybinding; |
|
1178 |
TBool validnumkey = EFalse; |
|
1179 |
CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
1180 |
TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout(); |
|
1181 |
||
1182 |
if( ptiengine != NULL ) |
|
1183 |
{ |
|
1184 |
lang = ptiengine->CurrentLanguage(); |
|
1185 |
} |
|
1186 |
if ( ptiengine && lang ) |
|
1187 |
{ |
|
1188 |
TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardtype)); |
|
1189 |
TInt numericKeysCount = keybinding.Count(); |
|
1190 |
while (numericKeysCount-- ) |
|
1191 |
{ |
|
1192 |
TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount]; |
|
1193 |
if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36) |
|
1194 |
&&(aKey == numKeyBind.iKey) ) |
|
1195 |
{ |
|
1196 |
index = numKeyBind.iChar - EPtiKey0 -1; |
|
1197 |
if ( UIContainer()->CandidatePane()->SelectIndex( index, EFalse ) ) |
|
1198 |
{ |
|
1199 |
validnumkey = ETrue; |
|
1200 |
} |
|
1201 |
break; |
|
1202 |
} |
|
1203 |
} |
|
1204 |
} |
|
1205 |
keybinding.Reset(); |
|
1206 |
return validnumkey; |
|
1207 |
} |
|
1208 |
// --------------------------------------------------------------------------- |
|
1209 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommandL |
|
1210 |
// Handling Command |
|
1211 |
// --------------------------------------------------------------------------- |
|
1212 |
// |
|
1213 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommandL( |
|
1214 |
TInt aCommandId ) |
|
1215 |
{ |
|
1216 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1217 |
MAknFepUICtrlCandidatePane* candidatePane = |
|
1218 |
UIContainer()->CandidatePane(); |
|
1219 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1220 |
TBool state = ETrue; |
|
1221 |
switch ( aCommandId ) |
|
1222 |
{ |
|
1223 |
// Handle the event frome command. |
|
1224 |
case EAknSoftkeySelect: |
|
1225 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
1226 |
if ( editPane->IsChangeState() ) |
|
1227 |
{ |
|
1228 |
state = EFalse; |
|
1229 |
} |
|
1230 |
else |
|
1231 |
{ |
|
1232 |
editPane->SetChangeState( EFalse ); |
|
1233 |
} |
|
1234 |
if ( state ) |
|
1235 |
{ |
|
1236 |
HandleCommitL(); |
|
1237 |
} |
|
1238 |
break; |
|
1239 |
default: |
|
1240 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
1241 |
break; |
|
1242 |
} |
|
1243 |
} |
|
1244 |
||
1245 |
// --------------------------------------------------------------------------- |
|
1246 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::HandleCommandL |
|
1247 |
// Handling Command |
|
1248 |
// --------------------------------------------------------------------------- |
|
1249 |
// |
|
1250 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::HandleCommandL( |
|
1251 |
TInt aCommandId ) |
|
1252 |
{ |
|
1253 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1254 |
MAknFepUICtrlCandidatePane* candidatePane = |
|
1255 |
UIContainer()->CandidatePane(); |
|
1256 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1257 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow(); |
|
1258 |
TBool state = ETrue; |
|
1259 |
switch ( aCommandId ) |
|
1260 |
{ |
|
1261 |
// Handle the event frome command. |
|
1262 |
case EAknSoftkeySelect: |
|
1263 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
1264 |
if ( editPane->IsChangeState() ) |
|
1265 |
{ |
|
1266 |
state = EFalse; |
|
1267 |
} |
|
1268 |
else |
|
1269 |
{ |
|
1270 |
editPane->SetChangeState( EFalse ); |
|
1271 |
} |
|
1272 |
if ( state ) |
|
1273 |
{ |
|
1274 |
if ( popup->IsEnabled() ) |
|
1275 |
{ |
|
1276 |
popup->Enable( EFalse ); |
|
1277 |
} |
|
1278 |
editPane->SetChangeState( ETrue ); |
|
1279 |
iOwner->ChangeState( EZhuyinCandidate ); |
|
1280 |
} |
|
1281 |
break; |
|
1282 |
default: |
|
1283 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
1284 |
break; |
|
1285 |
} |
|
1286 |
} |
|
1287 |
||
1288 |
// --------------------------------------------------------------------------- |
|
1289 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleCommandL |
|
1290 |
// Handling Command |
|
1291 |
// --------------------------------------------------------------------------- |
|
1292 |
// |
|
1293 |
void TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleCommandL( |
|
1294 |
TInt aCommandId ) |
|
1295 |
{ |
|
1296 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
1297 |
MAknFepUICtrlCandidatePane* candidatePane = |
|
1298 |
UIContainer()->CandidatePane(); |
|
1299 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow(); |
|
1300 |
TBool state = ETrue; |
|
1301 |
switch ( aCommandId ) |
|
1302 |
{ |
|
1303 |
// Handle the event frome command. |
|
1304 |
case EAknSoftkeySelect: |
|
1305 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
1306 |
if ( editPane->IsChangeState() ) |
|
1307 |
{ |
|
1308 |
state = EFalse; |
|
1309 |
} |
|
1310 |
else |
|
1311 |
{ |
|
1312 |
editPane->SetChangeState( EFalse ); |
|
1313 |
} |
|
1314 |
if ( state ) |
|
1315 |
{ |
|
1316 |
editPane->SetNeedClearDeliberateSelection( ETrue ); |
|
1317 |
CommitCandidateL(); |
|
1318 |
} |
|
1319 |
||
1320 |
break; |
|
1321 |
default: |
|
1322 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
1323 |
break; |
|
1324 |
} |
|
1325 |
} |
|
1326 |
//End of File |