13 * |
13 * |
14 * Description: Main class for Control Bar component. |
14 * Description: Main class for Control Bar component. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 // CLASS HEADER |
19 //<cmail> SF |
19 #include "fscontrolbar.h" |
|
20 |
|
21 // INCLUDES |
20 #include "emailtrace.h" |
22 #include "emailtrace.h" |
21 #include <alf/alfevent.h> |
23 #include <alf/alfevent.h> |
22 #include <alf/alfdecklayout.h> |
24 #include <alf/alfdecklayout.h> |
23 //</cmail> |
|
24 #include <AknsConstants.h> |
25 #include <AknsConstants.h> |
25 #include <AknUtils.h> |
26 #include <AknUtils.h> |
26 |
27 #include <layoutmetadata.cdl.h> |
27 #include "fscontrolbar.h" |
28 |
28 #include "fscontrolbarmodel.h" |
29 #include "fscontrolbarmodel.h" |
29 #include "fscontrolbarvisualiser.h" |
30 #include "fscontrolbarvisualiser.h" |
30 #include "fscontrolbutton.h" |
31 #include "fscontrolbutton.h" |
31 #include "fsgenericpanic.h" |
32 #include "fsgenericpanic.h" |
32 #include "fscontrolbuttonconst.h" |
33 #include "fscontrolbuttonconst.h" |
605 return eventHandled; |
606 return eventHandled; |
606 } |
607 } |
607 |
608 |
608 if ( aEvent.IsKeyEvent() ) |
609 if ( aEvent.IsKeyEvent() ) |
609 { |
610 { |
610 CFsControlButton* button( NULL ); |
611 CFsControlButton* button = iModel->ButtonById( iSelectedButton ); |
611 |
|
612 button = iModel->ButtonById( iSelectedButton ); |
|
613 |
|
614 if ( button && button->OfferEventL( aEvent ) ) |
612 if ( button && button->OfferEventL( aEvent ) ) |
615 { |
613 { |
616 eventHandled = ETrue; |
614 eventHandled = ETrue; |
617 } |
615 } |
618 else |
616 else |
619 { |
617 { |
620 if ( EEventKey == aEvent.Code() ) |
618 if( EEventKey == aEvent.Code() ) |
621 { |
619 { |
622 switch ( aEvent.KeyEvent().iScanCode ) |
620 TBool landscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
621 switch( aEvent.KeyEvent().iScanCode ) |
623 { |
622 { |
624 case EStdKeyLeftArrow: |
623 case EStdKeyLeftArrow: |
625 { |
624 { |
626 button = iModel->PrevButton( iSelectedButton ); |
625 if( landscape ) |
627 ChangeFocusL( button ); |
626 { |
628 // Always after keypress focus needs to be shown. |
627 LooseFocus( MFsControlBarObserver::EEventFocusLostAtBottom ); |
629 MakeSelectorVisible( ETrue ); |
628 } |
|
629 else |
|
630 { |
|
631 button = iModel->PrevButton( iSelectedButton ); |
|
632 ChangeFocusL( button, ETrue ); |
|
633 } |
630 eventHandled = ETrue; |
634 eventHandled = ETrue; |
631 break; |
635 break; |
632 } |
636 } |
633 |
637 |
634 case EStdKeyRightArrow: |
638 case EStdKeyRightArrow: |
635 { |
639 { |
636 button = iModel->NextButton( iSelectedButton ); |
640 if( !landscape ) |
637 ChangeFocusL( button ); |
641 { |
638 // Always after keypress focus needs to be shown. |
642 button = iModel->NextButton( iSelectedButton ); |
639 MakeSelectorVisible( ETrue ); |
643 ChangeFocusL( button, ETrue ); |
|
644 eventHandled = ETrue; |
|
645 } |
|
646 break; |
|
647 } |
|
648 |
|
649 case EStdKeyDownArrow: |
|
650 { |
|
651 if( landscape ) |
|
652 { |
|
653 button = iModel->NextButton( iSelectedButton, landscape ); |
|
654 ChangeFocusL( button, ETrue ); |
|
655 } |
|
656 else |
|
657 { |
|
658 LooseFocus( MFsControlBarObserver::EEventFocusLostAtBottom ); |
|
659 } |
640 eventHandled = ETrue; |
660 eventHandled = ETrue; |
641 break; |
661 break; |
642 } |
662 } |
643 |
663 case EStdKeyUpArrow: |
644 case EStdKeyDownArrow: |
|
645 { |
664 { |
646 LooseFocus( |
665 if( landscape ) |
647 MFsControlBarObserver::EEventFocusLostAtBottom ); |
666 { |
648 eventHandled = ETrue; |
667 button = iModel->PrevButton( iSelectedButton, landscape ); |
|
668 ChangeFocusL( button, ETrue ); |
|
669 eventHandled = ETrue; |
|
670 } |
649 break; |
671 break; |
650 } |
672 } |
651 |
|
652 default: |
673 default: |
653 { |
674 { |
654 eventHandled = EFalse; |
675 eventHandled = EFalse; |
655 break; |
676 break; |
656 } |
677 } |
721 { |
740 { |
722 NotifyObservers( MFsControlBarObserver::EEventButton, aButtonId ); |
741 NotifyObservers( MFsControlBarObserver::EEventButton, aButtonId ); |
723 break; |
742 break; |
724 } |
743 } |
725 |
744 |
726 // <cmail> Touch |
|
727 case EEventButtonTouchReleased: |
745 case EEventButtonTouchReleased: |
728 { |
746 { |
729 // Notify that button is released, focus can be hidden. |
747 // Notify that button is released, focus can be hidden. |
730 NotifyObservers( MFsControlBarObserver::EEventFocusVisibilityChanged ); |
748 NotifyObservers( MFsControlBarObserver::EEventFocusVisibilityChanged ); |
731 |
749 |
746 // Mark event not handled, because list might be waiting for this up event |
764 // Mark event not handled, because list might be waiting for this up event |
747 eventHandled = EFalse; |
765 eventHandled = EFalse; |
748 } |
766 } |
749 break; |
767 break; |
750 } |
768 } |
751 // </cmail> |
|
752 |
769 |
753 case EEventButtonReleased: |
770 case EEventButtonReleased: |
754 { |
771 { |
755 NotifyObservers( |
772 NotifyObservers( |
756 MFsControlBarObserver::EEventButtonReleased, aButtonId ); |
773 MFsControlBarObserver::EEventButtonReleased, aButtonId ); |
830 |
847 |
831 // --------------------------------------------------------------------------- |
848 // --------------------------------------------------------------------------- |
832 // Changes focus to another button or looses focus from control bar. |
849 // Changes focus to another button or looses focus from control bar. |
833 // --------------------------------------------------------------------------- |
850 // --------------------------------------------------------------------------- |
834 // |
851 // |
835 void CFsControlBar::ChangeFocusL( CFsControlButton* aButton ) |
852 void CFsControlBar::ChangeFocusL( |
|
853 CFsControlButton* aButton, TBool aMakeSelectorVisible ) |
836 { |
854 { |
837 FUNC_LOG; |
855 FUNC_LOG; |
838 if ( aButton ) |
856 if ( aButton ) |
839 { |
857 { |
840 // set focus to specified button |
858 // set focus to specified button |
841 SetFocusByIdL( aButton->Id() ); |
859 SetFocusByIdL( aButton->Id() ); |
|
860 if( aMakeSelectorVisible ) |
|
861 { |
|
862 MakeSelectorVisible( ETrue ); |
|
863 } |
842 } |
864 } |
843 else |
865 else |
844 { |
866 { |
845 // loose focus from bar |
867 // loose focus from bar |
846 LooseFocus( MFsControlBarObserver::EEventFocusLostAtSide ); |
868 LooseFocus( MFsControlBarObserver::EEventFocusLostAtSide ); |