menufw/menufwui/mmwidgets/src/mmgridview.cpp
branchRCL_3
changeset 12 9674c1a575e9
parent 5 c743ef5928ba
child 19 79311d856354
equal deleted inserted replaced
11:ff572dfe6d86 12:9674c1a575e9
    93         const TInt colNum = NumberOfColsInView();
    93         const TInt colNum = NumberOfColsInView();
    94         TInt itemCol = aItemIndex % colNum;
    94         TInt itemCol = aItemIndex % colNum;
    95         TInt mirroredItemCol = colNum - itemCol - 1;
    95         TInt mirroredItemCol = colNum - itemCol - 1;
    96         aItemIndex = aItemIndex - itemCol + mirroredItemCol;
    96         aItemIndex = aItemIndex - itemCol + mirroredItemCol;
    97         }
    97         }
    98     
    98 
    99     // return CAknGridView::ItemPos( aItemIndex );
    99     // return CAknGridView::ItemPos( aItemIndex );
   100     return CorrectItemPos( aItemIndex );
   100     return CorrectItemPos( aItemIndex );
   101     }
   101     }
   102 
   102 
   103 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   107 TPoint CMmGridView::CorrectItemPos( TInt aItemIndex ) const
   107 TPoint CMmGridView::CorrectItemPos( TInt aItemIndex ) const
   108     {
   108     {
   109     // it the assertion below fails, review this implementation to make sure that
   109     // it the assertion below fails, review this implementation to make sure that
   110     // primary vertical case is handled correctly
   110     // primary vertical case is handled correctly
   111     ASSERT( !IsPrimaryVertical() );
   111     ASSERT( !IsPrimaryVertical() );
   112     
   112 
   113     ASSERT( aItemIndex >= 0 );
   113     ASSERT( aItemIndex >= 0 );
   114     const TInt colNum = NumberOfColsInView();
   114     const TInt colNum = NumberOfColsInView();
   115     TInt itemRow = aItemIndex / colNum;
   115     TInt itemRow = aItemIndex / colNum;
   116     TInt itemCol = aItemIndex % colNum;
   116     TInt itemCol = aItemIndex % colNum;
   117     
   117 
   118     TInt topItemRow = TopItemIndex() / colNum;
   118     TInt topItemRow = TopItemIndex() / colNum;
   119 //    __ASSERT_DEBUG( TopItemIndex() % colNum == 0, User::Invariant() );
   119 //    __ASSERT_DEBUG( TopItemIndex() % colNum == 0, User::Invariant() );
   120     
   120 
   121     // it is safe to assume that size between items is (0, 0) because we
   121     // it is safe to assume that size between items is (0, 0) because we
   122     // explicitly set such value in CMmGrid::DoSetupLayoutL
   122     // explicitly set such value in CMmGrid::DoSetupLayoutL
   123     const TSize sizeBetweenItems( 0, 0 );
   123     const TSize sizeBetweenItems( 0, 0 );
   124     
   124 
   125     TPoint itemPos(
   125     TPoint itemPos(
   126         iViewRect.iTl.iX + itemCol *
   126         iViewRect.iTl.iX + itemCol *
   127             ( ColumnWidth() + sizeBetweenItems.iWidth ),
   127             ( ColumnWidth() + sizeBetweenItems.iWidth ),
   128         iViewRect.iTl.iY + (itemRow - topItemRow) *
   128         iViewRect.iTl.iY + (itemRow - topItemRow) *
   129             ( iItemHeight + sizeBetweenItems.iHeight ) + iVerticalOffset );
   129             ( iItemHeight + sizeBetweenItems.iHeight ) + iVerticalOffset );
   238 
   238 
   239     	drawingInitiated=ETrue;
   239     	drawingInitiated=ETrue;
   240 		iWin->Invalidate( *aClipRect );
   240 		iWin->Invalidate( *aClipRect );
   241 		iWin->BeginRedraw( *aClipRect );
   241 		iWin->BeginRedraw( *aClipRect );
   242     	}
   242     	}
   243     CAknGridView::Draw( aClipRect );
   243 
       
   244     if ( !itemDrawer->IsEditMode() )
       
   245         {
       
   246         itemDrawer->DrawBackgroundAndSeparatorLines(ViewRect());
       
   247         itemDrawer->SetRedrawItemBackground( EFalse );
       
   248         CAknGridView::Draw( aClipRect );
       
   249         itemDrawer->SetRedrawItemBackground( ETrue );
       
   250         }
       
   251     else
       
   252         {
       
   253         CAknGridView::Draw( aClipRect );
       
   254         }
   244 
   255 
   245 	if ( aClipRect )
   256 	if ( aClipRect )
   246 	    {
   257 	    {
   247     	TRect rect(*aClipRect);
   258     	TRect rect(*aClipRect);
   248     	TInt lastItemInView = (iModel->NumberOfItems() <= BottomItemIndex() )
   259     	TInt lastItemInView = (iModel->NumberOfItems() <= BottomItemIndex() )
   286 	{
   297 	{
   287 	//	we need to update the iItemHeight member in grid also (there are two different item height value holders - in grid and here in grid view)
   298 	//	we need to update the iItemHeight member in grid also (there are two different item height value holders - in grid and here in grid view)
   288 	CMmListBoxItemDrawer* itemDrawer =
   299 	CMmListBoxItemDrawer* itemDrawer =
   289 	        STATIC_CAST( CMmListBoxItemDrawer*, ItemDrawer() );
   300 	        STATIC_CAST( CMmListBoxItemDrawer*, ItemDrawer() );
   290 	static_cast<CMmGrid*>(itemDrawer->Widget())->SetItemHeight( aItemHeight );
   301 	static_cast<CMmGrid*>(itemDrawer->Widget())->SetItemHeight( aItemHeight );
   291 	
   302 
   292 	CAknGridView::SetItemHeight(aItemHeight);
   303 	CAknGridView::SetItemHeight(aItemHeight);
   293 	}
   304 	}
   294 
   305 
   295 // -----------------------------------------------------------------------------
   306 // -----------------------------------------------------------------------------
   296 //
   307 //