uifw/AvKon/src/akngrid.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 72 a5e7a4f63858
--- a/uifw/AvKon/src/akngrid.cpp	Tue Aug 31 15:28:30 2010 +0300
+++ b/uifw/AvKon/src/akngrid.cpp	Wed Sep 01 12:16:19 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -109,11 +109,12 @@
 
     public: // data 
         TInt iFlags;
-        // EMMA-7A8B9F.Ugly hack. Prevent MopSupplyObject being invoked 
-        // from CEikListBox::MopGetObject()
+
+        // This is used to prevent MopSupplyObject being invoked 
+        // from CEikListBox::MopGetObject().
         TBool iIsFromBaseClass;
+
         TPoint iLastPoint;
-        TBool iKineticScrolling;
         TBool iSingleClickEnabled;
     };
 
@@ -122,7 +123,6 @@
     iFlags(0), 
     iIsFromBaseClass( EFalse ),
     iLastPoint( 0, 0 ), 
-    iKineticScrolling( CAknPhysics::FeatureEnabled() ),
     iSingleClickEnabled( iAvkonAppUi->IsSingleClickCompatible() )
     {
     }
@@ -660,6 +660,7 @@
             iSBFrame->VerticalScrollBar()->Size()).Contains ( aPointerEvent.iPosition ))
             {
             if ( !ScrollingDisabled()
+                && iExtension 
                 && iExtension->iFlags & EAknGridStateButton1DownInGrid )
                 {
                 if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
@@ -687,17 +688,25 @@
             switch (aPointerEvent.iType)
                 {
                 case TPointerEvent::EButton1Down:
-                    iExtension->iLastPoint = aPointerEvent.iPosition;
-                    if ( visibleItemsRect.Contains(aPointerEvent.iPosition) )
-                        {
-                        iExtension->iFlags |= EAknGridStateButton1DownInGrid;                
-                        }
+                	{
+                    if( iExtension )
+                      {
+                      iExtension->iLastPoint = aPointerEvent.iPosition;
+                      if ( visibleItemsRect.Contains(aPointerEvent.iPosition) )
+                          {
+                          iExtension->iFlags |= EAknGridStateButton1DownInGrid;
+                          }
+                      }
                     _AKNTRACE( "TPointerEvent::EButton1Down" );
                     break;
-
+                	}
+                	
                 case TPointerEvent::EButton1Up:
                     {
-                    iExtension->iFlags &= ~EAknGridStateButton1DownInGrid;
+                    if ( iExtension )
+                        {
+                        iExtension->iFlags &= ~EAknGridStateButton1DownInGrid;
+                        }
                     _AKNTRACE( "TPointerEvent::EButton1Up" );
                     break;
                     }
@@ -1087,7 +1096,8 @@
         }
         
     // With single click first key event enables highlight
-    if ( iExtension->iSingleClickEnabled
+    if ( iExtension 
+            && iExtension->iSingleClickEnabled
             && ItemDrawer()->Flags()
             &  CListItemDrawer::ESingleClickDisabledHighlight )
         {
@@ -1336,8 +1346,16 @@
 EXPORT_C void CAknGrid::HandleResourceChange(TInt aType)
     {
     _AKNTRACE_FUNC_ENTER;
-    // Need to do this to set up the scroll bar model
-    TRAP_IGNORE( UpdateScrollBarsL() );
+    if ( aType != KEikMessageWindowsFadeChange && 
+    	 aType != KEikMessageUnfadeWindows && 
+    	 aType != KEikMessageFadeAllWindows && 
+    	 aType != KEikMessageColorSchemeChange && 
+    	 aType != KAknsMessageSkinChange )
+    	{
+        // Need to do this to set up the scroll bar model
+        TRAP_IGNORE( UpdateScrollBarsL() );
+    	}
+    
     
     if (aType==KEikDynamicLayoutVariantSwitch)
         {
@@ -1391,9 +1409,17 @@
     TRAP_IGNORE( ItemDrawer()->FormattedCellData()->SetupSkinContextL());
     // Data extension has animations which will change when skin changes.
     ItemDrawer()->FormattedCellData()->HandleResourceChange( aType );
-
-    // Need to do this to set up the scroll bar model
-    TRAP_IGNORE( UpdateScrollBarsL() );
+    
+    if ( aType != KEikMessageWindowsFadeChange && 
+    	 aType != KEikMessageUnfadeWindows && 
+    	 aType != KEikMessageFadeAllWindows && 
+    	 aType != KEikMessageColorSchemeChange && 
+    	 aType != KAknsMessageSkinChange )
+        {
+        // Need to do this to set up the scroll bar model
+        TRAP_IGNORE( UpdateScrollBarsL() );
+        }
+    
     _AKNTRACE_FUNC_EXIT;
     }
 
@@ -1481,8 +1507,12 @@
         
         // and calculate new top item index
         TInt topItemIndex = newTopRow * iNumOfColsInView ;
-        iView->SetItemOffsetInPixels(0);
-        SetTopItemIndex(topItemIndex);
+        if ( topItemIndex > KErrNotFound 
+             && topItemIndex < iModel->NumberOfItems() )
+            {
+            iView->SetItemOffsetInPixels( 0 );
+            SetTopItemIndex( topItemIndex );
+            }
         }
     _AKNTRACE_FUNC_EXIT;
     }
@@ -1499,7 +1529,7 @@
     
     if ( AknLayoutUtils::PenEnabled() )
         {
-        if ( !(iExtension->iFlags & EAknGridStateButton1DownInGrid) )
+        if ( !( iExtension && iExtension->iFlags & EAknGridStateButton1DownInGrid) )
             {
             _AKNTRACE_FUNC_EXIT;
             return;
@@ -1515,8 +1545,8 @@
         CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection;
         //        CListBoxView::TSelectionMode selectionMode = (iListBoxFlags & EMultipleSelection) ? CListBoxView::EContiguousSelection : CListBoxView::ESingleSelection;
         // END OF SERIES60 LAF
-        TInt speed = iExtension->GetScrollingSpeed( pointerIsOverAnItem, itemIndex, 
-                                                    *gridView, aPointerPos );
+        TInt speed = iExtension ? iExtension->GetScrollingSpeed( pointerIsOverAnItem, itemIndex, 
+                                                    *gridView, aPointerPos ):0;
         
         TInt oldCurrentItemIndex = CurrentItemIndex();
         TRect currentItemRect(gridView->ItemPos(oldCurrentItemIndex), gridView->ItemSize(oldCurrentItemIndex));       
@@ -1843,7 +1873,6 @@
         // EHXA-7AQ8N4. Only set it to 0 can make scrollbar empty.
         vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? 
             gridSize.iHeight : 0;
-        vSbarModel.iThumbSpan = gridView->NumberOfRowsInView();
         vSbarModel.iScrollSpan = GridModel()->NumberOfItems() >0 ? 
             gridSize.iHeight*iView->ItemHeight() : 0;
         vSbarModel.iThumbSpan = rect.Height();
@@ -1860,7 +1889,12 @@
         if (vSbarModel.iScrollSpan-vSbarModel.iThumbPosition<vSbarModel.iThumbSpan)
             {
             vSbarModel.iThumbPosition=Max(0,vSbarModel.iScrollSpan-vSbarModel.iThumbSpan);
-            gridView->MoveToItemIndexL(currentIndex,CListBoxView::ENoSelection); // force a scroll if neccessary
+            if ( iExtension && !iExtension->iSingleClickEnabled )
+                {
+                // force a scroll if neccessary
+                gridView->MoveToItemIndexL( currentIndex, 
+                    CListBoxView::ENoSelection );
+                }
             }
         }
     if (iSBFrame->ScrollBarVisibility(CEikScrollBar::EHorizontal)!=CEikScrollBarFrame::EOff)