|
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: Implementation of Pinyin phrase predictive candidate MiniQwerty 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 "AknFepUiInputStatePredictiveCandidateMiniQwertyChinesePhrase.h" |
|
34 #include "AknFepUiCtrlContainerChinese.h" |
|
35 #include "AknFepUIManagerStateInterface.h" |
|
36 #include "AknFepManagerUIInterface.h" |
|
37 #include "AknFepManager.h" |
|
38 #include "AknFepUICtrlCandidatePane.h" |
|
39 #include "aknfepuictrleditpane.h" |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase:: |
|
43 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase |
|
44 // (other items were commented in a header). |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase:: |
|
48 TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase( |
|
49 MAknFepUIManagerStateInterface* aOwner, |
|
50 MAknFepUICtrlContainerChinese* aUIContainer) |
|
51 :TAknFepInputStatePredictiveInputQwertyChinesePhrase(aOwner, aUIContainer) |
|
52 { |
|
53 iState = EPredictiveCandidate; |
|
54 UIContainer()->CandidatePane()->ShowCandidateOrdinals(EFalse); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::HandleKeyL |
|
59 // (other items were commented in a header). |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 TBool TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::HandleKeyL( |
|
63 TInt aKey, TKeyPressLength aLength) |
|
64 { |
|
65 TBool ret = ETrue; |
|
66 |
|
67 if(iOwner->IsValidChineseSymbol(aKey)) |
|
68 { |
|
69 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
70 ret = ETrue; |
|
71 } |
|
72 else if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) || |
|
73 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)|| |
|
74 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed)) |
|
75 { |
|
76 iOwner->FepMan()->TryCloseUiL(); |
|
77 ret = EFalse; |
|
78 } |
|
79 else if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || |
|
80 CAknFepFnKeyManager::EFnKeyLock == iOwner->FepMan()->FnKeyState() || |
|
81 CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState()) // for fn + a character |
|
82 { |
|
83 iOwner->FepMan()->TryCloseUiL(); |
|
84 ret = EFalse; |
|
85 } |
|
86 else if ( aKey ==EKeyLeftCtrl || aKey == EKeyRightCtrl) |
|
87 { |
|
88 iOwner->FepMan()->TryCloseUiL(); |
|
89 ret = EFalse; |
|
90 } |
|
91 else if (aKey == EStdKeyEnter) |
|
92 { |
|
93 iOwner->FepMan()->TryCloseUiL(); |
|
94 ret = EFalse; |
|
95 } |
|
96 else if (aKey == EStdKeyBackspace) |
|
97 { |
|
98 iOwner->FepMan()->TryCloseUiL(); |
|
99 } |
|
100 else if (aKey ==EKeyRightFunc)//fn key |
|
101 { |
|
102 iOwner->FepMan()->TryCloseUiL(); |
|
103 ret = EFalse; |
|
104 } |
|
105 else if ( aKey ==EStdKeySpace) |
|
106 { |
|
107 if (ECangJie ==iOwner->FepMan()->InputMode()) |
|
108 { |
|
109 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate(); |
|
110 if(text.Length()) |
|
111 { |
|
112 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
113 fepMan->NewTextL(text); |
|
114 fepMan->CommitInlineEditL(); |
|
115 iOwner->PtiEngine()->SetPredictiveChineseChar(text); |
|
116 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
117 { |
|
118 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
119 iOwner->FepMan()->TryCloseUiL(); |
|
120 } |
|
121 else |
|
122 { |
|
123 iOwner->ChangeState(EPredictiveCandidate); |
|
124 } |
|
125 } |
|
126 return ETrue; |
|
127 } |
|
128 else |
|
129 { |
|
130 iOwner->FepMan()->TryCloseUiL(); |
|
131 ret = EFalse; |
|
132 } |
|
133 } |
|
134 else if ( aKey == EStdKeyDevice0 || aKey == EStdKeyDevice3 ) // Add for SK1 and selection |
|
135 { |
|
136 TBool state = ETrue; |
|
137 if ( UIContainer()->EditPaneWindow()->IsChangeState() && aLength == ELongKeyPress ) |
|
138 { |
|
139 state = EFalse; |
|
140 } |
|
141 else |
|
142 { |
|
143 UIContainer()->EditPaneWindow()->SetChangeState( EFalse ); |
|
144 } |
|
145 if ( state ) |
|
146 { |
|
147 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate(); |
|
148 if(text.Length()) |
|
149 { |
|
150 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
151 fepMan->NewTextL(text); |
|
152 fepMan->CommitInlineEditL(); |
|
153 iOwner->PtiEngine()->SetPredictiveChineseChar(text); |
|
154 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
155 { |
|
156 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
157 iOwner->FepMan()->TryCloseUiL(); |
|
158 } |
|
159 else |
|
160 { |
|
161 iOwner->ChangeState(EPredictiveCandidate); |
|
162 } |
|
163 } |
|
164 } |
|
165 } |
|
166 else if(aKey == EStdKeyRightArrow ) |
|
167 { |
|
168 iOwner->ChangeState(EPredictiveInput); |
|
169 UIContainer()->CandidatePane()->SelectNext(); |
|
170 } |
|
171 else if (aKey == EStdKeyLeftArrow) |
|
172 { |
|
173 iOwner->ChangeState(EPredictiveInput); |
|
174 UIContainer()->CandidatePane()->SelectLastPhrase(); |
|
175 } |
|
176 else if(iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
177 { |
|
178 if ( aLength == ELongKeyPress ) |
|
179 { |
|
180 return ETrue; |
|
181 } |
|
182 |
|
183 if(EPinyin ==iOwner->FepMan()->InputMode()) |
|
184 { |
|
185 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
186 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
187 ptiengine->ClearCurrentWord(); |
|
188 ptiengine->ResetToneMark(); |
|
189 |
|
190 iOwner->ChangeState(EEntry); |
|
191 ret = EFalse; //passes to entry state to handle the key |
|
192 } |
|
193 else if(EZhuyin ==iOwner->FepMan()->InputMode() || |
|
194 ECangJie ==iOwner->FepMan()->InputMode() || |
|
195 EStroke ==iOwner->FepMan()->InputMode() ) |
|
196 { |
|
197 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
198 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
199 ptiengine->ClearCurrentWord(); |
|
200 ptiengine->ResetToneMark(); |
|
201 |
|
202 iOwner->ChangeState(EEntry); |
|
203 ret = EFalse; //passes to entry state to handle the key |
|
204 } |
|
205 |
|
206 } |
|
207 else if( aKey == EPtiKeyQwertyQ || |
|
208 aKey == EPtiKeyQwertyW || |
|
209 aKey == EPtiKeyQwertyO || |
|
210 aKey == EPtiKeyQwertyP || |
|
211 aKey == EPtiKeyQwertyA || |
|
212 aKey == EPtiKeyQwertyS || |
|
213 aKey == EPtiKeyQwertyL || |
|
214 aKey == EPtiKeyQwertyZ || |
|
215 aKey == EPtiKeyQwertyX || |
|
216 aKey == EPtiKeyQwertyC || |
|
217 aKey == EPtiKeyQwertyV || |
|
218 aKey == EPtiKeyQwertyB || |
|
219 aKey == EPtiKeyQwertyN || |
|
220 aKey == EPtiKeyQwertyM ) |
|
221 { |
|
222 if(EStroke ==iOwner->FepMan()->InputMode()) |
|
223 { |
|
224 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
225 //iOwner->FepMan()->TryCloseUiL(); |
|
226 } |
|
227 } |
|
228 else |
|
229 { |
|
230 ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
231 } |
|
232 |
|
233 return ret; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::HandleCommandL |
|
238 // Handling Command |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::HandleCommandL( |
|
242 TInt aCommandId ) |
|
243 { |
|
244 TBool state = ETrue; |
|
245 switch ( aCommandId ) |
|
246 { |
|
247 // Handle the event frome command. |
|
248 case EAknSoftkeySelect: |
|
249 // case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
250 if ( UIContainer()->EditPaneWindow()->IsChangeState( ) ) |
|
251 { |
|
252 state = EFalse; |
|
253 } |
|
254 else |
|
255 { |
|
256 UIContainer()->EditPaneWindow()->SetChangeState( EFalse ); |
|
257 } |
|
258 if ( state ) |
|
259 { |
|
260 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( ); |
|
261 if ( text.Length( ) ) |
|
262 { |
|
263 MAknFepManagerUIInterface* fepMan = iOwner->FepMan( ); |
|
264 fepMan->NewTextL( text ); |
|
265 fepMan->CommitInlineEditL( ); |
|
266 iOwner->PtiEngine()->SetPredictiveChineseChar( text ); |
|
267 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
|
268 { |
|
269 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
270 iOwner->FepMan()->TryCloseUiL( ); |
|
271 } |
|
272 else |
|
273 { |
|
274 iOwner->ChangeState( EPredictiveCandidate ); |
|
275 } |
|
276 } |
|
277 } |
|
278 break; |
|
279 default: |
|
280 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
281 break; |
|
282 } |
|
283 } |
|
284 // End of file |