|
1 /* |
|
2 * Copyright (c) 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef T_ALFCOMMAND_H |
|
21 #define T_ALFCOMMAND_H |
|
22 |
|
23 #include <alf/alfimage.h> |
|
24 |
|
25 class CAlfControl; |
|
26 class TAlfObjectCommand; |
|
27 class CAlfEnv; |
|
28 class CAlfVisual; |
|
29 class CAlfControlGroup; |
|
30 class CAlfTextVisual; |
|
31 class MAlfEventHandler; |
|
32 class CAlfDisplay; |
|
33 class CAlfImageVisual; |
|
34 class CAlfTransformation; |
|
35 |
|
36 /** |
|
37 * Command types. |
|
38 * All the commands that can be executed by the toolkit are enumerated here. |
|
39 */ |
|
40 enum TAlfCommandType |
|
41 { |
|
42 |
|
43 /** None corresponds the base class (TAlfCommand). */ |
|
44 EAlfCommandTypeNone = 0, |
|
45 |
|
46 EAlfCommandTypeObject, |
|
47 |
|
48 EAlfCommandTypeAction, |
|
49 |
|
50 EAlfCommandTypeGroup, |
|
51 |
|
52 EAlfCommandTypeControl, |
|
53 |
|
54 EAlfCommandTypeVisual, |
|
55 |
|
56 EAlfCommandTypeImage, |
|
57 |
|
58 EAlfCommandTypeText, |
|
59 |
|
60 EAlfCommandTypeValue, |
|
61 |
|
62 EAlfCommandTypePoint, |
|
63 |
|
64 EAlfCommandTypeTransformation, |
|
65 |
|
66 EAlfCommandTypeCustomEvent, |
|
67 |
|
68 /** Marker command type. Types up from here will be used for markers only. */ |
|
69 EAlfCommandTypeMarkerFirst = 10000, |
|
70 EAlfCommandTypeMarker0 = EAlfCommandTypeMarkerFirst, |
|
71 EAlfCommandTypeMarker1, |
|
72 EAlfCommandTypeMarker2, |
|
73 EAlfCommandTypeMarker3, |
|
74 EAlfCommandTypeMarker4, |
|
75 EAlfCommandTypeMarker5, |
|
76 EAlfCommandTypeMarker6, |
|
77 EAlfCommandTypeMarker7, |
|
78 EAlfCommandTypeMarker8, |
|
79 EAlfCommandTypeMarker9, |
|
80 EAlfCommandTypeMarker10 |
|
81 }; |
|
82 |
|
83 |
|
84 /** |
|
85 * Command operations. |
|
86 */ |
|
87 enum TAlfOp |
|
88 { |
|
89 EAlfOpNone = 0, |
|
90 |
|
91 /* Control Group operations. */ |
|
92 EAlfOpHide = 1000, |
|
93 EAlfOpShow, |
|
94 EAlfOpEnableInput, |
|
95 EAlfOpDisableInput, |
|
96 |
|
97 /* Control operations. */ |
|
98 /* (start from 2000) */ // None defined yet. |
|
99 |
|
100 /* Visual operations. */ |
|
101 EAlfOpRemoveAndDestroyAll = 3000, |
|
102 EAlfOpModifyFlags, |
|
103 EAlfOpSetPrimaryImage, |
|
104 EAlfOpSetSecondaryImage, |
|
105 EAlfOpSetText, |
|
106 EAlfOpEnableTransformation, |
|
107 EAlfOpDisableTransformation, |
|
108 |
|
109 /* Timed value operations. */ |
|
110 EAlfOpSet = 4000, |
|
111 EAlfOpSetWithSpeed, |
|
112 |
|
113 /* Timed value style operations. The actual is: |
|
114 TAlfInterpolationStyle(iOperation - EAlfOpSetStyle) */ |
|
115 EAlfOpSetStyle = 5000, |
|
116 |
|
117 /* Transformation operations. */ |
|
118 EAlfOpLoadIdentity = 6000, |
|
119 EAlfOpTranslate, |
|
120 EAlfOpScale, |
|
121 EAlfOpRotate, |
|
122 EAlfOpReplaceStep |
|
123 }; |
|
124 |
|
125 /** |
|
126 * Object types. |
|
127 * These are the different types of objects which can issue and receive commands. |
|
128 */ |
|
129 enum TAlfCommandObjectType |
|
130 { |
|
131 EAlfCommandObjectTypeNone, |
|
132 |
|
133 /** This object is a visual. */ |
|
134 EAlfCommandObjectTypeVisual, |
|
135 |
|
136 /** This object is a control. */ |
|
137 EAlfCommandObjectTypeControl, |
|
138 |
|
139 /** This object is a control group. */ |
|
140 EAlfCommandObjectTypeControlGroup |
|
141 }; |
|
142 |
|
143 /** |
|
144 * Value command target |
|
145 * |
|
146 */ |
|
147 enum TAlfValueCommandTarget |
|
148 { |
|
149 EAlfValueCommandVisualSetOpacity |
|
150 }; |
|
151 |
|
152 /** |
|
153 * Point command target |
|
154 * |
|
155 */ |
|
156 enum TAlfPointCommandTarget |
|
157 { |
|
158 EAlfPointCommandVisualSetPos, |
|
159 EAlfPointCommandVisualSetSize |
|
160 }; |
|
161 |
|
162 /** |
|
163 * TAlfCommand is the base class of all commands. A command is an |
|
164 * instruction to some class that can be set to occur some time in the future. |
|
165 * Each command stores information about an operation. Each command is also responsible for |
|
166 * the execution of the command. |
|
167 * Commands are processed by the class's OfferEventL() method. |
|
168 */ |
|
169 class TAlfCommand |
|
170 { |
|
171 public: |
|
172 |
|
173 /* Destructor. */ |
|
174 |
|
175 IMPORT_C virtual ~TAlfCommand(); |
|
176 |
|
177 |
|
178 /* Methods. */ |
|
179 |
|
180 IMPORT_C TAlfCommandType Type() const; |
|
181 |
|
182 /** |
|
183 * Returns a pointer to the command casted to TAlfObjectCommand. |
|
184 * If this is not possible (the command is not derived from |
|
185 * TAlfObjectCommand), returns NULL instead. |
|
186 */ |
|
187 IMPORT_C virtual const TAlfObjectCommand* ObjectCommand() const; |
|
188 |
|
189 /** |
|
190 * Executes the command. |
|
191 * |
|
192 * @param aEnv The environment in which the command is being executed. |
|
193 */ |
|
194 virtual void ExecuteL(CAlfEnv& aEnv) const = 0; |
|
195 |
|
196 /** |
|
197 * Returns the size of the command. |
|
198 */ |
|
199 virtual TInt Size() const = 0; |
|
200 |
|
201 protected: |
|
202 |
|
203 /* Constructor. */ |
|
204 |
|
205 /** |
|
206 * Protected constructor. |
|
207 * |
|
208 * @param aType Type of the command. |
|
209 */ |
|
210 IMPORT_C TAlfCommand(TAlfCommandType aType); |
|
211 |
|
212 IMPORT_C virtual void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
213 |
|
214 private: |
|
215 |
|
216 /* These member variables are shared by all commands. */ |
|
217 |
|
218 /** Type of the command. Depends on the command class. */ |
|
219 TAlfCommandType iType; |
|
220 |
|
221 private: |
|
222 TInt iSpare1; |
|
223 TInt iSpare2; |
|
224 }; |
|
225 |
|
226 /** |
|
227 * TAlfActionCommand is a simple action that triggers an action notification. |
|
228 * |
|
229 * They are reserved for notifying observers of user-initiated actions in the user |
|
230 * interface. |
|
231 * For example, a button control might send an action command when the user clicks on |
|
232 * the button. |
|
233 * |
|
234 * Usage: |
|
235 * @code |
|
236 * |
|
237 * //Candidate, interested in action notification, should implement |
|
238 * // MAlfActionObserver interface |
|
239 * class ActionCommandTest : public MAlfActionObserver |
|
240 * { |
|
241 * public: |
|
242 * ..... |
|
243 * ..... |
|
244 * ..... |
|
245 * void HandleAction( const TAlfActionCommand& aActionCommand ); |
|
246 * }; |
|
247 * |
|
248 * // From MAlfActionObserver |
|
249 * void ActionCommandTest::HandleAction( const TAlfActionCommand& aActionCommand ) |
|
250 * { |
|
251 * //Perform required action on notification |
|
252 * } |
|
253 * ------------------------------------------------------------------------------- |
|
254 * //Observer registrartion |
|
255 * ActionCommandTest* testClass = new ActionCommandTest(); |
|
256 * |
|
257 * //Create command |
|
258 * TAlfActionCommand command( 1 ); |
|
259 * |
|
260 * //Register test command as observer to environment |
|
261 * iEnv->AddActionObserverL( testClass ); |
|
262 * |
|
263 * //Send command |
|
264 * iEnv->Send( command, 1 ); |
|
265 * |
|
266 * //Cleanup |
|
267 * iEnv->RemoveActionObserver( testClass ); |
|
268 * delete testClass; |
|
269 * |
|
270 * @endcode |
|
271 * |
|
272 * @see MAlfActionObserver |
|
273 * @see CAlfEnv::AddActionObserverL() |
|
274 * @see CAlfEnv::RemoveActionObserver() |
|
275 */ |
|
276 class TAlfActionCommand : public TAlfCommand |
|
277 { |
|
278 public: |
|
279 |
|
280 /* Constructor. */ |
|
281 |
|
282 /** |
|
283 * Constructs a new action command. |
|
284 * |
|
285 * @param aId Identifier of the action. |
|
286 */ |
|
287 IMPORT_C TAlfActionCommand(TInt aId); |
|
288 |
|
289 /* Methods. */ |
|
290 |
|
291 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
292 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
293 |
|
294 /* Implementation of TAlfCommand::Size(). */ |
|
295 IMPORT_C TInt Size() const; |
|
296 |
|
297 /** |
|
298 * Determines the action identifier of the command. |
|
299 * |
|
300 * @param Action identifier. |
|
301 */ |
|
302 IMPORT_C TInt Id() const; |
|
303 |
|
304 |
|
305 protected: |
|
306 |
|
307 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
308 |
|
309 private: |
|
310 |
|
311 /** Action identifier. */ |
|
312 TInt iId; |
|
313 |
|
314 private: |
|
315 TInt iSpare1; |
|
316 TInt iSpare2; |
|
317 }; |
|
318 |
|
319 /** |
|
320 * TAlfObjectCommand is the base class for commands that modify data owned by |
|
321 * an object. If the object gets deleted and the scheduler is notified of this, |
|
322 * the command will be automatically canceled. |
|
323 * |
|
324 * Deriving class needs to override Clone() and Execute() functions from the Command |
|
325 * base class and NOT to call the base class implementation. |
|
326 */ |
|
327 class TAlfObjectCommand : public TAlfCommand |
|
328 { |
|
329 public: |
|
330 |
|
331 /* Methods. */ |
|
332 |
|
333 IMPORT_C const TAlfObjectCommand* ObjectCommand() const; |
|
334 |
|
335 /** |
|
336 * Returns the data owner object of the command. |
|
337 */ |
|
338 IMPORT_C TAny* Object() const; |
|
339 |
|
340 /** |
|
341 * Returns the operation of the command. |
|
342 */ |
|
343 IMPORT_C TAlfOp Operation() const; |
|
344 |
|
345 |
|
346 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
347 |
|
348 |
|
349 IMPORT_C TInt Size() const; |
|
350 |
|
351 protected: |
|
352 |
|
353 /* Constructor. */ |
|
354 |
|
355 /** |
|
356 * Protected constructor. |
|
357 * |
|
358 * @param aType Type of the command. |
|
359 * @param aDataOwnerObject Object that owns the data this command handles. |
|
360 * @param aOperation Operation being done on the object. |
|
361 */ |
|
362 IMPORT_C TAlfObjectCommand(TAlfCommandType aType, TAny* aDataOwnerObject, TAlfOp aOperation); |
|
363 |
|
364 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
365 |
|
366 private: |
|
367 |
|
368 /** Object that owns the data this command handles. */ |
|
369 TAny* iObject; |
|
370 |
|
371 /** Operation being done on the object. */ |
|
372 TAlfOp iOperation; |
|
373 |
|
374 private: |
|
375 TInt iSpare1; |
|
376 TInt iSpare2; |
|
377 }; |
|
378 |
|
379 /** |
|
380 * TAlfGroupCommand is an object command that operates on a control group. |
|
381 * Usage: |
|
382 * |
|
383 * @code |
|
384 * //Create control group command to show contro group on display |
|
385 * TAlfGroupCommand command( *iControlGroup, EAlfOpShow, &display ); |
|
386 * |
|
387 * //Send command , control group will be shown |
|
388 * iEnv->Send( command, 1 ); |
|
389 * |
|
390 * //Create control group command to hide control group on display |
|
391 * TAlfGroupCommand command1( *iControlGroup, EAlfOpHide, &display ); |
|
392 * |
|
393 * //Send command , control group will be hidden |
|
394 * iEnv->Send( command, 1 ); |
|
395 * @endcode |
|
396 */ |
|
397 class TAlfGroupCommand : public TAlfObjectCommand |
|
398 { |
|
399 public: |
|
400 |
|
401 /* Constructor. */ |
|
402 |
|
403 /** |
|
404 * Constructs a new control group command. |
|
405 * |
|
406 * @param aGroup Control group. |
|
407 * @param aDisplay Display associated with the command. |
|
408 * @param aOperation Operation to do on the group. |
|
409 */ |
|
410 IMPORT_C TAlfGroupCommand(CAlfControlGroup& aGroup, TAlfOp aOperation, |
|
411 CAlfDisplay* aDisplay = NULL); |
|
412 |
|
413 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
414 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
415 |
|
416 /* Implementation of TAlfCommand::Size(). */ |
|
417 IMPORT_C TInt Size() const; |
|
418 |
|
419 |
|
420 /* Methods. */ |
|
421 |
|
422 /** |
|
423 * Returns the control group that the command operates on. |
|
424 */ |
|
425 IMPORT_C CAlfControlGroup& ControlGroup() const; |
|
426 |
|
427 /** |
|
428 * Returns the display associated with the command. |
|
429 */ |
|
430 IMPORT_C CAlfDisplay* Display() const; |
|
431 |
|
432 protected: |
|
433 |
|
434 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
435 |
|
436 private: |
|
437 |
|
438 /** Display associated with the command. */ |
|
439 CAlfDisplay* iDisplay; |
|
440 |
|
441 private: |
|
442 TInt iSpare1; |
|
443 TInt iSpare2; |
|
444 }; |
|
445 |
|
446 /** |
|
447 * TAlfControlCommand is an object command that operates on a control. |
|
448 */ |
|
449 class TAlfControlCommand : public TAlfObjectCommand |
|
450 { |
|
451 public: |
|
452 |
|
453 /* Constructor. */ |
|
454 |
|
455 /** |
|
456 * Constructs a new control command. |
|
457 * |
|
458 * @param aControl Control. |
|
459 * @param aOperation Operation to do on the control. |
|
460 */ |
|
461 IMPORT_C TAlfControlCommand(CAlfControl& aControl, TAlfOp aOperation); |
|
462 |
|
463 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
464 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
465 |
|
466 /* Implementation of TAlfCommand::Size(). */ |
|
467 IMPORT_C TInt Size() const; |
|
468 |
|
469 /* Methods. */ |
|
470 |
|
471 /** |
|
472 * Returns the control that the command operates on. |
|
473 */ |
|
474 IMPORT_C CAlfControl& Control() const; |
|
475 |
|
476 protected: |
|
477 |
|
478 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
479 |
|
480 private: |
|
481 TInt iSpare1; |
|
482 TInt iSpare2; |
|
483 }; |
|
484 |
|
485 /** |
|
486 * TAlfVisualCommand is an object command that operates on a visual. |
|
487 * Usage: |
|
488 * |
|
489 * @code |
|
490 * //Create Visual command to move visual to front |
|
491 * TAlfVisualCommand command( *iVisual, EAlfOpEnableTransformation ); |
|
492 * |
|
493 * //Send command , visual will be moved to front |
|
494 * iEnv->Send( command, 1 ); |
|
495 * |
|
496 * @endcode |
|
497 * |
|
498 */ |
|
499 class TAlfVisualCommand : public TAlfObjectCommand |
|
500 { |
|
501 public: |
|
502 |
|
503 /* Constructor. */ |
|
504 |
|
505 /** |
|
506 * Constructs a new visual command. |
|
507 * |
|
508 * @param aVisual Visual. |
|
509 * @param aOperation Operation to do on the visual. |
|
510 */ |
|
511 IMPORT_C TAlfVisualCommand(CAlfVisual& aVisual, TAlfOp aOperation, |
|
512 TInt aSetFlags = 0, TInt aClearFlags = 0); |
|
513 |
|
514 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
515 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
516 |
|
517 /* Implementation of TAlfCommand::Size(). */ |
|
518 IMPORT_C TInt Size() const; |
|
519 |
|
520 /* Methods. */ |
|
521 |
|
522 /** |
|
523 * Returns the visual that the command operates on. |
|
524 */ |
|
525 IMPORT_C CAlfVisual& Visual() const; |
|
526 |
|
527 /** |
|
528 * Returns the flags that will be set by the command. |
|
529 */ |
|
530 IMPORT_C TInt FlagsToSet() const; |
|
531 |
|
532 /** |
|
533 * Returns the flags that will be cleared by the command. |
|
534 */ |
|
535 IMPORT_C TInt FlagsToClear() const; |
|
536 |
|
537 protected: |
|
538 |
|
539 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
540 |
|
541 private: |
|
542 |
|
543 /** Flags to set. */ |
|
544 TInt iSetFlags; |
|
545 |
|
546 /** Flags to clear. */ |
|
547 TInt iClearFlags; |
|
548 |
|
549 private: |
|
550 TInt iSpare1; |
|
551 TInt iSpare2; |
|
552 |
|
553 }; |
|
554 |
|
555 /** |
|
556 * TAlfImageCommand is a command that operaters on an image visual. |
|
557 * Usage: |
|
558 * |
|
559 * @code |
|
560 * |
|
561 * //Create Image command to set primary image for imagevisual |
|
562 * TAlfImageCommand command( *imageVisual, *image, EAlfOpSetPrimaryImage ); |
|
563 * |
|
564 * //Send command , Primary image will be set |
|
565 * iEnv->Send( command, 1 ); |
|
566 * |
|
567 * @endcode |
|
568 */ |
|
569 class TAlfImageCommand : public TAlfObjectCommand |
|
570 { |
|
571 public: |
|
572 |
|
573 /* Constructor. */ |
|
574 |
|
575 /** |
|
576 * Constructs a new image command. |
|
577 * |
|
578 * @param aImageVisual Image visual. |
|
579 * @param aImage Image. |
|
580 * @param aOperation Operation to do on the visual. |
|
581 */ |
|
582 IMPORT_C TAlfImageCommand(CAlfImageVisual& aImageVisual, const TAlfImage& aImage, |
|
583 TAlfOp aOperation = EAlfOpSetPrimaryImage); |
|
584 |
|
585 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
586 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
587 |
|
588 /* Implementation of TAlfCommand::Size(). */ |
|
589 IMPORT_C TInt Size() const; |
|
590 |
|
591 |
|
592 /* Methods. */ |
|
593 |
|
594 /** |
|
595 * Returns the visual that the command operates on. |
|
596 */ |
|
597 IMPORT_C CAlfImageVisual& ImageVisual() const; |
|
598 |
|
599 /** |
|
600 * Returns a reference to the image of the visual. |
|
601 */ |
|
602 IMPORT_C const TAlfImage& Image() const; |
|
603 |
|
604 protected: |
|
605 |
|
606 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
607 |
|
608 private: |
|
609 |
|
610 /** Image of the command. */ |
|
611 TAlfImage iImage; |
|
612 |
|
613 private: |
|
614 TInt iSpare1; |
|
615 TInt iSpare2; |
|
616 }; |
|
617 |
|
618 /** |
|
619 * TAlfTextCommand is a command that operaters on a text visual. |
|
620 * |
|
621 * Usage: |
|
622 * |
|
623 * @code |
|
624 * |
|
625 * //Create text command to set text in textvisual |
|
626 * TAlfTextCommand command( *textVisual, _L( "Text" ) ); |
|
627 * |
|
628 * //Send command , text will be set to textvisual |
|
629 * iEnv->Send( command, 1 ); |
|
630 * @endcode |
|
631 */ |
|
632 class TAlfTextCommand : public TAlfObjectCommand |
|
633 { |
|
634 public: |
|
635 |
|
636 /* Constructor. */ |
|
637 |
|
638 /** |
|
639 * Constructs a new text command. |
|
640 * |
|
641 * @param aTextVisual Text visual. |
|
642 * @param aText Text. |
|
643 * @param aOperation Operation to perform. |
|
644 */ |
|
645 IMPORT_C TAlfTextCommand(CAlfTextVisual& aTextVisual, const TDesC& aText, |
|
646 TAlfOp aOperation = EAlfOpSetText); |
|
647 |
|
648 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
649 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
650 |
|
651 /* Implementation of TAlfCommand::Size(). */ |
|
652 IMPORT_C TInt Size() const; |
|
653 |
|
654 |
|
655 /* Methods. */ |
|
656 |
|
657 /** |
|
658 * Returns the visual that the command operates on. |
|
659 */ |
|
660 IMPORT_C CAlfTextVisual& TextVisual() const; |
|
661 |
|
662 /** |
|
663 * Returns a reference to the text of the visual. |
|
664 */ |
|
665 IMPORT_C const TDesC& Text() const; |
|
666 |
|
667 protected: |
|
668 |
|
669 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
670 |
|
671 private: |
|
672 |
|
673 /** Text of the command. */ |
|
674 const TDesC& iText; |
|
675 |
|
676 private: |
|
677 TInt iSpare1; |
|
678 TInt iSpare2; |
|
679 }; |
|
680 |
|
681 |
|
682 /** |
|
683 * TAlfValueCommand is a command that operates on a single timed value. |
|
684 * |
|
685 * @code |
|
686 * |
|
687 * //Create timed value command to set visualopacity of a visual |
|
688 * TAlfValueCommand command( visual, EAlfValueCommandVisualSetOpacity, 0.2, 15 ); |
|
689 * |
|
690 * //Send command , visualopacity will be set |
|
691 * iEnv->Send( command, 1 ); |
|
692 * |
|
693 * @endcode |
|
694 */ |
|
695 class TAlfValueCommand : public TAlfObjectCommand |
|
696 { |
|
697 public: |
|
698 |
|
699 /* Constructor. */ |
|
700 |
|
701 /** |
|
702 * Constructs a new value command. |
|
703 * |
|
704 * @param aObject Object. Needs to match with aObjectType |
|
705 * @param aObjectType Timed value to modify. |
|
706 * @param aTarget Target value |
|
707 * @param aTransitionTime Time (in milliseconds) for the transition to occur. |
|
708 */ |
|
709 IMPORT_C TAlfValueCommand( |
|
710 TAny* aObject, |
|
711 TAlfValueCommandTarget aObjectType, |
|
712 TReal32 aTarget, |
|
713 TInt aTransitionTime = 0 ) __SOFTFP; |
|
714 |
|
715 /** |
|
716 * Constructs a new value command. This constructor takes an operation |
|
717 * parameter in addition to the target and timing values. |
|
718 * |
|
719 * @param aObject Object. Needs to match with aObjectType |
|
720 * @param aObjectType Timed value to modify. |
|
721 * @param aOperation Operation to perform. |
|
722 * @param aTarget Target value |
|
723 * @param aTiming Time (in milliseconds) for the transition to occur. |
|
724 */ |
|
725 IMPORT_C TAlfValueCommand(TAny* aObject, TAlfValueCommandTarget aObjectType, |
|
726 TAlfOp aOperation = EAlfOpSet, |
|
727 TReal32 aTarget = 0.0, TReal32 aTiming = 0.0) __SOFTFP; |
|
728 |
|
729 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
730 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
731 |
|
732 /* Implementation of TAlfCommand::Size(). */ |
|
733 IMPORT_C TInt Size() const; |
|
734 |
|
735 |
|
736 /* Methods. */ |
|
737 |
|
738 /** |
|
739 * Returns the visual that the command operates on. |
|
740 */ |
|
741 IMPORT_C TAlfValueCommandTarget TimedValue() const; |
|
742 |
|
743 /** |
|
744 * Returns the target value. |
|
745 */ |
|
746 IMPORT_C TReal32 Target() const __SOFTFP; |
|
747 |
|
748 /** |
|
749 * Returns the transition time. |
|
750 */ |
|
751 IMPORT_C TInt TransitionTime() const; |
|
752 |
|
753 /** |
|
754 * Returns the transition speed. Zero, if not set. |
|
755 */ |
|
756 IMPORT_C TReal32 Speed() const __SOFTFP; |
|
757 |
|
758 protected: |
|
759 |
|
760 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
761 |
|
762 private: |
|
763 |
|
764 /** Timed value being operated on. */ |
|
765 TAlfValueCommandTarget iTimedValue; |
|
766 |
|
767 /** Target value. */ |
|
768 TReal32 iTarget; |
|
769 |
|
770 /** Transition time in milliseconds. */ |
|
771 TInt iTransitionTime; |
|
772 |
|
773 /** Optionally, transition speed in units/second. */ |
|
774 TReal32 iSpeed; |
|
775 |
|
776 private: |
|
777 TInt iSpare1; |
|
778 TInt iSpare2; |
|
779 }; |
|
780 |
|
781 /** |
|
782 * TAlfPointCommand is a command that operates on a timed point. |
|
783 * Usage: |
|
784 * @code |
|
785 * |
|
786 * //Create timed point command to set visual size |
|
787 * TAlfRealPoint p1( 0.1, 0.1 ); |
|
788 * TAlfPointCommand command1( iVisual, EAlfValueCommandVisualSize, p1, 1 ); |
|
789 * |
|
790 * //Send command , Primary image will be set |
|
791 * iEnv->Send( command, 1 ); |
|
792 * |
|
793 * @endcode |
|
794 */ |
|
795 class TAlfPointCommand : public TAlfObjectCommand |
|
796 { |
|
797 public: |
|
798 |
|
799 enum TParameterTarget |
|
800 { |
|
801 EBoth = 0, // default |
|
802 EXOnly, |
|
803 EYOnly |
|
804 }; |
|
805 |
|
806 /* Constructor. */ |
|
807 |
|
808 /** |
|
809 * Constructs a new timed point command. |
|
810 * |
|
811 * @param aObject Object. Needs to match with aObjectType |
|
812 * @param aObjectType Timed value to modify. |
|
813 * @param aOperation Operation to perform. |
|
814 */ |
|
815 IMPORT_C TAlfPointCommand(TAny* aObject, TAlfPointCommandTarget aObjectType, |
|
816 TAlfOp aOperation); |
|
817 |
|
818 /** |
|
819 * Constructs a new timed point command. |
|
820 * |
|
821 * @param aObject Object. Needs to match with aObjectType |
|
822 * @param aObjectType Timed value to modify. |
|
823 * @param aTarget Target value |
|
824 * @param aTransitionTime Time (in milliseconds) for the transition to occur. |
|
825 */ |
|
826 IMPORT_C TAlfPointCommand(TAny* aObject, TAlfPointCommandTarget aObjectType, |
|
827 TAlfRealPoint aTarget, TInt aTransitionTime = 0, |
|
828 TParameterTarget aParameterTarget = EBoth ); |
|
829 |
|
830 /** |
|
831 * Constructs a new timed point command. This constructor takes an operation |
|
832 * parameter in addition to the target and timing values. |
|
833 * |
|
834 * @param aObject Object. Needs to match with aObjectType |
|
835 * @param aObjectType Timed value to modify. |
|
836 * @param aOperation Operation to perform. |
|
837 * @param aTarget Target value. |
|
838 * @param aTiming Time (in milliseconds) for the transition to occur. |
|
839 */ |
|
840 IMPORT_C TAlfPointCommand(TAny* aObject, TAlfPointCommandTarget aObjectType, |
|
841 TAlfOp aOperation, |
|
842 TAlfRealPoint aTarget, TReal32 aTiming = 0.0, |
|
843 TParameterTarget aParameterTarget = EBoth) __SOFTFP; |
|
844 |
|
845 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
846 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
847 |
|
848 /* Implementation of TAlfCommand::Size(). */ |
|
849 IMPORT_C TInt Size() const; |
|
850 |
|
851 |
|
852 /* Methods. */ |
|
853 |
|
854 /** |
|
855 * Returns the object type that the command operates on. |
|
856 */ |
|
857 IMPORT_C TAlfPointCommandTarget TimedPoint() const; |
|
858 |
|
859 /** |
|
860 * Returns the target value. |
|
861 */ |
|
862 IMPORT_C TAlfRealPoint Target() const; |
|
863 |
|
864 /** |
|
865 * Returns the transition time. |
|
866 */ |
|
867 IMPORT_C TInt TransitionTime() const; |
|
868 |
|
869 /** |
|
870 * Returns the transition speed. Zero, if not set. |
|
871 */ |
|
872 IMPORT_C TReal32 Speed() const __SOFTFP; |
|
873 |
|
874 protected: |
|
875 |
|
876 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
877 |
|
878 private: |
|
879 |
|
880 /** Timed point being operated on. */ |
|
881 TAlfPointCommandTarget iTimedPoint; |
|
882 |
|
883 /** Target value. */ |
|
884 TAlfRealPoint iTarget; |
|
885 |
|
886 /** Transition time in milliseconds. */ |
|
887 TInt iTransitionTime; |
|
888 |
|
889 /** Optionally, transition speed in units/second. */ |
|
890 TReal32 iSpeed; |
|
891 |
|
892 TParameterTarget iParameterTarget; |
|
893 |
|
894 private: |
|
895 TInt iSpare1; |
|
896 TInt iSpare2; |
|
897 }; |
|
898 |
|
899 /** |
|
900 * TAlfTransformationCommand is a command that operates on a transformation. |
|
901 * |
|
902 * Transformation command can generate one of the following operations: |
|
903 * @li EAlfOpLoadIdentity - Loads an identity matrix to the transformation. |
|
904 * @li EAlfOpTranslate - Applies a translation to the object affected by the transformation. |
|
905 * @li EAlfOpScale - Applies scaling to the object affected by the transformation. |
|
906 * @li EAlfOpRotate - Applies a rotation to the object that is affected by the transformation. |
|
907 * @li EAlfOpReplaceStep - Replaces the whole transformation step values with the |
|
908 * ones given as command parameters |
|
909 * |
|
910 * If the transformation operation is rotation the default rotation is around z-axis. |
|
911 * If the transformation operation is scaling the default scale factors are 1.0 on all axis. |
|
912 * On any other transformation the x,y and z components are zero by default. |
|
913 * |
|
914 * Usage: |
|
915 * @code |
|
916 * |
|
917 * //Enable transformation |
|
918 * iVisual->EnableTransformationL( ); |
|
919 * |
|
920 * //Get transformation object |
|
921 * CAlfTransformation* transformation = &iVisual->Transformation(); |
|
922 * |
|
923 * //Set transformation properties |
|
924 * const TInt rotateAngle = 23.67; |
|
925 * transformation->Rotate( rotateAngle ); |
|
926 * |
|
927 * //Create transformation command |
|
928 * TAlfTransformationCommand command( iVisual,transformation, EAlfOpRotate, 0 ); |
|
929 * |
|
930 * //Properties can also be set through command |
|
931 * command.SetAngle( TAlfTimedValue( 56 ) ); |
|
932 * |
|
933 * //Send command |
|
934 * iEnv->Send( command, 1 ); |
|
935 * |
|
936 * @endcode |
|
937 */ |
|
938 class TAlfTransformationCommand : public TAlfObjectCommand |
|
939 { |
|
940 public: |
|
941 |
|
942 enum |
|
943 { |
|
944 /** Used in the aStep parameter to specify that no step index is |
|
945 specified. */ |
|
946 EStepNone = -1 |
|
947 }; |
|
948 |
|
949 |
|
950 /* Constructor. */ |
|
951 |
|
952 /** |
|
953 * Constructs a new transformation command. |
|
954 * |
|
955 * @param aOwner Owner of the transformation. Allowed be NULL. |
|
956 * @param aTransformation Transformation to operate on. |
|
957 * @param aOperation Operation to perform. |
|
958 * @param aStep Step index in the transformation. |
|
959 */ |
|
960 IMPORT_C TAlfTransformationCommand(TAny* aOwner, CAlfTransformation& aTransformation, |
|
961 TAlfOp aOperation = EAlfOpLoadIdentity, |
|
962 TInt aStep = EStepNone); |
|
963 |
|
964 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
965 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
966 |
|
967 /* Implementation of TAlfCommand::Size(). */ |
|
968 IMPORT_C TInt Size() const; |
|
969 |
|
970 |
|
971 /* Methods. */ |
|
972 |
|
973 /** |
|
974 * Returns the transformation that the command operates on. |
|
975 */ |
|
976 IMPORT_C CAlfTransformation& Transformation() const; |
|
977 |
|
978 /** |
|
979 * Returns the transformation step index. |
|
980 */ |
|
981 IMPORT_C TInt Step() const; |
|
982 |
|
983 /** |
|
984 * Sets the X component. |
|
985 * - If transformation is translation this sets the amount of translation on X axis. |
|
986 * - If transformation is rotation this sets the X component of rotation axis vector. |
|
987 * - If transformation is scaling this sets the scaling factor for the X axis. |
|
988 * |
|
989 * @param aValue Timed value to set to the X component. |
|
990 */ |
|
991 IMPORT_C void SetX(const TAlfTimedValue& aValue); |
|
992 |
|
993 /** |
|
994 * Sets the Y component. |
|
995 * - If transformation is translation this sets the amount of translation on Y axis. |
|
996 * - If transformation is rotation this sets the Y component of rotation axis vector. |
|
997 * - If transformation is scaling this sets the scaling factor for the Y axis. |
|
998 * |
|
999 * @param aValue Timed value to set to the Y component. |
|
1000 */ |
|
1001 IMPORT_C void SetY(const TAlfTimedValue& aValue); |
|
1002 |
|
1003 /** |
|
1004 * Sets the Z component. |
|
1005 * - If transformation is translation this sets the amount of translation on Z axis. |
|
1006 * - If transformation is rotation this sets the Z component of rotation axis vector. |
|
1007 * - If transformation is scaling this sets the scaling factor for the Z axis. |
|
1008 * |
|
1009 * @param aValue Timed value to set to the Z component. |
|
1010 */ |
|
1011 IMPORT_C void SetZ(const TAlfTimedValue& aValue); |
|
1012 |
|
1013 /** |
|
1014 * Set the angle of rotation if the transformation is rotation. |
|
1015 */ |
|
1016 IMPORT_C void SetAngle(const TAlfTimedValue& aValue); |
|
1017 |
|
1018 protected: |
|
1019 |
|
1020 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
1021 |
|
1022 private: |
|
1023 |
|
1024 /** Image of the command. */ |
|
1025 CAlfTransformation& iTransformation; |
|
1026 |
|
1027 /** Step index. */ |
|
1028 TInt iStep; |
|
1029 |
|
1030 /** X component. Suspended. */ |
|
1031 TAlfTimedValue iX; |
|
1032 |
|
1033 /** Y component. Suspended. */ |
|
1034 TAlfTimedValue iY; |
|
1035 |
|
1036 /** Z component. Suspended. */ |
|
1037 TAlfTimedValue iZ; |
|
1038 |
|
1039 /** Angle component. Suspended. */ |
|
1040 TAlfTimedValue iAngle; |
|
1041 |
|
1042 private: |
|
1043 TInt iSpare1; |
|
1044 TInt iSpare2; |
|
1045 }; |
|
1046 |
|
1047 |
|
1048 /** |
|
1049 * TAlfMarkerCommand is a special marker command that has no functionality, |
|
1050 * but can be entered into the scheduler to mark a specific point in time. |
|
1051 */ |
|
1052 class TAlfMarkerCommand : public TAlfCommand |
|
1053 { |
|
1054 public: |
|
1055 |
|
1056 /* Constructor. */ |
|
1057 |
|
1058 /** |
|
1059 * Constructs a new marker command. |
|
1060 * |
|
1061 * @param aId Identifier of the marker. |
|
1062 */ |
|
1063 IMPORT_C TAlfMarkerCommand(TInt aId); |
|
1064 |
|
1065 |
|
1066 /* Methods. */ |
|
1067 |
|
1068 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
1069 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
1070 |
|
1071 /* Implementation of TAlfCommand::Size(). */ |
|
1072 IMPORT_C TInt Size() const; |
|
1073 |
|
1074 /** |
|
1075 * Determines the identifier of the marker. |
|
1076 * |
|
1077 * @param Marker identifier. |
|
1078 */ |
|
1079 IMPORT_C TInt Id() const; |
|
1080 |
|
1081 protected: |
|
1082 |
|
1083 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
1084 |
|
1085 private: |
|
1086 TInt iSpare1; |
|
1087 TInt iSpare2; |
|
1088 }; |
|
1089 |
|
1090 |
|
1091 |
|
1092 /** |
|
1093 * TAlfCustomEventCommand is a command that sends a custom event. The command |
|
1094 * can be sent to any individual MAlfEventHandler derived object or broadcasted to |
|
1095 * all Control derived objects. |
|
1096 * |
|
1097 * Usage |
|
1098 * |
|
1099 * @code |
|
1100 * //Create custom Event command, as iControl implements, MAlfEventHandler, |
|
1101 * // it will recieve custom event |
|
1102 * TAlfCustomEventCommand command( KCustomCommandIdDefault, iControl ); |
|
1103 * |
|
1104 * //Send command |
|
1105 * iEnv->Send( command, 1 ); |
|
1106 * |
|
1107 * @endcode |
|
1108 */ |
|
1109 class TAlfCustomEventCommand : public TAlfObjectCommand |
|
1110 { |
|
1111 public: |
|
1112 |
|
1113 /* Constructor. */ |
|
1114 |
|
1115 /** |
|
1116 * Constructs a new custom event command. |
|
1117 * |
|
1118 * @param aEventParam Parameter of the custom event. |
|
1119 * @param aRecipient Optional recipient of the event. |
|
1120 * @param aEventData Optional event data identifier. |
|
1121 * |
|
1122 * @todo It would be good to be able to specify more information to |
|
1123 * be sent with the custom event, e.g., a pointer. Also check |
|
1124 * out TAlfEvent. |
|
1125 */ |
|
1126 IMPORT_C TAlfCustomEventCommand( |
|
1127 TInt aEventParam, MAlfEventHandler* aRecipient = NULL, TInt aEventData = 0 ); |
|
1128 |
|
1129 /* Methods. */ |
|
1130 |
|
1131 /* Implementation of TAlfCommand::ExecuteL(). */ |
|
1132 IMPORT_C void ExecuteL(CAlfEnv& aEnv) const; |
|
1133 |
|
1134 /* Implementation of TAlfCommand::Size(). */ |
|
1135 IMPORT_C TInt Size() const; |
|
1136 |
|
1137 /** |
|
1138 * Returns the recipient of the event, or NULL if none defined. |
|
1139 */ |
|
1140 IMPORT_C MAlfEventHandler* Recipient() const; |
|
1141 |
|
1142 /** |
|
1143 * Determines the custom event parameter of the command. |
|
1144 * |
|
1145 * @return Parameter. |
|
1146 */ |
|
1147 IMPORT_C TInt Param() const; |
|
1148 |
|
1149 /** |
|
1150 * Returns the event data of the command. |
|
1151 * |
|
1152 * @return Event data. |
|
1153 */ |
|
1154 IMPORT_C TInt EventData() const; |
|
1155 |
|
1156 protected: |
|
1157 |
|
1158 IMPORT_C void CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
1159 |
|
1160 private: |
|
1161 |
|
1162 /** Custom event parameter. @todo Could be a pointer as well? */ |
|
1163 TInt iEventParam; |
|
1164 |
|
1165 /** Event data. */ |
|
1166 TInt iEventData; |
|
1167 |
|
1168 private: |
|
1169 TInt iSpare1; |
|
1170 TInt iSpare2; |
|
1171 }; |
|
1172 |
|
1173 |
|
1174 #endif // T_ALFCOMMAND_H |