menufw/menufwui/mmwidgets/src/mmwidgetcontainer.cpp
branchRCL_3
changeset 102 ba63c83f4716
parent 88 3321d3e205b6
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
    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.75 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: MM_71.1.17.1.70.2.1 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include <e32keys.h>
    19 #include <e32keys.h>
    20 #include <e32math.h>
    20 #include <e32math.h>
   109     , iLongTapDetector( NULL )
   109     , iLongTapDetector( NULL )
   110     , iAllowMove( EFalse )
   110     , iAllowMove( EFalse )
   111     , iRecipientId( KErrNotFound )
   111     , iRecipientId( KErrNotFound )
   112     , iEventParameters( NULL )
   112     , iEventParameters( NULL )
   113     , iDialogOpened( EFalse )
   113     , iDialogOpened( EFalse )
   114     , iHighlightVisibleBeforeLongTap( EFalse )    
   114     , iHighlightVisibleBeforeLongTap( EFalse )
   115     , iResetHighlight( EFalse )
       
   116     {
   115     {
   117     iWidgetPositionCache.iValid = EFalse;
   116     iWidgetPositionCache.iValid = EFalse;
   118     }
   117     }
   119 
   118 
   120 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   214     if( !iWidget->View()->XYPosToItemIndex(
   213     if( !iWidget->View()->XYPosToItemIndex(
   215             aPointerEvent.iPosition, iDraggedIndex ) )
   214             aPointerEvent.iPosition, iDraggedIndex ) )
   216         {
   215         {
   217         iDraggedIndex = KErrNotFound;
   216         iDraggedIndex = KErrNotFound;
   218         }
   217         }
   219     iItemRelativeTapPoint = aPointerEvent.iPosition
   218     iItemRelativeTapPoint = aPointerEvent.iPosition - iWidget->View()->ItemPos(
   220             - iWidget->View()->ItemPos( iDraggedIndex );
   219         iDraggedIndex );
   221     }
   220     }
   222 
   221 
   223 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   224 //
   223 //
   225 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   312 
   311 
   313     if( iLastDragHighlight != highlight )
   312     if( iLastDragHighlight != highlight )
   314         {
   313         {
   315         iDragAndDropObserver->HandleDragOverL( GetHighlight() );
   314         iDragAndDropObserver->HandleDragOverL( GetHighlight() );
   316         }
   315         }
   317 
   316     
   318     TPoint centerPoint( aPointerEvent.iPosition );
   317     TPoint centerPoint( aPointerEvent.iPosition );
   319     if( WidgetType() == EGridWidget )
   318     if( WidgetType() == EGridWidget )
   320         { // move item's TL corner by half width/height to center item horizontally.
   319         { // move item's TL corner by half width/height to center item horizontally.
   321         centerPoint.iX -= ( iWidget->View()->ItemSize( highlight ).iWidth / 2 );
   320         centerPoint.iX -= ( iWidget->View()->ItemSize( highlight ).iWidth / 2 );
   322         centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 );
   321         centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 );
   325         { // move item's T of corner by relative tap point to align left horizontally.
   324         { // move item's T of corner by relative tap point to align left horizontally.
   326         centerPoint.iX -= iItemRelativeTapPoint.iX;
   325         centerPoint.iX -= iItemRelativeTapPoint.iX;
   327         // move item's L of corner by half height to center item horizontally.
   326         // move item's L of corner by half height to center item horizontally.
   328         centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 );
   327         centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 );
   329         }
   328         }
   330 
   329     
   331     if( !tooFast )
   330     if( !tooFast )
   332         {
   331         {
   333         TSize itemSize = iWidget->View()->ItemSize( highlight );
   332         TSize itemSize = iWidget->View()->ItemSize( highlight );
   334         TPoint itemPos = iWidget->View()->ItemPos( highlight );
   333         TPoint itemPos = iWidget->View()->ItemPos( highlight );
   335 
   334 
   676         //        	iDrawer->ClearFlags( CListItemDrawer::EPressedDownState );
   675         //        	iDrawer->ClearFlags( CListItemDrawer::EPressedDownState );
   677         //        	}
   676         //        	}
   678         HandleButtonDownL( aPointerEvent );
   677         HandleButtonDownL( aPointerEvent );
   679         iDragAndDropObserver->HandleDragStartL( GetHighlight() );
   678         iDragAndDropObserver->HandleDragStartL( GetHighlight() );
   680         }
   679         }
   681     else if( IsNoItemDragged() && ( aPointerEvent.iType
       
   682             == TPointerEvent::EButton1Up ) )
       
   683         {
       
   684         iWidget->View()->ItemDrawer()->SetFlags(
       
   685                 CListItemDrawer::ESingleClickDisabledHighlight );
       
   686         TInt highlight = GetHighlight();
       
   687         CListBoxView* view = Widget()->View();
       
   688         Widget()->DrawNow( TRect( view->ItemPos( highlight ),
       
   689                 view->ItemSize( highlight ) ) );
       
   690         }
       
   691     else if( ( aPointerEvent.iType == TPointerEvent::EDrag
   680     else if( ( aPointerEvent.iType == TPointerEvent::EDrag
   692             || aPointerEvent.iType == TPointerEvent::EButtonRepeat )
   681             || aPointerEvent.iType == TPointerEvent::EButtonRepeat )
   693             && iDraggedIndex != KErrNotFound )
   682             && iDraggedIndex != KErrNotFound )
   694         {
   683         {
   695         //TODO: PROTO OF 2PHASE HIGHLIGHT EDITMODE BEHAVIOUR
   684         //TODO: PROTO OF 2PHASE HIGHLIGHT EDITMODE BEHAVIOUR
  1152             }
  1141             }
  1153         }
  1142         }
  1154 
  1143 
  1155     if( resp == EKeyWasNotConsumed )
  1144     if( resp == EKeyWasNotConsumed )
  1156         {
  1145         {
  1157         resp = iWidget->OfferKeyEventL( aKeyEvent, aType );        
  1146         resp = iWidget->OfferKeyEventL( aKeyEvent, aType );
  1158         }
  1147         }
  1159         
  1148 
  1160     if( iKeyEventObserver )
  1149     if( iKeyEventObserver )
  1161         {
  1150         {
  1162         resp = iKeyEventObserver->HandleKeyPressedL( aKeyEvent, aType );
  1151         resp = iKeyEventObserver->HandleKeyPressedL( aKeyEvent, aType );
  1163         }
  1152         }
  1164 
  1153 
  1174             {
  1163             {
  1175             iAllowLongPress = ETrue;
  1164             iAllowLongPress = ETrue;
  1176 
  1165 
  1177             SetHighlightVisibilityL( ETrue );
  1166             SetHighlightVisibilityL( ETrue );
  1178             SetDefaultHighlightL( ETrue );
  1167             SetDefaultHighlightL( ETrue );
  1179             HandleForegroundGainedL();            
  1168             HandleForegroundGainedL();
  1180             }
  1169             }
  1181         }
  1170         }
  1182     return resp;
  1171     return resp;
  1183     }
  1172     }
  1184 
  1173 
  1742     iWidgetPositionCache.iVerticalItemOffset = 0;
  1731     iWidgetPositionCache.iVerticalItemOffset = 0;
  1743     iWidgetPositionCache.iTopItemIndex = 0;
  1732     iWidgetPositionCache.iTopItemIndex = 0;
  1744     iWidgetPositionCache.iValid = EFalse;
  1733     iWidgetPositionCache.iValid = EFalse;
  1745     iWidgetPositionCache.iHighlightedItemId = KErrNotFound;
  1734     iWidgetPositionCache.iHighlightedItemId = KErrNotFound;
  1746     Widget()->SetTopItemIndex( 0 );
  1735     Widget()->SetTopItemIndex( 0 );
  1747     Widget()->View()->SetCurrentItemIndex( 0 );
       
  1748     SetVerticalItemOffset( 0 );
  1736     SetVerticalItemOffset( 0 );
  1749     iResetHighlight = ETrue;
       
  1750     }
  1737     }
  1751 
  1738 
  1752 // ---------------------------------------------------------------------------
  1739 // ---------------------------------------------------------------------------
  1753 //
  1740 //
  1754 // ---------------------------------------------------------------------------
  1741 // ---------------------------------------------------------------------------
  1888 //
  1875 //
  1889 // -----------------------------------------------------------------------------
  1876 // -----------------------------------------------------------------------------
  1890 //
  1877 //
  1891 EXPORT_C TBool CMmWidgetContainer::ScrollToItemL( TInt aIndex )
  1878 EXPORT_C TBool CMmWidgetContainer::ScrollToItemL( TInt aIndex )
  1892     {
  1879     {
  1893     TBool scrollConsumed( EFalse );
  1880     TInt scrollConsumed( EFalse );
  1894     if( aIndex >= 0 && aIndex <= NumberOfItems() )
  1881     if( aIndex >= 0 && aIndex <= NumberOfItems() )
  1895         {
  1882         {
  1896         scrollConsumed = AlignBottomOfViewL();
  1883         scrollConsumed = AlignBottomOfViewL();
  1897         if ( ( !scrollConsumed || iResetHighlight )
  1884         if ( !scrollConsumed && Widget()->View()->ItemIsPartiallyVisible(aIndex))
  1898                 && Widget()->View()->ItemIsPartiallyVisible(aIndex) )
       
  1899             {
  1885             {
  1900             //			the case when the item is partially visible at top or
  1886             //			the case when the item is partially visible at top or
  1901             //			bottom of screen. The view is scrolled the offset to
  1887             //			bottom of screen. The view is scrolled the offset to
  1902             //			make the item entirely visible.
  1888             //			make the item entirely visible.
  1903             TInt offsetBottom = Widget()->View()->ItemPos( aIndex ).iY
  1889             TInt offsetBottom = Widget()->View()->ItemPos( aIndex ).iY
  1909             if( offset != 0 )
  1895             if( offset != 0 )
  1910                 {
  1896                 {
  1911                 ScrollInPixelsL( offset );
  1897                 ScrollInPixelsL( offset );
  1912                 scrollConsumed = ETrue;
  1898                 scrollConsumed = ETrue;
  1913                 }
  1899                 }
       
  1900 
  1914             }
  1901             }
  1915         else if( !Widget()->View()->ItemIsVisible( aIndex ) )
  1902         else if( !Widget()->View()->ItemIsVisible( aIndex ) )
  1916             {
  1903             {
  1917             //			the case when the item is not visible on screen
  1904             //			the case when the item is not visible on screen
  1918             SetupScrollingEffectsL( aIndex > Widget()->BottomItemIndex() );
  1905             SetupScrollingEffectsL( aIndex > Widget()->BottomItemIndex() );
  1919             Widget()->ScrollToMakeItemVisible( aIndex );
  1906             Widget()->ScrollToMakeItemVisible( aIndex );
  1920             AlignBottomOfViewL();
  1907             AlignBottomOfViewL();
  1921             scrollConsumed = ETrue;
  1908             scrollConsumed = ETrue;
  1922             }
  1909             }
  1923         iResetHighlight = EFalse;
       
  1924         }
  1910         }
  1925     return scrollConsumed;
  1911     return scrollConsumed;
  1926     }
  1912     }
  1927 
  1913 
  1928 // -----------------------------------------------------------------------------
  1914 // -----------------------------------------------------------------------------
  2081             && !iDragOccured )
  2067             && !iDragOccured )
  2082         {
  2068         {
  2083         iListBoxObserver->HandleListBoxEventL( aListBox, aEventType );
  2069         iListBoxObserver->HandleListBoxEventL( aListBox, aEventType );
  2084         }
  2070         }
  2085     }
  2071     }
  2086                                   
       
  2087 // ---------------------------------------------------------------------------
       
  2088 //
       
  2089 // ---------------------------------------------------------------------------
       
  2090 //
       
  2091 EXPORT_C void CMmWidgetContainer::SetWidgetCommingFromBackground( TBool /*aCommingFromBackground*/)
       
  2092     {
       
  2093     // this method must not be implemented. Change and implement only descended methods.    
       
  2094     }
       
  2095 
       
  2096 //End of file
  2072 //End of file