526 void CCmDestinationIconMap::HandlePointerEventL( |
527 void CCmDestinationIconMap::HandlePointerEventL( |
527 const TPointerEvent& aPointerEvent ) |
528 const TPointerEvent& aPointerEvent ) |
528 { |
529 { |
529 if ( AknLayoutUtils::PenEnabled() ) |
530 if ( AknLayoutUtils::PenEnabled() ) |
530 { |
531 { |
531 TInt newGridX; // For the whole |
532 TInt xInPixels = aPointerEvent.iPosition.iX - iGridTopLeft.iX; |
532 TInt newGridY; // For the whole grid. |
|
533 TInt yInPixels = aPointerEvent.iPosition.iY - iGridTopLeft.iY; |
533 TInt yInPixels = aPointerEvent.iPosition.iY - iGridTopLeft.iY; |
534 newGridY = yInPixels / iGridItemHeight; |
534 TInt newGridX = xInPixels / iGridItemWidth; |
535 if ( ( aPointerEvent.iPosition.iX - iGridTopLeft.iX ) < 0 ) |
535 TInt newGridY = yInPixels / iGridItemHeight; |
536 { |
536 TInt globalY = newGridY + iFirstVisibleRow; |
537 newGridX = -1; |
|
538 } |
|
539 else |
|
540 { |
|
541 newGridX = ( aPointerEvent.iPosition.iX - iGridTopLeft.iX ) |
|
542 / iGridItemWidth; |
|
543 } |
|
544 |
537 |
545 // The pointer has been set down or dragged into the area of the grid. |
538 // The pointer has been set down or dragged into the area of the grid. |
546 // (it might be in the "white space" at the end of the grid) |
539 // Also, it may NOT be in the "empty slots" at the end of the grid. |
547 if ( ( yInPixels >= 0 && yInPixels < iGridItemHeight |
540 if ( xInPixels >= 0 && |
548 * iExtension->iMaxVisibleRows) && |
541 yInPixels >= 0 && |
549 // When the pointer is in rows except the recent icon row |
542 newGridX < iMaxColumns && |
550 ( ( ( ( newGridY + iFirstVisibleRow ) != 0 ) && |
543 yInPixels < iGridItemHeight * iExtension->iMaxVisibleRows && |
551 newGridX < iMaxColumns && newGridX >= 0 ) || |
544 globalY * iMaxColumns + newGridX + 1 <= iConsArray->Count() ) |
552 // When the pointer is in the recent icon row |
545 { |
553 ( ( newGridY + iFirstVisibleRow == 0 ) && |
|
554 ( newGridX < iMaxColumns ) ) ) ) |
|
555 { |
|
556 TUint globalY = newGridY + iFirstVisibleRow; |
|
557 // For any action to be taken, the pointer event must either be a |
546 // For any action to be taken, the pointer event must either be a |
558 // Button1Down or a drag event which has originated from a |
547 // Button1Down or a drag event which has originated from a |
559 // Button1Down in to the grid. |
548 // Button1Down in to the grid. |
560 if ( aPointerEvent.iType == TPointerEvent::EButton1Down || |
549 if ( aPointerEvent.iType == TPointerEvent::EButton1Down || |
561 aPointerEvent.iType == TPointerEvent::EDrag ) |
550 aPointerEvent.iType == TPointerEvent::EDrag ) |
1072 else // not mirrored |
1063 else // not mirrored |
1073 pos.iX += iGridItemWidth; |
1064 pos.iX += iGridItemWidth; |
1074 } |
1065 } |
1075 } |
1066 } |
1076 |
1067 |
1077 TInt iconIndex = ( iCurrentPage - 1 ) * |
1068 TInt iconIndex = iFirstVisibleRow * iMaxColumns; |
1078 ( iMaxColumns * iExtension->iMaxVisibleRows ); |
1069 TInt lCnt = iConsArray->Count(); |
1079 TInt lCnt = iConsArray->Count(); |
|
1080 cursorPos = iCursorPos.iX + iCursorPos.iY * iMaxColumns; |
1070 cursorPos = iCursorPos.iX + iCursorPos.iY * iMaxColumns; |
1081 if ( lCnt > 0 ) |
1071 if ( lCnt > 0 ) |
1082 { |
1072 { |
1083 TRect cellRect( TPoint( 0,0 ), |
1073 TRect cellRect( TPoint( 0,0 ), |
1084 TSize( iGridItemWidth - 1, iGridItemHeight - 1 ) ); |
1074 TSize( iGridItemWidth - 1, iGridItemHeight - 1 ) ); |
1085 for ( TInt j = iconIndex, i = 0; |
1075 for ( TInt j = iconIndex, i = 0; |
1086 j < lCnt && i < numberOfIconsToBeDrawn; |
1076 j < lCnt && i < numberOfIconsToBeDrawn; |
1087 j++, i++ ) |
1077 j++, i++ ) |
1088 { |
1078 { |
1089 DrawItem( gc, CursorRect( i ), j, cursorPos == i, EFalse ); |
1079 DrawItem( gc, i, j, cursorPos == i, EFalse ); |
1090 } |
1080 } |
1091 } |
1081 } |
1092 |
1082 |
1093 } |
1083 } |
1094 iDrawnBefore = ETrue; |
1084 iDrawnBefore = ETrue; |
1099 // CCmDestinationIconMap::DrawItem() |
1089 // CCmDestinationIconMap::DrawItem() |
1100 // ----------------------------------------------------------------------------- |
1090 // ----------------------------------------------------------------------------- |
1101 // |
1091 // |
1102 void CCmDestinationIconMap::DrawItem( |
1092 void CCmDestinationIconMap::DrawItem( |
1103 CWindowGc& aGc, |
1093 CWindowGc& aGc, |
1104 const TRect& aSctPosition, |
1094 TInt index, |
1105 TInt aIconIndex, |
1095 TInt aIconIndex, |
1106 TBool aHighlighted, |
1096 TBool aHighlighted, |
1107 TBool aDrawBackground ) const |
1097 TBool aDrawBackground ) const |
1108 { |
1098 { |
|
1099 TRect sctPosition = CursorRect( index ); |
1109 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
1100 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
1110 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
1101 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
1111 |
1102 |
1112 TBool skins = AknsDrawUtils::Background( skin,cc,aGc, aSctPosition ); |
1103 TBool skins = AknsDrawUtils::Background( skin,cc,aGc, sctPosition ); |
1113 TRgb color; |
1104 TRgb color; |
1114 if ( !skins ) |
1105 if ( !skins ) |
|
1106 { |
1115 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
1107 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1108 } |
|
1109 |
1116 if ( aHighlighted ) |
1110 if ( aHighlighted ) |
1117 { |
1111 { |
1118 TRgb colorHightLightRect = AKN_LAF_COLOR( 215 ); |
1112 TRgb colorHightLightRect = AKN_LAF_COLOR( 215 ); |
1119 AknsUtils::GetCachedColor( skin, |
1113 AknsUtils::GetCachedColor( skin, |
1120 colorHightLightRect, |
1114 colorHightLightRect, |
1121 KAknsIIDQsnLineColors, |
1115 KAknsIIDQsnLineColors, |
1122 EAknsCIQsnLineColorsCG7 ); |
1116 EAknsCIQsnLineColorsCG7 ); |
1123 aGc.SetPenColor( colorHightLightRect ); |
1117 aGc.SetPenColor( colorHightLightRect ); |
1124 aGc.DrawRect( aSctPosition ); |
1118 aGc.DrawRect( sctPosition ); |
1125 |
1119 |
1126 // Shrink by one pixel in all directions. |
1120 // Shrink by one pixel in all directions. |
1127 TRect innerRect = aSctPosition; |
1121 TRect innerRect = sctPosition; |
1128 innerRect.Shrink( 1,1 ); |
1122 innerRect.Shrink( 1,1 ); |
1129 |
1123 |
1130 color = AKN_LAF_COLOR( 210 ); |
1124 color = AKN_LAF_COLOR( 210 ); |
1131 AknsUtils::GetCachedColor( skin, |
1125 AknsUtils::GetCachedColor( skin, |
1132 color, |
1126 color, |
1569 TRect parent = gridWithScrollLayRect.Rect(); |
1557 TRect parent = gridWithScrollLayRect.Rect(); |
1570 |
1558 |
1571 TAknWindowComponentLayout scrollbarLayout = |
1559 TAknWindowComponentLayout scrollbarLayout = |
1572 AknLayoutScalable_Avkon::scroll_pane_cp5(); |
1560 AknLayoutScalable_Avkon::scroll_pane_cp5(); |
1573 |
1561 |
1574 iCurrentPage = ( iFirstVisibleRow / iExtension->iMaxVisibleRows ) + 1; |
1562 vSbarModel.iScrollSpan = iRows; |
1575 |
|
1576 vSbarModel.iScrollSpan = iNumPages * iExtension->iMaxVisibleRows; |
|
1577 vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows; |
1563 vSbarModel.iThumbSpan = iExtension->iMaxVisibleRows; |
1578 |
1564 |
1579 if ( iSBFrame && iSBFrame->TypeOfVScrollBar() == |
1565 if ( iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan ) |
1580 CEikScrollBarFrame::EDoubleSpan ) |
|
1581 { |
1566 { |
1582 // For EDoubleSpan type scrollbar |
1567 // For EDoubleSpan type scrollbar |
1583 vSbarModel.iThumbPosition = ( iCurrentPage - 1 ) * |
1568 vSbarModel.iThumbPosition = iFirstVisibleRow; |
1584 iExtension->iMaxVisibleRows; |
|
1585 TAknDoubleSpanScrollBarModel hDsSbarModel( hSbarModel ); |
1569 TAknDoubleSpanScrollBarModel hDsSbarModel( hSbarModel ); |
1586 TAknDoubleSpanScrollBarModel vDsSbarModel( vSbarModel ); |
1570 TAknDoubleSpanScrollBarModel vDsSbarModel( vSbarModel ); |
1587 |
1571 |
1588 // The y coordinate must be sifted 3 pixels up and x 3 to left |
1572 // The y coordinate must be sifted 3 pixels up and x 3 to left |
1589 parent.iTl.iY -= KVerticalDialogMargin; |
1573 parent.iTl.iY -= KVerticalDialogMargin; |
1911 { |
1896 { |
1912 case EEikScrollUp: |
1897 case EEikScrollUp: |
1913 case EEikScrollPageUp: |
1898 case EEikScrollPageUp: |
1914 { |
1899 { |
1915 // nothing done if we are already on the first page. |
1900 // nothing done if we are already on the first page. |
1916 if ( iFirstVisibleRow != 0 ) |
1901 if ( iFirstVisibleRow > 0 ) |
1917 { |
1902 { |
1918 iFirstVisibleRow -= iExtension->iMaxVisibleRows; |
1903 iFirstVisibleRow -= iExtension->iMaxVisibleRows; |
|
1904 if ( iFirstVisibleRow < 0 ) |
|
1905 { |
|
1906 iFirstVisibleRow = 0; |
|
1907 } |
1919 update = ETrue; |
1908 update = ETrue; |
1920 } |
1909 } |
1921 UpdateScrollIndicatorL(); |
1910 UpdateScrollIndicatorL(); |
1922 } |
1911 } |
1923 break; |
1912 break; |
1924 |
1913 |
1925 case EEikScrollDown: |
1914 case EEikScrollDown: |
1926 case EEikScrollPageDown: |
1915 case EEikScrollPageDown: |
1927 { |
1916 { |
1928 // nothing done if we are already on the last page. |
1917 // nothing done if we are already on the last page. |
1929 if ( iFirstVisibleRow != iRows/iExtension->iMaxVisibleRows * |
1918 if ( iFirstVisibleRow < iRows - iExtension->iMaxVisibleRows ) |
1930 iExtension->iMaxVisibleRows ) |
|
1931 { |
1919 { |
1932 iFirstVisibleRow += iExtension->iMaxVisibleRows; |
1920 iFirstVisibleRow += iExtension->iMaxVisibleRows; |
|
1921 if ( iFirstVisibleRow > iRows - iExtension->iMaxVisibleRows ) |
|
1922 { |
|
1923 iFirstVisibleRow = iRows - iExtension->iMaxVisibleRows; |
|
1924 } |
1933 update = ETrue; |
1925 update = ETrue; |
1934 } |
1926 } |
1935 UpdateScrollIndicatorL(); |
1927 UpdateScrollIndicatorL(); |
1936 } |
1928 } |
1937 break; |
1929 break; |
1938 |
1930 |
1939 case EEikScrollThumbDragVert: |
1931 case EEikScrollThumbDragVert: |
1940 { |
1932 { |
1941 TInt thumbPosition; |
|
1942 TInt halfPage = iExtension->iMaxVisibleRows/2; |
|
1943 // Ask which type of scrollbar is shown |
1933 // Ask which type of scrollbar is shown |
1944 //CAknAppUi* appUi = iAvkonAppUi; |
1934 TInt thumbPosition; |
|
1935 TBool isDoubleSpan = ( CEikScrollBarFrame::EDoubleSpan == iSBFrame->TypeOfVScrollBar() ); |
|
1936 if ( isDoubleSpan ) |
|
1937 { |
|
1938 thumbPosition = static_cast <const TAknDoubleSpanScrollBarModel*>( |
|
1939 aScrollBar->Model() )->FocusPosition(); |
|
1940 } |
|
1941 else |
|
1942 { |
|
1943 thumbPosition = aScrollBar->Model()->iThumbPosition; |
|
1944 } |
|
1945 |
|
1946 if ( thumbPosition != iFirstVisibleRow ) |
|
1947 { |
|
1948 iFirstVisibleRow = thumbPosition; |
|
1949 update = ETrue; |
|
1950 } |
|
1951 } |
|
1952 break; |
|
1953 |
|
1954 case EEikScrollThumbReleaseVert: |
|
1955 { |
|
1956 // Ask which type of scrollbar is shown |
1945 TBool isDoubleSpan = |
1957 TBool isDoubleSpan = |
1946 CEikScrollBarFrame::EDoubleSpan == iSBFrame->TypeOfVScrollBar(); |
1958 CEikScrollBarFrame::EDoubleSpan == iSBFrame->TypeOfVScrollBar(); |
1947 if ( isDoubleSpan ) |
1959 if ( isDoubleSpan ) |
1948 { |
1960 { |
1949 thumbPosition = static_cast <const TAknDoubleSpanScrollBarModel*>( |
1961 iFirstVisibleRow = static_cast <const TAknDoubleSpanScrollBarModel*>( |
1950 aScrollBar->Model() )->FocusPosition(); |
1962 aScrollBar->Model() )->FocusPosition(); |
1951 } |
1963 } |
1952 else |
1964 else |
1953 { |
1965 { |
1954 thumbPosition = aScrollBar->Model()->iThumbPosition; |
1966 iFirstVisibleRow = aScrollBar->Model()->iThumbPosition; |
1955 } |
1967 } |
1956 |
1968 update = ETrue; |
1957 // If the slider is in the range of less then a half page from a |
|
1958 // possible correct thumb position. thus 0 <= iFirstVisibleRow - |
|
1959 // thumbPosition < halfPage. Or in the other direction: |
|
1960 // 0 <= thumbPosition - iFirstVisibleRow < halfPage |
|
1961 if ( !( ( 0 <= iFirstVisibleRow - thumbPosition && |
|
1962 iFirstVisibleRow - thumbPosition < halfPage )|| |
|
1963 ( 0 <= thumbPosition - iFirstVisibleRow && |
|
1964 thumbPosition - iFirstVisibleRow < halfPage ) ) ) |
|
1965 { |
|
1966 TReal toRound = thumbPosition / |
|
1967 ( TReal )iExtension->iMaxVisibleRows; |
|
1968 if ( toRound * 2 > ( TInt )toRound * 2 + 1 ) |
|
1969 { |
|
1970 toRound++; |
|
1971 } |
|
1972 iFirstVisibleRow = ( TInt )toRound * |
|
1973 iExtension->iMaxVisibleRows; |
|
1974 update = ETrue; |
|
1975 } |
|
1976 } |
|
1977 break; |
|
1978 |
|
1979 case EEikScrollThumbReleaseVert: |
|
1980 { |
|
1981 UpdateScrollIndicatorL(); |
1969 UpdateScrollIndicatorL(); |
1982 } |
1970 } |
1983 break; |
1971 break; |
1984 |
1972 |
1985 case EEikScrollLeft: // flow through |
1973 case EEikScrollLeft: // flow through |
1986 case EEikScrollRight: // flow through |
1974 case EEikScrollRight: // flow through |
1987 case EEikScrollPageLeft: // flow through |
1975 case EEikScrollPageLeft: // flow through |
1988 case EEikScrollPageRight: // flow through |
1976 case EEikScrollPageRight: // flow through |
1989 case EEikScrollThumbDragHoriz: // flow through |
1977 case EEikScrollThumbDragHoriz: // flow through |
1990 case EEikScrollThumbReleaseHoriz: // flow through |
1978 case EEikScrollThumbReleaseHoriz: // flow through |
1991 // do nothing |
|
1992 break; |
|
1993 |
|
1994 default: |
1979 default: |
1995 // do nothing |
1980 // do nothing |
1996 break; |
1981 break; |
1997 } |
1982 } |
1998 |
1983 |
1999 // If we have moved down to the last page we check that the cursor is in |
|
2000 // a place where it can be drawn. |
|
2001 if ( iFirstVisibleRow == |
|
2002 iRows/iExtension->iMaxVisibleRows * iExtension->iMaxVisibleRows ) |
|
2003 { |
|
2004 // the old cursor is set to a "safe" position where it at least can be. |
|
2005 iOldCursorPos.iX = 0; |
|
2006 iOldCursorPos.iY = 0; |
|
2007 // if the last page has only one line which isn't filled complitely. |
|
2008 if ( ( iConsArray->Count() % iMaxColumns - 1 < iCursorPos.iX ) && |
|
2009 ( iRows % iExtension->iMaxVisibleRows ) == 1 ) |
|
2010 { |
|
2011 iCursorPos.iX = iConsArray->Count()%iMaxColumns - 1; |
|
2012 } |
|
2013 // If the cursor is in a position where it would go unto a spot without |
|
2014 // a icon when scrolled. |
|
2015 if ( iCursorPos.iY + iFirstVisibleRow >= iRows ) |
|
2016 { |
|
2017 if ( iConsArray->Count() % iMaxColumns > iCursorPos.iX ) |
|
2018 { |
|
2019 iCursorPos.iY = iRows - 1 - iFirstVisibleRow; |
|
2020 } |
|
2021 else |
|
2022 { |
|
2023 iCursorPos.iY = iRows - 2 - iFirstVisibleRow; |
|
2024 } |
|
2025 } |
|
2026 // If the cursor is actually on the last row, but is still in the |
|
2027 // area where there is now icons. ( the rest of the last row ) |
|
2028 if ( ( iConsArray->Count() <= ( iFirstVisibleRow + iCursorPos.iY ) |
|
2029 * iMaxColumns + iCursorPos.iX ) && |
|
2030 ( iCursorPos.iY + iFirstVisibleRow + 1 == iRows ) ) |
|
2031 { |
|
2032 iCursorPos.iY--; |
|
2033 } |
|
2034 // if the corrections did not help and the cursor is in the area |
|
2035 // where there is a valid row, but no icons anymore |
|
2036 } |
|
2037 |
|
2038 // to avoid flicker we draw only if there really was something new to draw. |
1984 // to avoid flicker we draw only if there really was something new to draw. |
2039 if ( update ) |
1985 if ( update ) |
2040 { |
1986 { |
2041 if ( iExtension->iObserver ) |
1987 if ( iExtension->iObserver ) |
2042 { |
1988 { |