emailuis/emailui/src/ncseditor.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: This file implements class CNcsEditor.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include <avkon.hrh>
       
    22 #include <aknenv.h> 		// CAknEnv
       
    23 #include <txtrich.h>
       
    24 #include <txtglobl.h>
       
    25 #include <AknUtils.h>		// AknLayoutUtils
       
    26 #include <AknsConstants.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <AknsSkinInstance.h>
       
    29 #include <aknedsts.h>
       
    30 #include <AknsBasicBackgroundControlContext.h>
       
    31 
       
    32 #include "ncseditor.h"
       
    33 #include "ncsutility.h"
       
    34 #include "ncscustomdraw.h"
       
    35 #include "ncseditorcustomdraw.h"
       
    36 
       
    37 // ========================= MEMBER FUNCTIONS ==================================
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CNcsEditor::CNcsEditor( MNcsFieldSizeObserver* aSizeObserver,
       
    44                         TBool aHeaderField,
       
    45                         TNcsEditorUsage aEditorUsage ) :
       
    46     MNcsControl( aSizeObserver ),
       
    47     iPreviousFontHeight( -1 ),
       
    48     iPreviousLineSpacingInTwips( -1 ),
       
    49     // Platform layout change
       
    50     iHeaderField( aHeaderField ),
       
    51     iNcsFontType ( NcsUtility::ENcsHeaderDetailFont ),
       
    52     iEditorUsage( aEditorUsage ),
       
    53     iRealRect( 0, 0, 0, 0 )
       
    54     {
       
    55     FUNC_LOG;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // second phase constructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void CNcsEditor::ConstructL( const CCoeControl* aParent,
       
    63                              TInt aNumberOfLines,
       
    64                              TInt aTextLimit )
       
    65     {
       
    66     FUNC_LOG;
       
    67     CEikRichTextEditor::ConstructL( aParent, aNumberOfLines, aTextLimit,
       
    68             CEikEdwin::EAvkonEditor | CEikEdwin::EResizable |
       
    69             CEikEdwin::ENoAutoSelection | CEikEdwin::EInclusiveSizeFixed |
       
    70             CEikEdwin::ENoHorizScrolling | CEikRichTextEditor::EPasteAsPlainText );
       
    71 
       
    72     iGlobalCharFormat = CCharFormatLayer::NewL();
       
    73     iGlobalCharFormat->SetBase( GlobalText()->GlobalCharFormatLayer() );
       
    74     GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // destructor
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CNcsEditor::~CNcsEditor()
       
    82     {
       
    83     FUNC_LOG;
       
    84     // <cmail> Platform layout change
       
    85     delete iBgContext;
       
    86     // </cmail>
       
    87     delete iGlobalCharFormat;
       
    88     
       
    89     if ( iEditorCustomDrawer )
       
    90         {
       
    91         delete iEditorCustomDrawer;        
       
    92         }
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CNcsEditor::OpenVirtualKeyBoardL()
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CNcsEditor::OpenVirtualKeyBoardL()
       
   100     {
       
   101     FUNC_LOG;
       
   102     MCoeFepAwareTextEditor_Extension1* fepAwareTextEditor( 
       
   103             InputCapabilities().FepAwareTextEditor()->Extension1() );
       
   104     CAknEdwinState* state( NULL );
       
   105     if ( fepAwareTextEditor )
       
   106         {
       
   107         state = static_cast<CAknEdwinState*>( 
       
   108                 fepAwareTextEditor->State( KNullUid ) );
       
   109         }
       
   110     if (state)
       
   111         {
       
   112         state->ReportAknEdStateEventL( 
       
   113                 MAknEdStateObserver::EAknActivatePenInputRequest );
       
   114         }
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CNcsEditor::GetLineRectL() const
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CNcsEditor::GetLineRectL( TRect& aLineRect ) const
       
   122     {
       
   123     FUNC_LOG;
       
   124     TPoint position;
       
   125     iLayout->DocPosToXyPosL( CursorPos(), position );
       
   126     iLayout->GetLineRect( position.iY, aLineRect );
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CNcsEditor::CursorLineNumber() const
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TInt CNcsEditor::CursorLineNumber() const
       
   134     {
       
   135     FUNC_LOG;
       
   136     TInt ret = iLayout->GetLineNumber( CursorPos() );
       
   137     ret++;
       
   138     return ret;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CNcsEditor::CursorPosition() const
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CNcsEditor::CursorPosition() const
       
   146     {
       
   147     FUNC_LOG;
       
   148 	// Return the position of the cursor relative
       
   149 	// to the top of the control (in pixels)
       
   150     TPoint position;
       
   151     TInt cp = CursorPos();
       
   152     TRAP_IGNORE( iLayout->DocPosToXyPosL( cp , position ) );
       
   153     position.iY += iLayout->PixelsAboveBand();
       
   154     return position.iY;
       
   155     }
       
   156 
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CNcsEditor::OfferKeyEventL() const
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TKeyResponse CNcsEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   163 	{
       
   164     FUNC_LOG;
       
   165 	TKeyResponse ret( EKeyWasNotConsumed );
       
   166     if( aKeyEvent.iCode == EKeyDelete && CursorPos() == TextLength() )
       
   167         {
       
   168         ClearSelectionL();
       
   169         return EKeyWasConsumed;
       
   170         }
       
   171     else
       
   172         {
       
   173         ret = CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType );
       
   174         }
       
   175 
       
   176 	return ret;
       
   177 	}
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CNcsEditor::SetTextL
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 void CNcsEditor::SetTextL( const TDesC* aDes )
       
   184     {
       
   185     FUNC_LOG;
       
   186     CEikEdwin::SetTextL( aDes );
       
   187     if ( ( *aDes ).Compare( KNullDesC ) == 0 )
       
   188         {
       
   189         // when text is emptied, set text color again
       
   190         SetTextColorL( iTextColor );
       
   191         UpdateFontSize();
       
   192         }
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CNcsEditor::SetRect
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 void CNcsEditor::SetRect( const TRect& aRect )
       
   200     {
       
   201     FUNC_LOG;
       
   202     //CCoeControl::SetRect( aRect );
       
   203     CEikRichTextEditor::SetRect( aRect );
       
   204     }
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CNcsEditor::HandleResourceChange
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 void CNcsEditor::HandleResourceChange( TInt aType )
       
   211     {
       
   212     FUNC_LOG;
       
   213     CEikRichTextEditor::HandleResourceChange( aType );
       
   214 
       
   215     if ( aType == KAknsMessageSkinChange )
       
   216         {
       
   217         // S60 skin support
       
   218         UpdateGraphics();
       
   219         UpdateFontSize();
       
   220         UpdateColors();
       
   221         if ( iCustomDrawer )
       
   222             {
       
   223             iCustomDrawer->UpdateColors();
       
   224             }
       
   225         }
       
   226     else if ( aType == KEikMessageColorSchemeChange )
       
   227         {
       
   228         UpdateFontSize();
       
   229         UpdateColors();
       
   230         if ( iCustomDrawer )
       
   231             {
       
   232             iCustomDrawer->UpdateColors();
       
   233             }
       
   234         }
       
   235     else if ( aType == KEikMessageZoomChange )
       
   236         {
       
   237         UpdateFontSize();
       
   238         }
       
   239 
       
   240     if ( iEditorCustomDrawer )
       
   241         {
       
   242         iEditorCustomDrawer->UpdateLayout( GetLayout() );
       
   243         }
       
   244     }
       
   245 
       
   246 //<cmail> Platform layout change
       
   247 // -----------------------------------------------------------------------------
       
   248 // CNcsEditor::CreateCustomDrawL
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 /*
       
   252 CLafEdwinCustomDrawBase* CNcsEditor::CreateCustomDrawL()
       
   253     {
       
   254     CLafEdwinCustomDrawBase* drawer = CEikEdwin::CreateCustomDrawL();
       
   255     iCustomDrawer = new ( ELeave ) CNcsCustomDraw(
       
   256         static_cast<CEikonEnv*>( ControlEnv() )->LafEnv(),
       
   257         *this,
       
   258         drawer,
       
   259         this,
       
   260         iHeaderField );
       
   261     iCustomDrawer->UpdateColors();
       
   262     return iCustomDrawer;
       
   263     }
       
   264 */    
       
   265 // </cmail>
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // CNcsEditor::SetupEditorL()
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 void CNcsEditor::SetupEditorL()
       
   272     {
       
   273     FUNC_LOG;
       
   274     // <cmail> Added text view creation.
       
   275     // In S60 5.0 we end up here before this control is "activated". Normally
       
   276     // text view is created in CEikGlobalTextEditor::ActivateL
       
   277     // Find out why this problem doesn't exist in Freestyle/S60 3.2.3.
       
   278     if ( !iTextView )
       
   279         {
       
   280         CreateTextViewL();
       
   281         }
       
   282     // </cmail>
       
   283 
       
   284     // <cmail> Platform layout change
       
   285     //TextLayout()->RestrictScrollToTopsOfLines( EFalse );
       
   286     // </cmail>
       
   287 
       
   288     // Set the cursor position to initialize the edit control
       
   289     SetCursorPosL(0,EFalse);
       
   290     UpdateFontSize();
       
   291     UpdateColors();
       
   292     // <cmail> S60 skin support
       
   293     UpdateGraphics();
       
   294     // </cmail>
       
   295 	}
       
   296 
       
   297 // -----------------------------------------------------------------------------
       
   298 // CNcsEditor::LineCount() const
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 TInt CNcsEditor::LineCount() const
       
   302     {
       
   303     FUNC_LOG;
       
   304     TInt lineCount = iLayout->GetLineNumber( TextLength() );
       
   305     lineCount++;
       
   306     return lineCount;
       
   307     }
       
   308 
       
   309 TInt CNcsEditor::ScrollableLines() const
       
   310     {
       
   311     FUNC_LOG;
       
   312 	TRect lineRect;
       
   313 	// First get the rect for one line
       
   314 	iLayout->GetLineRect(0, lineRect);
       
   315 	TRect rect = Rect();
       
   316 	TInt lines = rect.Height()/lineRect.Height();
       
   317 	return lines;
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CNcsEditor::PositionChanged() const
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CNcsEditor::PositionChanged()
       
   325     {    
       
   326     FUNC_LOG;
       
   327     if( iTextView )
       
   328         {
       
   329         TRect displayRect=iBorder.InnerRect(Rect());
       
   330 	    displayRect=iMargins.InnerRect(displayRect);
       
   331 	    iTextView->SetViewRect(displayRect);
       
   332         }
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // CNcsEditor::TextHeight() const
       
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 TInt CNcsEditor::TextHeight() const
       
   340     {
       
   341     FUNC_LOG;
       
   342     return iLayout->FormattedHeightInPixels();
       
   343     }
       
   344 
       
   345 #ifdef _DEBUG
       
   346 // Is is meant for debugging.
       
   347 // Break here to see what the values are.
       
   348 void CNcsEditor::DebugDump()
       
   349     {
       
   350     FUNC_LOG;
       
   351 	TInt bandHeight = iLayout->BandHeight();
       
   352 	TInt firstDocPosFullyInBad = iLayout->FirstDocPosFullyInBand();
       
   353 	TInt firstLineInBand = iLayout->FirstLineInBand();
       
   354 	TInt pixelsAboveBand = iLayout->PixelsAboveBand();
       
   355     }
       
   356 #endif
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // CNcsEditor::SetTextColorL()
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 void CNcsEditor::SetTextColorL( TLogicalRgb aColor )
       
   363 	{
       
   364     FUNC_LOG;
       
   365     TCharFormat charFormat;
       
   366     charFormat.iFontPresentation.iTextColor = aColor;
       
   367     TCharFormatMask charFormatMask;
       
   368     charFormatMask.SetAttrib( EAttColor );
       
   369     iGlobalCharFormat->SetL( charFormat, charFormatMask );
       
   370     GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
       
   371     NotifyNewFormatL();
       
   372     }
       
   373 
       
   374 TBool CNcsEditor::HasSemicolonAtTheEndL() const
       
   375 {
       
   376     HBufC* text = GetTextInHBufL();
       
   377     
       
   378     TBool result(EFalse);
       
   379     if ( text && text->Right(1).Compare(_L(";") ) == 0 )
       
   380         {
       
   381         result = ETrue;
       
   382         }
       
   383     delete text;
       
   384     text = NULL;
       
   385     
       
   386     return result;
       
   387 }
       
   388 
       
   389 // -----------------------------------------------------------------------------
       
   390 // CNcsEditor::TrimmedTextLength()
       
   391 // -----------------------------------------------------------------------------
       
   392 //
       
   393 TInt CNcsEditor::TrimmedTextLength()
       
   394     {
       
   395     FUNC_LOG;
       
   396     HBufC* text = NULL;
       
   397     TRAP_IGNORE( text = GetTextInHBufL() );
       
   398     TInt length = 0;
       
   399     if ( text )
       
   400         {
       
   401         text->Des().TrimAll();
       
   402         length = text->Des().Length();
       
   403         delete text;
       
   404         }
       
   405     return length;
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CNcsEditor::EditObserver()
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 void CNcsEditor::EditObserver( TInt aStart, TInt aExtent )
       
   413     {
       
   414     FUNC_LOG;
       
   415     CEikRichTextEditor::EditObserver( aStart, aExtent );
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // CNcsEditor::UpdateColors
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 void CNcsEditor::UpdateColors()
       
   423     {
       
   424     FUNC_LOG;
       
   425     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   426 	// <cmail> S60 Skin support
       
   427 	const TInt error( AknsUtils::GetCachedColor( skin, iTextColor,
       
   428     	KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) );
       
   429     if ( error )
       
   430     	{
       
   431         iTextColor = KRgbBlack;
       
   432         }
       
   433 
       
   434     // </cmail>
       
   435     TRAP_IGNORE( SetTextColorL( iTextColor ) );
       
   436     }
       
   437 
       
   438 // <cmail>
       
   439 // -----------------------------------------------------------------------------
       
   440 // CNcsEditor::SetNcsFontType
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 void CNcsEditor::SetNcsFontType( NcsUtility::TNcsLayoutFont aFontType )
       
   444     {
       
   445     FUNC_LOG;
       
   446     iNcsFontType = aFontType;
       
   447     }
       
   448 
       
   449 // -----------------------------------------------------------------------------
       
   450 // CNcsEditor::UpdateFontSize
       
   451 // -----------------------------------------------------------------------------
       
   452 //
       
   453 void CNcsEditor::UpdateFontSize()
       
   454     {
       
   455     FUNC_LOG;
       
   456     /*TCharFormat charFormat;
       
   457     TCharFormatMask charFormatMask;
       
   458 
       
   459     TNcsMeasures m = NcsUtility::Measures();
       
   460 
       
   461     // <cmail>
       
   462     CFont* editorFont = NULL;
       
   463 
       
   464     TRAPD( err, editorFont = NcsUtility::GetNearestFontL(
       
   465     	EAknLogicalFontPrimarySmallFont,
       
   466     	m.iEditorFontHeightPx)
       
   467     	);
       
   468 
       
   469     if( err == KErrNone )
       
   470     	{
       
   471     	*/
       
   472 
       
   473     TRAP_IGNORE( UpdateFontL() );
       
   474 //    CEikonEnv::Static()->ScreenDevice()->ReleaseFont( editorFont );
       
   475 //	}
       
   476     }
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CNcsEditor::UpdateFontL
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 void CNcsEditor::UpdateFontL()
       
   483     {
       
   484 	FUNC_LOG;
       
   485     TCharFormat charFormat;
       
   486     TCharFormatMask charFormatMask;
       
   487     charFormat.iFontSpec = NcsUtility::GetLayoutFont( Rect(), iNcsFontType )->FontSpecInTwips();
       
   488     charFormat.iFontPresentation.iTextColor = iTextColor;
       
   489     charFormatMask.SetAttrib(EAttColor);
       
   490     charFormatMask.SetAttrib(EAttFontTypeface);
       
   491     charFormatMask.SetAttrib(EAttFontHeight);
       
   492     iGlobalCharFormat->SetL(charFormat, charFormatMask);
       
   493     GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
       
   494     }
       
   495 
       
   496 // </cmail>
       
   497 
       
   498 // -----------------------------------------------------------------------------
       
   499 // CNcsEditor::UpdateGraphics
       
   500 // -----------------------------------------------------------------------------
       
   501 //
       
   502 void CNcsEditor::UpdateGraphics()
       
   503     {
       
   504     TRAP_IGNORE( DoUpdateGraphicsL() );
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // CNcsEditor::DoUpdateGraphicsL
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 void CNcsEditor::DoUpdateGraphicsL()
       
   512     {
       
   513 	// <cmail> S60 Skin support
       
   514     delete iBgContext;
       
   515     iBgContext = NULL;
       
   516 
       
   517     TSize mainPaneSize;
       
   518  	AknLayoutUtils::LayoutMetricsSize(
       
   519  	    AknLayoutUtils::EMainPane, mainPaneSize );
       
   520 
       
   521     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
   522         //KAknsIIDQgnFsGrafEmailContent,
       
   523         KAknsIIDQsnBgAreaMain,
       
   524         TRect( mainPaneSize ),
       
   525         EFalse );
       
   526 
       
   527     SetSkinBackgroundControlContextL( iBgContext );
       
   528 	// </cmail>
       
   529     }
       
   530 
       
   531 // ---------------------------------------------------------------------------
       
   532 // CNcsEditor::GetLabelText
       
   533 // ---------------------------------------------------------------------------
       
   534 //
       
   535 const TDesC& CNcsEditor::GetLabelText() const
       
   536     {
       
   537 	return KNullDesC;
       
   538     }
       
   539 
       
   540 // <cmail> Platform layout change
       
   541 // ---------------------------------------------------------------------------
       
   542 // CNcsEditor::LayoutLineCount
       
   543 // ---------------------------------------------------------------------------
       
   544 //
       
   545 TInt CNcsEditor::LayoutLineCount() const
       
   546     {
       
   547     return IsVisible() ? LineCount() : 0;
       
   548     }
       
   549 // </cmail> Platform layout change
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // CNcsEditor::GetNumChars
       
   553 // ---------------------------------------------------------------------------
       
   554 //
       
   555 TInt CNcsEditor::GetNumChars() const
       
   556     {
       
   557     FUNC_LOG;
       
   558 	TInt cnt = iLayout->DocumentLength();
       
   559 	return cnt;
       
   560     }
       
   561 
       
   562 TInt CNcsEditor::GetLineHeightL() const
       
   563     {
       
   564     FUNC_LOG;
       
   565 	TPoint pos;
       
   566 	TRect rect;
       
   567 	iLayout->DocPosToXyPosL(0, pos);
       
   568 	iLayout->GetLineRect(pos.iY,rect);
       
   569 	return rect.Height();
       
   570     }
       
   571 
       
   572 TInt CNcsEditor::DocumentLength() const
       
   573     {
       
   574     FUNC_LOG;
       
   575 	return iLayout->DocumentLength();
       
   576     }
       
   577 
       
   578 TInt CNcsEditor::PixelsAboveBand() const
       
   579     {
       
   580     FUNC_LOG;
       
   581 	return iLayout->PixelsAboveBand();
       
   582     }
       
   583 
       
   584 TInt CNcsEditor::ChangeBandTopL(TInt aPixels)
       
   585     {
       
   586     FUNC_LOG;
       
   587 	TInt px = aPixels;
       
   588 	return iLayout->ChangeBandTopL(px);
       
   589     }
       
   590 
       
   591 void CNcsEditor::ActivateL()
       
   592     {
       
   593     if ( IsActivated() )
       
   594         {
       
   595         return;
       
   596         }
       
   597 
       
   598     CEikRichTextEditor::ActivateL();
       
   599         
       
   600     if ( !iEditorCustomDrawer && iEditorUsage != ENcsEditorDefault )
       
   601         {
       
   602         TAknTextComponentLayout layout;
       
   603         if ( iEditorUsage == ENcsEditorBody )
       
   604             {
       
   605             layout = AknLayoutScalable_Apps::list_cmail_body_pane_t1();
       
   606             }
       
   607         else if ( iEditorUsage == ENcsEditorAddress ||
       
   608                   iEditorUsage == ENcsEditorSubject ) 
       
   609             {
       
   610             layout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety );
       
   611             }
       
   612 
       
   613         // Swap the custom drawer to our own to show text lines.
       
   614         const MFormCustomDraw* customDraw = TextLayout()->CustomDraw();
       
   615     
       
   616         iEditorCustomDrawer = CNcsEditorCustomDraw::NewL( customDraw, this, GetLayout() );
       
   617         
       
   618         TextLayout()->SetCustomDraw( iEditorCustomDrawer );
       
   619         }
       
   620     }
       
   621 
       
   622 //<cmail>
       
   623 void CNcsEditor::SetRealRect( TRect aRect )
       
   624 	{
       
   625 	iRealRect = aRect;
       
   626 	}
       
   627 
       
   628 void CNcsEditor::Draw( const TRect& /*aRect*/ ) const
       
   629     {
       
   630     if ( iTextView )
       
   631         {
       
   632         CWindowGc& gc=SystemGc();
       
   633         TRect viewRect( iTextView->ViewRect() );
       
   634         if( iRealRect.Height() > 0 )
       
   635         	{
       
   636         	if( !( viewRect.iTl.iY > iRealRect.iBr.iY || viewRect.iBr.iY < iRealRect.iTl.iY  ) )
       
   637         		{
       
   638         		TrappedDraw( iRealRect );
       
   639         		}
       
   640         	}
       
   641         else
       
   642         	{
       
   643         	TrappedDraw( viewRect );
       
   644         	}
       
   645         
       
   646         
       
   647     #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   648         // Workaround for clipping rect problem in multiline queries with text
       
   649         // entries.  Because of differences between CRemoteGc and CWindowGc, 
       
   650         // parts of the query wouldn't be drawn by CRemoteGc.  The Reset() call
       
   651         // is to cancel the clipping rect.  For some reason, CancelClippingRect()
       
   652         // and CancelClippingRegion() don't work.
       
   653         gc.Reset();
       
   654     #endif
       
   655         }
       
   656     }
       
   657 
       
   658 void CNcsEditor::FormatAllTextNowL()
       
   659 	{
       
   660 	NotifyNewFormatL();
       
   661 	iTextView->FinishBackgroundFormattingL();
       
   662 	}
       
   663 //</cmail>
       
   664 
       
   665 TAknTextComponentLayout CNcsEditor::GetLayout()
       
   666     {
       
   667     TAknTextComponentLayout layout;
       
   668 
       
   669     if ( iEditorUsage == ENcsEditorBody )
       
   670         {
       
   671         layout = AknLayoutScalable_Apps::list_cmail_body_pane_t1();
       
   672         }
       
   673     else if ( iEditorUsage == ENcsEditorAddress ||
       
   674               iEditorUsage == ENcsEditorSubject ) 
       
   675         {
       
   676         layout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety );
       
   677         }
       
   678 
       
   679     return layout;
       
   680     }
       
   681 
       
   682 
       
   683 void CNcsEditor::UpdateCustomDrawer()
       
   684     {
       
   685     if ( iEditorCustomDrawer )
       
   686         {
       
   687         iEditorCustomDrawer->UpdateLayout( GetLayout() );
       
   688         }
       
   689     }