|
1 /* |
|
2 * Copyright (c) 2006-2007 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 of THuiCommand and derived command classes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "uiacceltk/HuiCommand.h" // Class definition |
|
21 #include "uiacceltk/HuiStatic.h" |
|
22 #include "uiacceltk/HuiEnv.h" |
|
23 #include "uiacceltk/HuiScheduler.h" |
|
24 #include "uiacceltk/huieventhandler.h" |
|
25 #include "uiacceltk/HuiDisplay.h" |
|
26 #include "uiacceltk/HuiEvent.h" |
|
27 #include "uiacceltk/HuiControlGroup.h" |
|
28 #include "uiacceltk/HuiVisuals.h" |
|
29 #include "uiacceltk/HuiTransformation.h" |
|
30 #include "uiacceltk/HuiUtil.h" |
|
31 |
|
32 |
|
33 THuiCommand::THuiCommand(THuiCommandType aType) |
|
34 : iType(aType), iSenderType(EHuiCommandObjectTypeNone), iSender(NULL) |
|
35 { |
|
36 } |
|
37 |
|
38 |
|
39 EXPORT_C THuiCommand::~THuiCommand() |
|
40 { |
|
41 iSender = NULL; |
|
42 } |
|
43 |
|
44 |
|
45 EXPORT_C void THuiCommand::SetSender(THuiCommandObjectType aType, TAny* aSender) |
|
46 { |
|
47 iSenderType = aType; |
|
48 iSender = aSender; |
|
49 } |
|
50 |
|
51 |
|
52 EXPORT_C THuiCommandType THuiCommand::Type() const |
|
53 { |
|
54 return iType; |
|
55 } |
|
56 |
|
57 |
|
58 EXPORT_C const THuiObjectCommand* THuiCommand::ObjectCommand() const |
|
59 { |
|
60 return NULL; |
|
61 } |
|
62 |
|
63 |
|
64 EXPORT_C THuiCommandObjectType THuiCommand::SenderType() const |
|
65 { |
|
66 return iSenderType; |
|
67 } |
|
68 |
|
69 |
|
70 EXPORT_C TAny* THuiCommand::Sender() const |
|
71 { |
|
72 return iSender; |
|
73 } |
|
74 |
|
75 |
|
76 EXPORT_C CHuiVisual* THuiCommand::SenderVisual() const |
|
77 { |
|
78 if(iSenderType == EHuiCommandObjectTypeVisual) |
|
79 { |
|
80 return reinterpret_cast<CHuiVisual*>(iSender); |
|
81 } |
|
82 return NULL; |
|
83 } |
|
84 |
|
85 |
|
86 EXPORT_C CHuiControl* THuiCommand::SenderControl() const |
|
87 { |
|
88 if(iSenderType == EHuiCommandObjectTypeControl) |
|
89 { |
|
90 return reinterpret_cast<CHuiControl*>(iSender); |
|
91 } |
|
92 return NULL; |
|
93 } |
|
94 |
|
95 |
|
96 EXPORT_C CHuiControlGroup* THuiCommand::SenderControlGroup() const |
|
97 { |
|
98 if(iSenderType == EHuiCommandObjectTypeControlGroup) |
|
99 { |
|
100 return reinterpret_cast<CHuiControlGroup*>(iSender); |
|
101 } |
|
102 return NULL; |
|
103 } |
|
104 |
|
105 EXPORT_C void THuiCommand::CommandExtension(const TUid& /*aExtensionUid*/, TAny** /*aExtensionParams*/) |
|
106 { |
|
107 } |
|
108 |
|
109 EXPORT_C THuiActionCommand::THuiActionCommand(TInt aId) |
|
110 : THuiCommand(EHuiCommandTypeAction), iId(aId) |
|
111 { |
|
112 } |
|
113 |
|
114 |
|
115 EXPORT_C void THuiActionCommand::ExecuteL(CHuiEnv& aEnv) const |
|
116 { |
|
117 TInt error = aEnv.ReportAction(*this); |
|
118 if(error != KErrNone) |
|
119 { |
|
120 // Leave with the error code if one of the observers failed. |
|
121 User::Leave(error); |
|
122 } |
|
123 } |
|
124 |
|
125 |
|
126 EXPORT_C TInt THuiActionCommand::Size() const |
|
127 { |
|
128 return sizeof(*this); |
|
129 } |
|
130 |
|
131 |
|
132 EXPORT_C TInt THuiActionCommand::Id() const |
|
133 { |
|
134 return iId; |
|
135 } |
|
136 |
|
137 EXPORT_C void THuiActionCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
138 { |
|
139 THuiCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
140 } |
|
141 |
|
142 |
|
143 THuiObjectCommand::THuiObjectCommand(THuiCommandType aType, TAny* aDataOwnerObject, THuiOp aOperation) |
|
144 : THuiCommand(aType), iObject(aDataOwnerObject), iOperation(aOperation) |
|
145 { |
|
146 } |
|
147 |
|
148 |
|
149 EXPORT_C TAny* THuiObjectCommand::Object() const |
|
150 { |
|
151 return iObject; |
|
152 } |
|
153 |
|
154 |
|
155 EXPORT_C THuiOp THuiObjectCommand::Operation() const |
|
156 { |
|
157 return iOperation; |
|
158 } |
|
159 |
|
160 EXPORT_C TInt THuiObjectCommand::Size() const |
|
161 { |
|
162 return sizeof(*this); |
|
163 } |
|
164 |
|
165 |
|
166 EXPORT_C const THuiObjectCommand* THuiObjectCommand::ObjectCommand() const |
|
167 { |
|
168 // All object commands can be casted to THuiObjectCommand. |
|
169 return this; |
|
170 } |
|
171 |
|
172 EXPORT_C void THuiObjectCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
173 { |
|
174 HUI_DEBUG1(_L("THuiObjectCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
175 } |
|
176 |
|
177 EXPORT_C void THuiObjectCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
178 { |
|
179 THuiCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
180 } |
|
181 |
|
182 |
|
183 EXPORT_C THuiGroupCommand::THuiGroupCommand(CHuiControlGroup& aGroup, THuiOp aOperation, |
|
184 CHuiDisplay* aDisplay) |
|
185 : THuiObjectCommand(EHuiCommandTypeGroup, &aGroup, aOperation), |
|
186 iDisplay(aDisplay) |
|
187 { |
|
188 } |
|
189 |
|
190 |
|
191 EXPORT_C void THuiGroupCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
192 { |
|
193 switch(Operation()) |
|
194 { |
|
195 case EHuiOpShow: |
|
196 if(iDisplay) |
|
197 { |
|
198 iDisplay->Roster().ShowL(ControlGroup()); |
|
199 } |
|
200 break; |
|
201 |
|
202 case EHuiOpHide: |
|
203 if(iDisplay) |
|
204 { |
|
205 iDisplay->Roster().Hide(ControlGroup()); |
|
206 } |
|
207 break; |
|
208 |
|
209 case EHuiOpEnableInput: |
|
210 ControlGroup().SetAcceptInput(ETrue); |
|
211 break; |
|
212 |
|
213 case EHuiOpDisableInput: |
|
214 ControlGroup().SetAcceptInput(EFalse); |
|
215 break; |
|
216 |
|
217 default: |
|
218 HUI_DEBUG1(_L("THuiGroupCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
219 break; |
|
220 } |
|
221 } |
|
222 |
|
223 |
|
224 EXPORT_C TInt THuiGroupCommand::Size() const |
|
225 { |
|
226 return sizeof(*this); |
|
227 } |
|
228 |
|
229 |
|
230 EXPORT_C CHuiControlGroup& THuiGroupCommand::ControlGroup() const |
|
231 { |
|
232 return *static_cast<CHuiControlGroup*>(Object()); |
|
233 } |
|
234 |
|
235 |
|
236 EXPORT_C CHuiDisplay* THuiGroupCommand::Display() const |
|
237 { |
|
238 return iDisplay; |
|
239 } |
|
240 |
|
241 EXPORT_C void THuiGroupCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
242 { |
|
243 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
244 } |
|
245 |
|
246 |
|
247 EXPORT_C THuiControlCommand::THuiControlCommand(CHuiControl& aControl, THuiOp aOperation) |
|
248 : THuiObjectCommand(EHuiCommandTypeControl, &aControl, aOperation) |
|
249 { |
|
250 } |
|
251 |
|
252 |
|
253 EXPORT_C void THuiControlCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
254 { |
|
255 HUI_DEBUG1(_L("THuiControlCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
256 } |
|
257 |
|
258 |
|
259 EXPORT_C TInt THuiControlCommand::Size() const |
|
260 { |
|
261 return sizeof(*this); |
|
262 } |
|
263 |
|
264 |
|
265 EXPORT_C CHuiControl& THuiControlCommand::Control() const |
|
266 { |
|
267 return *static_cast<CHuiControl*>(Object()); |
|
268 } |
|
269 |
|
270 EXPORT_C void THuiControlCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
271 { |
|
272 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
273 } |
|
274 |
|
275 |
|
276 EXPORT_C THuiVisualCommand::THuiVisualCommand(CHuiVisual& aVisual, THuiOp aOperation, |
|
277 TInt aSetFlags, TInt aClearFlags) |
|
278 : THuiObjectCommand(EHuiCommandTypeVisual, &aVisual, aOperation), |
|
279 iSetFlags(aSetFlags), iClearFlags(aClearFlags) |
|
280 { |
|
281 } |
|
282 |
|
283 |
|
284 EXPORT_C void THuiVisualCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
285 { |
|
286 switch(Operation()) |
|
287 { |
|
288 case EHuiOpRemoveAndDestroyAll: |
|
289 Visual().RemoveAndDestroyAllD(); |
|
290 // The object is no longer valid after this. |
|
291 break; |
|
292 case EHuiOpEnableTransformation: |
|
293 HUI_DEBUG(_L("THuiVisualCommand::ExecuteL() -- Enable transformation.")); |
|
294 Visual().EnableTransformationL(ETrue); |
|
295 break; |
|
296 |
|
297 case EHuiOpDisableTransformation: |
|
298 HUI_DEBUG(_L("THuiVisualCommand::ExecuteL() -- Disable transformation.")); |
|
299 Visual().EnableTransformationL(EFalse); |
|
300 break; |
|
301 |
|
302 case EHuiOpModifyFlags: |
|
303 if(iSetFlags) |
|
304 { |
|
305 Visual().SetFlags(iSetFlags); |
|
306 } |
|
307 if(iClearFlags) |
|
308 { |
|
309 Visual().ClearFlags(iClearFlags); |
|
310 } |
|
311 break; |
|
312 |
|
313 default: |
|
314 HUI_DEBUG1(_L("THuiVisualCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
315 break; |
|
316 } |
|
317 } |
|
318 |
|
319 |
|
320 EXPORT_C TInt THuiVisualCommand::Size() const |
|
321 { |
|
322 return sizeof(*this); |
|
323 } |
|
324 |
|
325 |
|
326 EXPORT_C CHuiVisual& THuiVisualCommand::Visual() const |
|
327 { |
|
328 return *static_cast<CHuiVisual*>(Object()); |
|
329 } |
|
330 |
|
331 |
|
332 EXPORT_C TInt THuiVisualCommand::FlagsToSet() const |
|
333 { |
|
334 return iSetFlags; |
|
335 } |
|
336 |
|
337 |
|
338 EXPORT_C TInt THuiVisualCommand::FlagsToClear() const |
|
339 { |
|
340 return iClearFlags; |
|
341 } |
|
342 |
|
343 EXPORT_C void THuiVisualCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
344 { |
|
345 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
346 } |
|
347 |
|
348 |
|
349 EXPORT_C THuiImageCommand::THuiImageCommand(CHuiImageVisual& aImageVisual, |
|
350 const THuiImage& aImage, |
|
351 THuiOp aOperation) |
|
352 : THuiObjectCommand(EHuiCommandTypeImage, &aImageVisual, aOperation), |
|
353 iImage(aImage) |
|
354 { |
|
355 } |
|
356 |
|
357 |
|
358 EXPORT_C void THuiImageCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
359 { |
|
360 switch(Operation()) |
|
361 { |
|
362 case EHuiOpSetPrimaryImage: |
|
363 ImageVisual().SetImage(iImage); |
|
364 break; |
|
365 |
|
366 case EHuiOpSetSecondaryImage: |
|
367 ImageVisual().SetSecondaryImage(iImage); |
|
368 break; |
|
369 |
|
370 default: |
|
371 HUI_DEBUG1(_L("THuiImageCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
372 break; |
|
373 } |
|
374 } |
|
375 |
|
376 |
|
377 EXPORT_C TInt THuiImageCommand::Size() const |
|
378 { |
|
379 return sizeof(*this); |
|
380 } |
|
381 |
|
382 |
|
383 EXPORT_C CHuiImageVisual& THuiImageCommand::ImageVisual() const |
|
384 { |
|
385 return *static_cast<CHuiImageVisual*>( Object() ); |
|
386 } |
|
387 |
|
388 |
|
389 EXPORT_C const THuiImage& THuiImageCommand::Image() const |
|
390 { |
|
391 return iImage; |
|
392 } |
|
393 |
|
394 EXPORT_C void THuiImageCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
395 { |
|
396 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
397 } |
|
398 |
|
399 |
|
400 EXPORT_C THuiTextCommand::THuiTextCommand(CHuiTextVisual& aTextVisual, const TDesC& aText, |
|
401 THuiOp aOperation) |
|
402 : THuiObjectCommand(EHuiCommandTypeText, &aTextVisual, aOperation), |
|
403 iText(aText) |
|
404 { |
|
405 } |
|
406 |
|
407 |
|
408 EXPORT_C void THuiTextCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
409 { |
|
410 switch(Operation()) |
|
411 { |
|
412 case EHuiOpSetText: |
|
413 TextVisual().SetTextL(iText); |
|
414 break; |
|
415 |
|
416 default: |
|
417 HUI_DEBUG1(_L("THuiTextCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
418 break; |
|
419 } |
|
420 } |
|
421 |
|
422 |
|
423 EXPORT_C TInt THuiTextCommand::Size() const |
|
424 { |
|
425 return sizeof(*this); |
|
426 } |
|
427 |
|
428 |
|
429 EXPORT_C CHuiTextVisual& THuiTextCommand::TextVisual() const |
|
430 { |
|
431 return *static_cast<CHuiTextVisual*>( Object() ); |
|
432 } |
|
433 |
|
434 |
|
435 EXPORT_C const TDesC& THuiTextCommand::Text() const |
|
436 { |
|
437 return iText; |
|
438 } |
|
439 |
|
440 EXPORT_C void THuiTextCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
441 { |
|
442 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
443 } |
|
444 |
|
445 |
|
446 EXPORT_C THuiValueCommand::THuiValueCommand(TAny* aOwner, THuiTimedValue& aValue, |
|
447 TReal32 aTarget, TInt aTransitionTime) __SOFTFP |
|
448 : THuiObjectCommand(EHuiCommandTypeValue, aOwner, EHuiOpSet), |
|
449 iTimedValue(aValue), iTarget(aTarget), iTransitionTime(aTransitionTime), |
|
450 iSpeed(0.0) |
|
451 { |
|
452 } |
|
453 |
|
454 |
|
455 EXPORT_C THuiValueCommand::THuiValueCommand(TAny* aOwner, THuiTimedValue& aValue, |
|
456 THuiOp aOperation, |
|
457 TReal32 aTarget, TReal32 aTiming) __SOFTFP |
|
458 : THuiObjectCommand(EHuiCommandTypeValue, aOwner, aOperation), |
|
459 iTimedValue(aValue), iTarget(aTarget), iTransitionTime(0), |
|
460 iSpeed(0.0) |
|
461 { |
|
462 if(aOperation == EHuiOpSetWithSpeed) |
|
463 { |
|
464 iSpeed = aTiming; |
|
465 } |
|
466 else |
|
467 { |
|
468 iTransitionTime = TInt(aTiming); |
|
469 } |
|
470 } |
|
471 |
|
472 |
|
473 EXPORT_C void THuiValueCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
474 { |
|
475 // Check for interpolation style change ops. |
|
476 TInt op = Operation(); |
|
477 if(op >= EHuiOpSetStyle && op < EHuiOpSetStyle + EHuiTimedValueStyleLast) |
|
478 { |
|
479 iTimedValue.SetStyle(THuiInterpolationStyle(op - EHuiOpSetStyle)); |
|
480 } |
|
481 |
|
482 switch(Operation()) |
|
483 { |
|
484 case EHuiOpSet: |
|
485 iTimedValue.Set(iTarget, iTransitionTime); |
|
486 break; |
|
487 |
|
488 case EHuiOpSetWithSpeed: |
|
489 iTimedValue.SetWithSpeed(iTarget, iSpeed); |
|
490 break; |
|
491 |
|
492 default: |
|
493 HUI_DEBUG1(_L("THuiValueCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
494 break; |
|
495 } |
|
496 } |
|
497 |
|
498 |
|
499 EXPORT_C TInt THuiValueCommand::Size() const |
|
500 { |
|
501 return sizeof(*this); |
|
502 } |
|
503 |
|
504 |
|
505 EXPORT_C THuiTimedValue& THuiValueCommand::TimedValue() const |
|
506 { |
|
507 return iTimedValue; |
|
508 } |
|
509 |
|
510 |
|
511 EXPORT_C TReal32 THuiValueCommand::Target() const __SOFTFP |
|
512 { |
|
513 return iTarget; |
|
514 } |
|
515 |
|
516 |
|
517 EXPORT_C TInt THuiValueCommand::TransitionTime() const |
|
518 { |
|
519 return iTransitionTime; |
|
520 } |
|
521 |
|
522 |
|
523 EXPORT_C TReal32 THuiValueCommand::Speed() const __SOFTFP |
|
524 { |
|
525 return iSpeed; |
|
526 } |
|
527 |
|
528 EXPORT_C void THuiValueCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
529 { |
|
530 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
531 } |
|
532 |
|
533 |
|
534 EXPORT_C THuiPointCommand::THuiPointCommand(TAny* aOwner, THuiTimedPoint& aPoint, |
|
535 THuiOp aOperation) |
|
536 : THuiObjectCommand(EHuiCommandTypePoint, aOwner, aOperation), |
|
537 iTimedPoint(aPoint), iTransitionTime(0), iSpeed(0.0) |
|
538 { |
|
539 } |
|
540 |
|
541 |
|
542 EXPORT_C THuiPointCommand::THuiPointCommand(TAny* aOwner, THuiTimedPoint& aPoint, |
|
543 THuiRealPoint aTarget, TInt aTransitionTime) __SOFTFP |
|
544 : THuiObjectCommand(EHuiCommandTypePoint, aOwner, EHuiOpSet), |
|
545 iTimedPoint(aPoint), iTarget(aTarget), |
|
546 iTransitionTime(aTransitionTime), iSpeed(0.0) |
|
547 { |
|
548 } |
|
549 |
|
550 |
|
551 EXPORT_C THuiPointCommand::THuiPointCommand(TAny* aOwner, THuiTimedPoint& aPoint, |
|
552 THuiOp aOperation, |
|
553 THuiRealPoint aTarget, TReal32 aTiming) __SOFTFP |
|
554 : THuiObjectCommand(EHuiCommandTypePoint, aOwner, aOperation), |
|
555 iTimedPoint(aPoint), iTarget(aTarget), |
|
556 iTransitionTime(0), iSpeed(0.0) |
|
557 { |
|
558 if(aOperation == EHuiOpSetWithSpeed) |
|
559 { |
|
560 iSpeed = aTiming; |
|
561 } |
|
562 else |
|
563 { |
|
564 iTransitionTime = TInt(aTiming); |
|
565 } |
|
566 } |
|
567 |
|
568 |
|
569 EXPORT_C void THuiPointCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
570 { |
|
571 // Check for interpolation style change ops. |
|
572 TInt op = Operation(); |
|
573 if(op >= EHuiOpSetStyle && op < EHuiOpSetStyle + EHuiTimedValueStyleLast) |
|
574 { |
|
575 iTimedPoint.SetStyle(THuiInterpolationStyle(op - EHuiOpSetStyle)); |
|
576 } |
|
577 |
|
578 switch(Operation()) |
|
579 { |
|
580 case EHuiOpSet: |
|
581 iTimedPoint.Set(iTarget, iTransitionTime); |
|
582 break; |
|
583 |
|
584 case EHuiOpSetWithSpeed: |
|
585 iTimedPoint.SetWithSpeed(iTarget, iSpeed); |
|
586 break; |
|
587 |
|
588 default: |
|
589 HUI_DEBUG1(_L("THuiPointCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
590 break; |
|
591 } |
|
592 } |
|
593 |
|
594 |
|
595 EXPORT_C TInt THuiPointCommand::Size() const |
|
596 { |
|
597 return sizeof(*this); |
|
598 } |
|
599 |
|
600 |
|
601 EXPORT_C THuiTimedPoint& THuiPointCommand::TimedPoint() const |
|
602 { |
|
603 return iTimedPoint; |
|
604 } |
|
605 |
|
606 |
|
607 EXPORT_C THuiRealPoint THuiPointCommand::Target() const __SOFTFP |
|
608 { |
|
609 return iTarget; |
|
610 } |
|
611 |
|
612 |
|
613 EXPORT_C TInt THuiPointCommand::TransitionTime() const |
|
614 { |
|
615 return iTransitionTime; |
|
616 } |
|
617 |
|
618 |
|
619 EXPORT_C TReal32 THuiPointCommand::Speed() const __SOFTFP |
|
620 { |
|
621 return iSpeed; |
|
622 } |
|
623 |
|
624 EXPORT_C void THuiPointCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
625 { |
|
626 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
627 } |
|
628 |
|
629 |
|
630 EXPORT_C THuiTransformationCommand::THuiTransformationCommand( |
|
631 TAny* aOwner, CHuiTransformation& aTransformation, THuiOp aOperation, TInt aStep) |
|
632 : THuiObjectCommand(EHuiCommandTypeTransformation, aOwner, aOperation), |
|
633 iTransformation(aTransformation), iStep(aStep) |
|
634 { |
|
635 } |
|
636 |
|
637 |
|
638 EXPORT_C void THuiTransformationCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
639 { |
|
640 switch(Operation()) |
|
641 { |
|
642 case EHuiOpLoadIdentity: |
|
643 iTransformation.LoadIdentity(); |
|
644 break; |
|
645 |
|
646 case EHuiOpTranslate: |
|
647 if(iStep != EStepNone) |
|
648 { |
|
649 CHuiTransformation::TTransform& xs = iTransformation.Step(iStep); |
|
650 xs.iType = CHuiTransformation::ETypeTranslate; |
|
651 xs.iParams[EHuiTransformParamTranslateX] = iX; |
|
652 xs.iParams[EHuiTransformParamTranslateY] = iY; |
|
653 xs.iParams[EHuiTransformParamTranslateZ] = iZ; |
|
654 } |
|
655 else |
|
656 { |
|
657 iTransformation.Translate(iX, iY); |
|
658 } |
|
659 break; |
|
660 |
|
661 case EHuiOpScale: |
|
662 if(iStep != EStepNone) |
|
663 { |
|
664 CHuiTransformation::TTransform& xs = iTransformation.Step(iStep); |
|
665 xs.iType = CHuiTransformation::ETypeScale; |
|
666 xs.iParams[EHuiTransformParamScaleX] = iX; |
|
667 xs.iParams[EHuiTransformParamScaleY] = iY; |
|
668 xs.iParams[EHuiTransformParamScaleZ] = iZ; |
|
669 } |
|
670 else |
|
671 { |
|
672 iTransformation.Scale(iX, iY, iZ); |
|
673 } |
|
674 break; |
|
675 |
|
676 case EHuiOpRotate: |
|
677 if(iStep != EStepNone) |
|
678 { |
|
679 CHuiTransformation::TTransform& xs = iTransformation.Step(iStep); |
|
680 xs.iType = CHuiTransformation::ETypeRotate; |
|
681 xs.iParams[EHuiTransformParamRotateAngle] = iAngle; |
|
682 xs.iParams[EHuiTransformParamRotateAxisX] = iX; |
|
683 xs.iParams[EHuiTransformParamRotateAxisY] = iY; |
|
684 xs.iParams[EHuiTransformParamRotateAxisZ] = iZ; |
|
685 } |
|
686 else |
|
687 { |
|
688 THuiTimedValue unsuspended; |
|
689 unsuspended = iX; |
|
690 TReal32 x = unsuspended.Now(); |
|
691 unsuspended = iY; |
|
692 TReal32 y = unsuspended.Now(); |
|
693 unsuspended = iZ; |
|
694 TReal32 z = unsuspended.Now(); |
|
695 iTransformation.Rotate(iAngle, x, y, z); |
|
696 } |
|
697 break; |
|
698 |
|
699 default: |
|
700 HUI_DEBUG1(_L("THuiTransformationCommand::ExecuteL() - Unknown op %i."), Operation()); |
|
701 break; |
|
702 } |
|
703 } |
|
704 |
|
705 |
|
706 EXPORT_C TInt THuiTransformationCommand::Size() const |
|
707 { |
|
708 return sizeof(*this); |
|
709 } |
|
710 |
|
711 |
|
712 EXPORT_C CHuiTransformation& THuiTransformationCommand::Transformation() const |
|
713 { |
|
714 return iTransformation; |
|
715 } |
|
716 |
|
717 |
|
718 EXPORT_C TInt THuiTransformationCommand::Step() const |
|
719 { |
|
720 return iStep; |
|
721 } |
|
722 |
|
723 |
|
724 EXPORT_C void THuiTransformationCommand::SetX(const THuiTimedValue& aValue) |
|
725 { |
|
726 iX = aValue; |
|
727 iX.Suspend(); |
|
728 } |
|
729 |
|
730 |
|
731 EXPORT_C void THuiTransformationCommand::SetY(const THuiTimedValue& aValue) |
|
732 { |
|
733 iY = aValue; |
|
734 iY.Suspend(); |
|
735 } |
|
736 |
|
737 |
|
738 EXPORT_C void THuiTransformationCommand::SetZ(const THuiTimedValue& aValue) |
|
739 { |
|
740 iZ = aValue; |
|
741 iZ.Suspend(); |
|
742 } |
|
743 |
|
744 |
|
745 EXPORT_C void THuiTransformationCommand::SetAngle(const THuiTimedValue& aValue) |
|
746 { |
|
747 iAngle = aValue; |
|
748 iAngle.Suspend(); |
|
749 } |
|
750 |
|
751 EXPORT_C void THuiTransformationCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
752 { |
|
753 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
754 } |
|
755 |
|
756 |
|
757 EXPORT_C THuiMarkerCommand::THuiMarkerCommand(TInt aId) |
|
758 : THuiCommand(THuiCommandType(EHuiCommandTypeMarkerFirst + aId)) |
|
759 { |
|
760 } |
|
761 |
|
762 |
|
763 EXPORT_C void THuiMarkerCommand::ExecuteL(CHuiEnv& /*aEnv*/) const |
|
764 { |
|
765 HUI_DEBUG1(_L("THuiMarkerCommand::ExecuteL() - Marker %i reached."), Id()); |
|
766 } |
|
767 |
|
768 |
|
769 EXPORT_C TInt THuiMarkerCommand::Size() const |
|
770 { |
|
771 return sizeof(*this); |
|
772 } |
|
773 |
|
774 |
|
775 EXPORT_C TInt THuiMarkerCommand::Id() const |
|
776 { |
|
777 return Type() - EHuiCommandTypeMarkerFirst; |
|
778 } |
|
779 |
|
780 EXPORT_C void THuiMarkerCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
781 { |
|
782 THuiCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
783 } |
|
784 |
|
785 |
|
786 EXPORT_C THuiCustomEventCommand::THuiCustomEventCommand(TInt aEventParam, MHuiEventHandler* aRecipient) |
|
787 : THuiObjectCommand(EHuiCommandTypeCustomEvent, aRecipient, EHuiOpNone), |
|
788 iEventParam(aEventParam) |
|
789 { |
|
790 } |
|
791 |
|
792 |
|
793 EXPORT_C void THuiCustomEventCommand::ExecuteL(CHuiEnv& aEnv) const |
|
794 { |
|
795 THuiEvent customEvent(iEventParam); |
|
796 |
|
797 if(Recipient()) |
|
798 { |
|
799 Recipient()->OfferEventL(customEvent); |
|
800 } |
|
801 else |
|
802 { |
|
803 aEnv.BroadcastEventL(customEvent); |
|
804 } |
|
805 } |
|
806 |
|
807 |
|
808 EXPORT_C TInt THuiCustomEventCommand::Size() const |
|
809 { |
|
810 return sizeof(*this); |
|
811 } |
|
812 |
|
813 |
|
814 EXPORT_C MHuiEventHandler* THuiCustomEventCommand::Recipient() const |
|
815 { |
|
816 return static_cast<MHuiEventHandler*>( Object() ); |
|
817 } |
|
818 |
|
819 |
|
820 EXPORT_C TInt THuiCustomEventCommand::Param() const |
|
821 { |
|
822 return iEventParam; |
|
823 } |
|
824 |
|
825 EXPORT_C void THuiCustomEventCommand::CommandExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
826 { |
|
827 THuiObjectCommand::CommandExtension( aExtensionUid, aExtensionParams ); |
|
828 } |
|
829 |