693 TInt height = 0; // height of all menu items combined. |
693 TInt height = 0; // height of all menu items combined. |
694 TInt width = 0; // Width of menu |
694 TInt width = 0; // Width of menu |
695 TInt visibleItems = 0; // Number of visible items |
695 TInt visibleItems = 0; // Number of visible items |
696 |
696 |
697 // Find the widest visible item and count visible items |
697 // Find the widest visible item and count visible items |
698 TRect screenRect; |
|
699 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, |
|
700 screenRect ); |
|
701 TInt screenHeight( screenRect.Height() ); |
|
702 TInt screenWidth( screenRect.Width() ); |
|
703 |
|
704 const CFont* usedFont = AknLayoutUtils::FontFromId( |
|
705 AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).Font() ); |
|
706 for ( TInt i = 0; i < iItems.Count(); i++ ) |
698 for ( TInt i = 0; i < iItems.Count(); i++ ) |
707 { |
699 { |
708 if ( iItems[i]->iVisibility == KShown ) |
700 if ( iItems[i]->iVisibility == KShown ) |
709 { |
701 { |
710 visibleItems++; |
702 visibleItems++; |
711 textWidth = usedFont->TextWidthInPixels( *( iItems[i]->iText ) ); |
703 textWidth = AknLayoutUtils::FontFromId( AknLayoutScalable_Avkon:: |
|
704 list_single_popup_submenu_pane_t1( 0 ).LayoutLine().FontId() )->TextWidthInPixels( *( iItems[i]->iText ) ); |
712 width = Max( width, textWidth ); |
705 width = Max( width, textWidth ); |
713 } |
706 } |
714 } |
707 } |
715 |
708 |
716 if ( visibleItems == 0 ) |
709 if ( visibleItems == 0 ) |
717 { |
710 { |
718 return TSize( 0, 0 ); |
711 return TSize( 0, 0 ); |
719 } |
712 } |
720 |
713 |
721 // Check the minimum width from the layout data and adjust the width |
714 TRect mainPaneRect; |
722 // if the text would take less space than that. |
715 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
723 TInt minWidth = |
716 mainPaneRect ); |
724 TAknWindowComponentLayout::Compose( |
|
725 AknLayoutScalable_Avkon::popup_touch_menu_window( 0 ), |
|
726 TAknWindowComponentLayout::Compose( |
|
727 AknLayoutScalable_Avkon::list_touch_menu_pane( 0 ), |
|
728 AknLayoutScalable_Avkon::list_single_touch_menu_pane( 0 ) ) ).LayoutLine().iW; |
|
729 width = Max( width, minWidth ); |
|
730 |
|
731 TAknWindowLineLayout listLayout = |
717 TAknWindowLineLayout listLayout = |
732 AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine(); |
718 AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine(); |
733 |
719 |
734 TAknTextLineLayout textLayout = |
720 TAknTextLineLayout textLayout = |
735 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine(); |
721 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine(); |
738 AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine(); |
724 AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine(); |
739 |
725 |
740 TInt singleItemHeight = listLayout.iH; |
726 TInt singleItemHeight = listLayout.iH; |
741 height = singleItemHeight * visibleItems; |
727 height = singleItemHeight * visibleItems; |
742 |
728 |
743 if ( height > screenHeight ) |
729 if ( height > mainPaneRect.Height() ) |
744 { |
730 { |
745 // Amount of items that fit in the popup. |
731 TInt fitsToMenu = mainPaneRect.Height() / singleItemHeight; |
746 TInt fitsToMenu = visibleItems; |
|
747 |
|
748 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
749 { |
|
750 // In landscape orientation the max amount of items comes from |
|
751 // the layout data. |
|
752 TAknLayoutScalableParameterLimits paramLimits( |
|
753 AknLayoutScalable_Avkon::list_single_touch_menu_pane_ParamLimits() ); |
|
754 |
|
755 // Add one to the last row as it's row index starting from zero. |
|
756 fitsToMenu = paramLimits.LastRow() + 1; |
|
757 } |
|
758 else |
|
759 { |
|
760 // In potrait orientation the menu can show as many items as fit |
|
761 // on the screen. |
|
762 fitsToMenu = screenHeight / singleItemHeight; |
|
763 } |
|
764 |
|
765 height = fitsToMenu * singleItemHeight; |
732 height = fitsToMenu * singleItemHeight; |
766 TAknWindowLineLayout scrollBar = |
733 TAknWindowLineLayout scrollBar = |
767 AknLayoutScalable_Avkon::scroll_pane( 0 ); |
734 AknLayoutScalable_Avkon::scroll_pane( 0 ); |
768 width += scrollBar.iW; |
735 width += scrollBar.iW; |
769 } |
736 } |
770 |
737 |
771 width += textLayout.ir + textLayout.il; |
738 width += textLayout.ir + textLayout.il; |
772 |
739 |
773 if ( width > ( screenWidth - unit.iW ) ) |
740 if ( width > ( mainPaneRect.Width() - unit.iW ) ) |
774 { |
741 { |
775 width = screenWidth - ( unit.iW ); |
742 width = mainPaneRect.Width() - ( unit.iW ); |
776 } |
743 } |
777 |
744 |
778 return TSize( width, height ); |
745 return TSize( width, height ); |
779 } |
746 } |
780 |
747 |
789 |
756 |
790 if ( aType == KAknsMessageSkinChange ) |
757 if ( aType == KAknsMessageSkinChange ) |
791 { |
758 { |
792 // Implementation when graphics are ready. |
759 // Implementation when graphics are ready. |
793 } |
760 } |
794 else if ( aType == KEikMessageFadeAllWindows ) |
761 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
762 { |
|
763 |
|
764 // Background under highlight may have changed -> we need to update |
|
765 // highlight background to animation |
|
766 if ( iExtension ) |
|
767 { |
|
768 iExtension->HandleLayoutSwitch(); |
|
769 } |
|
770 |
|
771 iPopUpMenu.UpdatePosition(); |
|
772 } |
|
773 else if ( aType == KEikMessageFadeAllWindows ) |
795 { |
774 { |
796 if ( Observer() ) |
775 if ( Observer() ) |
797 { |
776 { |
798 if ( iExtension ) |
|
799 { |
|
800 iExtension->iInformObserver = EFalse; |
|
801 } |
|
802 // this will close the stylus popup menu |
777 // this will close the stylus popup menu |
803 TRAP_IGNORE( Observer()->HandleControlEventL( this, |
778 TRAP_IGNORE( Observer()->HandleControlEventL( this, |
804 MCoeControlObserver::EEventRequestExit ) ); |
779 MCoeControlObserver::EEventRequestExit ) ); |
805 } |
780 } |
806 } |
781 } |
807 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
808 { |
|
809 if ( Observer() ) |
|
810 { |
|
811 if ( iExtension ) |
|
812 { |
|
813 iExtension->iInformObserver = EFalse; |
|
814 } |
|
815 // this will close the stylus popup menu |
|
816 TRAP_IGNORE( Observer()->HandleControlEventL( this, |
|
817 MCoeControlObserver::EEventRequestCancel ) ); |
|
818 } |
|
819 } |
|
820 } |
782 } |
821 |
783 |
822 // ----------------------------------------------------------------------------- |
784 // ----------------------------------------------------------------------------- |
823 // CAknStylusPopUpMenuContent::HandlePointerEventL |
785 // CAknStylusPopUpMenuContent::HandlePointerEventL |
824 // ----------------------------------------------------------------------------- |
786 // ----------------------------------------------------------------------------- |
962 void CAknStylusPopUpMenuContent::DrawItem( |
921 void CAknStylusPopUpMenuContent::DrawItem( |
963 CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const |
922 CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const |
964 { |
923 { |
965 TRect rect( iItems[aItem]->iRect ); |
924 TRect rect( iItems[aItem]->iRect ); |
966 |
925 |
967 if ( !rect.IsEmpty() ) |
926 // Use offset to move items smoothly. |
968 { |
927 // If physics not in use, offset is always 0. |
969 // Use offset to move items smoothly. |
928 rect.Move( TPoint( 0, -Offset() ) ); |
970 // If physics not in use, offset is always 0. |
929 |
971 rect.Move( TPoint( 0, -Offset() ) ); |
930 if ( aHighlight == EDrawHighlight ) |
972 |
931 { |
973 if ( aHighlight == EDrawHighlight ) |
932 TBool drawOk = EFalse; |
974 { |
933 if( iExtension->iAnimation ) // Draw animated highlight |
975 TBool drawOk = EFalse; |
934 { |
976 if( iExtension->iAnimation ) // Draw animated highlight |
935 drawOk = iExtension->iAnimation->Render( aGc, rect ); |
|
936 } |
|
937 if ( !drawOk ) |
|
938 { |
|
939 // Animated highlight was not available, use normal skinned |
|
940 // rendering. |
|
941 TAknLayoutRect listRect; |
|
942 TAknLayoutRect innerRect; |
|
943 |
|
944 listRect.LayoutRect( rect, |
|
945 AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() ); |
|
946 innerRect.LayoutRect( listRect.Rect(), |
|
947 AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() ); |
|
948 |
|
949 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
950 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
951 // if we have transparent highlight, draw also background under highlight |
|
952 if ( Background() ) |
977 { |
953 { |
978 drawOk = iExtension->iAnimation->Render( aGc, rect ); |
954 Background()->Draw( aGc, *this, rect ); |
979 } |
955 } |
|
956 |
|
957 drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), |
|
958 KAknsIIDQsnFrList, KAknsIIDDefault ); |
|
959 |
|
960 //Both highlight animation and frame drawing failed. |
980 if ( !drawOk ) |
961 if ( !drawOk ) |
981 { |
962 { |
982 // Animated highlight was not available, use normal skinned |
963 listRect.DrawRect( aGc ); |
983 // rendering. |
964 innerRect.DrawRect( aGc ); |
984 TAknLayoutRect listRect; |
|
985 TAknLayoutRect innerRect; |
|
986 |
|
987 listRect.LayoutRect( rect, |
|
988 AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() ); |
|
989 innerRect.LayoutRect( listRect.Rect(), |
|
990 AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() ); |
|
991 |
|
992 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
993 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
994 // if we have transparent highlight, draw also background under highlight |
|
995 if ( Background() ) |
|
996 { |
|
997 Background()->Draw( aGc, *this, rect ); |
|
998 } |
|
999 |
|
1000 drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), |
|
1001 KAknsIIDQsnFrList, KAknsIIDDefault ); |
|
1002 |
|
1003 //Both highlight animation and frame drawing failed. |
|
1004 if ( !drawOk ) |
|
1005 { |
|
1006 listRect.DrawRect( aGc ); |
|
1007 innerRect.DrawRect( aGc ); |
|
1008 } |
|
1009 } |
965 } |
1010 } |
966 } |
1011 |
967 } |
1012 if ( aHighlight == ERemoveHighlight && Background() ) |
968 |
1013 { |
969 if ( aHighlight == ERemoveHighlight && Background() ) |
1014 Background()->Draw( aGc, *this, rect ); |
970 { |
1015 } |
971 Background()->Draw( aGc, *this, rect ); |
1016 |
972 } |
1017 TAknLayoutText layoutText; |
973 |
1018 layoutText.LayoutText( rect, |
974 TAknLayoutText layoutText; |
1019 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); |
975 layoutText.LayoutText( rect, |
1020 |
976 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); |
1021 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
977 |
1022 |
978 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
1023 TRgb textColor(layoutText.Color()); |
979 |
1024 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
980 TRgb textColor(layoutText.Color()); |
1025 EAknsCIQsnTextColorsCG20 ); |
981 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
1026 |
982 EAknsCIQsnTextColorsCG20 ); |
1027 layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); |
983 |
1028 |
984 layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); |
1029 if ( aItem < iLastVisibleItem ) |
|
1030 { |
|
1031 AknListUtils::DrawSeparator( aGc, rect, textColor, skin ); |
|
1032 } |
|
1033 } |
|
1034 } |
985 } |
1035 |
986 |
1036 // ----------------------------------------------------------------------------- |
987 // ----------------------------------------------------------------------------- |
1037 // CAknStylusPopUpMenuContent::StartAnimation |
988 // CAknStylusPopUpMenuContent::StartAnimation |
1038 // ----------------------------------------------------------------------------- |
989 // ----------------------------------------------------------------------------- |
1099 CEikScrollBarFrame::EOff ) ); |
1050 CEikScrollBarFrame::EOff ) ); |
1100 return; |
1051 return; |
1101 } |
1052 } |
1102 |
1053 |
1103 TAknDoubleSpanScrollBarModel vsbarModel; |
1054 TAknDoubleSpanScrollBarModel vsbarModel; |
|
1055 TAknDoubleSpanScrollBarModel hsbarModel; |
1104 |
1056 |
1105 if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff ) |
1057 if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff ) |
1106 { |
1058 { |
1107 vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset(); |
1059 vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset(); |
1108 vsbarModel.iScrollSpan = visibleItems * singleItemHeight; |
1060 vsbarModel.iScrollSpan = visibleItems * singleItemHeight; |
1109 vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight; |
1061 vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight; |
1110 |
1062 |
1111 TAknLayoutRect scrollBarLayout; |
1063 TEikScrollBarFrameLayout layout; |
1112 scrollBarLayout.LayoutRect( listRect, |
1064 layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant; |
1113 AknLayoutScalable_Avkon::scroll_pane() ); |
1065 layout.SetClientMargin(0); |
1114 TRect scrollBarRect( scrollBarLayout.Rect() ); |
1066 layout.SetInclusiveMargin(0); |
1115 |
1067 |
1116 iSBFrame->Tile( &vsbarModel, scrollBarRect ); |
1068 TBool changed ( EFalse ); |
1117 |
1069 TRect clientRect( listRect ); |
1118 iSBFrame->DrawScrollBarsDeferred(); |
1070 TRect inclusiveRect( listRect ); |
|
1071 TRAP_IGNORE ( changed = iSBFrame->TileL( &hsbarModel, |
|
1072 &vsbarModel, |
|
1073 clientRect, |
|
1074 inclusiveRect, |
|
1075 layout ) ); |
|
1076 if ( changed ) |
|
1077 { |
|
1078 iSBFrame->DrawScrollBarsDeferred(); |
|
1079 } |
1119 } |
1080 } |
1120 } |
1081 } |
1121 |
1082 |
1122 // ----------------------------------------------------------------------------- |
1083 // ----------------------------------------------------------------------------- |
1123 // CAknStylusPopUpMenuContent::CalculateShownItems |
1084 // CAknStylusPopUpMenuContent::CalculateShownItems |