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