|
1 /* |
|
2 * Copyright (c) 2005 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 TAknFepUIInputStateEntryQwertyCangJie methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
31 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
32 #include "AknFepUiInputStateEntryQwertyCangJie.h" |
|
33 #include "AknFepUICtrlCandidatePane.h" |
|
34 |
|
35 #include <PtiEngine.h> //CPtiEngine |
|
36 #include <e32keys.h> //keys |
|
37 #include <avkon.hrh> |
|
38 |
|
39 const TInt KEasyCangJieLengthLimit(2); // Spelling limit for Easy CangJie is 2 characters |
|
40 const TInt KNormalAdvCangJieLengthLimit(5); // Spelling limit for Normal and Advanced CangJie is 5 characters |
|
41 |
|
42 TAknFepInputStateEntryQwertyCangJie::TAknFepInputStateEntryQwertyCangJie( |
|
43 MAknFepUIManagerStateInterface* aOwner, |
|
44 MAknFepUICtrlContainerChinese* aUIContainer) |
|
45 :TAknFepInputStateEntryQwertyBase(aOwner,aUIContainer) |
|
46 { |
|
47 UIContainer()->CandidatePane()->ShowCandidateOrdinals(ETrue); |
|
48 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
49 |
|
50 ptiengine->SetInputMode( ( TPtiEngineInputMode )iOwner->FepMan()->CangJieMode() ); |
|
51 |
|
52 // This is a must otherwise Engine cannot find keys in KeyMapping |
|
53 ptiengine->SetCase(EPtiCaseLower); |
|
54 ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput); |
|
55 } |
|
56 |
|
57 TBool TAknFepInputStateEntryQwertyCangJie::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
58 { |
|
59 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
60 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
61 TPtiEngineInputMode currentMode = ptiengine->InputMode(); |
|
62 |
|
63 TBool processKey = ETrue; |
|
64 |
|
65 if (!IsValidCangJieCode(aKey)) |
|
66 return TAknFepInputStateEntryQwertyBase::HandleKeyL(aKey, aLength); |
|
67 |
|
68 TInt bufferLength = 0; |
|
69 TInt lengthLimit = 0; |
|
70 // Limit the length of the key append for different CangJie level |
|
71 switch(currentMode) |
|
72 { |
|
73 case EPtiEngineEasyCangjieQwerty: |
|
74 lengthLimit = KEasyCangJieLengthLimit; |
|
75 break; |
|
76 case EPtiEngineNormalCangjieQwerty: |
|
77 case EPtiEngineAdvCangjieQwerty: |
|
78 lengthLimit = KNormalAdvCangJieLengthLimit; |
|
79 break; |
|
80 default: |
|
81 break; |
|
82 } |
|
83 |
|
84 if (ptiengine->PhoneticSpellingCount() > 0) |
|
85 { |
|
86 TPtrC spellingBuf = ptiengine->GetPhoneticSpelling(1); |
|
87 bufferLength = spellingBuf.Length(); |
|
88 |
|
89 if (bufferLength >= lengthLimit) |
|
90 { |
|
91 processKey = EFalse; |
|
92 fepMan->PlaySound(EAvkonSIDConfirmationTone); |
|
93 } |
|
94 } |
|
95 |
|
96 return processKey ? TAknFepInputStateEntryQwertyBase::HandleKeyL(aKey, aLength) : ETrue; |
|
97 } |
|
98 |
|
99 |
|
100 // End of file |