emailuis/emailui/src/ncseditorcustomdraw.cpp
branchRCL_3
changeset 19 b13141f05c3d
parent 0 8466d47a6819
child 24 b5fbb9b25d57
--- a/emailuis/emailui/src/ncseditorcustomdraw.cpp	Wed Apr 14 15:42:15 2010 +0300
+++ b/emailuis/emailui/src/ncseditorcustomdraw.cpp	Tue Apr 27 16:20:14 2010 +0300
@@ -82,36 +82,43 @@
     TRect& aDrawn ) const
     {
     FUNC_LOG;
-    iCustomDrawer->DrawBackground( aParam, aBackground, aDrawn );
-    TInt lineHeigth( 0 );
-    TRAP_IGNORE( lineHeigth = iEditor->GetLineHeightL() );
-
-    TAknTextDecorationMetrics decorationMetrics( iTextPaneLayout.LayoutLine().FontId() );
-    TInt topMargin, bottomMargin;
-    decorationMetrics.GetTopAndBottomMargins( topMargin, bottomMargin );
-
-    TInt lineOffset = iTextPaneLayout.H() + topMargin + bottomMargin;
+    if ( iPrevBrX == 0 )
+        {
+        const_cast<CNcsEditorCustomDraw*>(this)->iPrevBrX = aParam.iDrawRect.iBr.iX;
+        }
+    
+    // draw background if text selection is ongoing
+    if ( iEditor->SelectionLength() )
+    	{
+		iCustomDrawer->DrawBackground( aParam, aBackground, aDrawn );
+    	}
+    else
+    	{
+        aDrawn = aParam.iDrawRect;
+    	}
+    	
+    if ( aParam.iDrawRect.iTl.iX < iPrevBrX )
+        {
+        aParam.iGc.SetPenColor( iLineColor );
     
-    TRgb lineColor = NcsUtility::CalculateMsgBodyLineColor( KFSColorDarkeningDegree, 
-                                                            NcsUtility::SeparatorLineColor() );
-    aParam.iGc.SetPenColor( lineColor );
-
-    TInt margin( 0 );
-    if ( aParam.iDrawRect.Height() < lineHeigth ||
-         aParam.iDrawRect.Height() == lineOffset )
-        {
-        margin = 1;
-        }
-
-    TRect currentRect( aParam.iDrawRect.iTl , TPoint( aParam.iDrawRect.iBr.iX, aParam.iDrawRect.iTl.iY + lineOffset - margin ));
+        TInt margin( 0 );
+        if ( aParam.iDrawRect.Height() < iLineHeigth ||
+             aParam.iDrawRect.Height() == iLineOffset )
+            {
+            margin = 1;
+            }
     
-    while ( currentRect.iBr.iY <= aParam.iDrawRect.iBr.iY )
-        {
-        if ( currentRect.iTl.iY >= aParam.iDrawRect.iTl.iY  )
+        TRect currentRect( aParam.iDrawRect.iTl , TPoint( aParam.iDrawRect.iBr.iX, aParam.iDrawRect.iTl.iY + iLineOffset - margin ));
+        
+        while ( currentRect.iBr.iY <= aParam.iDrawRect.iBr.iY )
             {
-            aParam.iGc.DrawLine( TPoint( currentRect.iTl.iX, currentRect.iBr.iY), currentRect.iBr );
+            if ( currentRect.iTl.iY >= aParam.iDrawRect.iTl.iY  )
+                {
+                aParam.iGc.DrawLine( TPoint( currentRect.iTl.iX, currentRect.iBr.iY), currentRect.iBr );
+                }
+            currentRect.Move( 0, iLineHeigth );
             }
-        currentRect.Move( 0, lineHeigth );
+        const_cast<CNcsEditorCustomDraw*>(this)->iPrevBrX = aParam.iDrawRect.iBr.iX;
         }
     }
 
@@ -164,4 +171,12 @@
 void CNcsEditorCustomDraw::UpdateLayout( TAknTextComponentLayout aLayout )
     {
     iTextPaneLayout = aLayout;
+    TRAP_IGNORE( iLineHeigth = iEditor->GetLineHeightL() );
+    iLineColor = NcsUtility::CalculateMsgBodyLineColor( KFSColorDarkeningDegree, 
+                                                            NcsUtility::SeparatorLineColor() );
+    TAknTextDecorationMetrics decorationMetrics( iTextPaneLayout.LayoutLine().FontId() );
+    TInt topMargin, bottomMargin;
+    decorationMetrics.GetTopAndBottomMargins( topMargin, bottomMargin );
+
+    iLineOffset = iTextPaneLayout.H() + topMargin + bottomMargin;
     }