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() ); |
698 for ( TInt i = 0; i < iItems.Count(); i++ ) |
706 for ( TInt i = 0; i < iItems.Count(); i++ ) |
699 { |
707 { |
700 if ( iItems[i]->iVisibility == KShown ) |
708 if ( iItems[i]->iVisibility == KShown ) |
701 { |
709 { |
702 visibleItems++; |
710 visibleItems++; |
703 textWidth = AknLayoutUtils::FontFromId( AknLayoutScalable_Avkon:: |
711 textWidth = usedFont->TextWidthInPixels( *( iItems[i]->iText ) ); |
704 list_single_popup_submenu_pane_t1( 0 ).LayoutLine().FontId() )->TextWidthInPixels( *( iItems[i]->iText ) ); |
|
705 width = Max( width, textWidth ); |
712 width = Max( width, textWidth ); |
706 } |
713 } |
707 } |
714 } |
708 |
715 |
709 if ( visibleItems == 0 ) |
716 if ( visibleItems == 0 ) |
710 { |
717 { |
711 return TSize( 0, 0 ); |
718 return TSize( 0, 0 ); |
712 } |
719 } |
713 |
720 |
714 TRect mainPaneRect; |
721 // Check the minimum width from the layout data and adjust the width |
715 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
722 // if the text would take less space than that. |
716 mainPaneRect ); |
723 TInt minWidth = |
|
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 |
717 TAknWindowLineLayout listLayout = |
731 TAknWindowLineLayout listLayout = |
718 AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine(); |
732 AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine(); |
719 |
733 |
720 TAknTextLineLayout textLayout = |
734 TAknTextLineLayout textLayout = |
721 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine(); |
735 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine(); |
724 AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine(); |
738 AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine(); |
725 |
739 |
726 TInt singleItemHeight = listLayout.iH; |
740 TInt singleItemHeight = listLayout.iH; |
727 height = singleItemHeight * visibleItems; |
741 height = singleItemHeight * visibleItems; |
728 |
742 |
729 if ( height > mainPaneRect.Height() ) |
743 if ( height > screenHeight ) |
730 { |
744 { |
731 TInt fitsToMenu = mainPaneRect.Height() / singleItemHeight; |
745 // Amount of items that fit in the popup. |
|
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 |
732 height = fitsToMenu * singleItemHeight; |
765 height = fitsToMenu * singleItemHeight; |
733 TAknWindowLineLayout scrollBar = |
766 TAknWindowLineLayout scrollBar = |
734 AknLayoutScalable_Avkon::scroll_pane( 0 ); |
767 AknLayoutScalable_Avkon::scroll_pane( 0 ); |
735 width += scrollBar.iW; |
768 width += scrollBar.iW; |
736 } |
769 } |
737 |
770 |
738 width += textLayout.ir + textLayout.il; |
771 width += textLayout.ir + textLayout.il; |
739 |
772 |
740 if ( width > ( mainPaneRect.Width() - unit.iW ) ) |
773 if ( width > ( screenWidth - unit.iW ) ) |
741 { |
774 { |
742 width = mainPaneRect.Width() - ( unit.iW ); |
775 width = screenWidth - ( unit.iW ); |
743 } |
776 } |
744 |
777 |
745 return TSize( width, height ); |
778 return TSize( width, height ); |
746 } |
779 } |
747 |
780 |
910 void CAknStylusPopUpMenuContent::DrawItem( |
946 void CAknStylusPopUpMenuContent::DrawItem( |
911 CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const |
947 CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const |
912 { |
948 { |
913 TRect rect( iItems[aItem]->iRect ); |
949 TRect rect( iItems[aItem]->iRect ); |
914 |
950 |
915 // Use offset to move items smoothly. |
951 if ( !rect.IsEmpty() ) |
916 // If physics not in use, offset is always 0. |
952 { |
917 rect.Move( TPoint( 0, -Offset() ) ); |
953 // Use offset to move items smoothly. |
918 |
954 // If physics not in use, offset is always 0. |
919 if ( aHighlight == EDrawHighlight ) |
955 rect.Move( TPoint( 0, -Offset() ) ); |
920 { |
956 |
921 TBool drawOk = EFalse; |
957 if ( aHighlight == EDrawHighlight ) |
922 if( iExtension->iAnimation ) // Draw animated highlight |
958 { |
923 { |
959 TBool drawOk = EFalse; |
924 drawOk = iExtension->iAnimation->Render( aGc, rect ); |
960 if( iExtension->iAnimation ) // Draw animated highlight |
925 } |
|
926 if ( !drawOk ) |
|
927 { |
|
928 // Animated highlight was not available, use normal skinned |
|
929 // rendering. |
|
930 TAknLayoutRect listRect; |
|
931 TAknLayoutRect innerRect; |
|
932 |
|
933 listRect.LayoutRect( rect, |
|
934 AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() ); |
|
935 innerRect.LayoutRect( listRect.Rect(), |
|
936 AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() ); |
|
937 |
|
938 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
939 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
940 // if we have transparent highlight, draw also background under highlight |
|
941 if ( Background() ) |
|
942 { |
961 { |
943 Background()->Draw( aGc, *this, rect ); |
962 drawOk = iExtension->iAnimation->Render( aGc, rect ); |
944 } |
963 } |
945 |
|
946 drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), |
|
947 KAknsIIDQsnFrList, KAknsIIDDefault ); |
|
948 |
|
949 //Both highlight animation and frame drawing failed. |
|
950 if ( !drawOk ) |
964 if ( !drawOk ) |
951 { |
965 { |
952 listRect.DrawRect( aGc ); |
966 // Animated highlight was not available, use normal skinned |
953 innerRect.DrawRect( aGc ); |
967 // rendering. |
|
968 TAknLayoutRect listRect; |
|
969 TAknLayoutRect innerRect; |
|
970 |
|
971 listRect.LayoutRect( rect, |
|
972 AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() ); |
|
973 innerRect.LayoutRect( listRect.Rect(), |
|
974 AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() ); |
|
975 |
|
976 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
977 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
978 // if we have transparent highlight, draw also background under highlight |
|
979 if ( Background() ) |
|
980 { |
|
981 Background()->Draw( aGc, *this, rect ); |
|
982 } |
|
983 |
|
984 drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), |
|
985 KAknsIIDQsnFrList, KAknsIIDDefault ); |
|
986 |
|
987 //Both highlight animation and frame drawing failed. |
|
988 if ( !drawOk ) |
|
989 { |
|
990 listRect.DrawRect( aGc ); |
|
991 innerRect.DrawRect( aGc ); |
|
992 } |
954 } |
993 } |
955 } |
994 } |
956 } |
995 |
957 |
996 if ( aHighlight == ERemoveHighlight && Background() ) |
958 if ( aHighlight == ERemoveHighlight && Background() ) |
997 { |
959 { |
998 Background()->Draw( aGc, *this, rect ); |
960 Background()->Draw( aGc, *this, rect ); |
999 } |
961 } |
1000 |
962 |
1001 TAknLayoutText layoutText; |
963 TAknLayoutText layoutText; |
1002 layoutText.LayoutText( rect, |
964 layoutText.LayoutText( rect, |
1003 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); |
965 AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); |
1004 |
966 |
1005 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
967 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
1006 |
968 |
1007 TRgb textColor(layoutText.Color()); |
969 TRgb textColor(layoutText.Color()); |
1008 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
970 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
1009 EAknsCIQsnTextColorsCG20 ); |
971 EAknsCIQsnTextColorsCG20 ); |
1010 |
972 |
1011 layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); |
973 layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); |
1012 |
|
1013 if ( aItem < iLastVisibleItem ) |
|
1014 { |
|
1015 AknListUtils::DrawSeparator( aGc, rect, textColor ); |
|
1016 } |
|
1017 } |
974 } |
1018 } |
975 |
1019 |
976 // ----------------------------------------------------------------------------- |
1020 // ----------------------------------------------------------------------------- |
977 // CAknStylusPopUpMenuContent::StartAnimation |
1021 // CAknStylusPopUpMenuContent::StartAnimation |
978 // ----------------------------------------------------------------------------- |
1022 // ----------------------------------------------------------------------------- |
1039 CEikScrollBarFrame::EOff ) ); |
1083 CEikScrollBarFrame::EOff ) ); |
1040 return; |
1084 return; |
1041 } |
1085 } |
1042 |
1086 |
1043 TAknDoubleSpanScrollBarModel vsbarModel; |
1087 TAknDoubleSpanScrollBarModel vsbarModel; |
1044 TAknDoubleSpanScrollBarModel hsbarModel; |
|
1045 |
1088 |
1046 if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff ) |
1089 if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff ) |
1047 { |
1090 { |
1048 vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset(); |
1091 vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset(); |
1049 vsbarModel.iScrollSpan = visibleItems * singleItemHeight; |
1092 vsbarModel.iScrollSpan = visibleItems * singleItemHeight; |
1050 vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight; |
1093 vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight; |
1051 |
1094 |
1052 TEikScrollBarFrameLayout layout; |
1095 TAknLayoutRect scrollBarLayout; |
1053 layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant; |
1096 scrollBarLayout.LayoutRect( listRect, |
1054 layout.SetClientMargin(0); |
1097 AknLayoutScalable_Avkon::scroll_pane() ); |
1055 layout.SetInclusiveMargin(0); |
1098 TRect scrollBarRect( scrollBarLayout.Rect() ); |
1056 |
1099 |
1057 TBool changed ( EFalse ); |
1100 iSBFrame->Tile( &vsbarModel, scrollBarRect ); |
1058 TRect clientRect( listRect ); |
1101 |
1059 TRect inclusiveRect( listRect ); |
1102 iSBFrame->DrawScrollBarsDeferred(); |
1060 TRAP_IGNORE ( changed = iSBFrame->TileL( &hsbarModel, |
|
1061 &vsbarModel, |
|
1062 clientRect, |
|
1063 inclusiveRect, |
|
1064 layout ) ); |
|
1065 if ( changed ) |
|
1066 { |
|
1067 iSBFrame->DrawScrollBarsDeferred(); |
|
1068 } |
|
1069 } |
1103 } |
1070 } |
1104 } |
1071 |
1105 |
1072 // ----------------------------------------------------------------------------- |
1106 // ----------------------------------------------------------------------------- |
1073 // CAknStylusPopUpMenuContent::CalculateShownItems |
1107 // CAknStylusPopUpMenuContent::CalculateShownItems |