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 |
}
|
|
516 |
UIContainer()->EditPaneWindow()->ResetAllArray();
|
|
517 |
UIContainer()->EditPaneWindow()->SetPhraseCreationFlag( EFalse );
|
|
518 |
if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
|
|
519 |
{
|
|
520 |
fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
|
|
521 |
}
|
|
522 |
if ( aAddUDB )
|
|
523 |
{
|
|
524 |
//here,we pass zhuyin-spelling to db together with phrase.
|
|
525 |
CDesCArrayFlat* phraseZhuYinSpellingArray = UIContainer()->EditPaneWindow()->PhraseZhuYinSpellingArray();
|
|
526 |
TBuf<(1+KMaxSpellLength)*KMaxPhraseCreationCount> phraseCreatedWithZhuYin;//(Zi+Zhuyin)* max_Zi
|
|
527 |
phraseCreatedWithZhuYin.FillZ();
|
|
528 |
for (TInt ii = 0; ii < phraseCount; ++ii)
|
|
529 |
{
|
|
530 |
TPtrC ptrZi = phraseArray->MdcaPoint(ii);
|
|
531 |
phraseCreatedWithZhuYin.Append(ptrZi);
|
|
532 |
|
|
533 |
TPtrC ptrZhuYin = phraseZhuYinSpellingArray->MdcaPoint(ii);
|
|
534 |
phraseCreatedWithZhuYin.Append(ptrZhuYin);
|
|
535 |
|
|
536 |
TInt zeroTail = (1+KMaxSpellLength)-(ptrZi.Length()+ptrZhuYin.Length());
|
|
537 |
phraseCreatedWithZhuYin.AppendFill(0,zeroTail);
|
|
538 |
|
|
539 |
}
|
|
540 |
AddPhraseToDB( phraseCreatedWithZhuYin );
|
|
541 |
}
|
|
542 |
fepMan->TryCloseUiL();
|
|
543 |
}
|
|
544 |
|
|
545 |
// ---------------------------------------------------------
|
|
546 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommitL
|
|
547 |
// Handle commit action
|
|
548 |
// ---------------------------------------------------------
|
|
549 |
//
|
|
550 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommitL()
|
|
551 |
{
|
|
552 |
TBuf<KMaxKeystrokeSize> currentText;
|
|
553 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
|
|
554 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
555 |
CDesCArrayFlat* phraseArray = editpane->PhraseArray();
|
|
556 |
CDesCArrayFlat* keystrokeArray = editpane->KeystrokeArray();
|
|
557 |
TInt phraseCount = phraseArray->Count();
|
|
558 |
TInt keyStrokeCount = keystrokeArray->Count();
|
|
559 |
|
|
560 |
if ( 0 == candidatePane->VisibleCandidateCount() && ( 1 == phraseCount
|
|
561 |
|| keyStrokeCount > 0 ) )
|
|
562 |
{
|
|
563 |
return;
|
|
564 |
}
|
|
565 |
if ( 0 != candidatePane->VisibleCandidateCount() && phraseCount < KMaxPhraseLength )
|
|
566 |
{
|
|
567 |
UIContainer()->EditPaneWindow()->SetChangeState( ETrue );
|
|
568 |
iOwner->ChangeState( EZhuyinSpelling );
|
|
569 |
return;
|
|
570 |
}
|
|
571 |
CommitContentL( ETrue );
|
|
572 |
}
|
|
573 |
|
|
574 |
// ---------------------------------------------------------
|
|
575 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RefreshUI
|
|
576 |
// Refresh UI if necessary
|
|
577 |
// ---------------------------------------------------------
|
|
578 |
//
|
|
579 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::RefreshUI()
|
|
580 |
{
|
|
581 |
MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
|
|
582 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
583 |
CDesCArrayFlat* showKeystroke = editpane->ShowKeystrokeArray();
|
|
584 |
TBuf<KMaxKeystrokeCount> preValidKeystroke;
|
|
585 |
TInt preValidKeystrokeCount = showKeystroke->Count();
|
|
586 |
for (TInt i=0; i < preValidKeystrokeCount; i++ )
|
|
587 |
{
|
|
588 |
preValidKeystroke.Append( showKeystroke->MdcaPoint( i ) );
|
|
589 |
}
|
|
590 |
GetValidKeystroke();
|
|
591 |
TBuf<KMaxKeystrokeCount> validKeystroke;
|
|
592 |
TInt validKeystrokeCount = showKeystroke->Count();
|
|
593 |
for (TInt i=0; i < validKeystrokeCount; i++ )
|
|
594 |
{
|
|
595 |
validKeystroke.Append( showKeystroke->MdcaPoint( i ) );
|
|
596 |
}
|
|
597 |
if ( preValidKeystroke.Compare( validKeystroke ) != 0 )
|
|
598 |
{
|
|
599 |
RefreshSpellingPane( ETrue );
|
|
600 |
RefreshCandidatePane();
|
|
601 |
}
|
|
602 |
else if ( popup->CurrentSelection() != 0 )
|
|
603 |
{
|
|
604 |
RefreshCandidatePane();
|
|
605 |
}
|
|
606 |
UpdateIndicator();
|
|
607 |
}
|
|
608 |
|
|
609 |
// ---------------------------------------------------------
|
|
610 |
// Init the show info
|
|
611 |
// ---------------------------------------------------------
|
|
612 |
//
|
|
613 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ImplicityShowInfo(
|
|
614 |
TBool aGetScreenCoordinates )
|
|
615 |
{
|
|
616 |
TRAP_IGNORE( ImplicityShowInfoL( aGetScreenCoordinates ) );
|
|
617 |
}
|
|
618 |
|
|
619 |
// ---------------------------------------------------------
|
|
620 |
// Init the show info
|
|
621 |
// ---------------------------------------------------------
|
|
622 |
//
|
|
623 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ImplicityShowInfoL(
|
|
624 |
TBool aGetScreenCoordinates )
|
|
625 |
{
|
|
626 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
627 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
628 |
// get cursor position
|
|
629 |
TPoint baseLine = TPoint( 0, 0 );
|
|
630 |
TInt height = 0;
|
|
631 |
TInt ascent = 0;
|
|
632 |
if ( aGetScreenCoordinates )
|
|
633 |
{
|
|
634 |
iOwner->FepMan()->GetScreenCoordinatesL( baseLine, height, ascent );
|
|
635 |
uiContainer->SetContainerPosition( baseLine, height );
|
|
636 |
}
|
|
637 |
editPane->ActiveCursor();
|
|
638 |
}
|
|
639 |
|
|
640 |
// ---------------------------------------------------------
|
|
641 |
// Init the show info
|
|
642 |
// ---------------------------------------------------------
|
|
643 |
//
|
|
644 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::ShowEEPInfo()
|
|
645 |
{
|
|
646 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
647 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
648 |
CDesCArrayFlat* keystroke = editPane->KeystrokeArray();
|
|
649 |
CDesCArrayFlat* phrase = editPane->PhraseArray();
|
|
650 |
TInt index = editPane->GetCursorIndexOfKeystroke();
|
|
651 |
TInt cursorPosInKeystroke = 0;
|
|
652 |
|
|
653 |
TBuf<KMaxKeystrokeSize> buf;
|
|
654 |
|
|
655 |
for (TInt i = 0; i < phrase->Count(); ++i )
|
|
656 |
{
|
|
657 |
buf.Append( phrase->MdcaPoint( i ) );
|
|
658 |
}
|
|
659 |
|
|
660 |
for (TInt i = 0; i < keystroke->Count(); ++i )
|
|
661 |
{
|
|
662 |
buf.Append( keystroke->MdcaPoint( i ) );
|
|
663 |
}
|
|
664 |
|
|
665 |
for (TInt i = 0; i < index; ++i )
|
|
666 |
{
|
|
667 |
cursorPosInKeystroke = cursorPosInKeystroke + keystroke->MdcaPoint( i ).Length();
|
|
668 |
}
|
|
669 |
|
|
670 |
editPane->SetText( buf, phrase->Count() + cursorPosInKeystroke, ETrue );
|
|
671 |
if ( editPane->GetEffictiveLength() == 0 )
|
|
672 |
{
|
|
673 |
editPane->SetHighlight( phrase->Count(), buf.Length() );
|
|
674 |
}
|
|
675 |
}
|
|
676 |
|
|
677 |
// ---------------------------------------------------------------------------
|
|
678 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::TAknFepInputStateSpellingMiniQwertyZhuyin
|
|
679 |
// C++ default constructor
|
|
680 |
// ---------------------------------------------------------------------------
|
|
681 |
//
|
|
682 |
TAknFepInputStateSpellingMiniQwertyZhuyin::TAknFepInputStateSpellingMiniQwertyZhuyin(
|
|
683 |
MAknFepUIManagerStateInterface* aOwner,
|
|
684 |
MAknFepUICtrlContainerChinese* aUIContainer ) :
|
|
685 |
TAknFepInputMiniQwertyZhuyinPhraseBase( aOwner, aUIContainer)
|
|
686 |
{
|
|
687 |
iState = EZhuyinSpelling;
|
|
688 |
|
|
689 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
690 |
uiContainer->FocusCandidatePane( EFalse );
|
|
691 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse );
|
|
692 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
693 |
uiContainer->ShowVerticalScrollArrows( ETrue );
|
|
694 |
uiContainer->ShowHorizontalScrollArrows( EFalse );
|
|
695 |
uiContainer->InputPane()->SetOverrideFontId( 0 );
|
|
696 |
uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutPhraseCreation );
|
|
697 |
uiContainer->EditPaneWindow()->DeactiveCursor();
|
|
698 |
RefreshUI();
|
|
699 |
// however we also need to clear the deliberate selection, in case we are not
|
|
700 |
// coming back to the input pane from the candidate pane
|
|
701 |
ClearDeliberateSelection();
|
|
702 |
UpdateIndicator();
|
|
703 |
|
|
704 |
iOwner->PtiEngine()->SetInputMode( EPtiEngineZhuyinPhraseQwerty );
|
|
705 |
iOwner->PtiEngine()->SetCase( EPtiCaseLower );
|
|
706 |
}
|
|
707 |
|
|
708 |
// ---------------------------------------------------------------------------
|
|
709 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::HandleKeyL
|
|
710 |
// Handle system key press event.
|
|
711 |
// ---------------------------------------------------------------------------
|
|
712 |
//
|
|
713 |
TBool TAknFepInputStateSpellingMiniQwertyZhuyin::HandleKeyL( TInt aKey,
|
|
714 |
TKeyPressLength aLength )
|
|
715 |
{
|
|
716 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
717 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
718 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
719 |
TBool ret = ETrue;
|
|
720 |
|
|
721 |
if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyLock
|
|
722 |
== iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyDown
|
|
723 |
== iOwner->FepMan()->FnKeyState() )
|
|
724 |
{
|
|
725 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
726 |
return ETrue;
|
|
727 |
}
|
|
728 |
else if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed )
|
|
729 |
|| iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) )
|
|
730 |
{
|
|
731 |
return ETrue;
|
|
732 |
}
|
|
733 |
|
|
734 |
switch ( aKey )
|
|
735 |
{
|
|
736 |
case EPtiKeyQwertyE:
|
|
737 |
case EPtiKeyQwertyR:
|
|
738 |
case EPtiKeyQwertyY:
|
|
739 |
case EPtiKeyQwertyU:
|
|
740 |
case EStdKeyLeftFunc:
|
|
741 |
{
|
|
742 |
if ( aLength == EShortKeyPress )
|
|
743 |
{
|
|
744 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
745 |
}
|
|
746 |
}
|
|
747 |
break;
|
|
748 |
case EKeyRightFunc:
|
|
749 |
case EKeyLeftShift:
|
|
750 |
case EKeyLeftCtrl:
|
|
751 |
case EKeyRightCtrl:
|
|
752 |
case EStdKeyEnter:
|
|
753 |
{
|
|
754 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
755 |
}
|
|
756 |
break;
|
|
757 |
case EStdKeyBackspace:
|
|
758 |
case EStdKeyUpArrow:
|
|
759 |
{
|
|
760 |
TBool state = ETrue;
|
|
761 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress )
|
|
762 |
{
|
|
763 |
state = EFalse;
|
|
764 |
}
|
|
765 |
else
|
|
766 |
{
|
|
767 |
editPane->SetChangeState( EFalse );
|
|
768 |
}
|
|
769 |
if ( state )
|
|
770 |
{
|
|
771 |
editPane->SetChangeState( ETrue );
|
|
772 |
iOwner->ChangeState( EMiniQwertyEdit );
|
|
773 |
}
|
|
774 |
}
|
|
775 |
break;
|
|
776 |
case EStdKeyDevice1:
|
|
777 |
{
|
|
778 |
iOwner->FepMan()->TryCloseUiL();
|
|
779 |
}
|
|
780 |
break;
|
|
781 |
case EStdKeyRightArrow:
|
|
782 |
{
|
|
783 |
if ( popup->IsEnabled() )
|
|
784 |
{
|
|
785 |
if ( popup->SelectNextPhrase() )
|
|
786 |
{
|
|
787 |
RefreshVaildKeyStroke();
|
|
788 |
RefreshCandidatePane();
|
|
789 |
RefreshSpellingPane();
|
|
790 |
RefreshEditPane();
|
|
791 |
UpdateIndicator();
|
|
792 |
}
|
|
793 |
}
|
|
794 |
}
|
|
795 |
break;
|
|
796 |
case EStdKeyLeftArrow:
|
|
797 |
{
|
|
798 |
if ( popup->IsEnabled() )
|
|
799 |
{
|
|
800 |
if ( popup->SelectPrevPhrase() )
|
|
801 |
{
|
|
802 |
RefreshVaildKeyStroke();
|
|
803 |
RefreshCandidatePane();
|
|
804 |
RefreshSpellingPane();
|
|
805 |
RefreshEditPane();
|
|
806 |
UpdateIndicator();
|
|
807 |
}
|
|
808 |
}
|
|
809 |
}
|
|
810 |
break;
|
|
811 |
case EStdKeyDownArrow:
|
|
812 |
case EStdKeyDevice3:
|
|
813 |
case EStdKeyDevice0:
|
|
814 |
{
|
|
815 |
TBool state = ETrue;
|
|
816 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress )
|
|
817 |
{
|
|
818 |
state = EFalse;
|
|
819 |
}
|
|
820 |
else
|
|
821 |
{
|
|
822 |
editPane->SetChangeState( EFalse );
|
|
823 |
}
|
|
824 |
if ( state )
|
|
825 |
{
|
|
826 |
if ( popup->IsEnabled() )
|
|
827 |
{
|
|
828 |
popup->Enable( EFalse );
|
|
829 |
}
|
|
830 |
editPane->SetChangeState( ETrue );
|
|
831 |
iOwner->ChangeState( EZhuyinCandidate );
|
|
832 |
}
|
|
833 |
}
|
|
834 |
break;
|
|
835 |
default:
|
|
836 |
{
|
|
837 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
838 |
return TAknFepInputMiniQwertyZhuyinPhraseBase::HandleKeyL(
|
|
839 |
aKey, aLength );
|
|
840 |
}
|
|
841 |
// break;
|
|
842 |
}
|
|
843 |
return ret;
|
|
844 |
}
|
|
845 |
|
|
846 |
// ---------------------------------------------------------
|
|
847 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI
|
|
848 |
// Refresh UI if necessary
|
|
849 |
// ---------------------------------------------------------
|
|
850 |
//
|
|
851 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI()
|
|
852 |
{
|
|
853 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
854 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
855 |
// get cursor position
|
|
856 |
TPoint baseLine = TPoint( 0, 0 );
|
|
857 |
TInt height = 0;
|
|
858 |
TInt ascent = 0;
|
|
859 |
|
|
860 |
TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
|
|
861 |
if ( ret == KErrNone )
|
|
862 |
{
|
|
863 |
uiContainer->SetContainerPosition( baseLine, height );
|
|
864 |
}
|
|
865 |
|
|
866 |
GetValidKeystroke( );
|
|
867 |
TBool needClearDeliberateSelection = editPane->NeedClearDeliberateSelection();
|
|
868 |
if ( needClearDeliberateSelection )
|
|
869 |
{
|
|
870 |
editPane->SetNeedClearDeliberateSelection( EFalse );
|
|
871 |
}
|
|
872 |
else
|
|
873 |
{
|
|
874 |
RefreshVaildKeyStroke();
|
|
875 |
}
|
|
876 |
RefreshEditPane();
|
|
877 |
RefreshCandidatePane( needClearDeliberateSelection );
|
|
878 |
RefreshSpellingPane( needClearDeliberateSelection );
|
|
879 |
}
|
|
880 |
|
|
881 |
// ---------------------------------------------------------
|
|
882 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshUI
|
|
883 |
// Refresh vaild key stroke length
|
|
884 |
// ---------------------------------------------------------
|
|
885 |
//
|
|
886 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::RefreshVaildKeyStroke()
|
|
887 |
{
|
|
888 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
889 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
890 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
891 |
CDesCArrayFlat* spelling = popup->PhoneticSpellingArray();
|
|
892 |
TInt currentSel = popup->CurrentSelection();
|
|
893 |
if ( currentSel >= spelling->Count() )
|
|
894 |
{
|
|
895 |
currentSel = 0;
|
|
896 |
}
|
|
897 |
TPtrC ptr = spelling->MdcaPoint( currentSel );
|
|
898 |
TInt currentLength = ptr.Length();
|
|
899 |
editPane->SetEffictiveLength( currentLength );
|
|
900 |
}
|
|
901 |
// ---------------------------------------------------------------------------
|
|
902 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::TAknFepInputStateCanindateSelectingMiniQwertyZhuyin
|
|
903 |
// C++ default constructor
|
|
904 |
// ---------------------------------------------------------------------------
|
|
905 |
//
|
|
906 |
TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::TAknFepInputStateCanindateSelectingMiniQwertyZhuyin(
|
|
907 |
MAknFepUIManagerStateInterface* aOwner,
|
|
908 |
MAknFepUICtrlContainerChinese* aUIContainer ) :
|
|
909 |
TAknFepInputMiniQwertyZhuyinPhraseBase( aOwner, aUIContainer)
|
|
910 |
{
|
|
911 |
iState = EZhuyinCandidate;
|
|
912 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
913 |
|
|
914 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && uiContainer->CandidatePane()->IsFirstPage());
|
|
915 |
TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
|
|
916 |
TBool showHorizontalScrollArrows = multiplePages || bufLength
|
|
917 |
> KMinCandidateCount;
|
|
918 |
|
|
919 |
uiContainer->ShowHorizontalScrollArrows( showHorizontalScrollArrows );
|
|
920 |
uiContainer->ShowVerticalScrollArrows( multiplePages );
|
|
921 |
uiContainer->FocusCandidatePane( ETrue );
|
|
922 |
uiContainer->CandidatePane()->ShowCandidateOrdinals( ETrue );
|
|
923 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
924 |
UpdateIndicator();
|
|
925 |
}
|
|
926 |
// ---------------------------------------------------------------------------
|
|
927 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleKeyL
|
|
928 |
// Handle system key press event.
|
|
929 |
// ---------------------------------------------------------------------------
|
|
930 |
//
|
|
931 |
TBool TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleKeyL(
|
|
932 |
TInt aKey, TKeyPressLength aLength )
|
|
933 |
{
|
|
934 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
935 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
936 |
TInt selected = uiContainer->CandidatePane()->SelectedIndex();
|
|
937 |
TInt numbertotal = uiContainer->CandidatePane()->VisibleCandidateCount();
|
|
938 |
TBool ret = ETrue;
|
|
939 |
|
|
940 |
if (iOwner->FepMan()->GetComposChrFlag() )
|
|
941 |
{
|
|
942 |
iOwner->FepMan()->SetComposChrFlag(EFalse);
|
|
943 |
return ETrue;
|
|
944 |
}
|
|
945 |
switch ( aKey )
|
|
946 |
{
|
|
947 |
case EStdKeySpace:
|
|
948 |
case EStdKeyEnter:
|
|
949 |
{
|
|
950 |
iOwner->FepMan()->PlaySound( EAvkonSIDDefaultSound );
|
|
951 |
}
|
|
952 |
break;
|
|
953 |
case EStdKeyLeftArrow:
|
|
954 |
{
|
|
955 |
if ( selected == 0 )
|
|
956 |
{
|
|
957 |
UIContainer()->CandidatePane()->SelectIndex( numbertotal-1 );
|
|
958 |
}
|
|
959 |
else
|
|
960 |
{
|
|
961 |
UIContainer()->CandidatePane()->SelectIndex( selected - 1 );
|
|
962 |
}
|
|
963 |
}
|
|
964 |
break;
|
|
965 |
case EStdKeyRightArrow:
|
|
966 |
{
|
|
967 |
if ( selected == numbertotal-1 )
|
|
968 |
{
|
|
969 |
UIContainer()->CandidatePane()->SelectIndex( 0 );
|
|
970 |
}
|
|
971 |
else
|
|
972 |
{
|
|
973 |
UIContainer()->CandidatePane()->SelectIndex( selected + 1 );
|
|
974 |
}
|
|
975 |
break;
|
|
976 |
}
|
|
977 |
case EStdKeyDevice1: // cancel key
|
|
978 |
{
|
|
979 |
iOwner->FepMan()->TryCloseUiL();
|
|
980 |
break;
|
|
981 |
}
|
|
982 |
case EStdKeyUpArrow:
|
|
983 |
{
|
|
984 |
if ( uiContainer->CandidatePane()->IsFirstPage() ) // same as the backspace
|
|
985 |
{
|
|
986 |
editPane->SetChangeState( ETrue );
|
|
987 |
iOwner->ChangeState( EZhuyinSpelling );
|
|
988 |
}
|
|
989 |
else // just move to the last page
|
|
990 |
{
|
|
991 |
uiContainer->CandidatePane()->PreviousCandidatePage();
|
|
992 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
993 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
994 |
UpdateIndicator();
|
|
995 |
}
|
|
996 |
break;
|
|
997 |
}
|
|
998 |
case EStdKeyDownArrow:
|
|
999 |
{
|
|
1000 |
ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL( aKey, aLength );
|
|
1001 |
}
|
|
1002 |
break;
|
|
1003 |
case EStdKeyBackspace: //
|
|
1004 |
{
|
|
1005 |
TBool state = ETrue;
|
|
1006 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress )
|
|
1007 |
{
|
|
1008 |
state = EFalse;
|
|
1009 |
}
|
|
1010 |
else
|
|
1011 |
{
|
|
1012 |
editPane->SetChangeState( EFalse );
|
|
1013 |
}
|
|
1014 |
if ( state )
|
|
1015 |
{
|
|
1016 |
editPane->SetChangeState( ETrue );
|
|
1017 |
iOwner->ChangeState( EZhuyinSpelling );
|
|
1018 |
}
|
|
1019 |
}
|
|
1020 |
break;
|
|
1021 |
case EStdKeyDevice0: //commit to editor
|
|
1022 |
case EStdKeyDevice3:
|
|
1023 |
{
|
|
1024 |
TBool state = ETrue;
|
|
1025 |
if ( editPane->IsChangeState() && aLength == ELongKeyPress )
|
|
1026 |
{
|
|
1027 |
state = EFalse;
|
|
1028 |
}
|
|
1029 |
else
|
|
1030 |
{
|
|
1031 |
editPane->SetChangeState( EFalse );
|
|
1032 |
}
|
|
1033 |
if ( state )
|
|
1034 |
{
|
|
1035 |
editPane->SetNeedClearDeliberateSelection( ETrue );
|
|
1036 |
CommitCandidateL();
|
|
1037 |
}
|
|
1038 |
}
|
|
1039 |
break;
|
|
1040 |
default:
|
|
1041 |
if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
|
|
1042 |
{
|
|
1043 |
iOwner->FepMan()->PlaySound(EAvkonSIDDefaultSound);
|
|
1044 |
break;
|
|
1045 |
}
|
|
1046 |
if ( SelectCandidate( aKey ) ) // is 1-6 key
|
|
1047 |
{
|
|
1048 |
editPane->SetNeedClearDeliberateSelection( ETrue );
|
|
1049 |
CommitCandidateL();
|
|
1050 |
}
|
|
1051 |
else
|
|
1052 |
{
|
|
1053 |
return TAknFepInputMiniQwertyZhuyinPhraseBase::HandleKeyL(
|
|
1054 |
aKey, aLength );
|
|
1055 |
}
|
|
1056 |
break;
|
|
1057 |
}
|
|
1058 |
return ret;
|
|
1059 |
}
|
|
1060 |
// ---------------------------------------------------------------------------
|
|
1061 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate
|
|
1062 |
// commint the charater to the editor pane
|
|
1063 |
// ---------------------------------------------------------------------------
|
|
1064 |
|
|
1065 |
TInt TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::GetIndexOfToneMark( const TDesC& aText)
|
|
1066 |
{
|
|
1067 |
TInt indexOfToneMark = -1;
|
|
1068 |
TInt num = sizeof(ZhuyinToneMap )/( sizeof(ZhuyinToneMap[0]));
|
|
1069 |
TInt len = aText.Length();
|
|
1070 |
for( TInt j = 0; j< len ;j++ )
|
|
1071 |
{
|
|
1072 |
indexOfToneMark = j;
|
|
1073 |
TBuf<1> keyStorkeBuf = aText.Mid( j ,1 );
|
|
1074 |
for (TInt i = 0; i<num; i++ )
|
|
1075 |
{
|
|
1076 |
if ( keyStorkeBuf[0] == ZhuyinToneMap[i].iValue )
|
|
1077 |
{
|
|
1078 |
return indexOfToneMark;
|
|
1079 |
}
|
|
1080 |
}
|
|
1081 |
}
|
|
1082 |
return -1;
|
|
1083 |
}
|
|
1084 |
// ---------------------------------------------------------------------------
|
|
1085 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate
|
|
1086 |
// commint the charater to the editor pane
|
|
1087 |
// ---------------------------------------------------------------------------
|
|
1088 |
//
|
|
1089 |
void TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidateL()
|
|
1090 |
{
|
|
1091 |
CDesCArrayFlat* keyStrokeArray = UIContainer()->EditPaneWindow()->KeystrokeArray();
|
|
1092 |
CDesCArrayFlat* phraseKeyStrokeArray = UIContainer()->EditPaneWindow()->PhraseShowKeyStrokeArray();
|
|
1093 |
CDesCArrayFlat* phraseArray = UIContainer()->EditPaneWindow()->PhraseArray();
|
|
1094 |
CDesCArrayFlat* phraseZhuYinSpellingArray = UIContainer()->EditPaneWindow()->PhraseZhuYinSpellingArray();
|
|
1095 |
TPtrC candidate = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
|
|
1096 |
|
|
1097 |
RArray<TInt>* keyCodeArray = UIContainer()->EditPaneWindow()->KeycodeArray();
|
|
1098 |
RArray<TInt>* keyCodePhraseArray = UIContainer()->EditPaneWindow()->PhraseKeycodeArray();
|
|
1099 |
TBuf<KMaxKeystrokeCount> spellingText;
|
|
1100 |
|
|
1101 |
UIContainer()->InputPane()->GetText( spellingText );
|
|
1102 |
|
|
1103 |
//phraseZhuYinSpellingArray must keep same count with phraseArray
|
|
1104 |
TInt delCount = phraseZhuYinSpellingArray->Count()-phraseArray->Count();//we can sure delCount>=0,impossible <0
|
|
1105 |
if(delCount>0)
|
|
1106 |
{
|
|
1107 |
phraseZhuYinSpellingArray->Delete(phraseArray->Count(),delCount);//delete from tail
|
|
1108 |
}
|
|
1109 |
phraseZhuYinSpellingArray->AppendL(spellingText);
|
|
1110 |
phraseArray->AppendL( candidate );
|
|
1111 |
|
|
1112 |
TBuf<KMaxKeystrokeCount> keyStoke;
|
|
1113 |
TInt replaceCount = 0;
|
|
1114 |
TInt delimiterIndex = spellingText.Find( KDelimiter );
|
|
1115 |
if ( KErrNotFound ==delimiterIndex )
|
|
1116 |
{
|
|
1117 |
delimiterIndex = -1;
|
|
1118 |
}
|
|
1119 |
TInt indexOfToneMark = GetIndexOfToneMark( spellingText );
|
|
1120 |
if ( delimiterIndex != KErrNotFound && indexOfToneMark >= 0 )
|
|
1121 |
{
|
|
1122 |
replaceCount = Min( delimiterIndex, indexOfToneMark );
|
|
1123 |
if ( delimiterIndex > indexOfToneMark )
|
|
1124 |
{
|
|
1125 |
replaceCount++;
|
|
1126 |
}
|
|
1127 |
}
|
|
1128 |
else if ( delimiterIndex != KErrNotFound && indexOfToneMark == -1 )
|
|
1129 |
{
|
|
1130 |
replaceCount = delimiterIndex;
|
|
1131 |
}
|
|
1132 |
else if ( delimiterIndex == KErrNotFound && indexOfToneMark != -1 )
|
|
1133 |
{
|
|
1134 |
replaceCount = indexOfToneMark + 1;
|
|
1135 |
}
|
|
1136 |
else
|
|
1137 |
{
|
|
1138 |
replaceCount = spellingText.Length();
|
|
1139 |
}
|
|
1140 |
for (TInt i = 0; i < replaceCount; i++ )
|
|
1141 |
{
|
|
1142 |
TPtrC ptr = keyStrokeArray->MdcaPoint( 0 );
|
|
1143 |
keyStoke.Append( ptr );
|
|
1144 |
keyStrokeArray->Delete( 0 );
|
|
1145 |
// added for the keycode
|
|
1146 |
TInt keyCodeValue = ( *keyCodeArray )[0];
|
|
1147 |
keyCodePhraseArray->AppendL( keyCodeValue );
|
|
1148 |
keyCodeArray->Remove( 0 );
|
|
1149 |
}
|
|
1150 |
phraseKeyStrokeArray->AppendL( keyStoke );
|
|
1151 |
|
|
1152 |
if ( GetValidKeystroke() )
|
|
1153 |
{
|
|
1154 |
iOwner->ChangeState( EZhuyinSpelling );
|
|
1155 |
}
|
|
1156 |
else
|
|
1157 |
{
|
|
1158 |
iOwner->ChangeState( EMiniQwertyEdit );
|
|
1159 |
}
|
|
1160 |
UIContainer()->EditPaneWindow()->SetChangeState(ETrue);
|
|
1161 |
RefreshSpellingPane();
|
|
1162 |
RefreshCandidatePane();
|
|
1163 |
ChangeCbaL();
|
|
1164 |
}
|
|
1165 |
|
|
1166 |
// ---------------------------------------------------------------------------
|
|
1167 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::CommitCandidate
|
|
1168 |
// to check the select number is valid or not
|
|
1169 |
// ---------------------------------------------------------------------------
|
|
1170 |
//
|
|
1171 |
TBool TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::SelectCandidate(
|
|
1172 |
TInt aKey )
|
|
1173 |
{
|
|
1174 |
TInt index = 0;
|
|
1175 |
MPtiLanguage *lang= NULL;
|
|
1176 |
RArray <TPtiNumericKeyBinding> keybinding;
|
|
1177 |
TBool validnumkey = EFalse;
|
|
1178 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
1179 |
TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout();
|
|
1180 |
|
|
1181 |
if( ptiengine != NULL )
|
|
1182 |
{
|
|
1183 |
lang = ptiengine->CurrentLanguage();
|
|
1184 |
}
|
|
1185 |
if ( ptiengine && lang )
|
|
1186 |
{
|
|
1187 |
TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardtype));
|
|
1188 |
TInt numericKeysCount = keybinding.Count();
|
|
1189 |
while (numericKeysCount-- )
|
|
1190 |
{
|
|
1191 |
TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount];
|
|
1192 |
if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36)
|
|
1193 |
&&(aKey == numKeyBind.iKey) )
|
|
1194 |
{
|
|
1195 |
index = numKeyBind.iChar - EPtiKey0 -1;
|
|
1196 |
if ( UIContainer()->CandidatePane()->SelectIndex( index, EFalse ) )
|
|
1197 |
{
|
|
1198 |
validnumkey = ETrue;
|
|
1199 |
}
|
|
1200 |
break;
|
|
1201 |
}
|
|
1202 |
}
|
|
1203 |
}
|
|
1204 |
keybinding.Reset();
|
|
1205 |
return validnumkey;
|
|
1206 |
}
|
|
1207 |
// ---------------------------------------------------------------------------
|
|
1208 |
// TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommandL
|
|
1209 |
// Handling Command
|
|
1210 |
// ---------------------------------------------------------------------------
|
|
1211 |
//
|
|
1212 |
void TAknFepInputStateEditingMiniQwertyZhuyinPhrase::HandleCommandL(
|
|
1213 |
TInt aCommandId )
|
|
1214 |
{
|
|
1215 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1216 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
1217 |
UIContainer()->CandidatePane();
|
|
1218 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
1219 |
TBool state = ETrue;
|
|
1220 |
switch ( aCommandId )
|
|
1221 |
{
|
|
1222 |
// Handle the event frome command.
|
|
1223 |
case EAknSoftkeySelect:
|
|
1224 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
|
|
1225 |
if ( editPane->IsChangeState() )
|
|
1226 |
{
|
|
1227 |
state = EFalse;
|
|
1228 |
}
|
|
1229 |
else
|
|
1230 |
{
|
|
1231 |
editPane->SetChangeState( EFalse );
|
|
1232 |
}
|
|
1233 |
if ( state )
|
|
1234 |
{
|
|
1235 |
HandleCommitL();
|
|
1236 |
}
|
|
1237 |
break;
|
|
1238 |
default:
|
|
1239 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
1240 |
break;
|
|
1241 |
}
|
|
1242 |
}
|
|
1243 |
|
|
1244 |
// ---------------------------------------------------------------------------
|
|
1245 |
// TAknFepInputStateSpellingMiniQwertyZhuyin::HandleCommandL
|
|
1246 |
// Handling Command
|
|
1247 |
// ---------------------------------------------------------------------------
|
|
1248 |
//
|
|
1249 |
void TAknFepInputStateSpellingMiniQwertyZhuyin::HandleCommandL(
|
|
1250 |
TInt aCommandId )
|
|
1251 |
{
|
|
1252 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1253 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
1254 |
UIContainer()->CandidatePane();
|
|
1255 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
1256 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
1257 |
TBool state = ETrue;
|
|
1258 |
switch ( aCommandId )
|
|
1259 |
{
|
|
1260 |
// Handle the event frome command.
|
|
1261 |
case EAknSoftkeySelect:
|
|
1262 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
|
|
1263 |
if ( editPane->IsChangeState() )
|
|
1264 |
{
|
|
1265 |
state = EFalse;
|
|
1266 |
}
|
|
1267 |
else
|
|
1268 |
{
|
|
1269 |
editPane->SetChangeState( EFalse );
|
|
1270 |
}
|
|
1271 |
if ( state )
|
|
1272 |
{
|
|
1273 |
if ( popup->IsEnabled() )
|
|
1274 |
{
|
|
1275 |
popup->Enable( EFalse );
|
|
1276 |
}
|
|
1277 |
editPane->SetChangeState( ETrue );
|
|
1278 |
iOwner->ChangeState( EZhuyinCandidate );
|
|
1279 |
}
|
|
1280 |
break;
|
|
1281 |
default:
|
|
1282 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
1283 |
break;
|
|
1284 |
}
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
// ---------------------------------------------------------------------------
|
|
1288 |
// TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleCommandL
|
|
1289 |
// Handling Command
|
|
1290 |
// ---------------------------------------------------------------------------
|
|
1291 |
//
|
|
1292 |
void TAknFepInputStateCanindateSelectingMiniQwertyZhuyin::HandleCommandL(
|
|
1293 |
TInt aCommandId )
|
|
1294 |
{
|
|
1295 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
1296 |
MAknFepUICtrlCandidatePane* candidatePane =
|
|
1297 |
UIContainer()->CandidatePane();
|
|
1298 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
1299 |
TBool state = ETrue;
|
|
1300 |
switch ( aCommandId )
|
|
1301 |
{
|
|
1302 |
// Handle the event frome command.
|
|
1303 |
case EAknSoftkeySelect:
|
|
1304 |
//case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
|
|
1305 |
if ( editPane->IsChangeState() )
|
|
1306 |
{
|
|
1307 |
state = EFalse;
|
|
1308 |
}
|
|
1309 |
else
|
|
1310 |
{
|
|
1311 |
editPane->SetChangeState( EFalse );
|
|
1312 |
}
|
|
1313 |
if ( state )
|
|
1314 |
{
|
|
1315 |
editPane->SetNeedClearDeliberateSelection( ETrue );
|
|
1316 |
CommitCandidateL();
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
break;
|
|
1320 |
default:
|
|
1321 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
1322 |
break;
|
|
1323 |
}
|
|
1324 |
}
|
|
1325 |
//End of File
|