10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * Version : %version: MM_71.1.17.1.42 % << Don't touch! Updated by Synergy at check-out. |
15 * Version : %version: MM_71.1.17.1.44 % << Don't touch! Updated by Synergy at check-out. |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 |
19 |
20 #include <e32keys.h> |
20 #include <e32keys.h> |
21 #include <e32math.h> |
21 #include <e32math.h> |
22 #include <AknsDrawUtils.h> |
22 #include <AknsDrawUtils.h> |
23 #include <layoutmetadata.cdl.h> |
23 #include <layoutmetadata.cdl.h> |
24 #include <aknlongtapdetector.h> |
24 #include <aknlongtapdetector.h> |
25 |
25 |
26 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
26 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
27 #include <aknlistloadertfx.h> |
27 #include <aknlistloadertfx.h> |
28 #include <aknlistboxtfxinternal.h> |
28 #include <aknlistboxtfxinternal.h> |
29 #include <aknlistboxtfx.h> |
29 #include <aknlistboxtfx.h> |
221 if ( aType == KEikDynamicLayoutVariantSwitch || |
221 if ( aType == KEikDynamicLayoutVariantSwitch || |
222 aType == KAknsMessageSkinChange ) |
222 aType == KAknsMessageSkinChange ) |
223 { |
223 { |
224 static_cast<CMmListBoxItemDrawer*>( iDrawer )->InvalidateCache(); |
224 static_cast<CMmListBoxItemDrawer*>( iDrawer )->InvalidateCache(); |
225 } |
225 } |
226 |
226 |
227 CCoeControl::HandleResourceChange( aType ); |
227 CCoeControl::HandleResourceChange( aType ); |
228 } |
228 } |
229 |
229 |
230 // ----------------------------------------------------------------------------- |
230 // ----------------------------------------------------------------------------- |
231 // |
231 // |
342 { |
342 { |
343 if (aAnimate) |
343 if (aAnimate) |
344 { |
344 { |
345 iDrawer->AnimateDragItemTransitionL(); |
345 iDrawer->AnimateDragItemTransitionL(); |
346 } |
346 } |
347 |
347 |
348 SetHighlightAfterDrag(); |
348 SetHighlightAfterDrag(); |
349 |
349 |
350 iDraggedIndex = -1; |
350 iDraggedIndex = -1; |
351 iDrawer->SetDraggedIndexL( iDraggedIndex, TPoint(0,0) ); |
351 iDrawer->SetDraggedIndexL( iDraggedIndex, TPoint(0,0) ); |
352 SetDraggableL( EFalse ); |
352 SetDraggableL( EFalse ); |
353 |
353 |
354 TInt dragFloatingItem; |
354 TInt dragFloatingItem; |
585 { |
585 { |
586 if ( iMarqueeAdapter && aPointerEvent.iType == TPointerEvent::EButton1Down ) |
586 if ( iMarqueeAdapter && aPointerEvent.iType == TPointerEvent::EButton1Down ) |
587 { |
587 { |
588 iMarqueeAdapter->StopMarqueeDrawing(); |
588 iMarqueeAdapter->StopMarqueeDrawing(); |
589 } |
589 } |
590 |
590 |
591 TInt index = KErrNotFound; |
591 TInt index = KErrNotFound; |
592 TBool itemExists = iWidget->View()->XYPosToItemIndex( aPointerEvent.iPosition, index ); |
592 TBool itemExists = iWidget->View()->XYPosToItemIndex( aPointerEvent.iPosition, index ); |
593 |
593 |
594 CCoeControl::HandlePointerEventL(aPointerEvent); |
594 CCoeControl::HandlePointerEventL(aPointerEvent); |
595 |
595 |
596 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
596 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
597 && itemExists ) |
597 && itemExists ) |
598 { |
598 { |
599 SetHighlightL( index ); |
599 SetHighlightL( index ); |
600 } |
600 } |
631 |
631 |
632 if ( IsEditMode() && iDragAndDropObserver ) |
632 if ( IsEditMode() && iDragAndDropObserver ) |
633 { |
633 { |
634 HandlePointerEventsInEditModeL(aPointerEvent, abortAnimation); |
634 HandlePointerEventsInEditModeL(aPointerEvent, abortAnimation); |
635 } |
635 } |
636 |
636 |
637 if ( iLongTapDetector ) |
637 if ( iLongTapDetector ) |
638 { |
638 { |
639 TPointerEvent longTapPointerEvent = aPointerEvent; |
639 TPointerEvent longTapPointerEvent = aPointerEvent; |
640 if ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) |
640 if ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) |
641 { |
641 { |
642 longTapPointerEvent.iType = TPointerEvent::EDrag; |
642 longTapPointerEvent.iType = TPointerEvent::EDrag; |
643 } |
643 } |
644 iLongTapDetector->PointerEventL( longTapPointerEvent ); |
644 iLongTapDetector->PointerEventL( longTapPointerEvent ); |
645 } |
645 } |
646 |
646 |
647 } |
647 } |
648 |
648 |
649 // ----------------------------------------------------------------------------- |
649 // ----------------------------------------------------------------------------- |
650 // |
650 // |
651 // ----------------------------------------------------------------------------- |
651 // ----------------------------------------------------------------------------- |
662 // |
662 // |
663 // ----------------------------------------------------------------------------- |
663 // ----------------------------------------------------------------------------- |
664 // |
664 // |
665 void CMmWidgetContainer::SetDraggableL( TBool aDraggable ) |
665 void CMmWidgetContainer::SetDraggableL( TBool aDraggable ) |
666 { |
666 { |
667 |
667 |
668 iDrawer = STATIC_CAST(CMmListBoxItemDrawer*, iWidget->View()->ItemDrawer()); |
668 iDrawer = STATIC_CAST(CMmListBoxItemDrawer*, iWidget->View()->ItemDrawer()); |
669 iDrawer->SetDraggableL( aDraggable ); |
669 iDrawer->SetDraggableL( aDraggable ); |
670 } |
670 } |
671 |
671 |
672 // ----------------------------------------------------------------------------- |
672 // ----------------------------------------------------------------------------- |
957 iMarqueeAdapter->StopMarqueeDrawing(); |
957 iMarqueeAdapter->StopMarqueeDrawing(); |
958 } |
958 } |
959 |
959 |
960 if (!AknLayoutUtils::PenEnabled() && iIsEditMode ) |
960 if (!AknLayoutUtils::PenEnabled() && iIsEditMode ) |
961 { |
961 { |
962 if ((GetHighlight() + ColumnsInCurrentView() > NumberOfItems() - 1) |
962 if ((GetHighlight() + ColumnsInCurrentView() > NumberOfItems() - 1) |
963 && aKeyEvent.iScanCode == EStdKeyDownArrow) |
963 && aKeyEvent.iScanCode == EStdKeyDownArrow) |
964 // the second condition is needed to block moving item down when there is no item below the moved item. |
964 // the second condition is needed to block moving item down when there is no item below the moved item. |
965 { |
965 { |
966 return resp; |
966 return resp; |
967 } |
967 } |
972 static_cast<CMmListBoxItemDrawer*>(iDrawer)->SetHighlightShown( EFalse ); |
972 static_cast<CMmListBoxItemDrawer*>(iDrawer)->SetHighlightShown( EFalse ); |
973 resp = iWidget->OfferKeyEventL( aKeyEvent, aType ); |
973 resp = iWidget->OfferKeyEventL( aKeyEvent, aType ); |
974 static_cast<CMmListBoxItemDrawer*>(iDrawer)->SetHighlightShown( ETrue ); |
974 static_cast<CMmListBoxItemDrawer*>(iDrawer)->SetHighlightShown( ETrue ); |
975 SetHighlightL( iWidget->CurrentItemIndex() ); |
975 SetHighlightL( iWidget->CurrentItemIndex() ); |
976 ScrollViewIfNeededL(); //only edit mode non-touch |
976 ScrollViewIfNeededL(); //only edit mode non-touch |
977 |
977 |
978 if ( prevIndex != GetHighlight() |
978 if ( prevIndex != GetHighlight() |
979 && KErrNotFound != prevIndex ) |
979 && KErrNotFound != prevIndex ) |
980 { |
980 { |
981 iDraggedIndex = prevIndex; |
981 iDraggedIndex = prevIndex; |
982 iDragAndDropObserver->HandleDragStartL( iDraggedIndex ); |
982 iDragAndDropObserver->HandleDragStartL( iDraggedIndex ); |
1102 // |
1102 // |
1103 // ----------------------------------------------------------------------------- |
1103 // ----------------------------------------------------------------------------- |
1104 // |
1104 // |
1105 TInt CMmWidgetContainer::RowsInCurrentView() |
1105 TInt CMmWidgetContainer::RowsInCurrentView() |
1106 { |
1106 { |
1107 //should be overridden by deriving classes |
1107 //should be overridden by deriving classes |
1108 CListBoxView *view = ((CListBoxView*) Widget()->View()); |
1108 CListBoxView *view = ((CListBoxView*) Widget()->View()); |
1109 return view->NumberOfItemsThatFitInRect( Rect());//Widget()->View()->ViewRect()); |
1109 return view->NumberOfItemsThatFitInRect( Rect());//Widget()->View()->ViewRect()); |
1110 } |
1110 } |
1111 |
1111 |
1112 // ----------------------------------------------------------------------------- |
1112 // ----------------------------------------------------------------------------- |
1198 HandleRockerPressL(); |
1198 HandleRockerPressL(); |
1199 resp = EKeyWasConsumed; |
1199 resp = EKeyWasConsumed; |
1200 } |
1200 } |
1201 else if ( iAllowLongPress && aType == EEventKey && aKeyEvent.iRepeats > 0 && |
1201 else if ( iAllowLongPress && aType == EEventKey && aKeyEvent.iRepeats > 0 && |
1202 ( aKeyEvent.iScanCode == EStdKeyDevice3 |
1202 ( aKeyEvent.iScanCode == EStdKeyDevice3 |
1203 || aKeyEvent.iScanCode == EStdKeyEnter |
1203 || aKeyEvent.iScanCode == EStdKeyEnter |
1204 || aKeyEvent.iScanCode == EStdKeyNkpEnter ) ) |
1204 || aKeyEvent.iScanCode == EStdKeyNkpEnter ) ) |
1205 { |
1205 { |
1206 HandleRockerPressL(); |
1206 HandleRockerPressL(); |
1207 resp = EKeyWasConsumed; |
1207 resp = EKeyWasConsumed; |
1208 iAllowLongPress = EFalse; |
1208 iAllowLongPress = EFalse; |
1209 } |
1209 } |
1210 |
1210 |
1211 return resp; |
1211 return resp; |
1212 } |
1212 } |
1213 |
1213 |
1214 // ----------------------------------------------------------------------------- |
1214 // ----------------------------------------------------------------------------- |
1215 // |
1215 // |
1241 { |
1241 { |
1242 SetupWidgetLayoutL(); |
1242 SetupWidgetLayoutL(); |
1243 } |
1243 } |
1244 iWidget->MakeVisible(ETrue); |
1244 iWidget->MakeVisible(ETrue); |
1245 |
1245 |
1246 Widget()->View()->ItemDrawer()->ClearFlags( |
1246 Widget()->View()->ItemDrawer()->ClearFlags( |
1247 CListItemDrawer::EPressedDownState ); |
1247 CListItemDrawer::EPressedDownState ); |
1248 iPostProcessor->StartAt( iWidget->BottomItemIndex() + 1 ); |
1248 iPostProcessor->StartAt( iWidget->BottomItemIndex() + 1 ); |
1249 } |
1249 } |
1250 |
1250 |
1251 // --------------------------------------------------------------------------- |
1251 // --------------------------------------------------------------------------- |
1374 |
1374 |
1375 // --------------------------------------------------------------------------- |
1375 // --------------------------------------------------------------------------- |
1376 // |
1376 // |
1377 // --------------------------------------------------------------------------- |
1377 // --------------------------------------------------------------------------- |
1378 // |
1378 // |
1379 TBool CMmWidgetContainer::FlipOpen() |
|
1380 { |
|
1381 return iFlipOpen; |
|
1382 } |
|
1383 |
|
1384 // --------------------------------------------------------------------------- |
|
1385 // |
|
1386 // --------------------------------------------------------------------------- |
|
1387 // |
|
1388 EXPORT_C void CMmWidgetContainer::SetFlipOpenL( TBool aIsFlipOpen ) |
|
1389 { |
|
1390 if ( aIsFlipOpen != iFlipOpen ) |
|
1391 { |
|
1392 iFlipOpen = aIsFlipOpen; |
|
1393 FlipStateChangedL(); |
|
1394 } |
|
1395 } |
|
1396 |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // |
|
1399 // --------------------------------------------------------------------------- |
|
1400 // |
|
1401 void CMmWidgetContainer::FlipStateChangedL() |
|
1402 { |
|
1403 // default do nothing |
|
1404 } |
|
1405 |
|
1406 // --------------------------------------------------------------------------- |
|
1407 // |
|
1408 // --------------------------------------------------------------------------- |
|
1409 // |
|
1410 EXPORT_C void CMmWidgetContainer::StopMovingL() |
1379 EXPORT_C void CMmWidgetContainer::StopMovingL() |
1411 { |
1380 { |
1412 if ( !AknLayoutUtils::PenEnabled() && iDragAndDropObserver ) |
1381 if ( !AknLayoutUtils::PenEnabled() && iDragAndDropObserver ) |
1413 iDragAndDropObserver->HandleDragStopL( GetHighlight() ); |
1382 iDragAndDropObserver->HandleDragStopL( GetHighlight() ); |
1414 } |
1383 } |
1424 - iWidget->TopItemIndex() / ColumnsInCurrentView() ) <= 1 ) |
1393 - iWidget->TopItemIndex() / ColumnsInCurrentView() ) <= 1 ) |
1425 { |
1394 { |
1426 return; |
1395 return; |
1427 } |
1396 } |
1428 |
1397 |
1429 TBool needToScrollUp = |
1398 TBool needToScrollUp = |
1430 GetHighlight() - iWidget->TopItemIndex() < ColumnsInCurrentView() |
1399 GetHighlight() - iWidget->TopItemIndex() < ColumnsInCurrentView() |
1431 && iWidget->TopItemIndex() != 0; |
1400 && iWidget->TopItemIndex() != 0; |
1432 |
1401 |
1433 TBool needToScrollDown = |
1402 TBool needToScrollDown = |
1434 iWidget->BottomItemIndex() - GetHighlight() < ColumnsInCurrentView() |
1403 iWidget->BottomItemIndex() - GetHighlight() < ColumnsInCurrentView() |
1435 && iWidget->BottomItemIndex() / ColumnsInCurrentView() |
1404 && iWidget->BottomItemIndex() / ColumnsInCurrentView() |
1436 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView(); |
1405 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView(); |
1437 |
1406 |
1438 if ( WidgetType() == EGridWidget ) |
1407 if ( WidgetType() == EGridWidget ) |
1439 { |
1408 { |
1440 // TODO: temporary - invisible partial items in MCL grid :/ |
1409 // TODO: temporary - invisible partial items in MCL grid :/ |
1441 needToScrollDown = |
1410 needToScrollDown = |
1442 iWidget->BottomItemIndex() - ColumnsInCurrentView() - GetHighlight() < ColumnsInCurrentView() |
1411 iWidget->BottomItemIndex() - ColumnsInCurrentView() - GetHighlight() < ColumnsInCurrentView() |
1443 && ( iWidget->BottomItemIndex() / ColumnsInCurrentView() ) - 1 |
1412 && ( iWidget->BottomItemIndex() / ColumnsInCurrentView() ) - 1 |
1444 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView() |
1413 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView() |
1445 && iWidget->BottomItemIndex() - iWidget->TopItemIndex() |
1414 && iWidget->BottomItemIndex() - iWidget->TopItemIndex() |
1446 > ColumnsInCurrentView() * RowsInCurrentView(); |
1415 > ColumnsInCurrentView() * RowsInCurrentView(); |
1447 } |
1416 } |
1448 |
1417 |
1449 if ( needToScrollUp ) |
1418 if ( needToScrollUp ) |
1450 { |
1419 { |
1451 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1420 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1452 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1421 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1453 if ( transApi ) |
1422 if ( transApi ) |
1466 #endif |
1435 #endif |
1467 UpdateViewScrollBarThumbs(); |
1436 UpdateViewScrollBarThumbs(); |
1468 } |
1437 } |
1469 else if ( needToScrollDown ) |
1438 else if ( needToScrollDown ) |
1470 { |
1439 { |
1471 |
1440 |
1472 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1441 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1473 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1442 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1474 if ( transApi ) |
1443 if ( transApi ) |
1475 { |
1444 { |
1476 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollDown ); |
1445 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollDown ); |
1484 if ( transApi ) |
1453 if ( transApi ) |
1485 { |
1454 { |
1486 transApi->Draw( Rect() ); |
1455 transApi->Draw( Rect() ); |
1487 } |
1456 } |
1488 #endif |
1457 #endif |
1489 |
1458 |
1490 UpdateViewScrollBarThumbs(); |
1459 UpdateViewScrollBarThumbs(); |
1491 } |
1460 } |
1492 } |
1461 } |
1493 |
1462 |
1494 //---------------------------------------------------------------------------- |
1463 //---------------------------------------------------------------------------- |
1495 // |
1464 // |
1496 // --------------------------------------------------------------------------- |
1465 // --------------------------------------------------------------------------- |
1497 // |
1466 // |
1498 void CMmWidgetContainer::UpdateViewScrollBarThumbs() |
1467 void CMmWidgetContainer::UpdateViewScrollBarThumbs() |
1499 { |
1468 { |
1500 |
1469 |
1501 } |
1470 } |
1502 |
1471 |
1503 //---------------------------------------------------------------------------- |
1472 //---------------------------------------------------------------------------- |
1504 // |
1473 // |
1505 // --------------------------------------------------------------------------- |
1474 // --------------------------------------------------------------------------- |
1522 iMarqueeAdapter->EnableMarquee( marqueeShouldBeEnabled ); |
1491 iMarqueeAdapter->EnableMarquee( marqueeShouldBeEnabled ); |
1523 } |
1492 } |
1524 } |
1493 } |
1525 } |
1494 } |
1526 |
1495 |
1527 //---------------------------------------------------------------------------- |
|
1528 // |
|
1529 // --------------------------------------------------------------------------- |
|
1530 // |
|
1531 EXPORT_C void CMmWidgetContainer::HandleZoomChanged( TAknUiZoom aZoom ) |
|
1532 { |
|
1533 SetZoom( aZoom ); |
|
1534 if( WidgetType() == EGridWidget ) |
|
1535 { |
|
1536 CMmGrid* grid = static_cast<CMmGrid*>( iWidget ); |
|
1537 grid->SetupLayout(); |
|
1538 } |
|
1539 Widget()->DrawDeferred(); |
|
1540 } |
|
1541 |
|
1542 // --------------------------------------------------------------------------- |
|
1543 // |
|
1544 // --------------------------------------------------------------------------- |
|
1545 // |
|
1546 EXPORT_C void CMmWidgetContainer::SetZoom( TAknUiZoom aZoom ) |
|
1547 { |
|
1548 CMmTemplateLibrary * templateLibrary = |
|
1549 static_cast<CMmListBoxItemDrawer*> ( |
|
1550 Widget()->View()->ItemDrawer() )->TemplateLibrary(); |
|
1551 |
|
1552 if ( WidgetType() == EGridWidget && EAknUiZoomSmall == aZoom ) |
|
1553 { |
|
1554 aZoom = EAknUiZoomNormal; |
|
1555 } |
|
1556 templateLibrary->SetZoom( aZoom ); |
|
1557 } |
|
1558 |
|
1559 // --------------------------------------------------------------------------- |
1496 // --------------------------------------------------------------------------- |
1560 // |
1497 // |
1561 // --------------------------------------------------------------------------- |
1498 // --------------------------------------------------------------------------- |
1562 // |
1499 // |
1563 void CMmWidgetContainer::SetHighlightAfterDrag() |
1500 void CMmWidgetContainer::SetHighlightAfterDrag() |
1564 { |
1501 { |
1565 if ( AknLayoutUtils::PenEnabled() && |
1502 if ( AknLayoutUtils::PenEnabled() && |
1566 iDraggedIndex != KErrNotFound && |
1503 iDraggedIndex != KErrNotFound && |
1567 iDraggedIndex != Widget()->CurrentItemIndex() |
1504 iDraggedIndex != Widget()->CurrentItemIndex() |
1568 && iDraggedIndex < NumberOfItems() ) |
1505 && iDraggedIndex < NumberOfItems() ) |
1569 { |
1506 { |
1570 TBool isFolder(EFalse); |
1507 TBool isFolder(EFalse); |
1571 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
1508 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
1572 CHnItemModel* onItemModel = model->GetItemModel( |
1509 CHnItemModel* onItemModel = model->GetItemModel( |
1573 model->IdByIndex( Widget()->CurrentItemIndex() )); |
1510 model->IdByIndex( Widget()->CurrentItemIndex() )); |
1574 if (onItemModel) |
1511 if (onItemModel) |
1575 { |
1512 { |
1576 isFolder = onItemModel->GetItemType() == EItemTypeParentFolder || |
1513 isFolder = onItemModel->GetItemType() == EItemTypeParentFolder || |
1577 onItemModel->GetItemType() == EItemTypeFolder; |
1514 onItemModel->GetItemType() == EItemTypeFolder; |
1587 // |
1524 // |
1588 // --------------------------------------------------------------------------- |
1525 // --------------------------------------------------------------------------- |
1589 // |
1526 // |
1590 void CMmWidgetContainer::ValidateWidgetCurrentItemIndex() |
1527 void CMmWidgetContainer::ValidateWidgetCurrentItemIndex() |
1591 { |
1528 { |
1592 if (Widget()->CurrentItemIndex() >= GetMmModel()->NumberOfItems() |
1529 if (Widget()->CurrentItemIndex() >= GetMmModel()->NumberOfItems() |
1593 || Widget()->CurrentItemIndex() == KErrNotFound ) |
1530 || Widget()->CurrentItemIndex() == KErrNotFound ) |
1594 { |
1531 { |
1595 iCurrentHighlight = GetMmModel()->NumberOfItems(); |
1532 iCurrentHighlight = GetMmModel()->NumberOfItems(); |
1596 if( iCurrentHighlight > 0 ) |
1533 if( iCurrentHighlight > 0 ) |
1597 { |
1534 { |
1613 iWidgetPositionCache.iVerticalItemOffset = VerticalItemOffset(); |
1550 iWidgetPositionCache.iVerticalItemOffset = VerticalItemOffset(); |
1614 iWidgetPositionCache.iTopItemIndex = Widget()->TopItemIndex(); |
1551 iWidgetPositionCache.iTopItemIndex = Widget()->TopItemIndex(); |
1615 iWidgetPositionCache.iLandscape |
1552 iWidgetPositionCache.iLandscape |
1616 = Layout_Meta_Data::IsLandscapeOrientation(); |
1553 = Layout_Meta_Data::IsLandscapeOrientation(); |
1617 iWidgetPositionCache.iHighlightedItemId = KErrNotFound; |
1554 iWidgetPositionCache.iHighlightedItemId = KErrNotFound; |
1618 |
1555 |
1619 TInt highlightedItemIndex = Widget()->CurrentItemIndex(); |
1556 TInt highlightedItemIndex = Widget()->CurrentItemIndex(); |
1620 CHnSuiteModel* suiteModel = GetMmModel()->GetSuiteModel(); |
1557 CHnSuiteModel* suiteModel = GetMmModel()->GetSuiteModel(); |
1621 if ( suiteModel && highlightedItemIndex != KErrNotFound |
1558 if ( suiteModel && highlightedItemIndex != KErrNotFound |
1622 && suiteModel->GetSuiteHighlight() == highlightedItemIndex |
1559 && suiteModel->GetSuiteHighlight() == highlightedItemIndex |
1623 && ItemIsVisible( highlightedItemIndex ) ) |
1560 && ItemIsVisible( highlightedItemIndex ) ) |
1624 { |
1561 { |
1625 iWidgetPositionCache.iHighlightedItemId = |
1562 iWidgetPositionCache.iHighlightedItemId = |
1626 suiteModel->IdByIndex( highlightedItemIndex ); |
1563 suiteModel->IdByIndex( highlightedItemIndex ); |
1627 } |
1564 } |
1628 |
1565 |
1629 iWidgetPositionCache.iValid = ETrue; |
1566 iWidgetPositionCache.iValid = ETrue; |
1630 } |
1567 } |
1631 |
1568 |
1632 // --------------------------------------------------------------------------- |
1569 // --------------------------------------------------------------------------- |
1633 // |
1570 // |
1652 } |
1589 } |
1653 |
1590 |
1654 Widget()->View()->SetTopItemIndex(iWidgetPositionCache.iTopItemIndex); |
1591 Widget()->View()->SetTopItemIndex(iWidgetPositionCache.iTopItemIndex); |
1655 SetVerticalItemOffset(iWidgetPositionCache.iVerticalItemOffset); |
1592 SetVerticalItemOffset(iWidgetPositionCache.iVerticalItemOffset); |
1656 TRAP_IGNORE( AlignBottomOfViewL() ); |
1593 TRAP_IGNORE( AlignBottomOfViewL() ); |
1657 |
1594 |
1658 // Important: If an item that was previously highlighted and visible is |
1595 // Important: If an item that was previously highlighted and visible is |
1659 // still highlighted and yet somehow is not visible after the position |
1596 // still highlighted and yet somehow is not visible after the position |
1660 // has been restored, fix the problem by scrolling the view until that |
1597 // has been restored, fix the problem by scrolling the view until that |
1661 // item is visible again: |
1598 // item is visible again: |
1662 CHnSuiteModel* suiteModel = GetMmModel()->GetSuiteModel(); |
1599 CHnSuiteModel* suiteModel = GetMmModel()->GetSuiteModel(); |
1726 { |
1663 { |
1727 if ( AknLayoutUtils::PenEnabled() ) |
1664 if ( AknLayoutUtils::PenEnabled() ) |
1728 { |
1665 { |
1729 CacheWidgetPosition(); |
1666 CacheWidgetPosition(); |
1730 Widget()->View()->SetDisableRedraw( ETrue ); |
1667 Widget()->View()->SetDisableRedraw( ETrue ); |
1731 |
1668 |
1732 HandleNumberOfItemsChangedL( aChange ); |
1669 HandleNumberOfItemsChangedL( aChange ); |
1733 |
1670 |
1734 Widget()->View()->SetDisableRedraw( EFalse ); |
1671 Widget()->View()->SetDisableRedraw( EFalse ); |
1735 RestoreWidgetPosition(); |
1672 RestoreWidgetPosition(); |
1736 } |
1673 } |
1737 else |
1674 else |
1738 { |
1675 { |
1794 TInt lastItemIndex = NumberOfItems() - 1; |
1731 TInt lastItemIndex = NumberOfItems() - 1; |
1795 TInt viewHeight = Widget()->View()->ViewRect().Height(); |
1732 TInt viewHeight = Widget()->View()->ViewRect().Height(); |
1796 TInt lastItemBottomY = Widget()->View()->ItemPos(lastItemIndex).iY |
1733 TInt lastItemBottomY = Widget()->View()->ItemPos(lastItemIndex).iY |
1797 + Widget()->ItemHeight(); |
1734 + Widget()->ItemHeight(); |
1798 TInt pixelsToScroll( 0 ); |
1735 TInt pixelsToScroll( 0 ); |
1799 |
1736 |
1800 if ( Widget()->ScrollBarFrame()->VerticalScrollBar()->IsVisible() ) |
1737 if ( Widget()->ScrollBarFrame()->VerticalScrollBar()->IsVisible() ) |
1801 { |
1738 { |
1802 pixelsToScroll = Min( 0, lastItemBottomY - viewHeight ); |
1739 pixelsToScroll = Min( 0, lastItemBottomY - viewHeight ); |
1803 } |
1740 } |
1804 else |
1741 else |
1805 { |
1742 { |
1806 pixelsToScroll = Widget()->View()->ItemPos( firstItemIndex ).iY; |
1743 pixelsToScroll = Widget()->View()->ItemPos( firstItemIndex ).iY; |
1807 } |
1744 } |
1808 |
1745 |
1809 return pixelsToScroll; |
1746 return pixelsToScroll; |
1810 } |
1747 } |
1811 |
1748 |
1812 |
1749 |
1813 // ----------------------------------------------------------------------------- |
1750 // ----------------------------------------------------------------------------- |
1834 // ----------------------------------------------------------------------------- |
1771 // ----------------------------------------------------------------------------- |
1835 // |
1772 // |
1836 void CMmWidgetContainer::ScrollInPixelsL(TInt aPixels) |
1773 void CMmWidgetContainer::ScrollInPixelsL(TInt aPixels) |
1837 { |
1774 { |
1838 SetupScrollingEffectsL( aPixels > 0 ); |
1775 SetupScrollingEffectsL( aPixels > 0 ); |
1839 |
1776 |
1840 if ( AknLayoutUtils::PenEnabled() ) |
1777 if ( AknLayoutUtils::PenEnabled() ) |
1841 { |
1778 { |
1842 Widget()->HandlePhysicsScrollEventL(aPixels); |
1779 Widget()->HandlePhysicsScrollEventL(aPixels); |
1843 } |
1780 } |
1844 else |
1781 else |
1845 { |
1782 { |
1846 // non-touch avkon doesn't seem to support scrolling by given |
1783 // non-touch avkon doesn't seem to support scrolling by given |
1847 // amount of pixels |
1784 // amount of pixels |
1848 TInt delta = aPixels / Widget()->View()->ItemHeight(); |
1785 TInt delta = aPixels / Widget()->View()->ItemHeight(); |
1849 |
1786 |
1850 Widget()->View()->VScrollTo( Widget()->TopItemIndex() + |
1787 Widget()->View()->VScrollTo( Widget()->TopItemIndex() + |
1851 delta * ColumnsInCurrentView() ); |
1788 delta * ColumnsInCurrentView() ); |
1852 } |
1789 } |
1853 } |
1790 } |
1854 |
1791 |
1855 // ----------------------------------------------------------------------------- |
1792 // ----------------------------------------------------------------------------- |
1862 if (aIndex >= 0 && aIndex <= NumberOfItems()) |
1799 if (aIndex >= 0 && aIndex <= NumberOfItems()) |
1863 { |
1800 { |
1864 scrollConsumed = AlignBottomOfViewL(); |
1801 scrollConsumed = AlignBottomOfViewL(); |
1865 if ( !scrollConsumed && Widget()->View()->ItemIsPartiallyVisible(aIndex)) |
1802 if ( !scrollConsumed && Widget()->View()->ItemIsPartiallyVisible(aIndex)) |
1866 { |
1803 { |
1867 // the case when the item is partially visible at top or |
1804 // the case when the item is partially visible at top or |
1868 // bottom of screen. Th e view is scrolled the offset to |
1805 // bottom of screen. Th e view is scrolled the offset to |
1869 // make the item entirely visible. |
1806 // make the item entirely visible. |
1870 TInt offsetBottom = Widget()->View()->ItemPos(aIndex).iY |
1807 TInt offsetBottom = Widget()->View()->ItemPos(aIndex).iY |
1871 + Widget()->ItemHeight() |
1808 + Widget()->ItemHeight() |
1872 - Widget()->View()->ViewRect().Height(); |
1809 - Widget()->View()->ViewRect().Height(); |
1916 // ----------------------------------------------------------------------------- |
1853 // ----------------------------------------------------------------------------- |
1917 // |
1854 // |
1918 EXPORT_C void CMmWidgetContainer::PrepareForGarbage() |
1855 EXPORT_C void CMmWidgetContainer::PrepareForGarbage() |
1919 { |
1856 { |
1920 // This is called when the suite model is destoyed and the container is set to be destroyed |
1857 // This is called when the suite model is destoyed and the container is set to be destroyed |
1921 // by the garbage collector. There should be no redraws done to the widget in this period |
1858 // by the garbage collector. There should be no redraws done to the widget in this period |
1922 // because this will cause the screen to be redrawn only containing the balnk background. |
1859 // because this will cause the screen to be redrawn only containing the balnk background. |
1923 // Before garbage cleanup an asynchronous redraw event may intend to redraw the widget. |
1860 // Before garbage cleanup an asynchronous redraw event may intend to redraw the widget. |
1924 // SetDisableRedraw() prevents redrawing. Animator is also prepared for garbage so there is |
1861 // SetDisableRedraw() prevents redrawing. Animator is also prepared for garbage so there is |
1925 // no instance which can enable redraw of the widget. |
1862 // no instance which can enable redraw of the widget. |
1926 Widget()->View()->SetDisableRedraw( ETrue ); |
1863 Widget()->View()->SetDisableRedraw( ETrue ); |
1946 |
1883 |
1947 // ----------------------------------------------------------------------------- |
1884 // ----------------------------------------------------------------------------- |
1948 // |
1885 // |
1949 // ----------------------------------------------------------------------------- |
1886 // ----------------------------------------------------------------------------- |
1950 // |
1887 // |
1951 void CMmWidgetContainer::HandleLongTapEventL( const TPoint& aPenEventLocation, |
1888 void CMmWidgetContainer::HandleLongTapEventL( const TPoint& aPenEventLocation, |
1952 const TPoint& aPenEventScreenLocation ) |
1889 const TPoint& aPenEventScreenLocation ) |
1953 { |
1890 { |
1954 TInt index( KErrNotFound ); |
1891 TInt index( KErrNotFound ); |
1955 if ( iWidget->View()->XYPosToItemIndex( aPenEventLocation, index ) ) |
1892 if ( iWidget->View()->XYPosToItemIndex( aPenEventLocation, index ) ) |
1956 { |
1893 { |
1975 |
1912 |
1976 // ----------------------------------------------------------------------------- |
1913 // ----------------------------------------------------------------------------- |
1977 // |
1914 // |
1978 // ----------------------------------------------------------------------------- |
1915 // ----------------------------------------------------------------------------- |
1979 // |
1916 // |
1980 EXPORT_C void CMmWidgetContainer::HandleTopFocusL( TBool aStopTimer ) |
1917 EXPORT_C void CMmWidgetContainer::EndLongTapL( TBool aStopTimer ) |
1981 { |
1918 { |
1982 if ( iLongTapInProgress ) |
1919 if ( iLongTapInProgress ) |
1983 { |
1920 { |
1984 iLongTapInProgress = EFalse; |
1921 iLongTapInProgress = EFalse; |
1985 if( aStopTimer ) |
1922 if( aStopTimer ) |
2033 { |
1970 { |
2034 iTimer->StopL( EFalse ); |
1971 iTimer->StopL( EFalse ); |
2035 break; |
1972 break; |
2036 } |
1973 } |
2037 } |
1974 } |
2038 |
1975 |
2039 // handle different behaviour in edit mode and normal mode |
1976 // handle different behaviour in edit mode and normal mode |
2040 if ( !IsEditMode() ) |
1977 if ( !IsEditMode() ) |
2041 { |
1978 { |
2042 switch ( aEventType ) |
1979 switch ( aEventType ) |
2043 { |
1980 { |
2044 case MEikListBoxObserver::EEventFlickStarted: |
1981 case MEikListBoxObserver::EEventFlickStarted: |
2045 { |
1982 { |
2046 static_cast<CMmListBoxItemDrawer*>( |
1983 static_cast<CMmListBoxItemDrawer*>( |
2047 Widget()->View()->ItemDrawer() )-> |
1984 Widget()->View()->ItemDrawer() )-> |
2048 EnableCachedDataUse( ETrue ); |
1985 EnableCachedDataUse( ETrue ); |
2049 break; |
1986 break; |
2050 } |
1987 } |
2051 case MEikListBoxObserver::EEventFlickStopped: |
1988 case MEikListBoxObserver::EEventFlickStopped: |
2052 { |
1989 { |
2053 static_cast<CMmListBoxItemDrawer*>( |
1990 static_cast<CMmListBoxItemDrawer*>( |
2054 Widget()->View()->ItemDrawer() )-> |
1991 Widget()->View()->ItemDrawer() )-> |
2055 EnableCachedDataUse( EFalse ); |
1992 EnableCachedDataUse( EFalse ); |
2056 DrawView(); |
1993 DrawView(); |
2057 break; |
1994 break; |
2058 } |
1995 } |
2059 } |
1996 } |
2060 } |
1997 } |
2061 else |
1998 else |
2062 { |
1999 { |
2063 switch ( aEventType ) |
2000 switch ( aEventType ) |
2064 { |
2001 { |
2065 case MEikListBoxObserver::EEventFlickStopped: |
2002 case MEikListBoxObserver::EEventFlickStopped: |
2066 { |
2003 { |
2067 // this fixes some problems with messed edit mode |
2004 // this fixes some problems with messed edit mode |
2068 // caused by kinetic scrolling |
2005 // caused by kinetic scrolling |
2069 iDrawer->GetAnimator()->SetNextRedrawToWholeScreen(); |
2006 iDrawer->GetAnimator()->SetNextRedrawToWholeScreen(); |
2070 break; |
2007 break; |
2071 } |
2008 } |
2072 } |
2009 } |
2073 } |
2010 } |
2074 |
2011 |
2075 if ( iListBoxObserver && !iLongTapInProgress ) |
2012 if ( iListBoxObserver && !iLongTapInProgress ) |
2076 { |
2013 { |
2077 iListBoxObserver->HandleListBoxEventL( aListBox, aEventType ); |
2014 iListBoxObserver->HandleListBoxEventL( aListBox, aEventType ); |
2078 } |
2015 } |
2079 |
2016 |
2080 } |
2017 } |
2081 |
2018 |
2082 // --------------------------------------------------------------------------- |
2019 // --------------------------------------------------------------------------- |
2083 // |
2020 // |
2084 // --------------------------------------------------------------------------- |
2021 // --------------------------------------------------------------------------- |
2085 // |
2022 // |
2086 EXPORT_C void CMmWidgetContainer::HandleOptionsMenuVisibilityChangeL( |
2023 EXPORT_C void CMmWidgetContainer::HandleOptionsMenuVisibilityChangeL( |
2087 TBool aOptionsMenuVisible ) |
2024 TBool aOptionsMenuVisible ) |
2088 { |
2025 { |
2089 if ( IsTimerActive() ) |
2026 if ( IsTimerActive() ) |
2090 { |
2027 { |
2091 TInt delay = (aOptionsMenuVisible) ? KDelayInfinite : KDelayInSeconds6; |
2028 TInt delay = (aOptionsMenuVisible) ? KDelayInfinite : KDelayInSeconds6; |