|
1 /* |
|
2 * Copyright (c) 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: Main class for Control Button component. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // <cmail> SF |
|
21 #include "emailtrace.h" |
|
22 #include <alf/alfevent.h> |
|
23 #include <alf/alfdecklayout.h> |
|
24 // </cmail> |
|
25 // Needed for pointer events. |
|
26 #include <alf/alfdisplay.h> |
|
27 #include <alf/alfroster.h> |
|
28 |
|
29 #include <AknUtils.h> |
|
30 |
|
31 #include <touchfeedback.h> // for MTouchFeedback |
|
32 |
|
33 #include "fscontrolbutton.h" |
|
34 #include "fscontrolbuttonmodel.h" |
|
35 #include "fscontrolbuttonvisualiser.h" |
|
36 #include "fscontrolbuttonobserver.h" |
|
37 #include "fsgenericpanic.h" |
|
38 #include "fstriggeredcomponent.h" |
|
39 #include "fstextstylemanager.h" |
|
40 #include "fslayoutmanager.h" |
|
41 |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CFsControlButton::CFsControlButton( |
|
50 MFsControlButtonObserver& aParent, |
|
51 CAlfDeckLayout& aParentLayout ) : |
|
52 iParent( aParent ), |
|
53 iParentLayout( aParentLayout ) |
|
54 { |
|
55 FUNC_LOG; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Second phase constructor. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CFsControlButton::ConstructL( |
|
64 CAlfEnv& aEnv, |
|
65 TInt aId, |
|
66 TFsControlButtonType aType, |
|
67 TRect& aStartPoint, |
|
68 CFsTextStyleManager* aTextStyleManager ) |
|
69 { |
|
70 FUNC_LOG; |
|
71 CAlfControl::ConstructL( aEnv ); |
|
72 |
|
73 iModel = CFsControlButtonModel::NewL( |
|
74 aId, aType, aStartPoint, iParentLayout ); |
|
75 |
|
76 iVisualiser = CFsControlButtonVisualiser::NewL( |
|
77 *this, iParentLayout, aTextStyleManager ); |
|
78 iVisualiser->InitializeL( *iModel ); |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Two-phased constructor. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CFsControlButton* CFsControlButton::NewL( |
|
87 CAlfEnv& aEnv, |
|
88 MFsControlButtonObserver& aParent, |
|
89 TInt aId, |
|
90 TFsControlButtonType aType, |
|
91 TRect& aStartPoint, |
|
92 CAlfDeckLayout& aParentLayout, |
|
93 CFsTextStyleManager* aTextStyleManager ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 CFsControlButton* self = |
|
97 new( ELeave ) CFsControlButton( aParent, aParentLayout ); |
|
98 CleanupStack::PushL( self ); |
|
99 self->ConstructL( |
|
100 aEnv, aId, aType, aStartPoint, aTextStyleManager ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // Destructor. |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CFsControlButton::~CFsControlButton() |
|
111 { |
|
112 FUNC_LOG; |
|
113 delete iModel; |
|
114 delete iVisualiser; |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Sets first line of text in button. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CFsControlButton::SetTextL( |
|
123 const TDesC& aLabel, |
|
124 TFsButtonContent aContent ) |
|
125 { |
|
126 FUNC_LOG; |
|
127 iModel->SetTextL( aLabel, aContent ); |
|
128 switch ( aContent ) |
|
129 { |
|
130 case EFsButtonFirstLine: |
|
131 iVisualiser->UpdateElementL( ECBElemLabelFirstLine ); |
|
132 break; |
|
133 case EFsButtonSecondLine: |
|
134 iVisualiser->UpdateElementL( ECBElemLabelSndLine ); |
|
135 break; |
|
136 default: |
|
137 User::Leave( KErrNotSupported ); |
|
138 break; |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Sets visualiser for the button. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CFsControlButton::SetVisualiserL( |
|
148 CFsControlButtonVisualiser* aVisualiser ) |
|
149 { |
|
150 FUNC_LOG; |
|
151 __ASSERT_ALWAYS( aVisualiser, User::Leave( KErrArgument ) ); |
|
152 |
|
153 CFsControlButtonVisualiser* newVisualiser( aVisualiser ); |
|
154 CleanupStack::PushL( newVisualiser ); |
|
155 |
|
156 newVisualiser->SetParentControlL( this ); |
|
157 newVisualiser->SetParentLayoutL( &iParentLayout ); |
|
158 newVisualiser->InitializeL( *iModel ); |
|
159 |
|
160 CleanupStack::Pop( newVisualiser ); |
|
161 |
|
162 delete iVisualiser; |
|
163 iVisualiser = newVisualiser; |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // Retrieves button's visualiser. |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CFsControlButtonVisualiser* CFsControlButton::Visualiser() |
|
172 { |
|
173 FUNC_LOG; |
|
174 return iVisualiser; |
|
175 } |
|
176 |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // Set the layout position index on controlbar. |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CFsControlButton::SetParentIndex( TInt aLayoutPos ) |
|
183 { |
|
184 FUNC_LOG; |
|
185 iModel->SetParentIndex( aLayoutPos ); |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // Retrieves id of the button. |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CFsControlButton::Id() const |
|
194 { |
|
195 FUNC_LOG; |
|
196 return iModel->Id(); |
|
197 } |
|
198 |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // Sets icon A or B. Panics if button's type is incorrect. |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CFsControlButton::SetIconL( |
|
205 CAlfTexture& aIcon, |
|
206 TFsControlButtonElem aWhich ) |
|
207 { |
|
208 FUNC_LOG; |
|
209 iModel->SetIconL( aIcon, aWhich ); |
|
210 iVisualiser->UpdateElementL( aWhich ); |
|
211 } |
|
212 |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // Sets width of the button. |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CFsControlButton::SetWidth( TInt aWidth ) |
|
219 { |
|
220 FUNC_LOG; |
|
221 iModel->SetAutoSizeMode( MFsControlButtonInterface::EFsManual ); |
|
222 iModel->SetWidth( aWidth ); |
|
223 iVisualiser->Refresh(); |
|
224 } |
|
225 |
|
226 // <cmail> Platform layout changes |
|
227 // --------------------------------------------------------------------------- |
|
228 // Sets size of the button. |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 void CFsControlButton::SetSize( const TSize& aSize ) |
|
232 { |
|
233 FUNC_LOG; |
|
234 iModel->SetAutoSizeMode( MFsControlButtonInterface::EFsManual ); |
|
235 iModel->SetSize( aSize ); |
|
236 iVisualiser->Refresh(); |
|
237 } |
|
238 // </cmail> Platform layout changes |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Set auto size mode for button. |
|
242 // Defines how the buttons size is changed. |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 void CFsControlButton::SetAutoSizeMode( TFsAutoSizeMode aAutoSizeMode ) |
|
246 { |
|
247 FUNC_LOG; |
|
248 TBool refresh( aAutoSizeMode != iModel->AutoSizeMode() ); |
|
249 iModel->SetAutoSizeMode( aAutoSizeMode ); |
|
250 if ( refresh ) |
|
251 { |
|
252 iVisualiser->Refresh(); |
|
253 } |
|
254 } |
|
255 |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // Sets focus to control button. |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 void CFsControlButton::SetFocus( TBool aState ) |
|
262 { |
|
263 FUNC_LOG; |
|
264 iModel->SetFocus( aState ); |
|
265 iVisualiser->Refresh(); |
|
266 } |
|
267 |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // Refresh the button's position. |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 void CFsControlButton::RefreshButtonPosition( TSize& aParentSize ) |
|
274 { |
|
275 FUNC_LOG; |
|
276 iModel->RefreshButtonPosition( aParentSize ); |
|
277 } |
|
278 |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // Checks if button has focus. |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 TBool CFsControlButton::IsFocused() const |
|
285 { |
|
286 FUNC_LOG; |
|
287 return iModel->IsFocused(); |
|
288 } |
|
289 |
|
290 // <cmail> Platform layout changes |
|
291 // --------------------------------------------------------------------------- |
|
292 // Sets position of the button (top left point). |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CFsControlButton::SetPos( const TPoint& aTlPoint ) |
|
296 { |
|
297 FUNC_LOG; |
|
298 iModel->SetPos( aTlPoint ); |
|
299 iModel->SetAutoSizeMode( MFsControlButtonInterface::EFsManual ); |
|
300 |
|
301 // Refresh buttons position to apply mirroring to it. |
|
302 TSize parent( iParentLayout.Size().Target().AsSize() ); |
|
303 iModel->RefreshButtonPosition( parent ); |
|
304 |
|
305 iVisualiser->Refresh(); |
|
306 } |
|
307 // </cmail> Platform layout changes |
|
308 |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // Retrieves position of button. |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 const TAlfTimedPoint CFsControlButton::Pos() const |
|
315 { |
|
316 FUNC_LOG; |
|
317 return iVisualiser->Layout()->Pos(); |
|
318 } |
|
319 |
|
320 |
|
321 // --------------------------------------------------------------------------- |
|
322 // Retrieves size of button. |
|
323 // --------------------------------------------------------------------------- |
|
324 // |
|
325 const TAlfTimedPoint CFsControlButton::Size() const |
|
326 { |
|
327 FUNC_LOG; |
|
328 return iVisualiser->Layout()->Size(); |
|
329 } |
|
330 |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // Sets component to button which will be triggered when button |
|
334 // is pressed. |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 void CFsControlButton::SetTriggeredComponent( |
|
338 MFsTriggeredComponent& aComponent ) |
|
339 { |
|
340 FUNC_LOG; |
|
341 iTriggeredComponent = &aComponent; |
|
342 } |
|
343 |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // Clears triggered component. No more events to triggered |
|
347 // component are sent. |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 void CFsControlButton::ClearTriggeredComponent() |
|
351 { |
|
352 FUNC_LOG; |
|
353 iTriggeredComponent = NULL; |
|
354 } |
|
355 |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // Sets alignment of element. |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CFsControlButton::SetElemAlignL( |
|
362 TFsControlButtonElem aButtonElem, |
|
363 TAlfAlignHorizontal aHAlign, |
|
364 TAlfAlignVertical aVAlign ) |
|
365 { |
|
366 FUNC_LOG; |
|
367 iVisualiser->SetElemAlignL( aButtonElem, aHAlign, aVAlign ); |
|
368 iVisualiser->Refresh(); |
|
369 } |
|
370 |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // Sets dimm state of the button. |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CFsControlButton::SetDimmed( TBool aDimmed ) |
|
377 { |
|
378 FUNC_LOG; |
|
379 if ( aDimmed != IsDimmed() ) |
|
380 { |
|
381 iModel->SetDimmed( aDimmed ); |
|
382 iVisualiser->Refresh(); |
|
383 |
|
384 iParent.HandleButtonEvent( |
|
385 MFsControlButtonObserver::EEventButtonDimmStateChanged, |
|
386 iModel->Id() ); |
|
387 } |
|
388 } |
|
389 |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // Checks dimm state of the button. |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 TBool CFsControlButton::IsDimmed() const |
|
396 { |
|
397 FUNC_LOG; |
|
398 return iModel->IsDimmed(); |
|
399 } |
|
400 |
|
401 |
|
402 // --------------------------------------------------------------------------- |
|
403 // Shows (enables) button. |
|
404 // --------------------------------------------------------------------------- |
|
405 // |
|
406 void CFsControlButton::ShowButtonL() |
|
407 { |
|
408 FUNC_LOG; |
|
409 if ( !iVisualiser->IsVisible() ) |
|
410 { |
|
411 iVisualiser->ShowL(); |
|
412 |
|
413 iParent.HandleButtonEvent( |
|
414 MFsControlButtonObserver::EEventButtonVisibilityChanged, |
|
415 iModel->Id() ); |
|
416 } |
|
417 } |
|
418 |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // Hides (disables) button. |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 void CFsControlButton::HideButton() |
|
425 { |
|
426 FUNC_LOG; |
|
427 if ( iVisualiser->IsVisible() ) |
|
428 { |
|
429 iVisualiser->Hide(); |
|
430 |
|
431 iParent.HandleButtonEvent( |
|
432 MFsControlButtonObserver::EEventButtonVisibilityChanged, |
|
433 iModel->Id() ); |
|
434 } |
|
435 } |
|
436 |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // Checks if button is visible or hidden. |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 TBool CFsControlButton::IsVisible() const |
|
443 { |
|
444 FUNC_LOG; |
|
445 return iVisualiser->IsVisible(); |
|
446 } |
|
447 |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // Sets button's background image. |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 void CFsControlButton::SetBackgroundImageL( CAlfImageBrush* aImage ) |
|
454 { |
|
455 FUNC_LOG; |
|
456 iVisualiser->SetBackgroundImageL( aImage ); |
|
457 } |
|
458 |
|
459 |
|
460 // --------------------------------------------------------------------------- |
|
461 // Sets button's background color. |
|
462 // --------------------------------------------------------------------------- |
|
463 // |
|
464 void CFsControlButton::SetBackgroundColor( const TRgb& aColor ) |
|
465 { |
|
466 FUNC_LOG; |
|
467 iModel->SetTextColor( aColor, CFsControlButtonModel::EButtonBackground ); |
|
468 iVisualiser->SetBackgroundColor( aColor ); |
|
469 } |
|
470 |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // Clears button's background color. Button is transparent. |
|
474 // --------------------------------------------------------------------------- |
|
475 // |
|
476 void CFsControlButton::ClearBackgroundColor() |
|
477 { |
|
478 FUNC_LOG; |
|
479 iVisualiser->ClearBackgroundColor(); |
|
480 } |
|
481 |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // Clears button's background image. |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 void CFsControlButton::ClearBackgroundImage() |
|
488 { |
|
489 FUNC_LOG; |
|
490 iVisualiser->ClearBackgroundImage(); |
|
491 } |
|
492 |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 // Retrieves text from control button. |
|
496 // --------------------------------------------------------------------------- |
|
497 // |
|
498 TPtrC CFsControlButton::Text( TFsButtonContent aContent ) const |
|
499 { |
|
500 FUNC_LOG; |
|
501 return iModel->Text( aContent ); |
|
502 } |
|
503 |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // Set new height for the button text. |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CFsControlButton::SetTextHeight( const TInt aTextHeight ) |
|
510 { |
|
511 FUNC_LOG; |
|
512 iVisualiser->SetTextHeight( aTextHeight ); |
|
513 } |
|
514 |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // Change the current font. |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 void CFsControlButton::SetTextFontL( const TFontSpec& aFontSpec ) |
|
521 { |
|
522 FUNC_LOG; |
|
523 iVisualiser->SetTextFontL( aFontSpec ); |
|
524 } |
|
525 |
|
526 |
|
527 // --------------------------------------------------------------------------- |
|
528 // Set button's text color when it's not focused or dimmed. |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 void CFsControlButton::SetNormalTextColor( const TRgb& aColor ) |
|
532 { |
|
533 FUNC_LOG; |
|
534 iModel->SetTextColor( aColor, CFsControlButtonModel::EButtonNormal ); |
|
535 iVisualiser->Refresh(); |
|
536 } |
|
537 |
|
538 |
|
539 // --------------------------------------------------------------------------- |
|
540 // Set button's text color when it's focused. |
|
541 // --------------------------------------------------------------------------- |
|
542 // |
|
543 void CFsControlButton::SetFocusedTextColor( const TRgb& aColor ) |
|
544 { |
|
545 FUNC_LOG; |
|
546 iModel->SetTextColor( aColor, CFsControlButtonModel::EButtonFocused ); |
|
547 iVisualiser->Refresh(); |
|
548 } |
|
549 |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // Set button's text color when it's dimmed. |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 void CFsControlButton::SetDimmedTextColor( const TRgb& aColor ) |
|
556 { |
|
557 FUNC_LOG; |
|
558 iModel->SetTextColor( aColor, CFsControlButtonModel::EButtonDimmed ); |
|
559 iVisualiser->Refresh(); |
|
560 } |
|
561 |
|
562 |
|
563 // --------------------------------------------------------------------------- |
|
564 // Retrieves control button type. |
|
565 // --------------------------------------------------------------------------- |
|
566 // |
|
567 TFsControlButtonType CFsControlButton::ControlButtonType() const |
|
568 { |
|
569 FUNC_LOG; |
|
570 return iModel->Type(); |
|
571 } |
|
572 |
|
573 // <cmail> Touch |
|
574 // --------------------------------------------------------------------------- |
|
575 // Returns this as CAlfControl |
|
576 // --------------------------------------------------------------------------- |
|
577 // |
|
578 CAlfControl* CFsControlButton::AsAlfControl() |
|
579 { |
|
580 return this; |
|
581 } |
|
582 // </cmail> |
|
583 |
|
584 // --------------------------------------------------------------------------- |
|
585 // |
|
586 // --------------------------------------------------------------------------- |
|
587 // |
|
588 void CFsControlButton::MakeFocusVisible( TBool aShow ) |
|
589 { |
|
590 FUNC_LOG; |
|
591 iVisualiser->MakeFocusVisible( aShow ); |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // From class CHuiControl/CAlfControl. |
|
596 // Called when an input event is being offered to the control. |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 TBool CFsControlButton::OfferEventL( const TAlfEvent& aEvent ) |
|
600 { |
|
601 FUNC_LOG; |
|
602 TBool result( EFalse ); |
|
603 |
|
604 // no key handling when not shown or dimmed. |
|
605 if ( !IsVisible() || IsDimmed() ) |
|
606 { |
|
607 return result; |
|
608 } |
|
609 |
|
610 if ( aEvent.IsKeyEvent() ) |
|
611 { |
|
612 switch ( aEvent.Code() ) |
|
613 { |
|
614 case EEventKeyDown: |
|
615 { |
|
616 if ( aEvent.KeyEvent().iScanCode == EStdKeyDevice3 ) |
|
617 { |
|
618 iParent.HandleButtonEvent( |
|
619 MFsControlButtonObserver::EEventButtonPressed, -1 ); |
|
620 result = ETrue; |
|
621 } |
|
622 break; |
|
623 } |
|
624 |
|
625 case EEventKey: |
|
626 { |
|
627 if ( aEvent.KeyEvent().iScanCode == EStdKeyDevice3 ) |
|
628 { |
|
629 iParent.HandleButtonEvent( |
|
630 MFsControlButtonObserver::EEventButton, |
|
631 iModel->Id() ); |
|
632 result = ETrue; |
|
633 |
|
634 if ( iTriggeredComponent ) |
|
635 { |
|
636 iTriggeredComponent->OpenComponent(); |
|
637 } |
|
638 } |
|
639 break; |
|
640 } |
|
641 |
|
642 case EEventKeyUp: |
|
643 { |
|
644 if ( aEvent.KeyEvent().iScanCode == EStdKeyDevice3 ) |
|
645 { |
|
646 iParent.HandleButtonEvent( |
|
647 MFsControlButtonObserver::EEventButtonReleased, -1 ); |
|
648 result = ETrue; |
|
649 } |
|
650 break; |
|
651 } |
|
652 |
|
653 default: |
|
654 { |
|
655 // event not consumed - result still got value EFalse |
|
656 break; |
|
657 } |
|
658 } |
|
659 } |
|
660 else if ( aEvent.IsPointerEvent() ) |
|
661 { |
|
662 const TPointerEvent& pointerEvent( aEvent.PointerEvent() ); |
|
663 switch (pointerEvent.iType) |
|
664 { |
|
665 case TPointerEvent::EButton1Down: |
|
666 { |
|
667 if( HitTest( aEvent.PointerEvent().iParentPosition ) ) |
|
668 { |
|
669 iTouchPressed = ETrue; |
|
670 // added for tactile feedback |
|
671 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
672 if (feedback) |
|
673 { |
|
674 feedback->InstantFeedback(ETouchFeedbackBasic); |
|
675 } |
|
676 |
|
677 GrabPointerEvents( ETrue ); |
|
678 result = iParent.HandleButtonEvent( |
|
679 MFsControlButtonObserver::EEventButtonTouchPressed, |
|
680 iModel->Id() ); |
|
681 } |
|
682 break; |
|
683 } |
|
684 case TPointerEvent::EButton1Up: |
|
685 { |
|
686 if( iTouchPressed ) |
|
687 { |
|
688 GrabPointerEvents( EFalse ); |
|
689 |
|
690 TInt buttonId( KErrNotFound ); |
|
691 if( HitTest( aEvent.PointerEvent().iParentPosition ) ) |
|
692 { |
|
693 buttonId = iModel->Id(); |
|
694 } |
|
695 result = iParent.HandleButtonEvent( |
|
696 MFsControlButtonObserver::EEventButtonTouchReleased, |
|
697 buttonId ); |
|
698 iTouchPressed = EFalse; |
|
699 } |
|
700 break; |
|
701 } |
|
702 default: |
|
703 { |
|
704 break; |
|
705 } |
|
706 } |
|
707 } |
|
708 return result; |
|
709 } |
|
710 |
|
711 // --------------------------------------------------------------------------- |
|
712 // |
|
713 // --------------------------------------------------------------------------- |
|
714 // |
|
715 void CFsControlButton::GrabPointerEvents( TBool aGrab ) |
|
716 { |
|
717 CAlfDisplay* display = Display(); |
|
718 if( display ) |
|
719 { |
|
720 if ( aGrab ) |
|
721 { |
|
722 display->Roster().AddPointerEventObserver( |
|
723 EAlfPointerEventReportUnhandled, *this ); |
|
724 } |
|
725 else |
|
726 { |
|
727 display->Roster().RemovePointerEventObserver( |
|
728 EAlfPointerEventReportUnhandled, *this ); |
|
729 } |
|
730 } |
|
731 } |