meetingrequest/mrgui/mrfieldbuildercommon/src/cesmreditor.cpp
branchRCL_3
changeset 18 6b8f3b30d0ec
parent 12 4ce476e64c59
equal deleted inserted replaced
17:67369d1b217f 18:6b8f3b30d0ec
    25 #include <txtglobl.h>
    25 #include <txtglobl.h>
    26 #include <txtrich.h>
    26 #include <txtrich.h>
    27 #include <gulfont.h>
    27 #include <gulfont.h>
    28 #include <eikenv.h>
    28 #include <eikenv.h>
    29 #include <avkon.hrh>
    29 #include <avkon.hrh>
       
    30 #include <AknUtils.h>
    30 
    31 
    31 
    32 
    32 #include "emailtrace.h"
    33 #include "emailtrace.h"
    33 
    34 
    34 // ======== MEMBER FUNCTIONS ========
    35 // ======== MEMBER FUNCTIONS ========
   124             TextLayout()->DocPosToXyPosL( CursorPos(), cursorPos);
   125             TextLayout()->DocPosToXyPosL( CursorPos(), cursorPos);
   125             TInt edwinTlY = Position().iY;
   126             TInt edwinTlY = Position().iY;
   126             TInt listHeight = iObserver->ListHeight();
   127             TInt listHeight = iObserver->ListHeight();
   127 
   128 
   128             // edwinTlY negative
   129             // edwinTlY negative
   129             if ( cursorLowerPosition > ( listHeight - edwinTlY )) 
   130             if ( cursorLowerPosition > ( listHeight - edwinTlY ))
   130                 {
   131                 {
   131                 iObserver->RePositionFields( -RowHeight() );
   132                 iObserver->RePositionFields( -RowHeight() );
   132                 }
   133                 }
   133             }
   134             }
   134         else if ( aKeyEvent.iCode == EKeyUpArrow && iObserver)
   135         else if ( aKeyEvent.iCode == EKeyUpArrow && iObserver)
   158 // ---------------------------------------------------------------------------
   159 // ---------------------------------------------------------------------------
   159 //
   160 //
   160 EXPORT_C void CESMREditor::FocusChanged(TDrawNow aDrawNow)
   161 EXPORT_C void CESMREditor::FocusChanged(TDrawNow aDrawNow)
   161     {
   162     {
   162     FUNC_LOG;
   163     FUNC_LOG;
   163     
   164 
   164     CEikRichTextEditor::FocusChanged( aDrawNow );
   165     CEikRichTextEditor::FocusChanged( aDrawNow );
   165     
   166 
   166     TRAPD( error, TryToSetSelectionL() );
   167     TRAPD( error, TryToSetSelectionL() );
   167     if ( error != KErrNone )
   168     if ( error != KErrNone )
   168         {
   169         {
   169         iCoeEnv->HandleError( error );// codescanner::eikonenvstatic
   170         iCoeEnv->HandleError( error );// codescanner::eikonenvstatic
   170         }
   171         }
   232         		{
   233         		{
   233         		if ( iObserver )
   234         		if ( iObserver )
   234         			{
   235         			{
   235         	        TInt curPos = CursorPos ();
   236         	        TInt curPos = CursorPos ();
   236         	        TInt textLength = TextLength();
   237         	        TInt textLength = TextLength();
   237         	        // Update viewarea scrolling in cases where the cursor location 
   238         	        // Update viewarea scrolling in cases where the cursor location
   238         	        // is changed directly from bottom to upmost position or vise versa.
   239         	        // is changed directly from bottom to upmost position or vise versa.
   239         	        if ( CursorPos () == TextLength() || CursorPos () == 0 )
   240         	        if ( CursorPos () == TextLength() || CursorPos () == 0 )
   240         	            {
   241         	            {
   241         	            // KErrNotFound as field id is interpret as focused field:
   242         	            // KErrNotFound as field id is interpret as focused field:
   242         	            iObserver->ScrollControlVisible( KErrNotFound );
   243         	            iObserver->ScrollControlVisible( KErrNotFound );
   243         	            }
   244         	            }
   244         			}
   245         			}
   245         		break;
   246         		break;
   246         		}
   247         		}
   247         		
   248 
   248         	case EEventTextUpdate:
   249         	case EEventTextUpdate:
   249         		{
   250         		{
   250         		if ( IsVisible() )
   251         		if ( IsVisible() )
   251         			{
   252         			{
   252         			DrawDeferred();
   253         			DrawDeferred();
   253         			}
   254         			}
   254         		break;
   255         		break;
   255         		}
   256         		}
   256         		
   257 
   257         	default:
   258         	default:
   258         		{
   259         		{
   259         		break;
   260         		break;
   260         		}
   261         		}
   261         	}
   262         	}
   290     TParaFormatMask paraFormatMask;
   291     TParaFormatMask paraFormatMask;
   291     paraFormat->iLineSpacingControl = CParaFormat::ELineSpacingExactlyInPixels;
   292     paraFormat->iLineSpacingControl = CParaFormat::ELineSpacingExactlyInPixels;
   292 
   293 
   293     paraFormatMask.SetAttrib( EAttLineSpacing );
   294     paraFormatMask.SetAttrib( EAttLineSpacing );
   294     paraFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
   295     paraFormat->iHorizontalAlignment = CParaFormat::ELeftAlign;
       
   296     if ( AknLayoutUtils::LayoutMirrored() )
       
   297         {
       
   298         paraFormat->iHorizontalAlignment = CParaFormat::ERightAlign;
       
   299         }
   295     paraFormatMask.SetAttrib( EAttAlignment );
   300     paraFormatMask.SetAttrib( EAttAlignment );
   296 
   301 
   297     TCharFormat charFormat;
   302     TCharFormat charFormat;
   298     TCharFormatMask formatMask;
   303     TCharFormatMask formatMask;
   299     charFormat.iFontSpec = fontSpec;
   304     charFormat.iFontSpec = fontSpec;
   303     formatMask.SetAttrib( EAttFontPosture );
   308     formatMask.SetAttrib( EAttFontPosture );
   304     formatMask.SetAttrib( EAttFontStrokeWeight );
   309     formatMask.SetAttrib( EAttFontStrokeWeight );
   305     formatMask.SetAttrib(EAttFontHighlightColor);
   310     formatMask.SetAttrib(EAttFontHighlightColor);
   306     formatMask.SetAttrib( EAttColor );
   311     formatMask.SetAttrib( EAttColor );
   307 
   312 
   308     charFormat.iFontPresentation.iTextColor = 
   313     charFormat.iFontPresentation.iTextColor =
   309         NMRColorManager::Color( NMRColorManager::EMRMainAreaTextColor );
   314         NMRColorManager::Color( NMRColorManager::EMRMainAreaTextColor );
   310     
   315 
   311     charFormat.iFontPresentation.iHighlightColor =  
   316     charFormat.iFontPresentation.iHighlightColor =
   312         NMRColorManager::Color( NMRColorManager::EMRCutCopyPasteHighlightColor );
   317         NMRColorManager::Color( NMRColorManager::EMRCutCopyPasteHighlightColor );
   313 
   318 
   314     CParaFormatLayer* paraFormatLayer =
   319     CParaFormatLayer* paraFormatLayer =
   315         CParaFormatLayer::NewL( paraFormat, paraFormatMask );
   320         CParaFormatLayer::NewL( paraFormat, paraFormatMask );
   316     CleanupStack::PushL( paraFormatLayer );
   321     CleanupStack::PushL( paraFormatLayer );
   319 
   324 
   320     SetParaFormatLayer( paraFormatLayer );
   325     SetParaFormatLayer( paraFormatLayer );
   321     CleanupStack::Pop( paraFormatLayer );
   326     CleanupStack::Pop( paraFormatLayer );
   322     CleanupStack::PopAndDestroy( paraFormat );
   327     CleanupStack::PopAndDestroy( paraFormat );
   323     SetCharFormatLayer( charFormatLayer );
   328     SetCharFormatLayer( charFormatLayer );
   324     
   329 
   325     // This forces CEikEdwin::OnReformatL to notify observer
   330     // This forces CEikEdwin::OnReformatL to notify observer
   326     // through HandleEdwinSizeEventL about changed size.
   331     // through HandleEdwinSizeEventL about changed size.
   327     // It is notified only if linecount changes.
   332     // It is notified only if linecount changes.
   328     CEikEdwin::iNumberOfLines = 0;
   333     CEikEdwin::iNumberOfLines = 0;
   329     CEikEdwin::FormatTextL();
   334     CEikEdwin::FormatTextL();
   383 EXPORT_C  void CESMREditor::SetDefaultTextL(
   388 EXPORT_C  void CESMREditor::SetDefaultTextL(
   384         HBufC* aDefaultText ) // codescanner::nonconsthbufc
   389         HBufC* aDefaultText ) // codescanner::nonconsthbufc
   385     {
   390     {
   386     FUNC_LOG;
   391     FUNC_LOG;
   387     SetTextL( aDefaultText );
   392     SetTextL( aDefaultText );
   388     
   393 
   389     if ( iDefaultText )
   394     if ( iDefaultText )
   390         {
   395         {
   391         delete iDefaultText;
   396         delete iDefaultText;
   392         iDefaultText = NULL;
   397         iDefaultText = NULL;
   393         }
   398         }