1 /* |
|
2 * Copyright (c) 2002-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: Implementation of Pinyin phrase predictive Qwerty state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // System includes |
|
30 #include <PtiEngine.h> |
|
31 |
|
32 // User includes |
|
33 #include "AknFepUiInputStatePredictiveInputQwertyPinyinPhrase.h" |
|
34 #include "AknFepUiInputStatePredictiveInputQwertyPhrase.h" |
|
35 #include "AknFepUiCtrlContainerChinese.h" |
|
36 #include "AknFepUIManagerStateInterface.h" |
|
37 #include "AknFepManagerUIInterface.h" |
|
38 #include "AknFepManager.h" |
|
39 #include "AknFepUICtrlCandidatePane.h" |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase:: |
|
43 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase |
|
44 // (other items were commented in a header). |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 TAknFepInputStatePredictiveInputQwertyPinyinPhrase:: |
|
48 TAknFepInputStatePredictiveInputQwertyPinyinPhrase( |
|
49 MAknFepUIManagerStateInterface* aOwner, |
|
50 MAknFepUICtrlContainerChinese* aUIContainer) |
|
51 :TAknFepInputStatePredictiveInputQwertyChinesePhrase(aOwner, aUIContainer) |
|
52 { |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase::HandleKeyL |
|
57 // (other items were commented in a header). |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 TBool TAknFepInputStatePredictiveInputQwertyPinyinPhrase::HandleKeyL(TInt aKey, |
|
61 TKeyPressLength aLength) |
|
62 { |
|
63 TBool ret = ETrue; |
|
64 |
|
65 if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) || |
|
66 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
67 { |
|
68 iOwner->FepMan()->TryCloseUiL(); |
|
69 ret = EFalse; |
|
70 } |
|
71 else if (aKey == EStdKeyEnter) |
|
72 { |
|
73 iOwner->FepMan()->TryCloseUiL(); |
|
74 iOwner->ChangeState(EQwerty); |
|
75 return EFalse; |
|
76 } |
|
77 else if (IsValidEntryKey(aKey)) |
|
78 { |
|
79 iOwner->FepMan()->TryCloseUiL(); |
|
80 ret = EFalse; |
|
81 } |
|
82 else if(iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
83 { |
|
84 if (IsValidPinyinKey(aKey)) |
|
85 { |
|
86 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
87 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
88 ptiengine->ClearCurrentWord(); |
|
89 ptiengine->ResetToneMark(); |
|
90 |
|
91 iOwner->ChangeState(EEntry); |
|
92 ret = EFalse; //passes to entry state to handle the key |
|
93 } |
|
94 else |
|
95 { |
|
96 iOwner->FepMan()->PlaySound(EAvkonSIDWarningTone); |
|
97 } |
|
98 } |
|
99 else if (aKey == EStdKeySpace) |
|
100 { |
|
101 TInt index = MapKeyToIndex(EStdKeyDevice3); |
|
102 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
103 |
|
104 candidatePane->SelectIndex(index); |
|
105 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
106 if(text.Length()) |
|
107 { |
|
108 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
109 fepMan->NewTextL(text); |
|
110 fepMan->CommitInlineEditL(); |
|
111 iOwner->PtiEngine()->SetPredictiveChineseChar(text); |
|
112 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
113 { |
|
114 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
115 iOwner->FepMan()->TryCloseUiL(); |
|
116 } |
|
117 else |
|
118 { |
|
119 iOwner->ChangeState(EPredictiveInput); |
|
120 } |
|
121 } |
|
122 else |
|
123 { |
|
124 // No candidates available. Back to Entry state. |
|
125 iOwner->ChangeState(EEntry); |
|
126 } |
|
127 } |
|
128 else |
|
129 { |
|
130 ret = TAknFepInputStatePredictiveInputQwertyChinesePhrase::HandleKeyL(aKey, aLength); |
|
131 } |
|
132 |
|
133 return ret; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase::IsValidPinyinKey |
|
138 // (other items were commented in a header). |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 TBool TAknFepInputStatePredictiveInputQwertyPinyinPhrase::IsValidPinyinKey(TInt aKey) |
|
142 { |
|
143 TBool response = ETrue; |
|
144 |
|
145 if (aKey == EPtiKeyQwertyU || aKey == EPtiKeyQwertyV || |
|
146 aKey == EPtiKeyQwertyI ) |
|
147 { |
|
148 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
149 response = EFalse; |
|
150 } |
|
151 |
|
152 return response; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase::IsValidEntryKey |
|
157 // (other items were commented in a header). |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 TBool TAknFepInputStatePredictiveInputQwertyPinyinPhrase::IsValidEntryKey(TInt aKey) |
|
161 { |
|
162 TBool response = ETrue; |
|
163 |
|
164 if ((aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ) || |
|
165 (aKey >= EStdKeyLeftArrow && aKey <= EStdKeyDownArrow) || |
|
166 (aKey >= EPtiKeyQwerty0 && aKey <= EPtiKeyQwerty9) || |
|
167 aKey == EStdKeyBackspace || aKey == EStdKeyLeftFunc || |
|
168 aKey == EStdKeyDevice1 || aKey == EStdKeySpace || |
|
169 aKey == EStdKeyDevice0 ||aKey == EStdKeyDevice3) |
|
170 { |
|
171 response = EFalse; |
|
172 } |
|
173 |
|
174 return response; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // TAknFepInputStatePredictiveInputQwertyPinyinPhrase::HandleCommandL |
|
179 // Handling Command |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void TAknFepInputStatePredictiveInputQwertyPinyinPhrase::HandleCommandL( |
|
183 TInt aCommandId ) |
|
184 { |
|
185 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( ); |
|
186 MAknFepManagerUIInterface* fepMan = iOwner->FepMan( ); |
|
187 switch ( aCommandId ) |
|
188 { |
|
189 // Handle the event frome command. |
|
190 case EAknSoftkeySelect: |
|
191 // case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
192 if ( text.Length( ) ) |
|
193 { |
|
194 fepMan->NewTextL( text ); |
|
195 fepMan->CommitInlineEditL( ); |
|
196 iOwner->PtiEngine()->SetPredictiveChineseChar( text ); |
|
197 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
|
198 { |
|
199 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
200 iOwner->FepMan()->TryCloseUiL( ); |
|
201 } |
|
202 else |
|
203 { |
|
204 iOwner->ChangeState( EPredictiveCandidate ); |
|
205 } |
|
206 } |
|
207 break; |
|
208 default: |
|
209 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
210 break; |
|
211 } |
|
212 } |
|
213 // End of file |
|