|
1 /* |
|
2 * Copyright (c) 2005-2006 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 for chinese peninput full screen hwr |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __PENINPUTHWRFSCNSTATEMANAGER_H__ |
|
20 #define __PENINPUTHWRFSCNSTATEMANAGER_H__ |
|
21 //SYSTEM INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <e32cmn.h> |
|
24 //FORWARD CLASS |
|
25 class CPeninputHwrfscnLayout; |
|
26 class CPeninputHwrfscnDataStore; |
|
27 class CPeninputHwrfscnStateManager; |
|
28 |
|
29 /** |
|
30 * Class MPeninputHwrfscnStateHandler |
|
31 * |
|
32 * The state handler interfaces |
|
33 * |
|
34 * @lib peninputhwrfscn.lib |
|
35 * @since S60 v5.0 |
|
36 */ |
|
37 class MPeninputHwrfscnStateHandler |
|
38 { |
|
39 public: |
|
40 /** |
|
41 * Handle command |
|
42 * |
|
43 * @since Series 60 5.0 |
|
44 */ |
|
45 virtual void HandleCommand( TInt aCmd, TUint8* aData ) = 0; |
|
46 |
|
47 /** |
|
48 * Handle state event |
|
49 * |
|
50 * @since Series 60 5.0 |
|
51 */ |
|
52 virtual void HandleEventL( TInt aEventType, const TDesC& aEventData ) = 0; |
|
53 |
|
54 /** |
|
55 * Handle the state entering action |
|
56 * |
|
57 * @since Series 60 5.0 |
|
58 */ |
|
59 virtual void OnEntry() = 0; |
|
60 |
|
61 /** |
|
62 * Handle the state exiting action |
|
63 * |
|
64 * @since Series 60 5.0 |
|
65 */ |
|
66 virtual void OnExit() = 0; |
|
67 }; |
|
68 |
|
69 /** |
|
70 * The state handler base class. |
|
71 * |
|
72 * @since Series 60 5.0. |
|
73 */ |
|
74 class CPeninputHwrfscnStateHandlerBase :public CBase |
|
75 ,public MPeninputHwrfscnStateHandler |
|
76 { |
|
77 |
|
78 public: |
|
79 /** |
|
80 * The handler base destructor |
|
81 * |
|
82 * @since Series 60 5.0 |
|
83 */ |
|
84 virtual ~CPeninputHwrfscnStateHandlerBase(); |
|
85 |
|
86 protected: |
|
87 /** |
|
88 * The constructor. |
|
89 * |
|
90 * @since Series 60 5.0 |
|
91 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
92 */ |
|
93 CPeninputHwrfscnStateHandlerBase( CPeninputHwrfscnStateManager& aStateManager ); |
|
94 |
|
95 protected: |
|
96 /** |
|
97 * The reference to state manager. |
|
98 * |
|
99 * @since Series 60 5.0 |
|
100 */ |
|
101 CPeninputHwrfscnStateManager& iStateManager; |
|
102 |
|
103 /** |
|
104 * The data store reference |
|
105 * |
|
106 * @since Series 60 5.0 |
|
107 */ |
|
108 CPeninputHwrfscnDataStore& iDataStore; |
|
109 }; |
|
110 |
|
111 /** |
|
112 * The Standby state class. |
|
113 * |
|
114 * @since Series 60 5.0 |
|
115 */ |
|
116 class CPeninputHwrfscnStateHandlerStandby : public CPeninputHwrfscnStateHandlerBase |
|
117 { |
|
118 public: |
|
119 /** |
|
120 * Factory function |
|
121 * |
|
122 * @since Series 60 5.0 |
|
123 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
124 * @return CPeninputHwrfscnStateHandlerStandby* Return the |
|
125 CPeninputHwrfscnStateHandlerStandby object pointer. |
|
126 */ |
|
127 static CPeninputHwrfscnStateHandlerStandby* NewL( |
|
128 CPeninputHwrfscnStateManager& aStateManager ); |
|
129 public: |
|
130 /** |
|
131 * Handle command |
|
132 * |
|
133 * @since Series 60 5.0 |
|
134 */ |
|
135 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
136 |
|
137 /** |
|
138 * Handle state event |
|
139 * |
|
140 * @since Series 60 5.0 |
|
141 */ |
|
142 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
143 |
|
144 /** |
|
145 * Handle the state entering action |
|
146 * |
|
147 * @since Series 60 5.0 |
|
148 */ |
|
149 void OnEntry(); |
|
150 |
|
151 /** |
|
152 * Handle the state exiting action |
|
153 * |
|
154 * @since Series 60 5.0 |
|
155 */ |
|
156 void OnExit(); |
|
157 |
|
158 private: |
|
159 /** |
|
160 * The constructor |
|
161 * |
|
162 * @since Series 60 5.0 |
|
163 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
164 */ |
|
165 CPeninputHwrfscnStateHandlerStandby( |
|
166 CPeninputHwrfscnStateManager& aStateManager ); |
|
167 |
|
168 }; |
|
169 |
|
170 /** |
|
171 * The Writing state class. |
|
172 * |
|
173 * @since Series 60 5.0 |
|
174 */ |
|
175 class CPeninputHwrfscnStateHandlerWriting : public CPeninputHwrfscnStateHandlerBase |
|
176 { |
|
177 public: |
|
178 /** |
|
179 * Factory function |
|
180 * |
|
181 * @since Series 60 5.0 |
|
182 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
183 * @return CPeninputHwrfscnStateHandlerWriting* Return the |
|
184 CPeninputHwrfscnStateHandlerWriting object pointer. |
|
185 */ |
|
186 static CPeninputHwrfscnStateHandlerWriting* NewL( |
|
187 CPeninputHwrfscnStateManager& aStateManager ); |
|
188 public: |
|
189 /** |
|
190 * Handle command |
|
191 * |
|
192 * @since Series 60 5.0 |
|
193 */ |
|
194 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
195 |
|
196 /** |
|
197 * Handle state event |
|
198 * |
|
199 * @since Series 60 5.0 |
|
200 */ |
|
201 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
202 |
|
203 /** |
|
204 * Handle the state entering action |
|
205 * |
|
206 * @since Series 60 5.0 |
|
207 */ |
|
208 void OnEntry(); |
|
209 |
|
210 /** |
|
211 * Handle the state exiting action |
|
212 * |
|
213 * @since Series 60 5.0 |
|
214 */ |
|
215 void OnExit(); |
|
216 |
|
217 private: |
|
218 /** |
|
219 * The constructor |
|
220 * |
|
221 * @since Series 60 5.0 |
|
222 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
223 */ |
|
224 CPeninputHwrfscnStateHandlerWriting( CPeninputHwrfscnStateManager& aStateManager ); |
|
225 |
|
226 private: |
|
227 /** |
|
228 * Handle the end writing event |
|
229 * |
|
230 * @since Series 60 5.0 |
|
231 * @param aEventData The trace data |
|
232 */ |
|
233 void OnEndWritingL( const TDesC& aEventData ); |
|
234 }; |
|
235 |
|
236 /** |
|
237 * The CandidateSelecting state class. |
|
238 * |
|
239 * @since Series 60 5.0 |
|
240 */ |
|
241 class CPeninputHwrfscnStateHandlerCandidateSelecting : public CPeninputHwrfscnStateHandlerBase |
|
242 { |
|
243 public: |
|
244 /** |
|
245 * Factory function |
|
246 * |
|
247 * @since Series 60 5.0 |
|
248 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
249 * @return CPeninputHwrfscnStateHandlerCandidateSelecting Return the |
|
250 CPeninputHwrfscnStateHandlerCandidateSelecting object pointer. |
|
251 */ |
|
252 static CPeninputHwrfscnStateHandlerCandidateSelecting* NewL( |
|
253 CPeninputHwrfscnStateManager& aStateManager ); |
|
254 public: |
|
255 /** |
|
256 * Handle command |
|
257 * |
|
258 * @since Series 60 5.0 |
|
259 */ |
|
260 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
261 |
|
262 /** |
|
263 * Handle state event |
|
264 * |
|
265 * @since Series 60 5.0 |
|
266 */ |
|
267 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
268 |
|
269 /** |
|
270 * Handle the state entering action |
|
271 * |
|
272 * @since Series 60 5.0 |
|
273 */ |
|
274 void OnEntry(); |
|
275 |
|
276 /** |
|
277 * Handle the state exiting action |
|
278 * |
|
279 * @since Series 60 5.0 |
|
280 */ |
|
281 void OnExit(); |
|
282 |
|
283 private: |
|
284 /** |
|
285 * The constructor |
|
286 * |
|
287 * @since Series 60 5.0 |
|
288 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
289 */ |
|
290 CPeninputHwrfscnStateHandlerCandidateSelecting( |
|
291 CPeninputHwrfscnStateManager& aStateManager ); |
|
292 |
|
293 private: |
|
294 /** |
|
295 * Handle one candiate selected event |
|
296 * |
|
297 * @since Series 60 5.0 |
|
298 * @param aEventData The selected candidate |
|
299 */ |
|
300 void OnSelectedCandidatesL( const TDesC& aEventData ); |
|
301 |
|
302 /** |
|
303 * Handle predictive candidate selected events |
|
304 * |
|
305 * @since Series 60 5.0 |
|
306 * @param aEventData The selected predictive candidate |
|
307 * @param aAppend ETrue if the aEventData need to be appended onto trigger string |
|
308 EFalse if the aEventData need to set trigger string and do not |
|
309 submit it to layout |
|
310 */ |
|
311 void OnSelectedPredictivesL( const TDesC& aEventData, TBool aAppend = ETrue ); |
|
312 }; |
|
313 |
|
314 /** |
|
315 * The HomophonicSelecting state class. |
|
316 * |
|
317 * @since Series 60 5.0 |
|
318 */ |
|
319 class CPeninputHwrfscnStateHandlerHomophonicSelecting : public CPeninputHwrfscnStateHandlerBase |
|
320 { |
|
321 public: |
|
322 /** |
|
323 * Factory function |
|
324 * |
|
325 * @since Series 60 5.0 |
|
326 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
327 * @return CPeninputHwrfscnStateHandlerHomophonicSelecting Return the |
|
328 CPeninputHwrfscnStateHandlerHomophonicSelecting object pointer. |
|
329 */ |
|
330 static CPeninputHwrfscnStateHandlerHomophonicSelecting* NewL( |
|
331 CPeninputHwrfscnStateManager& aStateManager ); |
|
332 public: |
|
333 /** |
|
334 * Handle command |
|
335 * |
|
336 * @since Series 60 5.0 |
|
337 */ |
|
338 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
339 |
|
340 /** |
|
341 * Handle state event |
|
342 * |
|
343 * @since Series 60 5.0 |
|
344 */ |
|
345 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
346 |
|
347 /** |
|
348 * Handle the state entering action |
|
349 * |
|
350 * @since Series 60 5.0 |
|
351 */ |
|
352 void OnEntry(); |
|
353 |
|
354 /** |
|
355 * Handle the state exiting action |
|
356 * |
|
357 * @since Series 60 5.0 |
|
358 */ |
|
359 void OnExit(); |
|
360 |
|
361 private: |
|
362 /** |
|
363 * The constructor |
|
364 |
|
365 * @since Series 60 5.0 |
|
366 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
367 */ |
|
368 CPeninputHwrfscnStateHandlerHomophonicSelecting( |
|
369 CPeninputHwrfscnStateManager& aStateManager ); |
|
370 |
|
371 private: |
|
372 /** |
|
373 * Handle one candiate selected event |
|
374 * |
|
375 * @since Series 60 5.0 |
|
376 * @param aEventData The selected candidate |
|
377 */ |
|
378 void OnSelectedCandidatesL( const TDesC& aEventData ); |
|
379 |
|
380 /** |
|
381 * Handle one predictive candiate selected event |
|
382 * |
|
383 * @since Series 60 5.0 |
|
384 * @param aEventData The selected candidate |
|
385 */ |
|
386 void OnSelectedPredictivesL( const TDesC& aEventData ); |
|
387 }; |
|
388 |
|
389 /** |
|
390 * The PredictSelecting state class. |
|
391 * |
|
392 * @since Series 60 5.0 |
|
393 */ |
|
394 class CPeninputHwrfscnStateHandlerPredictSelecting : public CPeninputHwrfscnStateHandlerBase |
|
395 { |
|
396 public: |
|
397 /** |
|
398 * Factory function |
|
399 * |
|
400 * @since Series 60 5.0 |
|
401 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
402 * @return CPeninputHwrfscnStateHandlerPredictSelecting Return the |
|
403 CPeninputHwrfscnStateHandlerPredictSelecting object pointer. |
|
404 */ |
|
405 static CPeninputHwrfscnStateHandlerPredictSelecting* NewL( |
|
406 CPeninputHwrfscnStateManager& aStateManager ); |
|
407 public: |
|
408 /** |
|
409 * Handle command |
|
410 * |
|
411 * @since Series 60 5.0 |
|
412 */ |
|
413 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
414 |
|
415 /** |
|
416 * Handle state event |
|
417 * |
|
418 * @since Series 60 5.0 |
|
419 */ |
|
420 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
421 |
|
422 /** |
|
423 * Handle the state entering action |
|
424 * |
|
425 * @since Series 60 5.0 |
|
426 */ |
|
427 void OnEntry(); |
|
428 |
|
429 /** |
|
430 * Handle the state exiting action |
|
431 * |
|
432 * @since Series 60 5.0 |
|
433 */ |
|
434 void OnExit(); |
|
435 |
|
436 private: |
|
437 /** |
|
438 * The constructor |
|
439 * |
|
440 * @since Series 60 5.0 |
|
441 * @param aStateManager The reference to state manager. @see CPeninputHwrfscnStateManager. |
|
442 */ |
|
443 CPeninputHwrfscnStateHandlerPredictSelecting( |
|
444 CPeninputHwrfscnStateManager& aStateManager ); |
|
445 |
|
446 private: |
|
447 /** |
|
448 * Handle one predictive candiate selected event |
|
449 * |
|
450 * @since Series 60 5.0 |
|
451 * @param aEventData The selected candidate |
|
452 */ |
|
453 void OnSelectedPredictivesL( const TDesC& aEventData ); |
|
454 }; |
|
455 |
|
456 /** |
|
457 * The full screen hwr state manager. |
|
458 * |
|
459 * @since Series 60 5.0 |
|
460 */ |
|
461 class CPeninputHwrfscnStateManager : public CBase |
|
462 { |
|
463 public: |
|
464 /** |
|
465 * The factory function |
|
466 * |
|
467 * @since Series 60 5.0 |
|
468 * @param aLayout The layout reference |
|
469 * @return CPeninputHwrfscnStateManager* The newly created CPeninputHwrfscnStateManager object |
|
470 */ |
|
471 static CPeninputHwrfscnStateManager* NewL( CPeninputHwrfscnLayout* aLayout ); |
|
472 |
|
473 /** |
|
474 * The destructor |
|
475 * |
|
476 *@since Series 60 5.0 |
|
477 */ |
|
478 ~CPeninputHwrfscnStateManager(); |
|
479 |
|
480 public: |
|
481 /** |
|
482 * The hwr states. |
|
483 * |
|
484 *@since Series 60 5.0 |
|
485 */ |
|
486 enum TPeninputHwrfscnState |
|
487 { |
|
488 EPeninputHwrfscnStateStandby = 0, |
|
489 EPeninputHwrfscnStateWriting, |
|
490 EPeninputHwrfscnStateCandidateSelecting, |
|
491 EPeninputHwrfscnStateHomophonicSelecting, |
|
492 EPeninputHwrfscnStatePredictSelecting, |
|
493 EPeninputHwrfscnStateCount |
|
494 }; |
|
495 |
|
496 public: |
|
497 /** |
|
498 * Handle the command |
|
499 * |
|
500 * @since Series 60 5.0 |
|
501 * @param aCmd The command ID |
|
502 * @param aData The command data |
|
503 */ |
|
504 void HandleCommand( TInt aCmd, TUint8* aData ); |
|
505 |
|
506 /** |
|
507 * Handle the hwr box and canidate events |
|
508 * |
|
509 * @since Series 60 5.0 |
|
510 * @param aEventType The event type |
|
511 * @param aEventData The event data |
|
512 */ |
|
513 void HandleEventL( TInt aEventType, const TDesC& aEventData ); |
|
514 |
|
515 /** |
|
516 * Return the layout reference |
|
517 * |
|
518 * @since Series 60 5.0 |
|
519 * CPeninputHwrfscnLayout& The hwr layout reference |
|
520 */ |
|
521 CPeninputHwrfscnLayout& HwrLayout(); |
|
522 |
|
523 /** |
|
524 * Set current state. |
|
525 * |
|
526 * @since Series 60 5.0 |
|
527 * @param aState The state to be set. @See TPeninputHwrfscnState. |
|
528 */ |
|
529 void SetState( TPeninputHwrfscnState aState ); |
|
530 |
|
531 private: |
|
532 /** |
|
533 * The constructor. |
|
534 * |
|
535 * @since Series 60 5.0 |
|
536 * @param aLayout The full screen HWR layout pointer. |
|
537 */ |
|
538 CPeninputHwrfscnStateManager( CPeninputHwrfscnLayout* aLayout ); |
|
539 |
|
540 private: |
|
541 /** |
|
542 * 2nd phase constructor. |
|
543 * |
|
544 * @since Series 60 5.0 |
|
545 */ |
|
546 void ConstructL(); |
|
547 |
|
548 /** |
|
549 * Find the current state object. |
|
550 * |
|
551 * @since Series 60 5.0 |
|
552 * @param aState According to this state type, |
|
553 * we could find the corresponding state obect. |
|
554 */ |
|
555 CPeninputHwrfscnStateHandlerBase* Find( TPeninputHwrfscnState ); |
|
556 |
|
557 private: |
|
558 /** |
|
559 * Pointer to the full screen hwr layout. |
|
560 * |
|
561 * Not own. |
|
562 */ |
|
563 CPeninputHwrfscnLayout* iLayout; |
|
564 |
|
565 /** |
|
566 * Store all states pointers. |
|
567 * Own. |
|
568 */ |
|
569 CPeninputHwrfscnStateHandlerBase* iStateHandlers[EPeninputHwrfscnStateCount]; |
|
570 |
|
571 /** |
|
572 * Store all states' types. |
|
573 * Own |
|
574 */ |
|
575 TPeninputHwrfscnState iStates[EPeninputHwrfscnStateCount]; |
|
576 |
|
577 /** |
|
578 * The pointer to current state. |
|
579 * Own |
|
580 */ |
|
581 CPeninputHwrfscnStateHandlerBase* iCurrentStateHandler; |
|
582 |
|
583 /** |
|
584 * The current state type. |
|
585 * |
|
586 */ |
|
587 TPeninputHwrfscnState iCurrentState; |
|
588 }; |
|
589 |
|
590 #endif //__PENINPUTHWRFSCNSTATEMANAGER_H__ |