taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswapgrid.cpp
branchRCL_3
changeset 17 b8fae6b8a148
parent 12 9674c1a575e9
child 18 d05a55b217df
equal deleted inserted replaced
12:9674c1a575e9 17:b8fae6b8a148
    29   * CTsFastSwapGrid
    29   * CTsFastSwapGrid
    30   * ================================================================================
    30   * ================================================================================
    31   */
    31   */
    32 
    32 
    33 const TInt KCloseIconRedrawTime = 300000; // 0.3 second
    33 const TInt KCloseIconRedrawTime = 300000; // 0.3 second
    34 const TInt KFeedbackTime = 0;
    34 
       
    35 const TInt KStrokeThickness = 1;
    35 
    36 
    36 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    37 // CTsFastSwapGrid::CTsFastSwapGrid
    38 // CTsFastSwapGrid::CTsFastSwapGrid
    38 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    39 //
    40 //
    51 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    52 //
    53 //
    53 CTsFastSwapGrid::~CTsFastSwapGrid()
    54 CTsFastSwapGrid::~CTsFastSwapGrid()
    54     {
    55     {
    55     iCloseItems.Close();
    56     iCloseItems.Close();
    56     delete iBgContext;
       
    57     delete iCloseIconRedrawTimer;
    57     delete iCloseIconRedrawTimer;
    58     delete iFeedbackTimer;
       
    59     iFullyVisibleItems.Close();
       
    60     iPartialVisibleItems.Close();
       
    61     }
    58     }
    62 
    59 
    63 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    64 // CTsFastSwapGrid::ConstructL
    61 // CTsFastSwapGrid::ConstructL
    65 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    71     
    68     
    72     iParent = aParent;
    69     iParent = aParent;
    73     CAknGrid::ConstructL( aParent, EAknListBoxSelectionGrid );
    70     CAknGrid::ConstructL( aParent, EAknListBoxSelectionGrid );
    74     SetPrimaryScrollingType(CAknGridView::EScrollFollowsItemsAndLoops);
    71     SetPrimaryScrollingType(CAknGridView::EScrollFollowsItemsAndLoops);
    75     SetSecondaryScrollingType(CAknGridView::EScrollFollowsItemsAndLoops);
    72     SetSecondaryScrollingType(CAknGridView::EScrollFollowsItemsAndLoops);
    76     iBgContext = CAknsFrameBackgroundControlContext::NewL(
       
    77                KAknsIIDQsnFrPopup,
       
    78                TRect(),
       
    79                TRect(),
       
    80                ETrue );
       
    81     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
       
    82     iCloseIconRedrawTimer = new (ELeave) CTsFastSwapTimer( *this );
    73     iCloseIconRedrawTimer = new (ELeave) CTsFastSwapTimer( *this );
    83     iCloseIconRedrawTimer->ConstructL();
    74     iCloseIconRedrawTimer->ConstructL();
    84     iFeedbackTimer = new (ELeave) CTsFastSwapTimer( *this );
       
    85     iFeedbackTimer->ConstructL();
       
    86     
    75     
    87     TSLOG_OUT();
    76     TSLOG_OUT();
    88     }
    77     }
    89 
    78 
    90 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
   196     TSLOG_CONTEXT( CTsFastSwapGrid::HandleDeviceStateChanged, TSLOG_LOCAL );
   185     TSLOG_CONTEXT( CTsFastSwapGrid::HandleDeviceStateChanged, TSLOG_LOCAL );
   197     TSLOG_IN();
   186     TSLOG_IN();
   198     
   187     
   199     if ( aChangeType == ESkin )
   188     if ( aChangeType == ESkin )
   200         {
   189         {
   201         LoadCloseIcon();
   190         LoadCloseIconAndStrokeParams();
   202         }
   191         }
   203     
   192     
   204     TSLOG_OUT();
   193     TSLOG_OUT();
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CTsFastSwapGrid::MopSupplyObject
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TTypeUid::Ptr CTsFastSwapGrid::MopSupplyObject( TTypeUid aId )
       
   212     {
       
   213     if ( aId.iUid == MAknsControlContext::ETypeId )
       
   214         {
       
   215         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   216         }
       
   217     return CCoeControl::MopSupplyObject( aId );
       
   218     }
   194     }
   219 
   195 
   220 
   196 
   221 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   222 // CTsFastSwapGrid::HandleResourceChange
   198 // CTsFastSwapGrid::HandleResourceChange
   241 // CTsFastSwapGrid::SizeChanged
   217 // CTsFastSwapGrid::SizeChanged
   242 // -----------------------------------------------------------------------------
   218 // -----------------------------------------------------------------------------
   243 //
   219 //
   244 void CTsFastSwapGrid::SizeChanged()
   220 void CTsFastSwapGrid::SizeChanged()
   245     {
   221     {
       
   222     }
       
   223 
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CTsFastSwapGrid::Draw
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CTsFastSwapGrid::Draw( const TRect& aRect ) const
       
   230     {
       
   231     CAknGrid::Draw(aRect);
       
   232     if ( !Model()->ItemTextArray()->MdcaCount() )
       
   233         {
       
   234         GridView()->DrawEmptyList();
       
   235         }
   246     }
   236     }
   247 
   237 
   248 
   238 
   249 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   250 // CTsFastSwapGrid::SetFastSwapGridObserver
   240 // CTsFastSwapGrid::SetFastSwapGridObserver
   283     CleanupStack::PushL( itemDrawer );
   273     CleanupStack::PushL( itemDrawer );
   284     itemDrawer->SetEdgeOffset( leftOffset, rightOffset );
   274     itemDrawer->SetEdgeOffset( leftOffset, rightOffset );
   285     iItemDrawer = itemDrawer;
   275     iItemDrawer = itemDrawer;
   286     CleanupStack::Pop( itemDrawer );
   276     CleanupStack::Pop( itemDrawer );
   287     CleanupStack::Pop( data );
   277     CleanupStack::Pop( data );
   288     LoadCloseIcon();
   278     LoadCloseIconAndStrokeParams();
   289     
   279     
   290     TSLOG_OUT();
   280     TSLOG_OUT();
   291     }
   281     }
   292 
   282 
   293 // -----------------------------------------------------------------------------
   283 // -----------------------------------------------------------------------------
   300         {
   290         {
   301         TInt itemToClose = iCloseIconHitIdx;
   291         TInt itemToClose = iCloseIconHitIdx;
   302         ResetCloseHit();
   292         ResetCloseHit();
   303         iFastSwapGridObserver->HandleCloseEventL( itemToClose );
   293         iFastSwapGridObserver->HandleCloseEventL( itemToClose );
   304         }
   294         }
   305     else if ( aSource == iFeedbackTimer )
       
   306         {
       
   307         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   308         if (feedback)
       
   309             {
       
   310             feedback->InstantFeedback(ETouchFeedbackSensitive);
       
   311             }
       
   312         }
       
   313     }
   295     }
   314 
   296 
   315 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   316 // CTsFastSwapGrid::SetCloseItemsL
   298 // CTsFastSwapGrid::SetCloseItemsL
   317 // -----------------------------------------------------------------------------
   299 // -----------------------------------------------------------------------------
   351 // -----------------------------------------------------------------------------
   333 // -----------------------------------------------------------------------------
   352 //
   334 //
   353 void CTsFastSwapGrid::ResetCloseHit()
   335 void CTsFastSwapGrid::ResetCloseHit()
   354     {
   336     {
   355     iCloseIconHitIdx = KErrNotFound;
   337     iCloseIconHitIdx = KErrNotFound;
       
   338     }
       
   339 
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CTsFastSwapGrid::SetStrokeColor
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 void CTsFastSwapGrid::SetStrokeColors( TRgb aColor,
       
   346                                        TRgb aHighlightedColor )
       
   347     {
       
   348     static_cast<CTsGridItemDrawer*>(iItemDrawer)->SetStrokeColors(aColor, aHighlightedColor);
       
   349     }
       
   350 
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CTsFastSwapGrid::SetStrokeItemsL
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void CTsFastSwapGrid::SetStrokeItemsL( RArray<TInt>& aItemIndex )
       
   357     {
       
   358     static_cast<CTsGridItemDrawer*>(iItemDrawer)->SetStrokeItemsL(aItemIndex);
   356     }
   359     }
   357 
   360 
   358 
   361 
   359 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   360 // CTsFastSwapGrid::SetBehaviour
   363 // CTsFastSwapGrid::SetBehaviour
   457     return retVal;
   460     return retVal;
   458     }
   461     }
   459 
   462 
   460 
   463 
   461 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   462 // CTsFastSwapGrid::LoadCloseIconL
   465 // CTsFastSwapGrid::LoadCloseIconAndStrokeParams
   463 // -----------------------------------------------------------------------------
   466 // -----------------------------------------------------------------------------
   464 //
   467 //
   465 void CTsFastSwapGrid::LoadCloseIcon()
   468 void CTsFastSwapGrid::LoadCloseIconAndStrokeParams()
   466     {
   469     {
   467     // Load and set close icon
   470     // Load and set close icon
   468     CFbsBitmap* icon = NULL;
   471     CFbsBitmap* icon = NULL;
   469     CFbsBitmap* mask = NULL;
   472     CFbsBitmap* iconMask = NULL;
   470 
   473     CFbsBitmap* iconPressed = NULL;
   471     TRAP_IGNORE(AknsUtils::CreateColorIconLC( AknsUtils::SkinInstance(),
   474     CFbsBitmap* iconPressedMask = NULL;
   472                 KAknsIIDQgnIndiItutListCollapse,
   475     
   473                 KAknsIIDQsnTextColors,    // we use text color here, eventhough this is an icon
   476     TRAP_IGNORE(AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
   474                 EAknsCIQsnTextColorsCG13, // softkey text color
   477                 KAknsIIDQgnIndiTsButtonClose,
   475                 icon,
   478                 icon,
   476                 mask,
   479                 iconMask,
   477                 KAvkonBitmapFile,
   480                 KAvkonBitmapFile,
   478                 EMbmAvkonQgn_indi_button_preview_close,
   481                 EMbmAvkonQgn_indi_button_preview_close,
   479                 EMbmAvkonQgn_indi_button_preview_close_mask,
   482                 EMbmAvkonQgn_indi_button_preview_close_mask
   480                 KRgbWhite
   483                 ));
   481                 );
   484     
   482                 CleanupStack::Pop( 2 ); // codescanner::cleanup
   485     TRAP_IGNORE(AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
   483                 );
   486                 KAknsIIDQgnIndiTsButtonClosePressed,
       
   487                 iconPressed,
       
   488                 iconPressedMask,
       
   489                 KAvkonBitmapFile,
       
   490                 EMbmAvkonQgn_indi_button_preview_close,
       
   491                 EMbmAvkonQgn_indi_button_preview_close_mask
       
   492                 ));
   484 
   493 
   485     TAknLayoutRect gridAppPane;
   494     TAknLayoutRect gridAppPane;
   486     TAknLayoutRect gridItem;
   495     TAknLayoutRect gridItem;
       
   496     TAknLayoutRect gridImage;
   487     TAknLayoutRect gridCloseButton;
   497     TAknLayoutRect gridCloseButton;
   488     TAknLayoutRect gridCloseIcon;
   498     TAknLayoutRect gridCloseIcon;
   489     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
   499     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
   490     TRect source = iParent ? iParent->Rect() : Rect();
   500     TRect source = iParent ? iParent->Rect() : Rect();
   491     gridAppPane.LayoutRect( source,
   501     gridAppPane.LayoutRect( source,
   492             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   502             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   493     gridItem.LayoutRect( gridAppPane.Rect(),
   503     gridItem.LayoutRect( gridAppPane.Rect(),
   494             AknLayoutScalable_Apps::cell_tport_appsw_pane( variety, 0, 0 ) );
   504             AknLayoutScalable_Apps::cell_tport_appsw_pane( variety, 0, 0 ) );
       
   505     gridImage.LayoutRect( gridItem.Rect(),
       
   506             AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ) ); 
   495     gridCloseButton.LayoutRect( gridItem.Rect(),
   507     gridCloseButton.LayoutRect( gridItem.Rect(),
   496             AknLayoutScalable_Apps::bg_button_pane_cp16( variety, 0, 0 ));
   508             AknLayoutScalable_Apps::bg_button_pane_cp16( variety, 0, 0 ));
   497     gridCloseIcon.LayoutRect( gridItem.Rect(),
   509     gridCloseIcon.LayoutRect( gridItem.Rect(),
   498             AknLayoutScalable_Apps::cell_tport_appsw_pane_g3( variety, 0, 0 ));
   510             AknLayoutScalable_Apps::cell_tport_appsw_pane_g3( variety, 0, 0 ));
       
   511     
       
   512     // Set icon size
   499     AknIconUtils::SetSize( icon, gridCloseIcon.Rect().Size(), EAspectRatioPreserved );
   513     AknIconUtils::SetSize( icon, gridCloseIcon.Rect().Size(), EAspectRatioPreserved );
   500     AknIconUtils::SetSize( mask, gridCloseIcon.Rect().Size(), EAspectRatioPreserved );
   514     AknIconUtils::SetSize( iconPressed, gridCloseIcon.Rect().Size(), EAspectRatioPreserved );
   501     CTsGridItemDrawer* itemDrawer =
   515     CTsGridItemDrawer* itemDrawer =
   502         static_cast<CTsGridItemDrawer*>(iItemDrawer);
   516         static_cast<CTsGridItemDrawer*>(iItemDrawer);
   503     itemDrawer->SetCloseIcon( icon, mask );
   517     
       
   518     // Setup close parameters
       
   519     itemDrawer->SetCloseIcon( icon, iconMask, iconPressed, iconPressedMask );
   504     TRect relGridCloseButton = TRect( TPoint( gridCloseButton.Rect().iTl.iX - gridItem.Rect().iTl.iX,
   520     TRect relGridCloseButton = TRect( TPoint( gridCloseButton.Rect().iTl.iX - gridItem.Rect().iTl.iX,
   505                                               gridCloseButton.Rect().iTl.iY - gridItem.Rect().iTl.iY),
   521                                               gridCloseButton.Rect().iTl.iY - gridItem.Rect().iTl.iY),
   506                                       gridCloseButton.Rect().Size() );
   522                                       gridCloseButton.Rect().Size() );
   507     TRect relGridCloseIconRect = TRect( TPoint( gridCloseIcon.Rect().iTl.iX - gridItem.Rect().iTl.iX,
   523     TRect relGridCloseIconRect = TRect( TPoint( gridCloseIcon.Rect().iTl.iX - gridItem.Rect().iTl.iX,
   508                                                 gridCloseIcon.Rect().iTl.iY - gridItem.Rect().iTl.iY),
   524                                                 gridCloseIcon.Rect().iTl.iY - gridItem.Rect().iTl.iY),
   509                                         gridCloseIcon.Rect().Size() );
   525                                         gridCloseIcon.Rect().Size() );
   510     itemDrawer->SetCloseIconRect( relGridCloseButton, relGridCloseIconRect );
   526     itemDrawer->SetCloseIconRect( relGridCloseButton, relGridCloseIconRect );
       
   527     
       
   528     // Setup stroke parameters
       
   529     TPoint strokeOffset;
       
   530     strokeOffset.iX = gridImage.Rect().iTl.iX - gridItem.Rect().iTl.iX - KStrokeThickness;
       
   531     strokeOffset.iY = gridImage.Rect().iTl.iY - gridItem.Rect().iTl.iY - KStrokeThickness;
       
   532     TSize strokeSize = gridImage.Rect().Size();
       
   533     strokeSize.iHeight += KStrokeThickness * 2;
       
   534     strokeSize.iWidth += KStrokeThickness * 2;
       
   535     itemDrawer->SetStrokeOffset( strokeOffset, strokeSize );
   511     }
   536     }
   512 
   537 
   513 
   538 
   514 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   515 // CTsFastSwapGrid::Redraw
   540 // CTsFastSwapGrid::Redraw
   528             ctrlToRedraw->DrawNow();
   553             ctrlToRedraw->DrawNow();
   529             }
   554             }
   530         }
   555         }
   531     }
   556     }
   532 
   557 
   533 // -----------------------------------------------------------------------------
   558 
   534 // CTsFastSwapGrid::LaunchTactileFeedback
   559 
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CTsFastSwapGrid::LaunchTactileFeedback()
       
   538     {
       
   539     if( !iTactileFeedbackSupport )
       
   540         {
       
   541         return;
       
   542         }
       
   543     
       
   544     iFeedbackTimer->Cancel();
       
   545     iFeedbackTimer->After(KFeedbackTime);
       
   546     }
       
   547 
       
   548 // -----------------------------------------------------------------------------
       
   549 // CTsFastSwapGrid::SetTactileFeedbackSupport
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 void CTsFastSwapGrid::SetTactileFeedbackSupport(TBool aSupport)
       
   553     {
       
   554     iTactileFeedbackSupport = aSupport;
       
   555     }
       
   556 
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CTsFastSwapGrid::RemoveFromVisibleItems
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 TBool CTsFastSwapGrid::RemoveFromVisibleItems(TInt aItem) const
       
   563     {
       
   564     TBool retVal(EFalse);
       
   565     TInt idx(0);
       
   566     idx = iFullyVisibleItems.Find(aItem); 
       
   567     if(  idx >= 0)
       
   568         {
       
   569         iFullyVisibleItems.Remove(idx);
       
   570         retVal = ETrue;
       
   571         }
       
   572     idx = iPartialVisibleItems.Find( aItem );
       
   573     if( idx >= 0)
       
   574         {
       
   575         iPartialVisibleItems.Remove(idx);
       
   576         retVal = ETrue;
       
   577         }
       
   578     return retVal;    
       
   579     }
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CTsFastSwapGrid::AddToFullyVisibleItems
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 TBool CTsFastSwapGrid::AddToFullyVisibleItems( TInt aItem ) const
       
   586     {
       
   587     TBool retVal(EFalse);
       
   588     TInt idx(0);
       
   589 
       
   590     idx = iPartialVisibleItems.Find(aItem); 
       
   591     if(  idx >= 0)
       
   592         {
       
   593         iPartialVisibleItems.Remove(idx);
       
   594         }
       
   595     idx = iFullyVisibleItems.Find( aItem );
       
   596     if( idx == KErrNotFound )
       
   597         {
       
   598         iFullyVisibleItems.Append(aItem);
       
   599         retVal = ETrue; 
       
   600         }
       
   601     return retVal;
       
   602     }
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CTsFastSwapGrid::MoveToPartialVisibleItems
       
   606 // -----------------------------------------------------------------------------
       
   607 //
       
   608 TBool CTsFastSwapGrid::MoveToPartialVisibleItems( TInt aItem ) const
       
   609     {
       
   610     TInt idx(0);
       
   611     idx = iFullyVisibleItems.Find(aItem); 
       
   612     if(  idx >= 0)
       
   613         {
       
   614         iFullyVisibleItems.Remove(idx);
       
   615         }
       
   616     idx = iPartialVisibleItems.Find( aItem );
       
   617     if( idx == KErrNotFound )
       
   618         {
       
   619         iPartialVisibleItems.Append(aItem);
       
   620         }
       
   621     return EFalse;
       
   622     }
       
   623 
   560 
   624 /* ================================================================================
   561 /* ================================================================================
   625  * CTsGridItemDrawer
   562  * CTsGridItemDrawer
   626  * ================================================================================
   563  * ================================================================================
   627  */
   564  */
   636         TRect aScreenRect )
   573         TRect aScreenRect )
   637 : CFormattedCellListBoxItemDrawer( aGrid->Model(),
   574 : CFormattedCellListBoxItemDrawer( aGrid->Model(),
   638         NULL,
   575         NULL,
   639         aData ),
   576         aData ),
   640   iGrid( aGrid ),
   577   iGrid( aGrid ),
   641   iScreenRect(aScreenRect)
   578   iScreenRect( aScreenRect ),
       
   579   iStrokeColor( KRgbBlack ),
       
   580   iHighlightStrokeColor( KRgbBlack )
   642     {
   581     {
   643     }
   582     }
   644 
   583 
   645 
   584 
   646 // -----------------------------------------------------------------------------
   585 // -----------------------------------------------------------------------------
   649 //
   588 //
   650 CTsGridItemDrawer::~CTsGridItemDrawer()
   589 CTsGridItemDrawer::~CTsGridItemDrawer()
   651     {
   590     {
   652     delete iCloseIcon;
   591     delete iCloseIcon;
   653     delete iCloseIconMask;
   592     delete iCloseIconMask;
       
   593     delete iCloseIconPressed;
       
   594     delete iCloseIconPressedMask;
       
   595     iStrokeItems.Close();
   654     }
   596     }
   655 
   597 
   656 
   598 
   657 // -----------------------------------------------------------------------------
   599 // -----------------------------------------------------------------------------
   658 // CTsGridItemDrawer::SetCloseIcon
   600 // CTsGridItemDrawer::SetCloseIcon
   659 // -----------------------------------------------------------------------------
   601 // -----------------------------------------------------------------------------
   660 //
   602 //
   661 void CTsGridItemDrawer::SetCloseIcon( CFbsBitmap* aBmp, CFbsBitmap* aMask )
   603 void CTsGridItemDrawer::SetCloseIcon( CFbsBitmap* aBmp, CFbsBitmap* aBmpMask,
       
   604                                       CFbsBitmap* aBmpPressed, CFbsBitmap* aBmpPressedMask  )
   662     {
   605     {
   663     delete iCloseIcon;
   606     delete iCloseIcon;
   664     iCloseIcon = aBmp;
   607     iCloseIcon = aBmp;
   665     delete iCloseIconMask;
   608     delete iCloseIconMask;
   666     iCloseIconMask = aMask;
   609     iCloseIconMask = aBmpMask;
       
   610     delete iCloseIconPressed;
       
   611     iCloseIconPressed = aBmpPressed;
       
   612     delete iCloseIconPressedMask;
       
   613     iCloseIconPressedMask = aBmpPressedMask;
   667     }
   614     }
   668 
   615 
   669 
   616 
   670 // -----------------------------------------------------------------------------
   617 // -----------------------------------------------------------------------------
   671 // CTsGridItemDrawer::SetCloseIconRect
   618 // CTsGridItemDrawer::SetCloseIconRect
   712     iRedrawBackground = aEnable;
   659     iRedrawBackground = aEnable;
   713     }
   660     }
   714 
   661 
   715 
   662 
   716 // -----------------------------------------------------------------------------
   663 // -----------------------------------------------------------------------------
       
   664 // CTsGridItemDrawer::SetStrokeColor
       
   665 // -----------------------------------------------------------------------------
       
   666 //
       
   667 void CTsGridItemDrawer::SetStrokeColors( TRgb aColor,
       
   668                                          TRgb aHighlightedColor )
       
   669     {
       
   670     iStrokeColor = aColor;
       
   671     iHighlightStrokeColor = aHighlightedColor;
       
   672     }
       
   673 
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 // CTsGridItemDrawer::SetStrokeItemsL
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 void CTsGridItemDrawer::SetStrokeItemsL( RArray<TInt>& aItemIndex )
       
   680     {
       
   681     iStrokeItems.Close();
       
   682     for ( TInt i = 0; i < aItemIndex.Count(); i++ )
       
   683         {
       
   684         iStrokeItems.AppendL( aItemIndex[i] );
       
   685         }
       
   686     }
       
   687 
       
   688 
       
   689 // -----------------------------------------------------------------------------
       
   690 // CTsGridItemDrawer::SetStrokeOffset
       
   691 // -----------------------------------------------------------------------------
       
   692 //
       
   693 void CTsGridItemDrawer::SetStrokeOffset( TPoint aStrokeOffset, TSize aStrokeSize )
       
   694     {
       
   695     iStrokeRect = TRect( aStrokeOffset, aStrokeSize );
       
   696     }
       
   697 
       
   698 
       
   699 // -----------------------------------------------------------------------------
   717 // CTsGridItemDrawer::DrawActualItem
   700 // CTsGridItemDrawer::DrawActualItem
   718 // -----------------------------------------------------------------------------
   701 // -----------------------------------------------------------------------------
   719 //
   702 //
   720  void CTsGridItemDrawer::DrawActualItem( TInt aItemIndex, const TRect& aActualItemRect,
   703  void CTsGridItemDrawer::DrawActualItem( TInt aItemIndex, const TRect& aActualItemRect,
   721                                                  TBool aItemIsCurrent, TBool aViewIsEmphasized,
   704                                                  TBool aItemIsCurrent, TBool aViewIsEmphasized,
   722                                                  TBool aViewIsDimmed, TBool aItemIsSelected ) const
   705                                                  TBool aViewIsDimmed, TBool aItemIsSelected ) const
   723     {
   706     {
   724     TBool feedbackNeed(EFalse);//feedback when item disappear or fully appear
       
   725     
       
   726     if (IsItemRectVisible(aActualItemRect))
   707     if (IsItemRectVisible(aActualItemRect))
   727         {
   708         {
   728         // Calculate offset of the visible rectangle
   709         // Calculate offset of the visible rectangle
   729         TRect drawRect = aActualItemRect;
   710         TRect drawRect = aActualItemRect;
   730         if ( drawRect.iTl.iX < iLeftOffset )
   711         if ( drawRect.iTl.iX < iLeftOffset )
   734         if ( iScreenRect.Width() - drawRect.iBr.iX < iRightOffset )
   715         if ( iScreenRect.Width() - drawRect.iBr.iX < iRightOffset )
   735             {
   716             {
   736             drawRect.iBr.iX = iScreenRect.Width() - iRightOffset;
   717             drawRect.iBr.iX = iScreenRect.Width() - iRightOffset;
   737             }
   718             }
   738         iGc->SetClippingRect(drawRect);
   719         iGc->SetClippingRect(drawRect);
   739                 
       
   740 		if(IsRectContained( aActualItemRect, drawRect ))
       
   741             {
       
   742             feedbackNeed = iGrid->AddToFullyVisibleItems( aItemIndex );
       
   743             }
       
   744         else
       
   745             {
       
   746             feedbackNeed = iGrid->MoveToPartialVisibleItems( aItemIndex );
       
   747             }
       
   748 			
   720 			
   749         // Check for item highlight
   721         // Check for item highlight
   750         TBool itemIsCurrent = !iGrid->IsHighlightVisible() ? EFalse : aItemIsCurrent;
   722         TBool itemIsCurrent = !iGrid->IsHighlightVisible() ? EFalse : aItemIsCurrent;
   751         
   723         
   752         // Draw background if necessary
   724         // Draw background if necessary
   767         
   739         
   768         // Draw item
   740         // Draw item
   769         CFormattedCellListBoxItemDrawer::DrawActualItem(aItemIndex, aActualItemRect,
   741         CFormattedCellListBoxItemDrawer::DrawActualItem(aItemIndex, aActualItemRect,
   770                 itemIsCurrent, aViewIsEmphasized, aViewIsDimmed, aItemIsSelected );
   742                 itemIsCurrent, aViewIsEmphasized, aViewIsDimmed, aItemIsSelected );
   771         
   743         
   772         if ( iGrid->CanCloseItem( aItemIndex ) && iCloseIcon && iCloseIconMask )
   744         // Draw stroke
       
   745         if ( iStrokeItems.Find( aItemIndex ) != KErrNotFound )
       
   746             {
       
   747             TRect strokeRect = iStrokeRect;
       
   748             strokeRect.Move( aActualItemRect.iTl );
       
   749             if ( itemIsCurrent )
       
   750                 {
       
   751                 iGc->SetPenColor( iHighlightStrokeColor );
       
   752                 }
       
   753             else
       
   754                 {
       
   755                 iGc->SetPenColor( iStrokeColor );
       
   756                 }
       
   757             // Thumbnail stroke
       
   758             iGc->DrawRect( strokeRect );
       
   759             }
       
   760         
       
   761         // Draw close button
       
   762         if ( iGrid->CanCloseItem( aItemIndex ) && iCloseIcon && iCloseIconPressed )
   773             {
   763             {
   774             TRect closeIconRect = GetCloseButtonRect( aActualItemRect );
   764             TRect closeIconRect = GetCloseButtonRect( aActualItemRect );
   775             // Draw frame
   765             // Draw frame
   776             TRect outerRect = closeIconRect;
   766             TRect outerRect = closeIconRect;
   777             TRect innerRect = CalculateInnerButtonRect( outerRect );
   767             TRect innerRect = CalculateInnerButtonRect( outerRect );
   778             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   768             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   779             if ( iGrid->IsItemCloseHit( aItemIndex ) )
   769             if ( iGrid->IsItemCloseHit( aItemIndex ) )
   780                 {
   770                 {
   781                 AknsDrawUtils::DrawFrame(skin, *iGc, outerRect, innerRect,
   771                 TRect sourceRect( TPoint(0,0), iCloseIconPressed->SizeInPixels() );
   782                         KAknsIIDQgnFrSctrlButtonPressed, KAknsIIDQgnFrSctrlButtonCenterPressed);
   772                 iGc->DrawBitmapMasked( innerRect,
       
   773                         iCloseIconPressed,
       
   774                         sourceRect,
       
   775                         iCloseIconPressedMask,
       
   776                         ETrue );
   783                 }
   777                 }
   784             else
   778             else
   785                 {
   779                 {
   786                 AknsDrawUtils::DrawFrame(skin, *iGc, outerRect, innerRect,
   780                 TRect sourceRect( TPoint(0,0), iCloseIcon->SizeInPixels() );
   787                         KAknsIIDQgnFrSctrlButton, KAknsIIDQgnFrSctrlButtonCenter);
   781                 iGc->DrawBitmapMasked( innerRect,
       
   782                         iCloseIcon,
       
   783                         sourceRect,
       
   784                         iCloseIconMask,
       
   785                         ETrue );
   788                 }
   786                 }
   789             // Draw close icon
   787             }
   790             TRect sourceRect( TPoint(0,0), iCloseIcon->SizeInPixels() );
       
   791             iGc->DrawBitmapMasked( innerRect, iCloseIcon, sourceRect, iCloseIconMask, ETrue );
       
   792             }
       
   793         }
       
   794     else
       
   795         {
       
   796         feedbackNeed = iGrid->RemoveFromVisibleItems(aItemIndex);
       
   797         }
       
   798     if(feedbackNeed)
       
   799         {
       
   800         iGrid->LaunchTactileFeedback();
       
   801         }
   788         }
   802     }
   789     }
   803 
   790 
   804 // -----------------------------------------------------------------------------
   791 // -----------------------------------------------------------------------------
   805 // CTsGridItemDrawer::DrawActualItem
   792 // CTsGridItemDrawer::DrawActualItem