|
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 CAknFepUIInputStateEntryQwertyZhuyin methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStateEntryQwertyZhuyin.h" |
|
31 #include "AknFepUIManagerStateInterface.h" |
|
32 |
|
33 #include <PtiEngine.h> |
|
34 #include <e32keys.h> |
|
35 #include <PtiDefs.h> //keys |
|
36 |
|
37 #include "AknFepUICtrlInputPane.h" |
|
38 #include "AknFepUICtrlCandidatePane.h" |
|
39 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
40 #include "AknFepManager.h" //FepMan flag |
|
41 |
|
42 const TInt KMaxCandidateCountFromCore = 6; |
|
43 |
|
44 TAknFepInputStateEntryQwertyZhuyin::TAknFepInputStateEntryQwertyZhuyin( |
|
45 MAknFepUIManagerStateInterface* aOwner, |
|
46 MAknFepUICtrlContainerChinese* aUIContainer) |
|
47 :TAknFepInputStateEntryQwertyBase(aOwner, aUIContainer) |
|
48 { |
|
49 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
50 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
51 |
|
52 uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse); |
|
53 |
|
54 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
55 if (EPtiEngineZhuyinQwerty != ptiengine->InputMode()) |
|
56 { |
|
57 ptiengine->SetInputMode(EPtiEngineZhuyinQwerty); |
|
58 } |
|
59 TBool multiplePages = iOwner->PtiEngine()->MoreCandidatePages(); |
|
60 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
61 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
62 |
|
63 uiContainer->CandidatePane()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
64 uiContainer->CandidatePane()->ShowVerticalScrollArrows(multiplePages); |
|
65 |
|
66 ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput); |
|
67 iOwner->PtiEngine()->SetCase(EPtiCaseLower); |
|
68 _LIT(KToneNoneZhuyin, ""); |
|
69 inputPane->SetToneMark(KToneNoneZhuyin); |
|
70 |
|
71 UpdateIndicator(); |
|
72 } |
|
73 |
|
74 TBool TAknFepInputStateEntryQwertyZhuyin::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
75 { |
|
76 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
77 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
78 |
|
79 TBool ret = ETrue; |
|
80 |
|
81 if((aKey == EPtiKey3 || |
|
82 aKey == EPtiKey4 || |
|
83 aKey == EPtiKey6 || |
|
84 aKey == EPtiKey7 || |
|
85 aKey == EStdKeySpace) && |
|
86 (aLength == EShortKeyPress)) |
|
87 { |
|
88 ptiengine->CancelTimerActivity(); |
|
89 if(ptiengine->SetToneMark(aKey)) |
|
90 { |
|
91 TBool multiplePages = ptiengine->MoreCandidatePages(); |
|
92 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
93 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
94 |
|
95 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
96 UIContainer()->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages()); |
|
97 SetInputPaneToneMark(); |
|
98 RefreshUI(); |
|
99 } |
|
100 } |
|
101 else if(aKey == EStdKeyBackspace) |
|
102 { |
|
103 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
104 { |
|
105 TBool multiplePages = ptiengine->MoreCandidatePages(); |
|
106 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
107 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
108 |
|
109 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
110 uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages()); |
|
111 SetInputPaneToneMark(); |
|
112 RefreshUI(); |
|
113 } |
|
114 else |
|
115 { |
|
116 iOwner->FepMan()->TryCloseUiL(); |
|
117 if (aLength == ELongKeyPress) |
|
118 { |
|
119 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue); |
|
120 } |
|
121 } |
|
122 } |
|
123 else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
124 { |
|
125 ptiengine->CancelTimerActivity(); |
|
126 ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
127 |
|
128 TBool multiplePages = ptiengine->MoreCandidatePages(); |
|
129 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
130 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
131 |
|
132 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
133 uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages()); |
|
134 SetInputPaneToneMark(); |
|
135 RefreshUI(); |
|
136 } |
|
137 else if(aKey == EStdKeyRightArrow || aKey == EStdKeyLeftArrow) |
|
138 { |
|
139 ptiengine->CancelTimerActivity(); |
|
140 iOwner->ChangeState(ECandidate); |
|
141 ret = EFalse; |
|
142 } |
|
143 else if(aKey == EStdKeyDevice1) |
|
144 { |
|
145 iOwner->FepMan()->TryCloseUiL(); |
|
146 } |
|
147 else if(!HandleVerticalNavigation(aKey)) |
|
148 { |
|
149 // it may be one of the 'valid' numbers.. |
|
150 TInt index = MapKeyToIndex(aKey); |
|
151 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
152 |
|
153 if(candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey == EStdKeyEnter) |
|
154 { |
|
155 TPtrC text = candidatePane->CurrentCandidate(); |
|
156 if(text.Length()) |
|
157 { |
|
158 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
159 fepMan->NewCharacterL(text); |
|
160 fepMan->CommitInlineEditL(); |
|
161 iOwner->PtiEngine()->SetPredictiveChineseChar(text); |
|
162 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
163 { |
|
164 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
165 iOwner->FepMan()->TryCloseUiL(); |
|
166 } |
|
167 else |
|
168 { |
|
169 iOwner->ChangeState(EPredictiveCandidate); |
|
170 } |
|
171 } |
|
172 else |
|
173 { |
|
174 // No candidates available. Back to Entry state. |
|
175 iOwner->ChangeState(EEntry); |
|
176 } |
|
177 } |
|
178 } |
|
179 return ret; |
|
180 } |
|
181 |
|
182 void TAknFepInputStateEntryQwertyZhuyin::KeyTimerExpired() |
|
183 { |
|
184 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
185 TPtrC candidates = ptiengine->CandidatePage(); |
|
186 TText toneMark; |
|
187 TBool toneMarkEntered = ptiengine->ToneMark(toneMark); |
|
188 TBool toneMarkValid = ptiengine->IsToneMarkValidForSpelling(); |
|
189 if(!candidates.Length() || (toneMarkEntered && !toneMarkValid)) |
|
190 { |
|
191 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
192 ptiengine->DeleteKeyPress(); |
|
193 SetInputPaneToneMark(); |
|
194 |
|
195 TBool multiplePages = ptiengine->MoreCandidatePages(); |
|
196 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
197 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
198 |
|
199 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
200 uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages()); |
|
201 RefreshUI(); |
|
202 } |
|
203 } |
|
204 |
|
205 void TAknFepInputStateEntryQwertyZhuyin::RefreshUI() |
|
206 { |
|
207 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
208 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
209 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
210 |
|
211 // set container's position |
|
212 TPoint baseLine = TPoint(0,0); |
|
213 TInt height = 0; |
|
214 TInt ascent = 0; |
|
215 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
216 if (ret == KErrNone) |
|
217 { |
|
218 uiContainer->SetContainerPosition(baseLine, height); |
|
219 } |
|
220 |
|
221 TPtrC candidates = ptiengine->CandidatePage(); |
|
222 uiContainer->CandidatePane()->SetCandidateBuffer(candidates); |
|
223 uiContainer->Enable(ETrue); |
|
224 uiContainer->CandidatePane()->SelectFirst(); |
|
225 TPtrC ptr = ptiengine->GetPhoneticSpelling(1); |
|
226 inputPane->SetText(ptr); |
|
227 UpdateIndicator(); |
|
228 } |
|
229 |
|
230 void TAknFepInputStateEntryQwertyZhuyin::UpdateIndicator() |
|
231 { |
|
232 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
233 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
234 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
235 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
236 |
|
237 if (ptiengine->NumberOfCandidates() == 0) |
|
238 { |
|
239 uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse); |
|
240 } |
|
241 else |
|
242 { |
|
243 uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue); |
|
244 } |
|
245 |
|
246 uiContainer->CandidatePane()->ShowDownScrollArrows |
|
247 (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse); |
|
248 |
|
249 if (candidatePane->SelectedIndex() == 0 && |
|
250 ptiengine->NumberOfCandidates() == 0) |
|
251 { |
|
252 uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse); |
|
253 } |
|
254 else |
|
255 { |
|
256 uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue); |
|
257 } |
|
258 |
|
259 if (bufLength != KMaxCandidateCountFromCore && |
|
260 candidatePane->SelectedIndex() == (bufLength -1)) |
|
261 { |
|
262 uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse); |
|
263 } |
|
264 else |
|
265 { |
|
266 uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue); |
|
267 } |
|
268 } |
|
269 |
|
270 TBool TAknFepInputStateEntryQwertyZhuyin::HandleVerticalNavigation(TInt aKey) |
|
271 { |
|
272 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
273 |
|
274 if (aKey == EStdKeyDownArrow || aKey == EStdKeySpace) |
|
275 { |
|
276 if (iOwner->PtiEngine()->CandidatePage().Length() != |
|
277 KMaxCandidateCountFromCore) |
|
278 { |
|
279 return ETrue; |
|
280 } |
|
281 ptiengine->NextCandidatePage(); |
|
282 } |
|
283 else if (aKey == EStdKeyUpArrow) |
|
284 { |
|
285 if (ptiengine->NumberOfCandidates() == 0) |
|
286 { |
|
287 return ETrue; |
|
288 } |
|
289 ptiengine->PreviousCandidatePage(); |
|
290 } |
|
291 else |
|
292 { |
|
293 return EFalse; |
|
294 } |
|
295 |
|
296 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
297 candidatePane->SelectFirst(); |
|
298 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
299 UpdateIndicator(); |
|
300 return ETrue; |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // TAknFepInputStateEntryQwertyZhuyin::HandleCommandL |
|
305 // Handling Command |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void TAknFepInputStateEntryQwertyZhuyin::HandleCommandL( TInt aCommandId ) |
|
309 { |
|
310 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
311 } |
|
312 // End of file |