messagingappbase/smartmessaging/richbio/src/CRichBio.cpp
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
child 22 52d61119153d
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *     This is a wrapper class for rich text editor.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include "CRichBio.h"                       // Own header
       
    24 #include <txtrich.h>                        // CRichText
       
    25 #include <calslbs.h>                        // Fonts
       
    26 #include <MsgExpandableControlEditor.h>     // CMsgExpandableControlEditor
       
    27 #include <MsgEditorCommon.h>                // MaxBodyHeight
       
    28 #include <AknLayoutDef.h>       // TAknLayoutId
       
    29 #include <AknUtils.h>
       
    30 
       
    31 #include    <applayout.cdl.h> // LAF
       
    32 #include    <aknlayoutscalable_apps.cdl.h>
       
    33 
       
    34 /// panic codes
       
    35 enum TRichBioPanicCodes
       
    36     {
       
    37     EPanicCacheProblem1 = 100,
       
    38     EPanicCacheProblem2,
       
    39     EPanicCacheMismatch1,
       
    40     EPanicCacheMismatch2,
       
    41     EPanicCacheMismatch3,
       
    42     EPanicEditorIsNull1,
       
    43     EPanicEditorIsNull2,
       
    44     EPanicNoCache,
       
    45     EPanicConstructedTwice,
       
    46     EPanicNoParent
       
    47     };
       
    48 
       
    49 // LOCAL CONSTANTS
       
    50 
       
    51 // Define the margins used in editor here.
       
    52 const TInt KMarginTop = 0;
       
    53 const TInt KMarginBottom = 0;
       
    54 const TInt KMarginLeft = 3;
       
    55 const TInt KMarginRight = 1;
       
    56 
       
    57 // CLASS DECLARATION
       
    58 
       
    59 /**
       
    60 * CRichbio inner class, which implements the observer
       
    61 * interface.
       
    62 */
       
    63 class CRichBio::CEdwinSizeObserver : public CBase,
       
    64     public MEikEdwinSizeObserver
       
    65     {
       
    66     public: // from MEikEdwinSizeObserver
       
    67 
       
    68         /**
       
    69         * Constructor.
       
    70         * @param Reference to the richbio object.
       
    71         */
       
    72         CEdwinSizeObserver( CRichBio& aRichBio );
       
    73 
       
    74         /**
       
    75          * Destructor.
       
    76          */
       
    77         ~CEdwinSizeObserver() {};
       
    78 
       
    79         /**
       
    80          * Handles edwin size event. Sets new size for this control and
       
    81          * reports the observer if the control editor's size is about to
       
    82          * change. Returns ETrue if size change is allowed.
       
    83          * @param aEdwin Edwin control.
       
    84          * @param aEventType Type of the event.
       
    85          * @param aDesirableEdwinSize control's desired size.
       
    86          * @return Boolean
       
    87          */
       
    88         TBool HandleEdwinSizeEventL(CEikEdwin* aEdwin,
       
    89             TEdwinSizeEvent aEventType,
       
    90             TSize aDesirableEdwinSize);
       
    91     private:
       
    92         /// Reference to the richbio control.
       
    93         CRichBio& iRichBio;
       
    94     };
       
    95 
       
    96 CRichBio::CEdwinSizeObserver::CEdwinSizeObserver( CRichBio& aRichBio ) :
       
    97     iRichBio( aRichBio )
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CEdwinSizeObserver::HandleEdwinSizeEventL
       
   103 //
       
   104 // Handles edwin size event. Sets new size for this control and reports the
       
   105 // observer if the control editor's size is about to change. Returns ETrue
       
   106 // if size change is allowed.
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 TBool CRichBio::CEdwinSizeObserver::HandleEdwinSizeEventL(
       
   110     CEikEdwin* /*aEdwin*/,
       
   111     TEdwinSizeEvent aEventType,
       
   112     TSize aDesirableEdwinSize)
       
   113     {
       
   114     if (aEventType == EEventSizeChanging)
       
   115         {
       
   116         TSize thisSize(iRichBio.Size());
       
   117         aDesirableEdwinSize.iHeight = MsgEditorCommons::MaxBodyHeight();
       
   118 
       
   119         TInt delta( aDesirableEdwinSize.iHeight - iRichBio.iEditor->Size().iHeight );
       
   120 
       
   121         if (delta)
       
   122             {
       
   123             thisSize.iHeight = aDesirableEdwinSize.iHeight;
       
   124             iRichBio.SetSizeWithoutNotification(thisSize);
       
   125             iRichBio.iEditor->SetSize(aDesirableEdwinSize);
       
   126             }
       
   127         return ETrue;
       
   128 
       
   129         }
       
   130     return EFalse;
       
   131     }
       
   132 
       
   133 EXPORT_C CRichBio* CRichBio::NewL(const CCoeControl* aParent,
       
   134     TRichBioMode aMode)
       
   135     {
       
   136     CRichBio* self = new (ELeave) CRichBio( aMode );
       
   137     CleanupStack::PushL( self );
       
   138     self->ConstructL( aParent );
       
   139     CleanupStack::Pop( self );
       
   140     return self;
       
   141     }
       
   142 
       
   143 CRichBio::~CRichBio()
       
   144     {
       
   145     delete iEdwinSizeObserver;
       
   146     delete iEditor;
       
   147     delete iLabelCache;
       
   148     delete iValueCache;
       
   149     }
       
   150 
       
   151 EXPORT_C void CRichBio::AddItemL(const TDesC& aLabel, const TDesC& aValue)
       
   152     {
       
   153     if (iEditor)
       
   154         {
       
   155         AddItemToRichTextL(aLabel, aValue);
       
   156         }
       
   157     // Items needs to be always cached, because of possible layout changes.
       
   158     CacheItemL(aLabel, aValue);
       
   159     }
       
   160 
       
   161 EXPORT_C TRect CRichBio::CurrentLineRect()
       
   162     {
       
   163     TRect lineRect(0,0,0,0);
       
   164 	// if fails return 0x0 rect
       
   165     // this method is part of public SDK and this cannot be changed to leaveable.
       
   166     TRAP_IGNORE((lineRect = iEditor->CurrentLineRectL()));
       
   167     return lineRect;
       
   168     }
       
   169 
       
   170 EXPORT_C CEikRichTextEditor& CRichBio::Editor()
       
   171     {
       
   172     __ASSERT_ALWAYS(iEditor, Panic(EPanicEditorIsNull1));
       
   173     return *iEditor;
       
   174     }
       
   175 
       
   176 EXPORT_C TBool CRichBio::IsEditorBaseMode() const
       
   177     {
       
   178     return (ERichBioModeEditorBase == iMode);
       
   179     }
       
   180 
       
   181 EXPORT_C void CRichBio::Reset()
       
   182     {
       
   183     iEditor->Reset();
       
   184     iIsFirstItem = ETrue;
       
   185     TRAP_IGNORE(LoadFromCacheL());
       
   186     }
       
   187 
       
   188 void CRichBio::AddItemToRichTextL(const TDesC& aLabel, const TDesC& aValue)
       
   189     {
       
   190     TCharFormat format;
       
   191     TCharFormatMask mask;
       
   192 
       
   193     if ( aLabel.Length() > 0 )
       
   194         {
       
   195         ApplyLabelFormat( format, mask );
       
   196         AppendTextL( aLabel , format, mask );
       
   197         }
       
   198 
       
   199     if ( aValue.Length() > 0 )
       
   200         {
       
   201         ApplyValueFormat( format, mask );
       
   202         AppendTextL( aValue , format, mask );
       
   203         }
       
   204     }
       
   205 
       
   206 void CRichBio::AppendTextL( const TDesC& aText,
       
   207     const TCharFormat& aFormat,
       
   208     const TCharFormatMask& aMask )
       
   209     {
       
   210     // Create the modifiable descriptor
       
   211     HBufC* buf = HBufC::NewLC( aText.Length() );
       
   212     TPtr modifiedText = buf->Des();
       
   213     modifiedText = aText;
       
   214 
       
   215 	// This is for example for arabic numbers
       
   216 	AknTextUtils::DisplayTextLanguageSpecificNumberConversion( modifiedText );
       
   217     TInt pos(0);
       
   218 
       
   219     /*
       
   220     We have four cases, where specific character(s) must be
       
   221     converted to the CRichText understandable linebreak character
       
   222     (CEditableText::ELineBreak).
       
   223     1)  Text contains ascii code linefeed (LF) character 0x0A, which
       
   224         is converted to linebreak.
       
   225     2)  Text contains ascii code carrier return (CR) character 0x0D
       
   226     3)  Text contains both LF and CR characters particularly in this order.
       
   227         These two characters must be converted to one linebreak.
       
   228     */
       
   229 
       
   230     TUint LF(0x0A); // Linefeed character in ascii set
       
   231     TUint CR(0x0D); // Carriage return character in ascii set
       
   232 
       
   233 
       
   234 	//this implementation won't handle mixed set of CRLF / LFCR / LF / CR 
       
   235 	//linefeeds "quite" properly but that situation is not very likely
       
   236 	
       
   237     // Case 1 and 3
       
   238     while ( ( pos = modifiedText.Locate( LF ) ) != KErrNotFound ) // Locate LF
       
   239         {
       
   240         if ( pos + 1 < modifiedText.Length() && CR == modifiedText[pos + 1] ) // Is the next CR?
       
   241             {
       
   242             modifiedText.Delete( pos + 1, 1 ); // Delete if CR
       
   243             }
       
   244         modifiedText[pos] = CEditableText::ELineBreak; // Replace LF with linebreak
       
   245         
       
   246         //as added measure we will check the previous character 
       
   247         if ( (pos-1) >= 0 && CR == modifiedText[pos - 1]  ) // Is the previous CR?
       
   248             {
       
   249             modifiedText.Delete( pos -1 , 1 ); // Delete if CR
       
   250             }
       
   251         }
       
   252 
       
   253     // Case 2
       
   254     while ( ( pos = modifiedText.Locate( CR ) ) != KErrNotFound ) // Locate CR
       
   255         {
       
   256 		if ( pos + 1 < modifiedText.Length() && LF == modifiedText[pos + 1]  ) // Is the next LF?
       
   257             {
       
   258             modifiedText.Delete( pos + 1, 1 ); // Delete if LF
       
   259             }
       
   260         modifiedText[pos] = CEditableText::ELineBreak; // Replace CR with linebreak
       
   261         
       
   262         //as added measure we will check the previous character 
       
   263         if ( (pos-1) >= 0 && LF == modifiedText[pos - 1 ] ) // Is the previous LF?
       
   264             {
       
   265             modifiedText.Delete( pos -1, 1 ); // Delete if LF
       
   266             }
       
   267         }
       
   268 
       
   269     // Append the modified text to the richtext.
       
   270     CRichText* rich = iEditor->RichText();
       
   271     User::LeaveIfNull( rich );
       
   272 
       
   273     TInt documentPos = rich->DocumentLength();
       
   274 
       
   275     // Every time when text is added, the cursor is left at the end of the line.
       
   276     // When the new text is added we must first add linebreak and then the text
       
   277     // linebreak is not added if the text is first item.
       
   278     if ( !iIsFirstItem )
       
   279         {
       
   280         // Append the linebreak to the end of the richtext.
       
   281         rich->InsertL(documentPos, CEditableText::ELineBreak);
       
   282         }
       
   283     else
       
   284         {
       
   285         iIsFirstItem = EFalse;
       
   286         }
       
   287 
       
   288     documentPos = rich->DocumentLength();
       
   289     rich->SetInsertCharFormatL(aFormat, aMask, documentPos);
       
   290     rich->InsertL( documentPos, modifiedText );
       
   291 
       
   292     rich->CancelInsertCharFormat();
       
   293 
       
   294     CleanupStack::PopAndDestroy( buf );
       
   295     }
       
   296 
       
   297 TKeyResponse CRichBio::OfferKeyEventL(
       
   298     const TKeyEvent& aKeyEvent,TEventCode aType)
       
   299     {
       
   300     return iEditor->OfferKeyEventL(aKeyEvent, aType);
       
   301     }
       
   302 
       
   303 EXPORT_C void CRichBio::SetAndGetSizeL(TSize& aSize)
       
   304     {
       
   305     TInt maxHeight( MsgEditorCommons::MaxBodyHeight() );
       
   306     iEditor->SetMaximumHeight( maxHeight );
       
   307     
       
   308     iEditor->SetAndGetSizeL( aSize );
       
   309     
       
   310 
       
   311     if ( aSize.iHeight > maxHeight )
       
   312         {
       
   313         aSize.iHeight = maxHeight;
       
   314         }
       
   315     SetSizeWithoutNotification( aSize );
       
   316     }
       
   317 
       
   318 EXPORT_C TInt CRichBio::VirtualHeight()
       
   319     {
       
   320     return iEditor->VirtualHeight();
       
   321     }
       
   322 
       
   323 EXPORT_C TInt CRichBio::VirtualVisibleTop()
       
   324     {
       
   325     return iEditor->VirtualVisibleTop();
       
   326     }
       
   327 
       
   328 EXPORT_C TBool CRichBio::IsCursorLocation(TMsgCursorLocation aLocation) const
       
   329     {
       
   330     TBool location(EFalse);
       
   331     switch (aLocation)
       
   332         {
       
   333         case EMsgTop:
       
   334             location = iEditor->CursorInFirstLine();
       
   335             break;
       
   336         case EMsgBottom:
       
   337             location = iEditor->CursorInLastLine();
       
   338             break;
       
   339         default:
       
   340             break;
       
   341         }
       
   342 
       
   343     return location;
       
   344     }
       
   345 
       
   346 void CRichBio::ApplyLabelFormat(TCharFormat& aFormat, TCharFormatMask& aMask)
       
   347     {
       
   348     ApplyFormat(aFormat, aMask, ETrue);
       
   349     }
       
   350 
       
   351 void CRichBio::ApplyValueFormat(TCharFormat& aFormat, TCharFormatMask& aMask)
       
   352     {
       
   353     ApplyFormat(aFormat, aMask, EFalse);
       
   354     }
       
   355 
       
   356 void CRichBio::ApplyFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TBool aIsLabel)
       
   357     {
       
   358 	if ( aIsLabel )
       
   359 		{
       
   360 		TAknTextComponentLayout msg_body_pane_t2 =
       
   361 			AknLayoutScalable_Apps::msg_body_pane_t2( 0 );
       
   362 		TAknTextLineLayout textLayout = msg_body_pane_t2.LayoutLine();//AppLayout::Smart_Messages_Line_1( 0 );
       
   363 	    const CFont* labelFont = AknLayoutUtils::FontFromId( textLayout.FontId() );
       
   364 		aFormat.iFontSpec = labelFont->FontSpecInTwips();
       
   365 		}
       
   366 	else
       
   367 		{
       
   368 		TAknTextComponentLayout msg_body_pane_t3 =
       
   369 			AknLayoutScalable_Apps::msg_body_pane_t3( 0 );
       
   370 		TAknTextLineLayout editorLayout = msg_body_pane_t3.LayoutLine(); //AppLayout::Smart_Messages_Line_2( 0 );
       
   371 		const CFont* editorFont = AknLayoutUtils::FontFromId( editorLayout.FontId() );
       
   372 		aFormat.iFontSpec = editorFont->FontSpecInTwips();
       
   373 		}
       
   374 
       
   375     aMask.ClearAll();
       
   376     aMask.SetAttrib(EAttFontStrokeWeight);
       
   377     aMask.SetAttrib(EAttFontHeight);
       
   378     aMask.SetAttrib(EAttFontTypeface);
       
   379     }
       
   380 
       
   381 EXPORT_C CRichBio::CRichBio(TRichBioMode aMode) : iMode(aMode)
       
   382     {
       
   383     }
       
   384 
       
   385 EXPORT_C void CRichBio::ConstructL(const CCoeControl* aParent)
       
   386     {
       
   387     __ASSERT_DEBUG(!iEditor, Panic( EPanicConstructedTwice ));
       
   388     TUint32 flags = 0;
       
   389     iEditor = new (ELeave) CMsgExpandableControlEditor( aParent, flags, NULL);
       
   390     iEditor->ConstructL();
       
   391 
       
   392     TAknLayoutText headerTextLayout;
       
   393     TMargins8 edwinMargins;
       
   394     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   395         {
       
   396         TAknLayoutRect msgTextPane;
       
   397         msgTextPane.LayoutRect(
       
   398             MsgEditorCommons::MsgDataPane(),
       
   399             AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() );
       
   400 
       
   401         TAknLayoutRect msgBodyPane;
       
   402         msgBodyPane.LayoutRect(
       
   403             msgTextPane.Rect(),
       
   404             AknLayoutScalable_Apps::msg_body_pane().LayoutLine() );
       
   405         headerTextLayout.LayoutText(
       
   406             msgBodyPane.Rect(),
       
   407             AknLayoutScalable_Apps::msg_body_pane_t2( 0 ).LayoutLine() );
       
   408 
       
   409 	    edwinMargins.iTop    = KMarginTop;
       
   410 	    edwinMargins.iBottom = KMarginBottom;
       
   411 	    edwinMargins.iLeft   = headerTextLayout.TextRect().iTl.iX; //KMarginLeft;
       
   412 	    edwinMargins.iRight  =
       
   413 	    	msgTextPane.Rect().iBr.iX -
       
   414 	    	headerTextLayout.TextRect().iBr.iX;// KMarginRight;
       
   415         }
       
   416 	else
       
   417 		{
       
   418 		// use old margins
       
   419 		edwinMargins.iTop    = KMarginTop;
       
   420 		edwinMargins.iBottom = KMarginBottom;
       
   421 		edwinMargins.iLeft   = KMarginLeft;
       
   422 		edwinMargins.iRight  = KMarginRight;
       
   423 		}
       
   424     iEditor->SetBorderViewMargins(edwinMargins);
       
   425 
       
   426     // Create the observer.
       
   427     iEdwinSizeObserver = new (ELeave) CEdwinSizeObserver( *this );
       
   428     iEditor->SetEdwinSizeObserver( iEdwinSizeObserver );
       
   429     iIsFirstItem = ETrue;
       
   430     iEditor->SetReadOnly(ETrue);
       
   431     if (CacheExists())
       
   432         {
       
   433         LoadFromCacheL();
       
   434         }
       
   435     SetContainerWindowL(*aParent);
       
   436     }
       
   437 
       
   438 TInt CRichBio::CountComponentControls() const
       
   439     {
       
   440     return 1; // iEditor ( created in constructL, so always 1 )
       
   441     }
       
   442 
       
   443 CCoeControl* CRichBio::ComponentControl(TInt aIndex) const
       
   444     {
       
   445     if (aIndex == 0)
       
   446         {
       
   447         return iEditor;
       
   448         }
       
   449     return NULL;
       
   450     }
       
   451 
       
   452 void CRichBio::SizeChanged()
       
   453     {
       
   454     iEditor->SetExtent(Position(), iEditor->Size());
       
   455     }
       
   456 
       
   457 void CRichBio::Panic( TInt aPanic )
       
   458     {
       
   459     _LIT(KDll, "richbio.dll");
       
   460     User::Panic(KDll, aPanic);
       
   461     }
       
   462 
       
   463 TBool CRichBio::CacheExists()
       
   464     {
       
   465     if (iLabelCache)
       
   466         {
       
   467         __ASSERT_DEBUG(iValueCache, Panic(EPanicCacheProblem1));
       
   468         return ETrue;
       
   469         }
       
   470     __ASSERT_DEBUG(!iValueCache, Panic(EPanicCacheProblem2));
       
   471     return EFalse;
       
   472     }
       
   473 
       
   474 void CRichBio::LoadFromCacheL()
       
   475     {
       
   476     __ASSERT_DEBUG(iLabelCache && iValueCache, Panic(EPanicNoCache));
       
   477 
       
   478     TInt count(iLabelCache->Count());
       
   479     __ASSERT_DEBUG(iValueCache->Count() == count,
       
   480         Panic(EPanicCacheMismatch1));
       
   481     for (TInt n(0); n < count; n++)
       
   482         {
       
   483         AddItemToRichTextL((*iLabelCache)[n], (*iValueCache)[n]);
       
   484         }
       
   485     }
       
   486 
       
   487 void CRichBio::CacheItemL(const TDesC& aLabel, const TDesC& aValue)
       
   488     {
       
   489     if (!iLabelCache || !iValueCache)
       
   490         {
       
   491         delete iLabelCache;
       
   492         delete iValueCache;
       
   493         iLabelCache = NULL;
       
   494         iValueCache = NULL;
       
   495         iLabelCache = new (ELeave) CDesC16ArrayFlat(10); //granularity of 10
       
   496         iValueCache = new (ELeave) CDesC16ArrayFlat(10); //granularity of 10
       
   497         }
       
   498     iLabelCache->AppendL(aLabel);
       
   499     iValueCache->AppendL(aValue);
       
   500 
       
   501     __ASSERT_DEBUG(iLabelCache->Count() == iValueCache->Count(),
       
   502         Panic(EPanicCacheMismatch2));
       
   503     __ASSERT_DEBUG(iLabelCache->Count() > 0, Panic(EPanicCacheMismatch3));
       
   504     }
       
   505     
       
   506 void CRichBio::Draw(const TRect& /*aRect*/) const
       
   507     {
       
   508     //removed the clearing of window background,causes flicker
       
   509     }
       
   510 
       
   511 #ifdef RD_SCALABLE_UI_V2
       
   512 EXPORT_C TInt CRichBio::ScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection )
       
   513     {
       
   514     TInt pixelsToScroll( 0 );
       
   515     TInt marginPixels( 0 );
       
   516 
       
   517     CTextLayout* textLayout = iEditor->TextLayout();
       
   518 
       
   519     if ( aDirection == EMsgScrollDown )
       
   520         {
       
   521         TInt pixelsAboveBand( textLayout->PixelsAboveBand() );
       
   522         TInt bandHeight( textLayout->BandHeight() );
       
   523         TInt virtualHeight( iEditor->VirtualHeight() );
       
   524 
       
   525         if ( pixelsAboveBand + bandHeight + aPixelsToScroll >= virtualHeight )
       
   526             {
       
   527             pixelsToScroll = -( virtualHeight - ( pixelsAboveBand + bandHeight ) );
       
   528 
       
   529             if ( pixelsToScroll != 0 )
       
   530                 {
       
   531                 // Control has reaches end. Mark margin pixels scrolled.
       
   532                 marginPixels = iEditor->Size().iHeight - Size().iHeight;
       
   533                 }
       
   534             }
       
   535         else
       
   536             {
       
   537             // Negative pixels means scrolling down.
       
   538             pixelsToScroll = -aPixelsToScroll;
       
   539             }
       
   540         }
       
   541     else
       
   542         {
       
   543         pixelsToScroll = aPixelsToScroll;
       
   544         }
       
   545 
       
   546     if ( pixelsToScroll != 0 )
       
   547         {
       
   548 		//scrolling to be restricted to full lines
       
   549 		//so there will not be any clipping of text on view        
       
   550         textLayout->RestrictScrollToTopsOfLines( ETrue );
       
   551         iEditor->TextView()->ScrollDisplayPixelsL( pixelsToScroll );
       
   552 
       
   553         }
       
   554 
       
   555     return Abs( pixelsToScroll ) + marginPixels;
       
   556     }
       
   557 
       
   558 EXPORT_C void CRichBio::NotifyViewEvent( TMsgViewEvent aEvent, TInt /*aParam*/ )
       
   559     {
       
   560     switch ( aEvent )
       
   561         {
       
   562         case EMsgViewEventPrepareFocusTransitionUp:
       
   563             {
       
   564             if ( IsFocused() )
       
   565                 {
       
   566                 //possible leaves are discarded
       
   567                 TRAP_IGNORE( iEditor->ClearSelectionL() );
       
   568                 }
       
   569             break;
       
   570             }
       
   571         case EMsgViewEventPrepareFocusTransitionDown:
       
   572             {
       
   573             if ( IsFocused() )
       
   574                 {
       
   575                 //possible leaves are discarded
       
   576                 TRAP_IGNORE( iEditor->ClearSelectionL() );
       
   577                 }
       
   578             break;
       
   579             }
       
   580         case EMsgViewEventSetCursorFirstPos:
       
   581             {
       
   582             if ( iEditor->TextView() )
       
   583             	{
       
   584             	if ( iEditor->IsFirstLineVisible()  )
       
   585                     {
       
   586                     //possible leaves are discarded
       
   587             		TRAP_IGNORE( iEditor->SetCursorPosL( 0, EFalse ) );
       
   588 					}
       
   589 				}
       
   590             break;
       
   591             }
       
   592         case EMsgViewEventSetCursorLastPos:
       
   593             {
       
   594             if ( iEditor->TextView() )
       
   595                 {
       
   596                 TInt len = iEditor->TextLength();
       
   597 
       
   598                 if ( iEditor->IsLastLineVisible()  )
       
   599                     {
       
   600                     //possible leaves are discarded
       
   601                     TRAP_IGNORE( iEditor->SetCursorPosL( len, EFalse ) );
       
   602                     }
       
   603                 }
       
   604             break;
       
   605             }
       
   606         default:
       
   607             {
       
   608             break;
       
   609             }
       
   610         }
       
   611     }
       
   612     
       
   613 #else
       
   614 EXPORT_C TInt CRichBio::ScrollL( TInt /*aPixelsToScroll*/, 
       
   615                                  TMsgScrollDirection /*aDirection*/ )
       
   616     {
       
   617     return 0;
       
   618     }
       
   619 
       
   620 EXPORT_C void CRichBio::NotifyViewEvent( TMsgViewEvent /*aEvent*/,
       
   621                                          TInt /*aParam*/ )
       
   622     {
       
   623     //no op
       
   624     }
       
   625     
       
   626 #endif //RD_SCALABLE_UI_V2
       
   627 
       
   628 
       
   629 
       
   630 //end of file
       
   631