51 #include "mmcacheforitem.h" |
52 #include "mmcacheforitem.h" |
52 #include "mmitemsdatacache.h" |
53 #include "mmitemsdatacache.h" |
53 #include "mmwidgetcontainer.h" |
54 #include "mmwidgetcontainer.h" |
54 #include "hnsuitemodel.h" |
55 #include "hnsuitemodel.h" |
55 #include "menudebug.h" |
56 #include "menudebug.h" |
|
57 #include "hnextbmpiconholder.h" |
56 |
58 |
57 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
58 // |
60 // |
59 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
60 // |
62 // |
75 iZoomIconIndex = -1; |
77 iZoomIconIndex = -1; |
76 iIconAnimationZoomRatio = 1; |
78 iIconAnimationZoomRatio = 1; |
77 // this is needed to get iColors initialized on first use: |
79 // this is needed to get iColors initialized on first use: |
78 iLastDrawnItemWasFloating = ETrue; |
80 iLastDrawnItemWasFloating = ETrue; |
79 SetFlags( CListItemDrawer::EDisableHighlight ); |
81 SetFlags( CListItemDrawer::EDisableHighlight ); |
|
82 iIsSwapFloating = EFalse; |
80 } |
83 } |
81 |
84 |
82 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
83 // |
86 // |
84 // ----------------------------------------------------------------------------- |
87 // ----------------------------------------------------------------------------- |
312 TInt tempZoomRatio = iIconAnimationZoomRatio; |
315 TInt tempZoomRatio = iIconAnimationZoomRatio; |
313 |
316 |
314 iZoomIconIndex = iFloatingItems[i].GetDrawnItemIndex(); |
317 iZoomIconIndex = iFloatingItems[i].GetDrawnItemIndex(); |
315 iIconAnimationZoomRatio = iFloatingItems[i].GetCurrentZoomRatio(); |
318 iIconAnimationZoomRatio = iFloatingItems[i].GetCurrentZoomRatio(); |
316 |
319 |
317 if ( ItemHasFloatingType( drawnItemIndex, EDrag) || |
320 if ( ItemHasFloatingType( drawnItemIndex, EDrag) || |
318 ItemHasFloatingType( drawnItemIndex, EDragTransition) ) |
321 ItemHasFloatingType( drawnItemIndex, EDragTransition) ) |
319 { |
322 { |
320 ClearFlags( CListItemDrawer::EPressedDownState ); |
323 ClearFlags( CListItemDrawer::EPressedDownState ); |
321 } |
324 } |
322 |
325 type == ESwapTransition ? iIsSwapFloating = ETrue : iIsSwapFloating = EFalse; |
323 DrawActualItem( drawnItemIndex, rect, ETrue, EFalse, EFalse, EFalse ); |
326 DrawActualItem( drawnItemIndex, rect, ETrue, EFalse, EFalse, EFalse ); |
324 iIconAnimationZoomRatio = tempZoomRatio; |
327 iIconAnimationZoomRatio = tempZoomRatio; |
325 iZoomIconIndex = tempZoomIconIndex; |
328 iZoomIconIndex = tempZoomIconIndex; |
326 } |
329 } |
327 } |
330 } |
328 else |
331 else |
397 const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = ETrue; |
400 const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = ETrue; |
398 break; |
401 break; |
399 } |
402 } |
400 } |
403 } |
401 |
404 |
|
405 iIsSwapFloating = EFalse; |
402 DrawActualItem(aItemIndex, actualItemRect, aItemIsCurrent, aViewIsEmphasized, |
406 DrawActualItem(aItemIndex, actualItemRect, aItemIsCurrent, aViewIsEmphasized, |
403 aViewIsDimmed, aItemIsSelected); |
407 aViewIsDimmed, aItemIsSelected); |
404 const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = EFalse; |
408 const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = EFalse; |
405 |
409 |
406 const_cast<CMmListBoxItemDrawer*>(this)->DrawFloatingItems(actualItemRect); |
410 const_cast<CMmListBoxItemDrawer*>(this)->DrawFloatingItems(actualItemRect); |
1181 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1185 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1182 if( icon ) |
1186 if( icon ) |
1183 { |
1187 { |
1184 CFbsBitmap* bitmap = icon->Bitmap(); |
1188 CFbsBitmap* bitmap = icon->Bitmap(); |
1185 ASSERT( bitmap ); |
1189 ASSERT( bitmap ); |
|
1190 TInt errTooBig( KErrNone ); |
1186 //resize the item if it is a move indicator |
1191 //resize the item if it is a move indicator |
1187 if( iIsIndicatorItem ) |
1192 if( iIsIndicatorItem ) |
1188 { |
1193 { |
1189 AknIconUtils::SetSize( bitmap, child.iRectAccordingToParent.Size(), |
1194 errTooBig = AknIconUtils::SetSize( bitmap, |
|
1195 child.iRectAccordingToParent.Size(), |
1190 EAspectRatioNotPreserved ); |
1196 EAspectRatioNotPreserved ); |
1191 } |
1197 } |
1192 else |
1198 else |
1193 { |
1199 { |
1194 TSize bmpSize = bitmap->SizeInPixels(); |
1200 TSize bmpSize = bitmap->SizeInPixels(); |
1195 TBool setSizeRequired = bitmap->DisplayMode() == ENone; |
1201 TBool setSizeRequired = bitmap->DisplayMode() == ENone; |
1196 if ( targetSize.iWidth && targetSize.iHeight && |
1202 if ( targetSize.iWidth && targetSize.iHeight && |
1197 ( setSizeRequired || !BitmapFitsIntoTarget( bmpSize, targetSize ) ) ) |
1203 ( setSizeRequired || !BitmapFitsIntoTarget( bmpSize, targetSize ) ) ) |
1198 { |
1204 { |
1199 CFbsBitmap* mask = icon->Mask(); |
1205 CFbsBitmap* mask = icon->Mask(); |
1200 if( mask ) |
1206 if( mask ) |
1201 { |
1207 { |
1202 __ASSERT_DEBUG( bmpSize == mask->SizeInPixels(), User::Invariant() ); |
1208 __ASSERT_DEBUG( bmpSize == mask->SizeInPixels(), User::Invariant() ); |
1203 AknIconUtils::SetSize( mask, targetSize, EAspectRatioPreservedAndUnusedSpaceRemoved ); |
1209 errTooBig = AknIconUtils::SetSize( mask, targetSize, |
1204 } |
1210 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
1205 AknIconUtils::SetSize( bitmap, targetSize, EAspectRatioPreservedAndUnusedSpaceRemoved ); |
1211 } |
|
1212 if( !errTooBig ) |
|
1213 errTooBig = AknIconUtils::SetSize( bitmap, targetSize, |
|
1214 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
1206 } |
1215 } |
1207 } |
1216 } |
1208 |
1217 |
1209 TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )->AppendIconL( iconHolder ); |
1218 if( errTooBig == KErrTooBig ) |
|
1219 { |
|
1220 // If icon is not created, try to create default application icon |
|
1221 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
1222 CFbsBitmap* bitmap( NULL ); |
|
1223 CFbsBitmap* maskBitmap( NULL ); |
|
1224 TRAPD( err, |
|
1225 { |
|
1226 AknsUtils::CreateIconLC( skin, |
|
1227 KAknsIIDQgnMenuUnknownLst, bitmap, maskBitmap, |
|
1228 AknIconUtils::AvkonIconFileName(), |
|
1229 EMbmAvkonQgn_menu_unknown_lst, |
|
1230 EMbmAvkonQgn_menu_unknown_lst_mask ); |
|
1231 CleanupStack::Pop( 2 ); // for trap |
|
1232 } |
|
1233 ); |
|
1234 if( !err ) |
|
1235 { |
|
1236 if( maskBitmap) |
|
1237 AknIconUtils::SetSize( maskBitmap, targetSize, |
|
1238 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
1239 AknIconUtils::SetSize( bitmap, targetSize, |
|
1240 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
1241 static_cast<CHnExtBmpIconHolder*>(iconHolder)->CleanBmpBuffer(); |
|
1242 icon->SetBitmap(bitmap); |
|
1243 icon->SetMask(maskBitmap); |
|
1244 icon->SetBitmapsOwnedExternally(EFalse); |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )->AppendIconL( iconHolder ); |
1210 |
1249 |
1211 HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex ); |
1250 HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex ); |
1212 const TInt newLength = aItemText.Length() + number->Length(); |
1251 const TInt newLength = aItemText.Length() + number->Length(); |
1213 if( aItemText.MaxLength() < newLength ) |
1252 if( aItemText.MaxLength() < newLength ) |
1214 { |
1253 { |
1320 if( child.iImageVisualId == EImageVisualIdEditMode && |
1359 if( child.iImageVisualId == EImageVisualIdEditMode && |
1321 child.iIsImage ) |
1360 child.iIsImage ) |
1322 { |
1361 { |
1323 TSize itemSize = GetItemSize( aItemIndex, |
1362 TSize itemSize = GetItemSize( aItemIndex, |
1324 aItemIndex == iWidget->View()->CurrentItemIndex() ); |
1363 aItemIndex == iWidget->View()->CurrentItemIndex() ); |
1325 CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics( aItemIndex, child.iData, &itemSize ); |
1364 CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics( |
|
1365 aItemIndex, child.iData, &itemSize ); |
1326 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1366 icon = iconHolder ? iconHolder->GetGulIcon() : NULL; |
1327 if( icon ) |
1367 if( icon ) |
1328 { |
1368 { |
1329 CFbsBitmap* bitmap = icon->Bitmap(); |
1369 CFbsBitmap* bitmap = icon->Bitmap(); |
1330 child.iRectAccordingToParent = TRect( TPoint( 0, 0 ), |
1370 child.iRectAccordingToParent = TRect( TPoint( 0, 0 ), |
1331 TPoint( itemSize.iWidth, itemSize.iHeight ) ); |
1371 TPoint( itemSize.iWidth, itemSize.iHeight ) ); |
1332 AknIconUtils::SetSize( bitmap, itemSize, |
1372 AknIconUtils::SetSize( bitmap, itemSize, |
1333 EAspectRatioNotPreserved ); |
1373 EAspectRatioNotPreserved ); |
1334 TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )->AppendIconL( iconHolder ); |
1374 TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )-> |
|
1375 AppendIconL( iconHolder ); |
1335 |
1376 |
1336 HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex ); |
1377 HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex ); |
1337 TInt newLength = aItemText.Length() + number->Length(); |
1378 TInt newLength = aItemText.Length() + number->Length(); |
1338 if( aItemText.MaxLength() < newLength ) |
1379 if( aItemText.MaxLength() < newLength ) |
1339 { |
1380 { |
1397 |
1438 |
1398 iLastSubcellsSetupCode.Clear(); |
1439 iLastSubcellsSetupCode.Clear(); |
1399 |
1440 |
1400 //Backdrop icon as first element to draw |
1441 //Backdrop icon as first element to draw |
1401 TInt subcellIncrement( 0 ); |
1442 TInt subcellIncrement( 0 ); |
1402 if( GetBackdropVisibility( aItemIndex, aItemIsCurrent ) ) |
1443 if( ( GetBackdropVisibility( aItemIndex, aItemIsCurrent ) |
|
1444 || ItemHasFloatingType( aItemIndex, ESwapTransition ) ) |
|
1445 && !iIsSwapFloating ) |
1403 { |
1446 { |
1404 SetupBackdropSubcellL( templateChildArray, aItemIndex, itemText, subcellIncrement ); |
1447 SetupBackdropSubcellL( templateChildArray, aItemIndex, itemText, subcellIncrement ); |
1405 iItemHasBackdrop = ETrue; |
1448 iItemHasBackdrop = ETrue; |
|
1449 iIsSwapFloating = EFalse; |
1406 } |
1450 } |
1407 else |
1451 else |
1408 { |
1452 { |
1409 iItemHasBackdrop = EFalse; |
1453 iItemHasBackdrop = EFalse; |
1410 } |
1454 } |
1517 TBool aItemIsCurrent, TBool aAllowHighlightForNonDraggedItem ) const |
1561 TBool aItemIsCurrent, TBool aAllowHighlightForNonDraggedItem ) const |
1518 { |
1562 { |
1519 TBool highlightVisibility( EFalse ); |
1563 TBool highlightVisibility( EFalse ); |
1520 if( !iItemHasBackdrop && !iLeftOverAreaUnderAnimatedItem ) //never draw highlight when item has backdrop or when left over area under animated item |
1564 if( !iItemHasBackdrop && !iLeftOverAreaUnderAnimatedItem ) //never draw highlight when item has backdrop or when left over area under animated item |
1521 { |
1565 { |
1522 TBool currentlyDraggedItem = |
1566 TBool currentlyDraggedItem = |
1523 ItemHasFloatingType( aItemIndex, EDrag ) || |
1567 ItemHasFloatingType( aItemIndex, EDrag ) || |
1524 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1568 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1525 |
1569 |
1526 if( ( STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsHighlightVisible() |
1570 if( ( STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsHighlightVisible() |
1527 && aItemIsCurrent && aAllowHighlightForNonDraggedItem ) |
1571 && aItemIsCurrent && aAllowHighlightForNonDraggedItem ) |
1528 || currentlyDraggedItem ) |
1572 || currentlyDraggedItem ) |
1529 { |
1573 { |
1538 // ----------------------------------------------------------------------------- |
1582 // ----------------------------------------------------------------------------- |
1539 // |
1583 // |
1540 TBool CMmListBoxItemDrawer::GetBackdropVisibility( TInt aItemIndex, |
1584 TBool CMmListBoxItemDrawer::GetBackdropVisibility( TInt aItemIndex, |
1541 TBool aItemIsCurrent ) const |
1585 TBool aItemIsCurrent ) const |
1542 { |
1586 { |
1543 TBool currentlyDraggedItem = |
1587 TBool currentlyDraggedItem = |
1544 ItemHasFloatingType( aItemIndex, EDrag ) || |
1588 ItemHasFloatingType( aItemIndex, EDrag ) || |
1545 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1589 ItemHasFloatingType( aItemIndex, EDragTransition ); |
1546 |
1590 |
1547 return IsEditMode() /* draw the backdrop only in edit mode */ |
1591 return IsEditMode() /* draw the backdrop only in edit mode */ |
1548 && !currentlyDraggedItem /* backdrop is disabled for dragged items */ |
1592 && !currentlyDraggedItem /* backdrop is disabled for dragged items */ |