58 // |
58 // |
59 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
60 // |
60 // |
61 CMmListBoxItemDrawer::CMmListBoxItemDrawer( |
61 CMmListBoxItemDrawer::CMmListBoxItemDrawer( |
62 CMmListBoxModel* aMmListBoxModel, |
62 CMmListBoxModel* aMmListBoxModel, |
63 const CFont* aFont, |
63 const CFont* aFont, |
64 CFormattedCellListBoxData* aFormattedCellData, |
64 CFormattedCellListBoxData* aFormattedCellData, |
65 TMmWidgetType aWidgetType, |
65 TMmWidgetType aWidgetType, |
66 CMmTemplateLibrary* aTemplateLibrary ) |
66 CMmTemplateLibrary* aTemplateLibrary ) |
67 : CFormattedCellListBoxItemDrawer( aMmListBoxModel , aFont, aFormattedCellData), |
67 : CFormattedCellListBoxItemDrawer( aMmListBoxModel , aFont, aFormattedCellData), |
68 iFont(aFont), iLeftOverAreaUnderAnimatedItem(EFalse) |
68 iFont(aFont), iLeftOverAreaUnderAnimatedItem(EFalse) |
69 { |
69 { |
70 iWidgetType = aWidgetType; |
70 iWidgetType = aWidgetType; |
71 iTemplateLibrary = aTemplateLibrary; |
71 iTemplateLibrary = aTemplateLibrary; |
72 iMmModel = aMmListBoxModel; |
72 iMmModel = aMmListBoxModel; |
73 iRedrawBackground = ETrue; |
73 iRedrawBackground = ETrue; |
74 iDrawSeparatorLines = EFalse; |
74 iDrawSeparatorLines = EFalse; |
75 iZoomIconIndex = -1; |
75 iZoomIconIndex = -1; |
76 iIconAnimationZoomRatio = 1; |
76 iIconAnimationZoomRatio = 1; |
77 // this is needed to get iColors initialized on first use: |
77 // this is needed to get iColors initialized on first use: |
78 iLastDrawnItemWasFloating = ETrue; |
78 iLastDrawnItemWasFloating = ETrue; |
79 SetFlags( CListItemDrawer::EDisableHighlight ); |
79 SetFlags( CListItemDrawer::EDisableHighlight ); |
80 } |
80 } |
81 |
81 |
82 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
83 // |
83 // |
503 { |
503 { |
504 transApi->StopDrawing(); |
504 transApi->StopDrawing(); |
505 } |
505 } |
506 #endif |
506 #endif |
507 |
507 |
508 if( iDrawSeparatorLines ) |
508 if( iDrawSeparatorLines ) |
509 { |
509 { |
510 CMmListBoxView* view = static_cast<CMmListBoxView*>( iWidget->View() ); |
510 CMmListBoxView* view = static_cast<CMmListBoxView*>( iWidget->View() ); |
511 if( aItemIndex != ( view->ModelItemsCount() - 1 )) |
511 if( aItemIndex != ( view->ModelItemsCount() - 1 )) |
512 { |
512 { |
513 AknListUtils::DrawSeparator( *iGc, aItemTextRect, iColors.iBack ); |
513 AknListUtils::DrawSeparator( *iGc, aItemTextRect, iColors.iBack ); |
614 // |
614 // |
615 void CMmListBoxItemDrawer::SetupSubIcondDragHighlightCellL( |
615 void CMmListBoxItemDrawer::SetupSubIcondDragHighlightCellL( |
616 TTemplateChild aSubCellTemplate, TInt aIndex, TInt aItemIndex ) const |
616 TTemplateChild aSubCellTemplate, TInt aIndex, TInt aItemIndex ) const |
617 { |
617 { |
618 aSubCellTemplate.iRectAccordingToParent.iBr |
618 aSubCellTemplate.iRectAccordingToParent.iBr |
619 = TPoint(ItemCellSize().iWidth * iIconAnimationZoomRatio, |
619 = TPoint(ItemCellSize().iWidth * iIconAnimationZoomRatio, |
620 ItemCellSize().iHeight * iIconAnimationZoomRatio); |
620 ItemCellSize().iHeight * iIconAnimationZoomRatio); |
621 |
621 |
622 aSubCellTemplate.iRectAccordingToParent.iTl = TPoint(0, 0); |
622 aSubCellTemplate.iRectAccordingToParent.iTl = TPoint(0, 0); |
623 SetupSubCellL( aSubCellTemplate, aIndex, aItemIndex ); |
623 SetupSubCellL( aSubCellTemplate, aIndex, aItemIndex ); |
624 } |
624 } |
625 |
625 |
929 // ----------------------------------------------------------------------------- |
929 // ----------------------------------------------------------------------------- |
930 // |
930 // |
931 // ----------------------------------------------------------------------------- |
931 // ----------------------------------------------------------------------------- |
932 // |
932 // |
933 void CMmListBoxItemDrawer::SetDraggedPointL( TPoint aPoint ) |
933 void CMmListBoxItemDrawer::SetDraggedPointL( TPoint aPoint ) |
934 { |
934 { |
935 TInt dragFloatingItem = GetFloatingItemIndex(EDrag); |
935 TInt dragFloatingItem = GetFloatingItemIndex(EDrag); |
936 if (dragFloatingItem != KErrNotFound ) |
936 if (dragFloatingItem != KErrNotFound ) |
937 { |
937 { |
938 TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem ); |
938 TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem ); |
939 TMmFloatingItem floatingItem( item.GetDrawnItemIndex(), |
939 TMmFloatingItem floatingItem( item.GetDrawnItemIndex(), |
940 aPoint, EDrag, MmEffects::KNoAnimationFramesCount, NULL ); |
940 aPoint, EDrag, MmEffects::KNoAnimationFramesCount, NULL ); |
941 floatingItem.SetManualDelete( ETrue ); |
941 floatingItem.SetManualDelete( ETrue ); |
942 |
942 |
943 TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(), |
943 TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(), |
944 item.GetItemPosition(), EPostDragRefreshItem, |
944 item.GetItemPosition(), EPostDragRefreshItem, |
945 MmEffects::KNoAnimationFramesCount, iWidget->View() ); |
945 MmEffects::KNoAnimationFramesCount, iWidget->View() ); |
946 |
946 |
947 iFloatingItems.Remove( dragFloatingItem ); |
947 iFloatingItems.Remove( dragFloatingItem ); |
948 |
948 |
1054 // ----------------------------------------------------------------------------- |
1054 // ----------------------------------------------------------------------------- |
1055 // |
1055 // |
1056 // ----------------------------------------------------------------------------- |
1056 // ----------------------------------------------------------------------------- |
1057 // |
1057 // |
1058 void CMmListBoxItemDrawer::DrawActualIndicatorItem( TInt aItemIndex, TRect /*actualItemRect*/ ) |
1058 void CMmListBoxItemDrawer::DrawActualIndicatorItem( TInt aItemIndex, TRect /*actualItemRect*/ ) |
1059 { |
1059 { |
1060 if ( iDrawMoveIndicators ) |
1060 if ( iDrawMoveIndicators ) |
1061 { |
1061 { |
1062 iIsIndicatorItem = ETrue; |
1062 iIsIndicatorItem = ETrue; |
1063 TBool redrawItemBackground = |
1063 TBool redrawItemBackground = |
1064 IsRedrawItemBackgroundEnabled( ); |
1064 IsRedrawItemBackgroundEnabled( ); |
1065 SetRedrawItemBackground( EFalse ); |
1065 SetRedrawItemBackground( EFalse ); |
1066 |
1066 |
1067 DrawActualItem( aItemIndex, AdjustItemRect( aItemIndex ) , EFalse, EFalse, EFalse, EFalse); |
1067 DrawActualItem( aItemIndex, AdjustItemRect( aItemIndex ) , EFalse, EFalse, EFalse, EFalse); |
1068 |
1068 |
1069 SetRedrawItemBackground( redrawItemBackground ); |
1069 SetRedrawItemBackground( redrawItemBackground ); |
1070 iIsIndicatorItem = EFalse; |
1070 iIsIndicatorItem = EFalse; |
1112 // ----------------------------------------------------------------------------- |
1112 // ----------------------------------------------------------------------------- |
1113 // |
1113 // |
1114 // ----------------------------------------------------------------------------- |
1114 // ----------------------------------------------------------------------------- |
1115 // |
1115 // |
1116 void CMmListBoxItemDrawer::SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn ) |
1116 void CMmListBoxItemDrawer::SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn ) |
1117 { |
1117 { |
1118 iIsMarqueeBeingDrawn = aIsMarqueeBeingDrawn; |
1118 iIsMarqueeBeingDrawn = aIsMarqueeBeingDrawn; |
1119 } |
1119 } |
1120 |
1120 |
1121 |
1121 |
1122 // ----------------------------------------------------------------------------- |
1122 // ----------------------------------------------------------------------------- |
1123 // |
1123 // |
1124 // ----------------------------------------------------------------------------- |
1124 // ----------------------------------------------------------------------------- |
1125 // |
1125 // |
1126 TBool CMmListBoxItemDrawer::IsTextClippedL( TTemplateChild aTemplateChild, |
1126 TBool CMmListBoxItemDrawer::IsTextClippedL( TTemplateChild aTemplateChild, |
1127 const TDesC& aText ) const |
1127 const TDesC& aText ) const |
1128 { |
1128 { |
1129 TBuf< MmMarqueeConstants::KClippingBufLength > clipbuf |
1129 TBuf< MmMarqueeConstants::KClippingBufLength > clipbuf |
1130 = aText.Left( MmMarqueeConstants::KTextTrimmingThreshold); |
1130 = aText.Left( MmMarqueeConstants::KTextTrimmingThreshold); |
1131 TInt maxClipWidth = aTemplateChild.iRectAccordingToParent.Width(); |
1131 TInt maxClipWidth = aTemplateChild.iRectAccordingToParent.Width(); |
1132 const CFont* font = AknLayoutUtils::FontFromId(aTemplateChild.iFontId); |
1132 const CFont* font = AknLayoutUtils::FontFromId(aTemplateChild.iFontId); |
1133 return AknBidiTextUtils::ConvertToVisualAndClipL( clipbuf, *font, |
1133 return AknBidiTextUtils::ConvertToVisualAndClipL( clipbuf, *font, |
1134 aTemplateChild.iRectAccordingToParent.Width(), maxClipWidth ); |
1134 aTemplateChild.iRectAccordingToParent.Width(), maxClipWidth ); |
1135 } |
1135 } |
1136 |
1136 |
1137 // ----------------------------------------------------------------------------- |
1137 // ----------------------------------------------------------------------------- |
1146 // ----------------------------------------------------------------------------- |
1146 // ----------------------------------------------------------------------------- |
1147 // |
1147 // |
1148 // ----------------------------------------------------------------------------- |
1148 // ----------------------------------------------------------------------------- |
1149 // |
1149 // |
1150 void CMmListBoxItemDrawer::SetupIconSubcellL( |
1150 void CMmListBoxItemDrawer::SetupIconSubcellL( |
1151 RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex, |
1151 RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex, |
1152 RBuf& aItemText, TInt& aSubcellIncrement ) const |
1152 RBuf& aItemText, TInt& aSubcellIncrement ) const |
1153 { |
1153 { |
1154 CGulIcon* icon = NULL; |
1154 CGulIcon* icon = NULL; |
1155 TTemplateChild child = aTemplateChildArray[aChildIndex]; |
1155 TTemplateChild child = aTemplateChildArray[aChildIndex]; |
1156 if ( !IsEditMode() && |
1156 if ( !IsEditMode() && |
1157 child.iImageVisualId == EImageVisualIdEditMode ) |
1157 child.iImageVisualId == EImageVisualIdEditMode ) |
1158 { |
1158 { |
1159 child.iIsImage = EFalse; |
1159 child.iIsImage = EFalse; |
1160 } |
1160 } |
1161 |
1161 |
1162 if( IsEditMode() && IsDraggable() && aItemIndex == iZoomIconIndex ) |
1162 if( IsEditMode() && IsDraggable() && aItemIndex == iZoomIconIndex ) |
1163 { |
1163 { |
1164 const TReal KNormalZoomRatio = 1.0; |
1164 const TReal KNormalZoomRatio = 1.0; |
1165 TReal zoomDelta = ( iIconAnimationZoomRatio - KNormalZoomRatio ) / 2.0; |
1165 TReal zoomDelta = ( iIconAnimationZoomRatio - KNormalZoomRatio ) / 2.0; |
1319 TTemplateChild child = aTemplateChildArray[i]; |
1319 TTemplateChild child = aTemplateChildArray[i]; |
1320 if( child.iImageVisualId == EImageVisualIdEditMode && |
1320 if( child.iImageVisualId == EImageVisualIdEditMode && |
1321 child.iIsImage ) |
1321 child.iIsImage ) |
1322 { |
1322 { |
1323 TSize itemSize = GetItemSize( aItemIndex, |
1323 TSize itemSize = GetItemSize( aItemIndex, |
1324 aItemIndex == iWidget->View()->CurrentItemIndex() ); |
1324 aItemIndex == iWidget->View()->CurrentItemIndex() ); |
1325 CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics( aItemIndex, child.iData, &itemSize ); |
1325 CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics( aItemIndex, child.iData, &itemSize ); |
1326 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1326 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1327 if( icon ) |
1327 if( icon ) |
1328 { |
1328 { |
1329 CFbsBitmap* bitmap = icon->Bitmap(); |
1329 CFbsBitmap* bitmap = icon->Bitmap(); |
1384 |
1384 |
1385 RArray<TTemplateChild> templateChildArray; |
1385 RArray<TTemplateChild> templateChildArray; |
1386 CleanupClosePushL( templateChildArray ); |
1386 CleanupClosePushL( templateChildArray ); |
1387 if( !iIsIndicatorItem ) |
1387 if( !iIsIndicatorItem ) |
1388 { |
1388 { |
1389 iTemplateLibrary->GetChildrenL( iWidgetType, templateChildArray, mmTemplate, |
1389 iTemplateLibrary->GetChildrenL( iWidgetType, templateChildArray, mmTemplate, |
1390 landscapeOrientation, aItemIsCurrent, IsEditMode() ); |
1390 landscapeOrientation, aItemIsCurrent, IsEditMode() ); |
1391 } |
1391 } |
1392 else if ( !AknLayoutUtils::PenEnabled() ) |
1392 else if ( !AknLayoutUtils::PenEnabled() ) |
1393 { |
1393 { |
1394 iTemplateLibrary->GetMoveIndicatorChildrenL( iWidgetType, templateChildArray, |
1394 iTemplateLibrary->GetMoveIndicatorChildrenL( iWidgetType, templateChildArray, |
1395 mmTemplate, landscapeOrientation, aItemIsCurrent ); |
1395 mmTemplate, landscapeOrientation, aItemIsCurrent ); |
1396 } |
1396 } |
1397 |
1397 |
1398 iLastSubcellsSetupCode.Clear(); |
1398 iLastSubcellsSetupCode.Clear(); |
1399 |
1399 |
1400 //Backdrop icon as first element to draw |
1400 //Backdrop icon as first element to draw |
1401 TInt subcellIncrement( 0 ); |
1401 TInt subcellIncrement( 0 ); |
1407 else |
1407 else |
1408 { |
1408 { |
1409 iItemHasBackdrop = EFalse; |
1409 iItemHasBackdrop = EFalse; |
1410 } |
1410 } |
1411 |
1411 |
1412 for ( TInt i( 0 ) ; i < templateChildArray.Count() && !iLeftOverAreaUnderAnimatedItem; i++ ) |
1412 for ( TInt i( 0 ) ; i < templateChildArray.Count() && !iLeftOverAreaUnderAnimatedItem; i++ ) |
1413 { |
1413 { |
1414 TTemplateChild child = templateChildArray[i]; |
1414 TTemplateChild child = templateChildArray[i]; |
1415 if ( child.iImageVisualId == EImageVisualIdEditMode && child.iIsImage ) |
1415 if ( child.iImageVisualId == EImageVisualIdEditMode && child.iIsImage ) |
1416 { |
1416 { |
1417 continue; |
1417 continue; |
1418 } |
1418 } |
1419 else if( !child.iIsImage ) |
1419 else if( !child.iIsImage ) |
1420 { |
1420 { |
1421 SetupTextSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement ); |
1421 SetupTextSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement ); |
1422 } |
1422 } |
1423 else |
1423 else |
1424 { |
1424 { |
1425 SetupIconSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement ); |
1425 SetupIconSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement ); |
1426 } |
1426 } |
1427 } |
1427 } |
1428 TInt subcellsJustSet = subcellIncrement; |
1428 TInt subcellsJustSet = subcellIncrement; |
1429 iCurrentNumberOfSubcellsSet = Max( iCurrentNumberOfSubcellsSet, subcellsJustSet ); |
1429 iCurrentNumberOfSubcellsSet = Max( iCurrentNumberOfSubcellsSet, subcellsJustSet ); |
1430 __ASSERT_DEBUG( iCurrentNumberOfSubcellsSet <= MmTemplateContants::KSubCellsCount, |
1430 __ASSERT_DEBUG( iCurrentNumberOfSubcellsSet <= MmTemplateContants::KSubCellsCount, |
1431 User::Invariant() ); |
1431 User::Invariant() ); |
1432 |
1432 |
1433 for( TInt i = subcellIncrement; i < iCurrentNumberOfSubcellsSet; i++ ) |
1433 for( TInt i = subcellIncrement; i < iCurrentNumberOfSubcellsSet; i++ ) |
1434 { |
1434 { |
1543 TBool currentlyDraggedItem = |
1543 TBool currentlyDraggedItem = |
1544 ItemHasFloatingType( aItemIndex, EDrag ) || |
1544 ItemHasFloatingType( aItemIndex, EDrag ) || |
1545 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1545 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1546 |
1546 |
1547 return IsEditMode() /* draw the backdrop only in edit mode */ |
1547 return IsEditMode() /* draw the backdrop only in edit mode */ |
1548 && !currentlyDraggedItem /* backdrop is disabled for dragged items */ |
1548 && !currentlyDraggedItem /* backdrop is disabled for dragged items */ |
1549 && !iIsIndicatorItem /* in non-touch backdrop is not drawn, just "move indicators" */ |
1549 && !iIsIndicatorItem /* in non-touch backdrop is not drawn, just "move indicators" */ |
1550 && !iLeftOverAreaUnderAnimatedItem /* is the currently drawn item the area left over behind dragged item*/ |
1550 && !iLeftOverAreaUnderAnimatedItem /* is the currently drawn item the area left over behind dragged item*/ |
1551 && !( STATIC_CAST( CMmWidgetContainer*,Widget()->Parent() )->IsHighlightVisible() |
1551 && !( STATIC_CAST( CMmWidgetContainer*,Widget()->Parent() )->IsHighlightVisible() |
1552 && aItemIsCurrent );/*if the timer is active then we want to draw highlight (not backdrop) on the current index*/ |
1552 && aItemIsCurrent );/*if the timer is active then we want to draw highlight (not backdrop) on the current index*/ |
1553 } |
1553 } |
1554 |
1554 |
1555 // ----------------------------------------------------------------------------- |
1555 // ----------------------------------------------------------------------------- |
1556 // |
1556 // |
1557 // ----------------------------------------------------------------------------- |
1557 // ----------------------------------------------------------------------------- |