1 /* |
1 /* |
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
107 const TPoint& aPoint ) const; |
107 const TPoint& aPoint ) const; |
108 |
108 |
109 |
109 |
110 public: // data |
110 public: // data |
111 TInt iFlags; |
111 TInt iFlags; |
112 // EMMA-7A8B9F.Ugly hack. Prevent MopSupplyObject being invoked |
112 |
113 // from CEikListBox::MopGetObject() |
113 // This is used to prevent MopSupplyObject being invoked |
|
114 // from CEikListBox::MopGetObject(). |
114 TBool iIsFromBaseClass; |
115 TBool iIsFromBaseClass; |
|
116 |
115 TPoint iLastPoint; |
117 TPoint iLastPoint; |
116 TBool iKineticScrolling; |
|
117 TBool iSingleClickEnabled; |
118 TBool iSingleClickEnabled; |
118 }; |
119 }; |
119 |
120 |
120 CAknGridExtension::CAknGridExtension() |
121 CAknGridExtension::CAknGridExtension() |
121 : |
122 : |
122 iFlags(0), |
123 iFlags(0), |
123 iIsFromBaseClass( EFalse ), |
124 iIsFromBaseClass( EFalse ), |
124 iLastPoint( 0, 0 ), |
125 iLastPoint( 0, 0 ), |
125 iKineticScrolling( CAknPhysics::FeatureEnabled() ), |
|
126 iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() ) |
126 iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() ) |
127 { |
127 { |
128 } |
128 } |
129 |
129 |
130 CAknGridExtension::~CAknGridExtension() |
130 CAknGridExtension::~CAknGridExtension() |
658 // because of iSBFrame->VerticalScrollBar owning window. |
658 // because of iSBFrame->VerticalScrollBar owning window. |
659 if( iSBFrame && TRect(iSBFrame->VerticalScrollBar()->Position(), |
659 if( iSBFrame && TRect(iSBFrame->VerticalScrollBar()->Position(), |
660 iSBFrame->VerticalScrollBar()->Size()).Contains ( aPointerEvent.iPosition )) |
660 iSBFrame->VerticalScrollBar()->Size()).Contains ( aPointerEvent.iPosition )) |
661 { |
661 { |
662 if ( !ScrollingDisabled() |
662 if ( !ScrollingDisabled() |
|
663 && iExtension |
663 && iExtension->iFlags & EAknGridStateButton1DownInGrid ) |
664 && iExtension->iFlags & EAknGridStateButton1DownInGrid ) |
664 { |
665 { |
665 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
666 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
666 { |
667 { |
667 iExtension->iFlags &= ~EAknGridStateButton1DownInGrid; |
668 iExtension->iFlags &= ~EAknGridStateButton1DownInGrid; |
685 |
686 |
686 // switch pointer event type and set button 1 down in grid flag on and off depending where event happened. |
687 // switch pointer event type and set button 1 down in grid flag on and off depending where event happened. |
687 switch (aPointerEvent.iType) |
688 switch (aPointerEvent.iType) |
688 { |
689 { |
689 case TPointerEvent::EButton1Down: |
690 case TPointerEvent::EButton1Down: |
690 iExtension->iLastPoint = aPointerEvent.iPosition; |
691 { |
691 if ( visibleItemsRect.Contains(aPointerEvent.iPosition) ) |
692 if( iExtension ) |
692 { |
693 { |
693 iExtension->iFlags |= EAknGridStateButton1DownInGrid; |
694 iExtension->iLastPoint = aPointerEvent.iPosition; |
694 } |
695 if ( visibleItemsRect.Contains(aPointerEvent.iPosition) ) |
|
696 { |
|
697 iExtension->iFlags |= EAknGridStateButton1DownInGrid; |
|
698 } |
|
699 } |
695 _AKNTRACE( "TPointerEvent::EButton1Down" ); |
700 _AKNTRACE( "TPointerEvent::EButton1Down" ); |
696 break; |
701 break; |
697 |
702 } |
|
703 |
698 case TPointerEvent::EButton1Up: |
704 case TPointerEvent::EButton1Up: |
699 { |
705 { |
700 iExtension->iFlags &= ~EAknGridStateButton1DownInGrid; |
706 if ( iExtension ) |
|
707 { |
|
708 iExtension->iFlags &= ~EAknGridStateButton1DownInGrid; |
|
709 } |
701 _AKNTRACE( "TPointerEvent::EButton1Up" ); |
710 _AKNTRACE( "TPointerEvent::EButton1Up" ); |
702 break; |
711 break; |
703 } |
712 } |
704 |
713 |
705 default: |
714 default: |
1085 else |
1094 else |
1086 selectionMode = CListBoxView::ENoSelection; |
1095 selectionMode = CListBoxView::ENoSelection; |
1087 } |
1096 } |
1088 |
1097 |
1089 // With single click first key event enables highlight |
1098 // With single click first key event enables highlight |
1090 if ( iExtension->iSingleClickEnabled |
1099 if ( iExtension |
|
1100 && iExtension->iSingleClickEnabled |
1091 && ItemDrawer()->Flags() |
1101 && ItemDrawer()->Flags() |
1092 & CListItemDrawer::ESingleClickDisabledHighlight ) |
1102 & CListItemDrawer::ESingleClickDisabledHighlight ) |
1093 { |
1103 { |
1094 if ( aKeyEvent.iCode == EKeyUpArrow || |
1104 if ( aKeyEvent.iCode == EKeyUpArrow || |
1095 aKeyEvent.iCode == EKeyDownArrow || |
1105 aKeyEvent.iCode == EKeyDownArrow || |
1334 } |
1344 } |
1335 |
1345 |
1336 EXPORT_C void CAknGrid::HandleResourceChange(TInt aType) |
1346 EXPORT_C void CAknGrid::HandleResourceChange(TInt aType) |
1337 { |
1347 { |
1338 _AKNTRACE_FUNC_ENTER; |
1348 _AKNTRACE_FUNC_ENTER; |
1339 // Need to do this to set up the scroll bar model |
1349 if ( aType != KEikMessageWindowsFadeChange && |
1340 TRAP_IGNORE( UpdateScrollBarsL() ); |
1350 aType != KEikMessageUnfadeWindows && |
|
1351 aType != KEikMessageFadeAllWindows && |
|
1352 aType != KEikMessageColorSchemeChange && |
|
1353 aType != KAknsMessageSkinChange ) |
|
1354 { |
|
1355 // Need to do this to set up the scroll bar model |
|
1356 TRAP_IGNORE( UpdateScrollBarsL() ); |
|
1357 } |
|
1358 |
1341 |
1359 |
1342 if (aType==KEikDynamicLayoutVariantSwitch) |
1360 if (aType==KEikDynamicLayoutVariantSwitch) |
1343 { |
1361 { |
1344 CAknGridView* gridView = GridView(); |
1362 CAknGridView* gridView = GridView(); |
1345 |
1363 |
1389 CEikListBox::HandleResourceChange(aType); |
1407 CEikListBox::HandleResourceChange(aType); |
1390 |
1408 |
1391 TRAP_IGNORE( ItemDrawer()->FormattedCellData()->SetupSkinContextL()); |
1409 TRAP_IGNORE( ItemDrawer()->FormattedCellData()->SetupSkinContextL()); |
1392 // Data extension has animations which will change when skin changes. |
1410 // Data extension has animations which will change when skin changes. |
1393 ItemDrawer()->FormattedCellData()->HandleResourceChange( aType ); |
1411 ItemDrawer()->FormattedCellData()->HandleResourceChange( aType ); |
1394 |
1412 |
1395 // Need to do this to set up the scroll bar model |
1413 if ( aType != KEikMessageWindowsFadeChange && |
1396 TRAP_IGNORE( UpdateScrollBarsL() ); |
1414 aType != KEikMessageUnfadeWindows && |
|
1415 aType != KEikMessageFadeAllWindows && |
|
1416 aType != KEikMessageColorSchemeChange && |
|
1417 aType != KAknsMessageSkinChange ) |
|
1418 { |
|
1419 // Need to do this to set up the scroll bar model |
|
1420 TRAP_IGNORE( UpdateScrollBarsL() ); |
|
1421 } |
|
1422 |
1397 _AKNTRACE_FUNC_EXIT; |
1423 _AKNTRACE_FUNC_EXIT; |
1398 } |
1424 } |
1399 |
1425 |
1400 |
1426 |
1401 EXPORT_C void CAknGrid::FocusChanged( TDrawNow aDrawNow ) |
1427 EXPORT_C void CAknGrid::FocusChanged( TDrawNow aDrawNow ) |
1479 newTopRow = currRow - rowsFitInView + 1; |
1505 newTopRow = currRow - rowsFitInView + 1; |
1480 newTopRow = Max( 0, newTopRow ); |
1506 newTopRow = Max( 0, newTopRow ); |
1481 |
1507 |
1482 // and calculate new top item index |
1508 // and calculate new top item index |
1483 TInt topItemIndex = newTopRow * iNumOfColsInView ; |
1509 TInt topItemIndex = newTopRow * iNumOfColsInView ; |
1484 iView->SetItemOffsetInPixels(0); |
1510 if ( topItemIndex > KErrNotFound |
1485 SetTopItemIndex(topItemIndex); |
1511 && topItemIndex < iModel->NumberOfItems() ) |
|
1512 { |
|
1513 iView->SetItemOffsetInPixels( 0 ); |
|
1514 SetTopItemIndex( topItemIndex ); |
|
1515 } |
1486 } |
1516 } |
1487 _AKNTRACE_FUNC_EXIT; |
1517 _AKNTRACE_FUNC_EXIT; |
1488 } |
1518 } |
1489 |
1519 |
1490 EXPORT_C void CAknGrid::HandleDragEventL(TPoint aPointerPos) |
1520 EXPORT_C void CAknGrid::HandleDragEventL(TPoint aPointerPos) |
1513 TBool pointerIsOverAnItem = gridView->XYPosToItemIndex(aPointerPos, itemIndex); |
1543 TBool pointerIsOverAnItem = gridView->XYPosToItemIndex(aPointerPos, itemIndex); |
1514 // SERIES60 LAF |
1544 // SERIES60 LAF |
1515 CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection; |
1545 CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection; |
1516 // CListBoxView::TSelectionMode selectionMode = (iListBoxFlags & EMultipleSelection) ? CListBoxView::EContiguousSelection : CListBoxView::ESingleSelection; |
1546 // CListBoxView::TSelectionMode selectionMode = (iListBoxFlags & EMultipleSelection) ? CListBoxView::EContiguousSelection : CListBoxView::ESingleSelection; |
1517 // END OF SERIES60 LAF |
1547 // END OF SERIES60 LAF |
1518 TInt speed = iExtension->GetScrollingSpeed( pointerIsOverAnItem, itemIndex, |
1548 TInt speed = iExtension ? iExtension->GetScrollingSpeed( pointerIsOverAnItem, itemIndex, |
1519 *gridView, aPointerPos ); |
1549 *gridView, aPointerPos ):0; |
1520 |
1550 |
1521 TInt oldCurrentItemIndex = CurrentItemIndex(); |
1551 TInt oldCurrentItemIndex = CurrentItemIndex(); |
1522 TRect currentItemRect(gridView->ItemPos(oldCurrentItemIndex), gridView->ItemSize(oldCurrentItemIndex)); |
1552 TRect currentItemRect(gridView->ItemPos(oldCurrentItemIndex), gridView->ItemSize(oldCurrentItemIndex)); |
1523 TInt numOfRows = Max(GridView()->GridCellDimensions().iHeight,1); |
1553 TInt numOfRows = Max(GridView()->GridCellDimensions().iHeight,1); |
1524 const TInt placesInGrid = numOfRows * iNumOfColsInView; |
1554 const TInt placesInGrid = numOfRows * iNumOfColsInView; |
1841 |
1871 |
1842 vSbarModel.iThumbPosition = row; |
1872 vSbarModel.iThumbPosition = row; |
1843 // EHXA-7AQ8N4. Only set it to 0 can make scrollbar empty. |
1873 // EHXA-7AQ8N4. Only set it to 0 can make scrollbar empty. |
1844 vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? |
1874 vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? |
1845 gridSize.iHeight : 0; |
1875 gridSize.iHeight : 0; |
1846 vSbarModel.iThumbSpan = gridView->NumberOfRowsInView(); |
|
1847 vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? |
1876 vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? |
1848 gridSize.iHeight*iView->ItemHeight() : 0; |
1877 gridSize.iHeight*iView->ItemHeight() : 0; |
1849 vSbarModel.iThumbSpan = rect.Height(); |
1878 vSbarModel.iThumbSpan = rect.Height(); |
1850 |
1879 |
1851 if (iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan) |
1880 if (iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan) |
1858 vSbarModel.iThumbPosition = topRow; |
1887 vSbarModel.iThumbPosition = topRow; |
1859 } |
1888 } |
1860 if (vSbarModel.iScrollSpan-vSbarModel.iThumbPosition<vSbarModel.iThumbSpan) |
1889 if (vSbarModel.iScrollSpan-vSbarModel.iThumbPosition<vSbarModel.iThumbSpan) |
1861 { |
1890 { |
1862 vSbarModel.iThumbPosition=Max(0,vSbarModel.iScrollSpan-vSbarModel.iThumbSpan); |
1891 vSbarModel.iThumbPosition=Max(0,vSbarModel.iScrollSpan-vSbarModel.iThumbSpan); |
1863 gridView->MoveToItemIndexL(currentIndex,CListBoxView::ENoSelection); // force a scroll if neccessary |
1892 if ( iExtension && !iExtension->iSingleClickEnabled ) |
|
1893 { |
|
1894 // force a scroll if neccessary |
|
1895 gridView->MoveToItemIndexL( currentIndex, |
|
1896 CListBoxView::ENoSelection ); |
|
1897 } |
1864 } |
1898 } |
1865 } |
1899 } |
1866 if (iSBFrame->ScrollBarVisibility(CEikScrollBar::EHorizontal)!=CEikScrollBarFrame::EOff) |
1900 if (iSBFrame->ScrollBarVisibility(CEikScrollBar::EHorizontal)!=CEikScrollBarFrame::EOff) |
1867 { |
1901 { |
1868 GridView()->CalcDataWidth(); |
1902 GridView()->CalcDataWidth(); |