|
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: states implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <aknfeppeninputenums.h> |
|
21 #include <peninputdropdownlist.h> |
|
22 |
|
23 #include "peninputhwrbxlayout.h" |
|
24 #include "peninputhwrbxwnd.h" |
|
25 #include "peninputhwrbxstate.h" |
|
26 #include "peninputhwrevent.h" |
|
27 #include "peninputhwrbxdatastore.h" |
|
28 #include "peninputhwrtriggerstr.h" |
|
29 |
|
30 //CAknFepHwrBxStateBase |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // C++ constructor |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 CAknFepHwrBxStateBase::CAknFepHwrBxStateBase(CAknFepHwrBxLayout* aLayout) |
|
37 { |
|
38 iLayout = aLayout; |
|
39 iWnd = NULL; |
|
40 iDataStore = NULL; |
|
41 |
|
42 if (iLayout) |
|
43 { |
|
44 iWnd = iLayout->Window(); |
|
45 iDataStore = iLayout->DataStore(); |
|
46 } |
|
47 |
|
48 ASSERT(iLayout != NULL); |
|
49 ASSERT(iWnd != NULL); |
|
50 ASSERT(iDataStore != NULL); |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // Destructor |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CAknFepHwrBxStateBase::~CAknFepHwrBxStateBase() |
|
58 { |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // Handle layout command event |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 TInt CAknFepHwrBxStateBase::HandleCommandL(TInt /*aCmd*/, TUint8* /*aData*/) |
|
66 { |
|
67 return KErrNone; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // Handle raw event key |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 TBool CAknFepHwrBxStateBase::HandleKeyEventL(const TRawEvent& /*aKeyEvent*/) |
|
75 { |
|
76 return EFalse; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // Handle raw event key |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 TBool CAknFepHwrBxStateBase::HandleEventL(TInt /*aEventType*/, const TDesC& /*aEventData*/) |
|
84 { |
|
85 //not handled |
|
86 return EFalse; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // Doing something before entry a state |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 void CAknFepHwrBxStateBase::OnEntry() |
|
94 { |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // Doing something before exit a state |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CAknFepHwrBxStateBase::OnExit() |
|
102 { |
|
103 } |
|
104 |
|
105 //CAknFepHwrBxStateBase end |
|
106 |
|
107 //CAknFepHwrBxStateCloseable |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // C++ constructor |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 CAknFepHwrBxStateCloseable::CAknFepHwrBxStateCloseable(CAknFepHwrBxLayout* aLayout) |
|
114 : CAknFepHwrBxStateBase(aLayout) |
|
115 { |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // Destructor |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 CAknFepHwrBxStateCloseable::~CAknFepHwrBxStateCloseable() |
|
123 { |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------- |
|
127 // Handle ECmdPenInputWindowClose |
|
128 // --------------------------------------------------------- |
|
129 // |
|
130 TInt CAknFepHwrBxStateCloseable::HandleCommandL(TInt aCmd, TUint8* /*aData*/) |
|
131 { |
|
132 if (ECmdPenInputWindowClose == aCmd) |
|
133 { |
|
134 //jump to init state |
|
135 CAknFepHwrBxStateInit* state = CAknFepHwrBxStateInit::NewLC(iLayout); |
|
136 iLayout->SetCurrentStateL(state); |
|
137 CleanupStack::Pop(state); |
|
138 |
|
139 //record the close mode: automatically |
|
140 state->SetAutoClosed(ETrue); |
|
141 } |
|
142 |
|
143 return KErrNone; |
|
144 } |
|
145 |
|
146 //CAknFepHwrBxStateCloseable end |
|
147 |
|
148 //CAknFepHwrBxStateInit |
|
149 |
|
150 // --------------------------------------------------------- |
|
151 // Symbian constructor |
|
152 // --------------------------------------------------------- |
|
153 // |
|
154 CAknFepHwrBxStateInit* CAknFepHwrBxStateInit::NewLC(CAknFepHwrBxLayout* aLayout) |
|
155 { |
|
156 CAknFepHwrBxStateInit* self = new (ELeave) CAknFepHwrBxStateInit(aLayout); |
|
157 CleanupStack::PushL(self); |
|
158 |
|
159 return self; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // C++ default constructor |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 CAknFepHwrBxStateInit::CAknFepHwrBxStateInit(CAknFepHwrBxLayout* aLayout) |
|
167 : CAknFepHwrBxStateBase(aLayout) |
|
168 { |
|
169 iAutoClosed = ETrue; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // destructor |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 CAknFepHwrBxStateInit::~CAknFepHwrBxStateInit() |
|
177 { |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // Record last closed mode |
|
182 // --------------------------------------------------------- |
|
183 // |
|
184 void CAknFepHwrBxStateInit::SetAutoClosed(TBool aAutoFlag) |
|
185 { |
|
186 iAutoClosed = aAutoFlag; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // Handle command |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TInt CAknFepHwrBxStateInit::HandleCommandL(TInt aCmd, TUint8* aData) |
|
194 { |
|
195 return KErrNone; |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------- |
|
199 // Doing something before entry a state |
|
200 // --------------------------------------------------------- |
|
201 // |
|
202 void CAknFepHwrBxStateInit::OnEntry() |
|
203 { |
|
204 iWnd->CancelWriting(); |
|
205 iWnd->CancelRepeat(); |
|
206 iWnd->Hide(ETrue); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // Doing something before exit a state |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CAknFepHwrBxStateInit::OnExit() |
|
214 { |
|
215 iWnd->Hide(EFalse); |
|
216 } |
|
217 |
|
218 //CAknFepHwrBxStateInit end |
|
219 |
|
220 //CAknFepHwrBxStateStandby |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // Symbian constructor |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 CAknFepHwrBxStateStandby* CAknFepHwrBxStateStandby::NewLC(CAknFepHwrBxLayout* aLayout) |
|
227 { |
|
228 CAknFepHwrBxStateStandby* self = new (ELeave) CAknFepHwrBxStateStandby(aLayout); |
|
229 CleanupStack::PushL(self); |
|
230 |
|
231 return self; |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------- |
|
235 // Symbian constructor |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 CAknFepHwrBxStateStandby* CAknFepHwrBxStateStandby::NewL(CAknFepHwrBxLayout* aLayout) |
|
239 { |
|
240 CAknFepHwrBxStateStandby* self = CAknFepHwrBxStateStandby::NewLC( aLayout ); |
|
241 CleanupStack::Pop(self); |
|
242 |
|
243 return self; |
|
244 } |
|
245 |
|
246 // C++ default constructor |
|
247 // --------------------------------------------------------- |
|
248 // |
|
249 CAknFepHwrBxStateStandby::CAknFepHwrBxStateStandby(CAknFepHwrBxLayout* aLayout) |
|
250 : CAknFepHwrBxStateCloseable(aLayout) |
|
251 { |
|
252 } |
|
253 |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // destructor |
|
257 // --------------------------------------------------------- |
|
258 // |
|
259 CAknFepHwrBxStateStandby::~CAknFepHwrBxStateStandby() |
|
260 { |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------- |
|
264 // Handle event |
|
265 // --------------------------------------------------------- |
|
266 // |
|
267 TBool CAknFepHwrBxStateStandby::HandleEventL(TInt aEventType, const TDesC& /*aEventData*/) |
|
268 { |
|
269 TBool handled = ETrue; |
|
270 CAknFepHwrBxStateBase* state = NULL; |
|
271 |
|
272 switch (aEventType) |
|
273 { |
|
274 case EHwrEventBeginWriting: |
|
275 state = CAknFepHwrBxStateBeginWriting::NewLC(iLayout); |
|
276 iLayout->SetCurrentStateL(state); |
|
277 CleanupStack::Pop(state);//state |
|
278 break; |
|
279 case EHwrEventWindowClose: |
|
280 //jump to init state |
|
281 state = CAknFepHwrBxStateInit::NewLC(iLayout); |
|
282 iLayout->SetCurrentStateL(state); |
|
283 CleanupStack::Pop(state); |
|
284 |
|
285 //record the close mode: manully |
|
286 static_cast<CAknFepHwrBxStateInit*>(state)->SetAutoClosed(EFalse); |
|
287 handled = EFalse; |
|
288 break; |
|
289 default: |
|
290 handled = EFalse; |
|
291 break; |
|
292 } |
|
293 |
|
294 return handled; |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------- |
|
298 // Doing something before entry a state |
|
299 // --------------------------------------------------------- |
|
300 // |
|
301 void CAknFepHwrBxStateStandby::OnEntry() |
|
302 { |
|
303 iDataStore->ClearCandidates(); |
|
304 //cancel writing timer |
|
305 iWnd->CancelWriting(); |
|
306 } |
|
307 |
|
308 //CAknFepHwrBxStateStandby end |
|
309 |
|
310 //CAknFepHwrBxStateBeginWriting |
|
311 |
|
312 // --------------------------------------------------------- |
|
313 // Symbian constructor |
|
314 // --------------------------------------------------------- |
|
315 // |
|
316 CAknFepHwrBxStateBeginWriting* CAknFepHwrBxStateBeginWriting::NewLC(CAknFepHwrBxLayout* aLayout) |
|
317 { |
|
318 CAknFepHwrBxStateBeginWriting* self = new (ELeave) CAknFepHwrBxStateBeginWriting(aLayout); |
|
319 CleanupStack::PushL(self); |
|
320 |
|
321 return self; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // C++ default constructor |
|
326 // --------------------------------------------------------- |
|
327 // |
|
328 CAknFepHwrBxStateBeginWriting::CAknFepHwrBxStateBeginWriting(CAknFepHwrBxLayout* aLayout) |
|
329 : CAknFepHwrBxStateCloseable(aLayout) |
|
330 { |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------- |
|
334 // Destructor |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 CAknFepHwrBxStateBeginWriting::~CAknFepHwrBxStateBeginWriting() |
|
338 { |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------- |
|
342 // Handle event |
|
343 // --------------------------------------------------------- |
|
344 // |
|
345 TBool CAknFepHwrBxStateBeginWriting::HandleEventL(TInt aEventType, const TDesC& aEventData) |
|
346 { |
|
347 CAknFepHwrBxStateBase* state = NULL; |
|
348 |
|
349 switch (aEventType) |
|
350 { |
|
351 case EHwrEventEndStroke: |
|
352 { |
|
353 const RArray<TPoint>* aTraceData = (RArray<TPoint>*)aEventData.Ptr(); |
|
354 iDataStore->DoRecognizeL(*aTraceData); |
|
355 |
|
356 state = CAknFepHwrBxStateEndWriting::NewLC(iLayout); |
|
357 iLayout->SetCurrentStateL(state); |
|
358 CleanupStack::Pop(state);//state |
|
359 |
|
360 break; |
|
361 } |
|
362 default: |
|
363 break; |
|
364 } |
|
365 |
|
366 //All events are discarded. |
|
367 return ETrue; |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------- |
|
371 // Doing something before entry a state |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 void CAknFepHwrBxStateBeginWriting::OnEntry() |
|
375 { |
|
376 //disable draging |
|
377 //iWnd->SetDragEnable(EFalse); |
|
378 iWnd->DimInputContextField(ETrue); |
|
379 } |
|
380 |
|
381 //CAknFepHwrBxStateBeginWriting end |
|
382 |
|
383 //CAknFepHwrBxStateEndWriting |
|
384 |
|
385 // --------------------------------------------------------- |
|
386 // Symbian constructor |
|
387 // --------------------------------------------------------- |
|
388 // |
|
389 CAknFepHwrBxStateEndWriting* CAknFepHwrBxStateEndWriting::NewLC(CAknFepHwrBxLayout* aLayout) |
|
390 { |
|
391 CAknFepHwrBxStateEndWriting* self = new (ELeave) CAknFepHwrBxStateEndWriting(aLayout); |
|
392 CleanupStack::PushL(self); |
|
393 |
|
394 return self; |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------- |
|
398 // C++ default constructor |
|
399 // --------------------------------------------------------- |
|
400 // |
|
401 CAknFepHwrBxStateEndWriting::CAknFepHwrBxStateEndWriting(CAknFepHwrBxLayout* aLayout) |
|
402 : CAknFepHwrBxStateCloseable(aLayout) |
|
403 { |
|
404 } |
|
405 |
|
406 // --------------------------------------------------------- |
|
407 // Destructor |
|
408 // --------------------------------------------------------- |
|
409 // |
|
410 CAknFepHwrBxStateEndWriting::~CAknFepHwrBxStateEndWriting() |
|
411 { |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------- |
|
415 // Handle event |
|
416 // --------------------------------------------------------- |
|
417 // |
|
418 TBool CAknFepHwrBxStateEndWriting::HandleEventL(TInt aEventType, const TDesC& aEventData) |
|
419 { |
|
420 TBuf<KMaxCandidateLen> charCode; |
|
421 TBool handled = ETrue; |
|
422 CAknFepHwrBxStateBase* state = NULL; |
|
423 |
|
424 switch (aEventType) |
|
425 { |
|
426 case EHwrEventNewWriting: |
|
427 //submit the first char to fep |
|
428 iDataStore->GetCandidate(0, charCode); |
|
429 iLayout->SubmitL(charCode); |
|
430 |
|
431 iDataStore->ClearCandidates(); |
|
432 // fall-through intended here |
|
433 case EHwrEventBeginWriting: |
|
434 state = CAknFepHwrBxStateBeginWriting::NewLC(iLayout); |
|
435 iLayout->SetCurrentStateL(state); |
|
436 CleanupStack::Pop(state);//state |
|
437 break; |
|
438 case EHwrEventCandidateSelected: |
|
439 OnCandidateSelectedL(aEventData); |
|
440 break; |
|
441 case EHwrEventKeyBack: |
|
442 // fall-through intended here |
|
443 case EHwrEventPointerOutsideWnd: |
|
444 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
445 iLayout->SetCurrentStateL(state); |
|
446 CleanupStack::Pop(state);//state |
|
447 |
|
448 break; |
|
449 case EHwrEventEndWriting: |
|
450 { |
|
451 iDataStore->GetCandidate(0, charCode); |
|
452 iLayout->SubmitL(charCode); |
|
453 |
|
454 TPtrC16 ptrBack; |
|
455 TPtrC16 ptrEnter; |
|
456 ptrBack.Set(&KBackRep, sizeof(KBackRep)/2); |
|
457 ptrEnter.Set(&KEnterRep, sizeof(KEnterRep)/2); |
|
458 |
|
459 //if char code is backspace or enter |
|
460 if (charCode.CompareC(ptrBack) == 0 || charCode.CompareC(ptrEnter) == 0) |
|
461 { |
|
462 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
463 iLayout->SetCurrentStateL(state); |
|
464 } |
|
465 else |
|
466 { |
|
467 state = CAknFepHwrBxStateCandidateSelecting::NewLC(iLayout); |
|
468 iLayout->SetCurrentStateL(state); |
|
469 } |
|
470 |
|
471 CleanupStack::Pop(state);//state |
|
472 break; |
|
473 } |
|
474 case EHwrEventWindowClose: |
|
475 iDataStore->GetCandidate(0, charCode); |
|
476 iLayout->SubmitL(charCode); |
|
477 |
|
478 //jump to init state |
|
479 state = CAknFepHwrBxStateInit::NewLC(iLayout); |
|
480 iLayout->SetCurrentStateL(state); |
|
481 CleanupStack::Pop(state); |
|
482 |
|
483 //record the close mode: manully |
|
484 static_cast<CAknFepHwrBxStateInit*>(state)->SetAutoClosed(EFalse); |
|
485 handled = EFalse; |
|
486 break; |
|
487 default: |
|
488 iDataStore->GetCandidate(0, charCode); |
|
489 iLayout->SubmitL(charCode); |
|
490 |
|
491 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
492 iLayout->SetCurrentStateL(state); |
|
493 CleanupStack::Pop(state);//state |
|
494 |
|
495 handled = EFalse; |
|
496 break; |
|
497 } |
|
498 |
|
499 return handled; |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // Handle raw event key |
|
504 // --------------------------------------------------------- |
|
505 // |
|
506 TBool CAknFepHwrBxStateEndWriting::HandleKeyEventL(const TRawEvent& /*aKeyEvent*/) |
|
507 { |
|
508 //code is removed because of submit char to wrong editor when focus changed |
|
509 /* |
|
510 TBuf<KMaxCandidateLen> charCode; |
|
511 |
|
512 iDataStore->GetCandidate(0, charCode); |
|
513 iLayout->SubmitL(charCode); |
|
514 |
|
515 CAknFepHwrBxStateBase* state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
516 iLayout->SetCurrentStateL(state); |
|
517 CleanupStack::Pop(state);//state |
|
518 */ |
|
519 return EFalse; |
|
520 } |
|
521 |
|
522 // --------------------------------------------------------- |
|
523 // Handle EHwrEventCandidateSelected |
|
524 // --------------------------------------------------------- |
|
525 // |
|
526 void CAknFepHwrBxStateEndWriting::OnCandidateSelectedL(const TDesC& aEventData) |
|
527 { |
|
528 CAknFepHwrBxStateBase* state = NULL; |
|
529 |
|
530 //cancel writing timer |
|
531 iWnd->CancelWriting(); |
|
532 |
|
533 //There must be a charcode and length at least |
|
534 if (aEventData.Length() > 1) |
|
535 { |
|
536 //get the candidate index |
|
537 const TInt cellNo = aEventData[aEventData.Length()-1]; |
|
538 |
|
539 //get and submit the candidate to fep |
|
540 TBuf<KMaxCandidateLen> charCode; |
|
541 iDataStore->GetCandidate(cellNo, charCode); |
|
542 iLayout->SubmitL(charCode); |
|
543 |
|
544 if (iDataStore->IsChinese(cellNo)) |
|
545 { |
|
546 iDataStore->TriggerStr()->Set(aEventData.Left(aEventData.Length() - 1)); |
|
547 iDataStore->DoPredictiveL(); |
|
548 |
|
549 if (iDataStore->PredictiveCount()>0) |
|
550 { |
|
551 state = CAknFepHwrBxStatePredictiveSelecting::NewLC(iLayout); |
|
552 iLayout->SetCurrentStateL(state); |
|
553 } |
|
554 else |
|
555 { |
|
556 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
557 iLayout->SetCurrentStateL(state); |
|
558 } |
|
559 } |
|
560 else |
|
561 { |
|
562 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
563 iLayout->SetCurrentStateL(state); |
|
564 } |
|
565 CleanupStack::Pop(state);//state |
|
566 } |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------- |
|
570 // Doing something before exit a state |
|
571 // --------------------------------------------------------- |
|
572 // |
|
573 void CAknFepHwrBxStateEndWriting::OnExit() |
|
574 { |
|
575 //enable draging |
|
576 //iWnd->SetDragEnable(ETrue); |
|
577 iWnd->DimInputContextField(EFalse); |
|
578 } |
|
579 |
|
580 |
|
581 //CAknFepHwrBxStateEndWriting end |
|
582 |
|
583 //CAknFepHwrBxStateCandidateSelecting |
|
584 |
|
585 // --------------------------------------------------------- |
|
586 // Symbian constructor |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 CAknFepHwrBxStateCandidateSelecting* CAknFepHwrBxStateCandidateSelecting::NewLC( |
|
590 CAknFepHwrBxLayout* aLayout) |
|
591 { |
|
592 CAknFepHwrBxStateCandidateSelecting* self = new (ELeave) |
|
593 CAknFepHwrBxStateCandidateSelecting(aLayout); |
|
594 CleanupStack::PushL(self); |
|
595 |
|
596 return self; |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------- |
|
600 // C++ default constructor |
|
601 // --------------------------------------------------------- |
|
602 // |
|
603 CAknFepHwrBxStateCandidateSelecting::CAknFepHwrBxStateCandidateSelecting( |
|
604 CAknFepHwrBxLayout* aLayout) |
|
605 : CAknFepHwrBxStateCloseable(aLayout) |
|
606 { |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------- |
|
610 // Destructor |
|
611 // --------------------------------------------------------- |
|
612 // |
|
613 CAknFepHwrBxStateCandidateSelecting::~CAknFepHwrBxStateCandidateSelecting() |
|
614 { |
|
615 } |
|
616 |
|
617 // --------------------------------------------------------- |
|
618 // Handle event |
|
619 // --------------------------------------------------------- |
|
620 // |
|
621 TBool CAknFepHwrBxStateCandidateSelecting::HandleEventL(TInt aEventType, const TDesC& aEventData) |
|
622 { |
|
623 TBool handled = ETrue; |
|
624 CAknFepHwrBxStateBase* state = NULL; |
|
625 |
|
626 switch (aEventType) |
|
627 { |
|
628 case EHwrEventBeginWriting: |
|
629 iDataStore->ClearCandidates(); |
|
630 state = CAknFepHwrBxStateBeginWriting::NewLC(iLayout); |
|
631 iLayout->SetCurrentStateL(state); |
|
632 CleanupStack::Pop(state);//state |
|
633 break; |
|
634 case EHwrEventCandidateSelected: |
|
635 OnCandidateSelectedL(aEventData); |
|
636 break; |
|
637 case EHwrEventWindowClose: |
|
638 //jump to init state |
|
639 state = CAknFepHwrBxStateInit::NewLC(iLayout); |
|
640 iLayout->SetCurrentStateL(state); |
|
641 CleanupStack::Pop(state);//state |
|
642 |
|
643 //record the close mode: manully |
|
644 static_cast<CAknFepHwrBxStateInit*>(state)->SetAutoClosed(EFalse); |
|
645 handled = EFalse; |
|
646 break; |
|
647 default: |
|
648 iDataStore->ClearCandidates(); |
|
649 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
650 iLayout->SetCurrentStateL(state); |
|
651 CleanupStack::Pop(state);//state |
|
652 |
|
653 handled = EFalse; |
|
654 break; |
|
655 } |
|
656 |
|
657 return handled; |
|
658 } |
|
659 |
|
660 // --------------------------------------------------------- |
|
661 // Handle raw event key |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 TBool CAknFepHwrBxStateCandidateSelecting::HandleKeyEventL(const TRawEvent& /*aKeyEvent*/) |
|
665 { |
|
666 CAknFepHwrBxStateBase* state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
667 |
|
668 iLayout->SetCurrentStateL(state); |
|
669 CleanupStack::Pop(state);//state |
|
670 |
|
671 return EFalse; |
|
672 } |
|
673 |
|
674 // --------------------------------------------------------- |
|
675 // Doing something before entry a state |
|
676 // --------------------------------------------------------- |
|
677 // |
|
678 void CAknFepHwrBxStateCandidateSelecting::OnEntry() |
|
679 { |
|
680 if (iDataStore->CandidateCount() > 0) |
|
681 { |
|
682 //hight the first |
|
683 iWnd->HighlightCell(0); |
|
684 } |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------- |
|
688 // Handle EHwrEventCandidateSelected |
|
689 // --------------------------------------------------------- |
|
690 // |
|
691 void CAknFepHwrBxStateCandidateSelecting::OnCandidateSelectedL(const TDesC& aEventData) |
|
692 { |
|
693 CAknFepHwrBxStateBase* state = NULL; |
|
694 |
|
695 if (aEventData.Length() > 1) |
|
696 { |
|
697 //get the candidate index |
|
698 const TInt cellNo = aEventData[aEventData.Length()-1]; |
|
699 |
|
700 //not the first candidate, replace previouse char |
|
701 if (cellNo > 0) |
|
702 { |
|
703 //get the first candidate |
|
704 TBuf<KMaxCandidateLen> oldCharCode; |
|
705 iDataStore->GetCandidate(0, oldCharCode); |
|
706 |
|
707 //get the new candidate |
|
708 TBuf<KMaxCandidateLen> newCharCode; |
|
709 iDataStore->GetCandidate(cellNo, newCharCode); |
|
710 |
|
711 iLayout->TranslateCharCode( newCharCode ); |
|
712 |
|
713 //delete the first candidate submitted and submit new |
|
714 iLayout->ReplaceL(oldCharCode, newCharCode); |
|
715 |
|
716 TPtrC16 ptrBack; |
|
717 TPtrC16 ptrEnter; |
|
718 ptrBack.Set(&KBackRep, sizeof(KBackRep)/2); |
|
719 ptrEnter.Set(&KEnterRep, sizeof(KEnterRep)/2); |
|
720 |
|
721 if ((newCharCode.Compare(ptrBack) == 0) || (newCharCode.Compare(ptrEnter) == 0)) |
|
722 { |
|
723 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
724 iLayout->SetCurrentStateL(state); |
|
725 CleanupStack::Pop(state); |
|
726 return; |
|
727 } |
|
728 } |
|
729 |
|
730 if (iDataStore->IsChinese(cellNo)) |
|
731 { |
|
732 iDataStore->TriggerStr()->Set(aEventData.Left(aEventData.Length()-1)); |
|
733 |
|
734 iDataStore->DoPredictiveL(); |
|
735 if (iDataStore->PredictiveCount() > 0) |
|
736 { |
|
737 state = CAknFepHwrBxStatePredictiveSelecting::NewLC(iLayout); |
|
738 iLayout->SetCurrentStateL(state); |
|
739 } |
|
740 else |
|
741 { |
|
742 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
743 iLayout->SetCurrentStateL(state); |
|
744 } |
|
745 } |
|
746 else |
|
747 { |
|
748 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
749 iLayout->SetCurrentStateL(state); |
|
750 } |
|
751 |
|
752 CleanupStack::Pop(state);//state |
|
753 } |
|
754 } |
|
755 |
|
756 //CAknFepHwrBxStateCandidateSelecting end |
|
757 |
|
758 //CAknFepHwrBxStatePredictiveSelecting |
|
759 |
|
760 // --------------------------------------------------------- |
|
761 // Symbian constructor |
|
762 // --------------------------------------------------------- |
|
763 // |
|
764 CAknFepHwrBxStatePredictiveSelecting* CAknFepHwrBxStatePredictiveSelecting::NewLC( |
|
765 CAknFepHwrBxLayout* aLayout) |
|
766 { |
|
767 CAknFepHwrBxStatePredictiveSelecting* self = new (ELeave) |
|
768 CAknFepHwrBxStatePredictiveSelecting(aLayout); |
|
769 CleanupStack::PushL(self); |
|
770 |
|
771 return self; |
|
772 } |
|
773 |
|
774 // --------------------------------------------------------- |
|
775 // C++ default constructor |
|
776 // --------------------------------------------------------- |
|
777 // |
|
778 CAknFepHwrBxStatePredictiveSelecting::CAknFepHwrBxStatePredictiveSelecting( |
|
779 CAknFepHwrBxLayout* aLayout) |
|
780 : CAknFepHwrBxStateCloseable(aLayout) |
|
781 { |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------- |
|
785 // Destructor |
|
786 // --------------------------------------------------------- |
|
787 // |
|
788 CAknFepHwrBxStatePredictiveSelecting::~CAknFepHwrBxStatePredictiveSelecting() |
|
789 { |
|
790 } |
|
791 |
|
792 // --------------------------------------------------------- |
|
793 // Doing something before enter a state |
|
794 // --------------------------------------------------------- |
|
795 // |
|
796 void CAknFepHwrBxStatePredictiveSelecting::OnEntry() |
|
797 { |
|
798 //fill the candidat list |
|
799 iDataStore->SetPredictives(); |
|
800 } |
|
801 |
|
802 // --------------------------------------------------------- |
|
803 // Handle event |
|
804 // --------------------------------------------------------- |
|
805 // |
|
806 TBool CAknFepHwrBxStatePredictiveSelecting::HandleEventL(TInt aEventType, const TDesC& aEventData) |
|
807 { |
|
808 TBool handled = ETrue; |
|
809 CAknFepHwrBxStateBase* state = NULL; |
|
810 |
|
811 switch (aEventType) |
|
812 { |
|
813 case EHwrEventBeginWriting: |
|
814 iDataStore->ClearCandidates(); |
|
815 state = CAknFepHwrBxStateBeginWriting::NewLC(iLayout); |
|
816 iLayout->SetCurrentStateL(state); |
|
817 CleanupStack::Pop(state);//state |
|
818 break; |
|
819 case EHwrEventCandidateSelected: |
|
820 OnPredictiveSelectedL(aEventData); |
|
821 break; |
|
822 case EHwrEventKeyBack: |
|
823 OnKeyBackL(); |
|
824 break; |
|
825 case EHwrEventWindowClose: |
|
826 //jump to init state |
|
827 state = CAknFepHwrBxStateInit::NewLC(iLayout); |
|
828 iLayout->SetCurrentStateL(state); |
|
829 CleanupStack::Pop(state);//state |
|
830 |
|
831 //record the close mode: manully |
|
832 static_cast<CAknFepHwrBxStateInit*>(state)->SetAutoClosed(EFalse); |
|
833 handled = EFalse; |
|
834 break; |
|
835 case EHwrEventGetNextCandidatePage: |
|
836 { |
|
837 handled = EFalse; |
|
838 } |
|
839 break; |
|
840 case EHwrEventCandidateExisted: |
|
841 { |
|
842 if (iDataStore->PredictiveCount() >= KMaxPredictCandCnt) |
|
843 { |
|
844 iWnd->DropdownList()->SetFlagCandidateExist(EFalse); |
|
845 } |
|
846 else |
|
847 { |
|
848 iWnd->DropdownList()->SetFlagCandidateExist( |
|
849 iDataStore->PredictiveCandidateExisted()); |
|
850 } |
|
851 } |
|
852 break; |
|
853 case EHwrEventGetPreviousCandidatePage: |
|
854 // actually, 'get previous page candidate' will do nothing |
|
855 // here handled is ETrue, so it will not be handled by layout either |
|
856 // this branch is just to avoid 'press arrow up' button be treated in |
|
857 // 'default' branch |
|
858 break; |
|
859 default: |
|
860 iDataStore->ClearCandidates(); |
|
861 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
862 iLayout->SetCurrentStateL(state); |
|
863 CleanupStack::Pop(state);//state |
|
864 |
|
865 handled = EFalse; |
|
866 break; |
|
867 } |
|
868 |
|
869 return handled; |
|
870 } |
|
871 |
|
872 // --------------------------------------------------------- |
|
873 // Handle raw event key |
|
874 // --------------------------------------------------------- |
|
875 // |
|
876 TBool CAknFepHwrBxStatePredictiveSelecting::HandleKeyEventL(const TRawEvent& /*aKeyEvent*/) |
|
877 { |
|
878 //CAknFepHwrBxStateBase* state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
879 |
|
880 //iLayout->SetCurrentStateL(state); |
|
881 //CleanupStack::Pop(state);//state |
|
882 |
|
883 return EFalse; |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------- |
|
887 // Handle EHwrEventPredictiveSelected |
|
888 // --------------------------------------------------------- |
|
889 // |
|
890 void CAknFepHwrBxStatePredictiveSelecting::OnPredictiveSelectedL(const TDesC& aEventData) |
|
891 { |
|
892 //There must be a charcode and length at least |
|
893 if (aEventData.Length() > 1) |
|
894 { |
|
895 //get the Predictive index |
|
896 const TInt cellNo = aEventData[aEventData.Length()-1]; |
|
897 |
|
898 //get and submit the Predictive to fep |
|
899 TBuf<KMaxPredictiveLen> charCode; |
|
900 iDataStore->GetPredictive(cellNo, charCode); |
|
901 iLayout->SubmitL(charCode); |
|
902 |
|
903 iDataStore->TriggerStr()->Append(aEventData.Left(aEventData.Length()-1)); |
|
904 iDataStore->DoPredictiveL(); |
|
905 |
|
906 if (iDataStore->PredictiveCount() == 0) |
|
907 { |
|
908 iDataStore->TriggerStr()->SetLast(); |
|
909 iDataStore->DoPredictiveL(); |
|
910 } |
|
911 |
|
912 if (iDataStore->PredictiveCount() == 0) |
|
913 { |
|
914 CAknFepHwrBxStateBase* state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
915 iLayout->SetCurrentStateL(state); |
|
916 CleanupStack::Pop(state);//state |
|
917 } |
|
918 } |
|
919 } |
|
920 |
|
921 // --------------------------------------------------------- |
|
922 // Handle EHwrEventKeyBack |
|
923 // --------------------------------------------------------- |
|
924 // |
|
925 void CAknFepHwrBxStatePredictiveSelecting::OnKeyBackL() |
|
926 { |
|
927 CAknFepHwrBxStateBase* state = NULL; |
|
928 |
|
929 iLayout->Delete(); |
|
930 |
|
931 //do predictive again |
|
932 iDataStore->TriggerStr()->DeleteLast(); |
|
933 if (iDataStore->TriggerStr()->IsEmpty()) |
|
934 { |
|
935 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
936 iLayout->SetCurrentStateL(state); |
|
937 CleanupStack::Pop(state);//state |
|
938 } |
|
939 else |
|
940 { |
|
941 iDataStore->DoPredictiveL(); |
|
942 if (iDataStore->PredictiveCount() == 0) |
|
943 { |
|
944 iDataStore->TriggerStr()->SetLast(); |
|
945 iDataStore->DoPredictiveL(); |
|
946 } |
|
947 |
|
948 if (iDataStore->PredictiveCount() == 0) |
|
949 { |
|
950 state = CAknFepHwrBxStateStandby::NewLC(iLayout); |
|
951 iLayout->SetCurrentStateL(state); |
|
952 CleanupStack::Pop(state);//state |
|
953 } |
|
954 } |
|
955 } |
|
956 |
|
957 //CAknFepHwrBxStatePredictiveSelecting end |
|
958 |
|
959 // End Of File |