|
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: drop-down list control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknFepGlobalEnums.h> |
|
20 #include <peninputdropdownlist.h> |
|
21 #include <PtiEngine.h> |
|
22 #include <aknfeppeninputenums.h> |
|
23 |
|
24 #include "peninputitutchnuimgr.h" |
|
25 #include "peninputgenericitutlayout.h" |
|
26 #include "peninputgenericitutlayoutcontext.h" |
|
27 #include "peninputgenericitutdatamgr.h" |
|
28 #include "peninputitutchnuistatestandby.h" |
|
29 #include "peninputitutchnuistatepredict.h" |
|
30 #include "peninputitutchnuistatestrokezhuyincomposition.h" |
|
31 #include "peninputitutchnuistatepinyincomposition.h" |
|
32 #include "peninputitutwesternuistatespelling.h" |
|
33 #include "peninputitutwesternuistatenonpredict.h" |
|
34 #include "peninputitutwesternuistatematchselection.h" |
|
35 #include "peninputgenericitutwindowmanager.h" |
|
36 |
|
37 CChnItutUiMgr* CChnItutUiMgr::NewL(MItutLayoutContext* aContext, |
|
38 CGenericItutDataMgr* aDataMgr, |
|
39 CGenericItutWindowManager* aUiManager) |
|
40 { |
|
41 CChnItutUiMgr* self = new (ELeave) CChnItutUiMgr(aContext, aDataMgr,aUiManager); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CChnItutUiMgr::~CChnItutUiMgr() |
|
49 { |
|
50 if (iCurrentState) |
|
51 { |
|
52 iCurrentState->OnExit(); |
|
53 } |
|
54 |
|
55 delete iStandbyState; |
|
56 delete iPinyinComp; |
|
57 delete iStoZhuComp; |
|
58 delete iPredictState; |
|
59 |
|
60 delete iNormalState; |
|
61 delete iMatchSelState; |
|
62 delete iSpellState; |
|
63 } |
|
64 |
|
65 CChnItutUiMgr::CChnItutUiMgr(MItutLayoutContext* aContext, |
|
66 CGenericItutDataMgr* aDataMgr, |
|
67 CGenericItutWindowManager* aUiManager) |
|
68 :CGenericItutUiMgrBase(aContext, aDataMgr,aUiManager) |
|
69 { |
|
70 } |
|
71 |
|
72 void CChnItutUiMgr::ConstructL() |
|
73 { |
|
74 CGenericItutUiMgrBase::ConstructL(); |
|
75 |
|
76 iStandbyState = CChnItutUiStateStandby::NewL(this); |
|
77 iPinyinComp = CChnItutUiStatePinyinComposition::NewL(this); |
|
78 iStoZhuComp = CChnItutUiStateStrokeZhuyinComposition::NewL(this); |
|
79 iPredictState = CChnItutUiStatePredict::NewL(this); |
|
80 |
|
81 iNormalState = CWesternItutUiStateNonPredict::NewL(this); |
|
82 iMatchSelState = CWesternItutUiStateMatchSelection::NewL(this); |
|
83 iSpellState = CWesternItutUiStateSpelling::NewL(this); |
|
84 } |
|
85 |
|
86 TInt CChnItutUiMgr::HandleCommandL(TInt aCmd, TUint8* aData) |
|
87 { |
|
88 if (aCmd == EItutExtCmdCustomerState || |
|
89 aCmd == ECmdPenInputFingerMatchSelection || |
|
90 aCmd == ECmdPenInputFingerSpelling) |
|
91 { |
|
92 if (!(*(reinterpret_cast<TBool*>(aData)))) |
|
93 { |
|
94 // state not on |
|
95 if (!IsChineseMode()) |
|
96 { |
|
97 SetCurrentStateL(CGenericItutUiMgrBase::EStateWesternStandby); |
|
98 } |
|
99 return KErrNone; |
|
100 } |
|
101 } |
|
102 |
|
103 TUint* data = (TUint*) aData; |
|
104 |
|
105 switch (aCmd) |
|
106 { |
|
107 case ECmdPenInputFingerMatchSelection: |
|
108 { |
|
109 SetCurrentStateL(CGenericItutUiMgrBase::EStateMatchSelection); |
|
110 return KErrNone; |
|
111 } |
|
112 case ECmdPenInputFingerSpelling: |
|
113 { |
|
114 SetCurrentStateL(CGenericItutUiMgrBase::EStateSpelling); |
|
115 UiManager()->ResetIndicatorL(UiManager()->Control(ECtrlIdSpellIndicator)); |
|
116 return KErrNone; |
|
117 } |
|
118 case ECmdPenInputFingerKeyPress: |
|
119 { |
|
120 if (iCurrentState && iCurrentState->HandleKeyL(aCmd, *data)) |
|
121 { |
|
122 return KErrNone; |
|
123 } |
|
124 |
|
125 return KErrNotSupported; |
|
126 } |
|
127 case ECmdPenInputFingerLongKeyPress: |
|
128 { |
|
129 if (!IsChineseMode()) |
|
130 { |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 if (*data >= EPtiKey0 && *data <= EPtiKey9) |
|
135 { |
|
136 HandleLongPressNumberKeyL(TPtiKey(*data)); |
|
137 |
|
138 // long key press |
|
139 if (iCurrentState->StateType() == CGenericItutUiMgrBase::EStateComposition) |
|
140 { |
|
141 return KErrNone; |
|
142 } |
|
143 } |
|
144 else if (iCurrentState && iCurrentState->HandleKeyL(aCmd, *data)) |
|
145 { |
|
146 return KErrNone; |
|
147 } |
|
148 |
|
149 // means not handled by ui |
|
150 return KErrNotSupported; |
|
151 } |
|
152 case ECmdPenInputDeActive: |
|
153 { |
|
154 if (!iCurrentState) |
|
155 { |
|
156 return KErrNone; |
|
157 } |
|
158 |
|
159 TBool changeState = EFalse; |
|
160 TUiState state; |
|
161 |
|
162 if (IsChineseMode()) |
|
163 { |
|
164 iCurrentState->StateType() != CGenericItutUiMgrBase::EStateStandby ? |
|
165 changeState = ETrue : changeState = EFalse; |
|
166 |
|
167 state = CGenericItutUiMgrBase::EStateStandby; |
|
168 } |
|
169 else |
|
170 { |
|
171 iCurrentState->StateType() == CGenericItutUiMgrBase::EStateMatchSelection ? |
|
172 changeState = ETrue : changeState = EFalse; |
|
173 |
|
174 state = CGenericItutUiMgrBase::EStateWesternStandby; |
|
175 } |
|
176 |
|
177 if (changeState) |
|
178 { |
|
179 SetCurrentStateL(state); |
|
180 } |
|
181 } |
|
182 break; |
|
183 case ECmdPenInputNoFreeSpace: |
|
184 { |
|
185 if (!iCurrentState) |
|
186 { |
|
187 return KErrNone; |
|
188 } |
|
189 |
|
190 if (IsChineseMode() && |
|
191 iCurrentState->StateType() != CGenericItutUiMgrBase::EStateStandby) |
|
192 { |
|
193 SetCurrentStateL(CGenericItutUiMgrBase::EStateStandby); |
|
194 } |
|
195 } |
|
196 break; |
|
197 case ECmdPenInputCase: |
|
198 { |
|
199 if (iCurrentState)// && !IsChineseMode()) |
|
200 { |
|
201 iLayoutContext->DataMgr()->SetCase(*((TUint*) aData)); |
|
202 return KErrNone; |
|
203 } |
|
204 } |
|
205 break; |
|
206 case ECmdPenInputFingerMatchList: |
|
207 { |
|
208 if (iCurrentState) |
|
209 { |
|
210 iCurrentState->HandleCommandL(aCmd, aData); |
|
211 } |
|
212 } |
|
213 break; |
|
214 case ECmdPenInputIsSecretText: |
|
215 { |
|
216 if (iCurrentState) |
|
217 { |
|
218 iCurrentState->HandleCommandL(aCmd, aData); |
|
219 } |
|
220 } |
|
221 break; |
|
222 case EItutCmdCheckIcfEmpty: |
|
223 { |
|
224 if (iCurrentState && |
|
225 iCurrentState->StateType() == CGenericItutUiMgrBase::EStateSpelling) |
|
226 { |
|
227 iCurrentState->HandleCommandL(aCmd, aData); |
|
228 } |
|
229 |
|
230 } |
|
231 break; |
|
232 case EItutExtCmdSizeChanged: |
|
233 { |
|
234 if(iCurrentState) |
|
235 { |
|
236 iCurrentState->HandleCommandL(aCmd, aData); |
|
237 } |
|
238 } |
|
239 break; |
|
240 default: |
|
241 break; |
|
242 } |
|
243 |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 TBool CChnItutUiMgr::HandleCtrlEventL(TInt aEventType, |
|
248 CFepUiBaseCtrl* aCtrl, |
|
249 const TDesC& aEventData) |
|
250 { |
|
251 if (!iCurrentState) |
|
252 { |
|
253 return EFalse; |
|
254 } |
|
255 |
|
256 if (!IsChineseMode()) |
|
257 { |
|
258 return iCurrentState->HandleCtrlEventL(aEventType, aCtrl, aEventData); |
|
259 } |
|
260 |
|
261 if (!iCurrentState->HandleCtrlEventL(aEventType, aCtrl, aEventData)) |
|
262 { |
|
263 switch (aEventType) |
|
264 { |
|
265 case EEventRawKeyUpEvent: |
|
266 { |
|
267 if (aCtrl->ControlId() == ECtrlIdBackspace) |
|
268 { |
|
269 // if clear key released |
|
270 SetClrConsume(EFalse); |
|
271 } |
|
272 else |
|
273 { |
|
274 // if number key released |
|
275 const TKeyEvent *key = reinterpret_cast<const TKeyEvent*>(aEventData.Ptr()); |
|
276 |
|
277 if ((key->iScanCode >= EPtiKey0) && (key->iScanCode <= EPtiKey9)) |
|
278 { |
|
279 SetNumLongPressValid(EFalse); |
|
280 } |
|
281 } |
|
282 } |
|
283 break; |
|
284 default: |
|
285 break; |
|
286 } |
|
287 |
|
288 return EFalse; |
|
289 } |
|
290 else |
|
291 { |
|
292 // handled by state |
|
293 return ETrue; |
|
294 } |
|
295 } |
|
296 |
|
297 void CChnItutUiMgr::SetCurrentStateL(TUiState aNewStateType) |
|
298 { |
|
299 if (iCurrentState && |
|
300 aNewStateType == iCurrentState->StateType()) |
|
301 { |
|
302 return; |
|
303 } |
|
304 |
|
305 CGenericItutUiStateBase* newState = NULL; |
|
306 |
|
307 switch (aNewStateType) |
|
308 { |
|
309 case CGenericItutUiMgrBase::EStateStandby: |
|
310 { |
|
311 newState = iStandbyState; |
|
312 } |
|
313 break; |
|
314 case CGenericItutUiMgrBase::EStateComposition: |
|
315 { |
|
316 newState = (DataMgr()->InputMode() == EPinyin) ? |
|
317 iPinyinComp : iStoZhuComp; |
|
318 } |
|
319 break; |
|
320 case CGenericItutUiMgrBase::EStatePredict: |
|
321 { |
|
322 newState = iPredictState; |
|
323 } |
|
324 break; |
|
325 case CGenericItutUiMgrBase::EStateWesternStandby: |
|
326 { |
|
327 newState = iNormalState; |
|
328 } |
|
329 break; |
|
330 case CGenericItutUiMgrBase::EStateMatchSelection: |
|
331 { |
|
332 newState = iMatchSelState; |
|
333 } |
|
334 break; |
|
335 case CGenericItutUiMgrBase::EStateSpelling: |
|
336 { |
|
337 newState = iSpellState; |
|
338 } |
|
339 break; |
|
340 default: |
|
341 return; |
|
342 } |
|
343 |
|
344 if (iCurrentState) |
|
345 { |
|
346 iCurrentState->OnExit(); |
|
347 } |
|
348 |
|
349 iCurrentState = newState; |
|
350 if(DataMgr()->IsUpdate()) |
|
351 { |
|
352 DataMgr()->SetUpdate(EFalse); |
|
353 CGenericItutUiLayout* itutLayout = |
|
354 static_cast<CGenericItutUiLayout*>( LayoutContext()->UiLayout() ); |
|
355 itutLayout->SizeChanged( NULL ); |
|
356 } |
|
357 |
|
358 iCurrentState->OnEntryL(); |
|
359 } |
|
360 |
|
361 void CChnItutUiMgr::ActivateUiL() |
|
362 { |
|
363 |
|
364 if (iCurrentState && !IsChineseMode()) |
|
365 { |
|
366 iCurrentState->OnEntryL(); |
|
367 return; |
|
368 } |
|
369 |
|
370 switch (DataMgr()->InputMode()) |
|
371 { |
|
372 case EPinyin: |
|
373 case EStroke: |
|
374 case EZhuyin: |
|
375 SetCurrentStateL(CGenericItutUiMgrBase::EStateStandby); |
|
376 break; |
|
377 default: |
|
378 SetCurrentStateL(CGenericItutUiMgrBase::EStateWesternStandby); |
|
379 break; |
|
380 } |
|
381 } |
|
382 |
|
383 void CChnItutUiMgr::DeactivateUI() |
|
384 { |
|
385 if (iCurrentState) |
|
386 { |
|
387 iCurrentState->OnExit(); |
|
388 iCurrentState = NULL; |
|
389 } |
|
390 |
|
391 SetNumLongPressValid(EFalse); |
|
392 } |
|
393 |
|
394 void CChnItutUiMgr::HandleLongPressNumberKeyL(TPtiKey /*aKey*/) |
|
395 { |
|
396 if (NumLongPressValid()) |
|
397 { |
|
398 // go to standby state |
|
399 SetCurrentStateL(CGenericItutUiMgrBase::EStateStandby); |
|
400 |
|
401 DataMgr()->PtiEngine()->ClearCurrentWord(); |
|
402 |
|
403 SetNumLongPressValid(EFalse); |
|
404 } |
|
405 } |
|
406 |
|
407 TBool CChnItutUiMgr::IsChineseMode() |
|
408 { |
|
409 TInt immode = DataMgr()->InputMode(); |
|
410 TBool chineseMode = EFalse; |
|
411 |
|
412 if (immode == EPinyin || immode == EStroke || immode == EZhuyin) |
|
413 { |
|
414 chineseMode = ETrue; |
|
415 } |
|
416 |
|
417 return chineseMode; |
|
418 } |
|
419 |
|
420 // End Of File |