uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 59 978afdc0236f
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
   100 
   100 
   101 #include "smileymanager.h"
   101 #include "smileymanager.h"
   102 #include "smileycustomwrap.h"
   102 #include "smileycustomwrap.h"
   103 #include <touchfeedback.h>
   103 #include <touchfeedback.h>
   104 
   104 
       
   105 // declare function
       
   106 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId );
       
   107 void ReadSCTHeadPane( TResourceReader& aReader );
       
   108 
   105 GLDEF_C void Panic(TEikEdwinPanic aPanic)
   109 GLDEF_C void Panic(TEikEdwinPanic aPanic)
   106     {
   110     {
   107     _LIT(KPanicCat,"EIKON-EDWIN");
   111     _LIT(KPanicCat,"EIKON-EDWIN");
   108     User::Panic(KPanicCat,aPanic);
   112     User::Panic(KPanicCat,aPanic);
   109     }
   113     }
   137 
   141 
   138 // Unicode for euro sign
   142 // Unicode for euro sign
   139 const TInt KEuroSign = 0x20AC;
   143 const TInt KEuroSign = 0x20AC;
   140 const TInt KSegmSize = 1024;
   144 const TInt KSegmSize = 1024;
   141 
   145 
   142 const TInt KMicroSecondsDelay = 500000;
   146 
   143 
   147 
   144 const TInt KNormalAnimPlayTimes = 2;
   148 const TInt KNormalAnimPlayTimes = 2;
   145 const TInt KInfiniteAnimPlayTimes = 0x7ffff;
   149 const TInt KInfiniteAnimPlayTimes = 0x7ffff;
   146 const TInt KAdditionalPixels = 0x400;
   150 const TInt KAdditionalPixels = 0x400;
   147 
   151 
   148 const TInt KFullFormatLengthForSmiley = 5000;
   152 const TInt KFullFormatLengthForSmiley = 5000;
       
   153 
       
   154 const TInt KContentThreshold = 8;
       
   155 
       
   156 const TInt KNmericSCTLimit( 256 );
       
   157 const TInt KTInt16Length( sizeof( TInt16 ) );
       
   158 const TInt KTInt32Length( sizeof( TInt32 ) );
       
   159 const TInt KTUint32Length( sizeof( TUint32 ) );
   149 
   160 
   150 //
   161 //
   151 // class CEikEdwin::CUndoBuffer
   162 // class CEikEdwin::CUndoBuffer
   152 //
   163 //
   153 
   164 
   215 
   226 
   216 NONSHARABLE_CLASS(CEikEdwinFepSupport) : public CBase, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, public TCoeInputCapabilities::MCoeFepSpecificExtensions
   227 NONSHARABLE_CLASS(CEikEdwinFepSupport) : public CBase, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, public TCoeInputCapabilities::MCoeFepSpecificExtensions
   217     {
   228     {
   218     friend class CEikEdwin;
   229     friend class CEikEdwin;
   219 public:
   230 public:
       
   231     // The length of text window
       
   232     const static TInt KMaxSegmentLength = 10000;
       
   233     // The threshold for text window position change
       
   234     const static TInt KSegmentUpdateTrigger = 100;
       
   235     
   220     static CEikEdwinFepSupport* New(CEikEdwin& aEdwin);
   236     static CEikEdwinFepSupport* New(CEikEdwin& aEdwin);
   221     virtual ~CEikEdwinFepSupport();
   237     virtual ~CEikEdwinFepSupport();
   222     TBool IsHandledByFepL(TPointerEvent::TType aType, TUint aModifiers, TInt aDocumentPosition);
   238     TBool IsHandledByFepL(TPointerEvent::TType aType, TUint aModifiers, TInt aDocumentPosition);
   223     /**
   239     /**
   224     * Set the input capabilities in the edwin fep support object. A copy of the input capabilities
   240     * Set the input capabilities in the edwin fep support object. A copy of the input capabilities
   230     const TCoeInputCapabilities* InputCapabilities() const;
   246     const TCoeInputCapabilities* InputCapabilities() const;
   231     void ConstructStateHolder();
   247     void ConstructStateHolder();
   232     // from MCoeFepAwareTextEditor_Extension1
   248     // from MCoeFepAwareTextEditor_Extension1
   233     void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid);
   249     void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid);
   234     CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership
   250     CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership
   235 
   251     
       
   252     // New functions for Touch Input sync performance improvement. A sliding window method is used 
       
   253     // here to show only part of text of editor to Touch Input, so the text sync between Touch input and 
       
   254     // editor can be faster.
       
   255     /**
       
   256      * To update start position of text window according to cursor position. The cursor position has to
       
   257      * be in the visible text window.
       
   258      */
       
   259     void UpdateDocPosOffsetL( TInt aCursorPos );
       
   260 
       
   261     /**
       
   262      * To check if FEP wants to get information of whole text, not the text window.
       
   263      */
       
   264     TBool FepRequireWholeTextData() const;
       
   265     
   236 private:
   266 private:
   237     enum TPointerState
   267     enum TPointerState
   238         {
   268         {
   239         EPointerIsUp,
   269         EPointerIsUp,
   240         EPointerIsDownStartingInsideInlineText,
   270         EPointerIsDownStartingInsideInlineText,
   290 public: 
   320 public: 
   291     const MFormCustomDraw* iOldCustomDraw; // does not own anything
   321     const MFormCustomDraw* iOldCustomDraw; // does not own anything
   292     MTouchFeedback* iFeedback;
   322     MTouchFeedback* iFeedback;
   293     TBool iSelectionIsCancel;
   323     TBool iSelectionIsCancel;
   294     TInt iMoveThumbFeedbackNeeded;
   324     TInt iMoveThumbFeedbackNeeded;
       
   325     // record start position of text window
       
   326 	TInt iDocPosOffset;
   295 private:    
   327 private:    
   296     MFepPointerEventHandlerDuringInlineEdit* iPointerEventHandlerDuringInlineEdit; // does not own anything
   328     MFepPointerEventHandlerDuringInlineEdit* iPointerEventHandlerDuringInlineEdit; // does not own anything
   297     SPointerEventInInlineText iLastPointerEventInInlineText;
   329     SPointerEventInInlineText iLastPointerEventInInlineText;
   298     TPointerState iPointerState;
   330     TPointerState iPointerState;
   299     TCoeInputCapabilities* iInputCapabilities;
   331     TCoeInputCapabilities* iInputCapabilities;
   518     iPositionOfInlineTextInDocument=selection.LowerPos();
   550     iPositionOfInlineTextInDocument=selection.LowerPos();
   519     iPointerEventHandlerDuringInlineEdit=&aPointerEventHandlerDuringInlineEdit;
   551     iPointerEventHandlerDuringInlineEdit=&aPointerEventHandlerDuringInlineEdit;
   520     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   552     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   521     TInt numberOfCharactersSuccessfullyDeleted=0;
   553     TInt numberOfCharactersSuccessfullyDeleted=0;
   522     TInt numberOfCharactersSuccessfullyInserted=0;
   554     TInt numberOfCharactersSuccessfullyInserted=0;
       
   555     
       
   556     iEdwin.ConvertSmileyForDeleteL( selection );
       
   557     
   523     // handle extended highlights
   558     // handle extended highlights
   524 
   559 
   525 /* 
   560 /* 
   526 WARNING.  do not insert any leaving function calls after the iEdwin.iText->StartFepInlineEditL unless they are trapped
   561 WARNING.  do not insert any leaving function calls after the iEdwin.iText->StartFepInlineEditL unless they are trapped
   527 as this will call update-state problems.
   562 as this will call update-state problems.
   570     TInt numberOfCharactersSuccessfullyDeleted=0;
   605     TInt numberOfCharactersSuccessfullyDeleted=0;
   571     TInt numberOfCharactersSuccessfullyInserted=0;
   606     TInt numberOfCharactersSuccessfullyInserted=0;
   572     TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText));
   607     TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText));
   573     iLengthOfInlineText=numberOfCharactersSuccessfullyInserted;
   608     iLengthOfInlineText=numberOfCharactersSuccessfullyInserted;
   574     UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error);
   609     UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error);
   575     iEdwin.ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
       
   576     }
   610     }
   577 
   611 
   578 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
   612 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
   579     {
   613     {
   580     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState7)); // assert that we're currently inline editing
       
   581     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState8));
       
   582     iEdwin.SetCursorVisibilityL(aCursorVisibility);
   614     iEdwin.SetCursorVisibilityL(aCursorVisibility);
   583     iShowCursor = aCursorVisibility;
   615     iShowCursor = aCursorVisibility;
   584     }
   616     }
   585 
   617 
   586 void CEikEdwinFepSupport::CancelFepInlineEdit()
   618 void CEikEdwinFepSupport::CancelFepInlineEdit()
   622 #endif
   654 #endif
   623     }
   655     }
   624 
   656 
   625 TInt CEikEdwinFepSupport::DocumentLengthForFep() const
   657 TInt CEikEdwinFepSupport::DocumentLengthForFep() const
   626     {
   658     {
       
   659     // If the length between text window start position and text end is shorter
       
   660     // than length of text window, return the short length, otherwise return
       
   661     // text window length.
       
   662     if ( !FepRequireWholeTextData() && iEdwin.TextLength() > KMaxSegmentLength )
       
   663         {
       
   664         TInt lengthToEnd( iEdwin.TextLength() - iDocPosOffset );
       
   665         if ( lengthToEnd < KMaxSegmentLength )
       
   666             {
       
   667             return lengthToEnd;
       
   668             }
       
   669         return KMaxSegmentLength;
       
   670         }
   627     return iEdwin.TextLength();
   671     return iEdwin.TextLength();
   628     }
   672     }
   629 
   673 
   630 TInt CEikEdwinFepSupport::DocumentMaximumLengthForFep() const
   674 TInt CEikEdwinFepSupport::DocumentMaximumLengthForFep() const
   631     {
   675     {
       
   676     // return the length between textlimit and text window start position
       
   677     if ( !FepRequireWholeTextData() && KMaxSegmentLength < iEdwin.iTextLimit )
       
   678         {
       
   679         return iEdwin.iTextLimit - iDocPosOffset;
       
   680         }
   632     return iEdwin.iTextLimit;
   681     return iEdwin.iTextLimit;
   633     }
   682     }
   634 
   683 
   635 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   684 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   636     {
   685     {
       
   686     // if text window is enabled, the pos of parameter selection are relative to
       
   687     // text window start position, so convert them back to actual doc pos.
   637     TInt cursorPos( aCursorSelection.iCursorPos );
   688     TInt cursorPos( aCursorSelection.iCursorPos );
   638     TInt anchorPos( aCursorSelection.iAnchorPos );
   689     TInt anchorPos( aCursorSelection.iAnchorPos );
       
   690     TInt textLength( iEdwin.TextLength() );
       
   691     if ( !FepRequireWholeTextData() )
       
   692         {
       
   693         cursorPos += iDocPosOffset;
       
   694         anchorPos += iDocPosOffset;
       
   695         cursorPos = cursorPos > textLength ? textLength : cursorPos;
       
   696         anchorPos = anchorPos > textLength ? textLength : anchorPos;
       
   697         if ( cursorPos != anchorPos )
       
   698             {
       
   699             TCursorSelection select( iEdwin.Selection() );
       
   700             if ( ( anchorPos == iDocPosOffset || anchorPos == iDocPosOffset + 
       
   701                 KMaxSegmentLength ) && anchorPos >= select.LowerPos() && 
       
   702                 anchorPos <= select.HigherPos() )
       
   703                 {
       
   704                 anchorPos = cursorPos > anchorPos ? select.LowerPos() : 
       
   705                     select.HigherPos();
       
   706                 }
       
   707             }
       
   708         }
       
   709     // Selection position can not be in smiley code string, so check if
       
   710     // the position needs to be changed.
   639     if ( iEdwin.IsSmileyEnabled() )
   711     if ( iEdwin.IsSmileyEnabled() )
   640         {  
   712         {  
   641         CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
   713         CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
   642         TInt oldPos = ( cursorPos == anchorPos ) ? iEdwin.CursorPos() : anchorPos; 
   714         TInt oldPos = ( cursorPos == anchorPos ) ? iEdwin.CursorPos() : anchorPos; 
   643         smiley->HandleSetCursor( oldPos, cursorPos );       
   715         smiley->HandleSetCursor( oldPos, cursorPos );       
   648         else
   720         else
   649             {
   721             {
   650             smiley->HandleSetCursor( cursorPos, anchorPos );
   722             smiley->HandleSetCursor( cursorPos, anchorPos );
   651             }
   723             }
   652         }
   724         }
   653 	iEdwin.SetSelectionL( cursorPos, anchorPos );
   725     iEdwin.SetSelectionL( cursorPos, anchorPos );
       
   726     // Cursor pos is changed, so update text window position.
       
   727 	UpdateDocPosOffsetL( cursorPos );
   654     iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
   728     iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
   655     }
   729     }
   656 
   730 
   657 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   731 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   658     {
   732     {
   659     aCursorSelection=iEdwin.Selection();
   733     aCursorSelection=iEdwin.Selection();
       
   734     // To use text window, FEP can not access text view of editor directly but 
       
   735     // FEP needs to know some information which can not be provided by current 
       
   736     // interface. So use below method to transfer the information to FEP.
       
   737     CAknEdwinState* state( iEdwin.EditorState() );
       
   738     if ( state )
       
   739         {
       
   740         TInt flag( state->Flags() );
       
   741         TTmDocPos docPos;
       
   742         iEdwin.TextView()->GetCursorPos( docPos );
       
   743         if ( docPos.iLeadingEdge )
       
   744             {
       
   745             flag |= EAknEditorFlagCursorLedingEdge;
       
   746             }
       
   747         else
       
   748             {
       
   749             flag &= ~EAknEditorFlagCursorLedingEdge;
       
   750             }
       
   751         state->SetFlags( flag );
       
   752         }
       
   753     // If text window is enabled, convert the actual doc pos to relative doc pos.
       
   754     if ( !FepRequireWholeTextData() )
       
   755         {
       
   756         if ( aCursorSelection.iAnchorPos < iDocPosOffset )
       
   757             {
       
   758             aCursorSelection.iAnchorPos = iDocPosOffset;
       
   759             }
       
   760         else if ( aCursorSelection.iAnchorPos > iDocPosOffset + KMaxSegmentLength )
       
   761             {
       
   762             aCursorSelection.iAnchorPos = iDocPosOffset + KMaxSegmentLength;
       
   763             }
       
   764         aCursorSelection.iCursorPos -= iDocPosOffset;
       
   765         aCursorSelection.iAnchorPos -= iDocPosOffset;
       
   766         }
   660     }
   767     }
   661 
   768 
   662 void CEikEdwinFepSupport::GetEditorContentForFep(TDes& aEditorContent,TInt aDocumentPosition,TInt aLengthToRetrieve) const
   769 void CEikEdwinFepSupport::GetEditorContentForFep(TDes& aEditorContent,TInt aDocumentPosition,TInt aLengthToRetrieve) const
   663     {
   770     {
       
   771     // If text window is enabled, convert relative doc pos to actual doc pos.
       
   772     if ( !FepRequireWholeTextData() )
       
   773         {
       
   774         aDocumentPosition += iDocPosOffset;
       
   775         }
   664     TInt length( Min( aLengthToRetrieve, iEdwin.TextLength() - aDocumentPosition ) );
   776     TInt length( Min( aLengthToRetrieve, iEdwin.TextLength() - aDocumentPosition ) );
       
   777     if ( !FepRequireWholeTextData() )
       
   778         {
       
   779         length = Min( length, KMaxSegmentLength );
       
   780         }    
   665     iEdwin.iText->Extract( aEditorContent, aDocumentPosition, length );
   781     iEdwin.iText->Extract( aEditorContent, aDocumentPosition, length );
   666     if ( iEdwin.IsSmileyEnabled() )
   782     CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
   667         {
   783     if ( smiley && smiley->HasSmileyIconsInText() )
   668         CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley );
   784         {        
   669         CAknEdwinState* state( iEdwin.EditorState() );
   785         CAknEdwinState* state( iEdwin.EditorState() );
   670         if ( state )
   786         if ( state )
   671             {
   787             {
   672             TCursorSelection inlineText( state->CurrentInlineEditSpan() );
   788             TCursorSelection inlineText( state->CurrentInlineEditSpan() );
   673             if ( aDocumentPosition >= inlineText.LowerPos() && 
   789             if ( aDocumentPosition >= inlineText.LowerPos() && 
   674                 aDocumentPosition + length <= inlineText.HigherPos() )
   790                 aDocumentPosition + length <= inlineText.HigherPos() )
   675                 {
   791                 {
   676                 iEdwin.iEdwinExtension->iSmiley->ConvertTextForSmileyL(
   792                 TRAP_IGNORE( smiley->ConvertTextForSmileyL( aDocumentPosition, aEditorContent, 
   677                     aDocumentPosition, aEditorContent, EFalse );
   793                     EFalse ); )
   678                 }
   794                 }
   679             }
   795             }
   680         TBool prevIsCode( EFalse );
   796         // Replace all 'i' following smiley code to invisbile placeholder for
       
   797         // Touch Input can not recognize it as part of smiley code string.
       
   798         TInt smileyEndPos( 0 );
   681         for ( TInt i( 0 ); i < length; i++ )
   799         for ( TInt i( 0 ); i < length; i++ )
   682             {
   800             {
   683             if ( aEditorContent[i] == CSmileyManager::KCompensateChar )
   801             if ( aEditorContent[i] == CSmileyManager::KCompensateChar )
   684                 {
   802                 {
   685                 if ( i == 0 )
   803                 // when 'i' is the first character, it is unkonwn whether it is
   686                     {
   804                 // part of a smiley code string or not, so we have to use another 
   687                     prevIsCode = ( CSmileyManager::IsSmileyCode( 
   805                 // function to decide.
   688                         smiley->SmileyCodeByPos( aDocumentPosition ) ) );
   806                 if ( ( i > 0 && i < smileyEndPos ) ||
   689                     }
   807                      ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) )
   690                 if ( prevIsCode )
       
   691                     {
   808                     {
   692                     aEditorContent[i] = CSmileyManager::KPlaceHolder;
   809                     aEditorContent[i] = CSmileyManager::KPlaceHolder;
   693                     }
   810                     }
   694                 }
   811                 }
   695             else
   812             else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
   696                 {
   813                 {
   697                 prevIsCode = CSmileyManager::IsSmileyCode( aEditorContent[i] );
   814                 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
   698                 }
   815                 }
   699             }
   816             }
   700         }
   817         }
   701     }
   818     }
   702 
   819 
   706     STATIC_CAST(CGlobalText*,iEdwin.iText)->GetCharFormat(aFormat,notUsed,aDocumentPosition,(aDocumentPosition==iEdwin.TextLength())? 0: 1);
   823     STATIC_CAST(CGlobalText*,iEdwin.iText)->GetCharFormat(aFormat,notUsed,aDocumentPosition,(aDocumentPosition==iEdwin.TextLength())? 0: 1);
   707     }
   824     }
   708 
   825 
   709 void CEikEdwinFepSupport::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,TInt& aHeight,TInt& aAscent,TInt aDocumentPosition) const
   826 void CEikEdwinFepSupport::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,TInt& aHeight,TInt& aAscent,TInt aDocumentPosition) const
   710     {
   827     {
       
   828     // If text window is enabled, convert relative doc pos to actual doc pos.
       
   829     aDocumentPosition += iDocPosOffset;
   711     aDocumentPosition %= ( iEdwin.iText->DocumentLength() + 1 );    
   830     aDocumentPosition %= ( iEdwin.iText->DocumentLength() + 1 );    
   712     iEdwin.iTextView->DocPosToXyPosL(aDocumentPosition,aLeftSideOfBaseLine);
   831     iEdwin.iTextView->DocPosToXyPosL(aDocumentPosition,aLeftSideOfBaseLine);
   713     aLeftSideOfBaseLine+=iEdwin.DrawableWindow()->InquireOffset(iEdwin.iCoeEnv->RootWin()); // make position "absolute" (i.e. not relative to the window that iEdwin is using) - note that *any* group window can be passed into InquireOffset to return the desired result, it doesn't have to be an ancestor of the window being used by iEdwin (i.e. this line of code does *not* make the assumption that iEdwin is (even indirectly) attached to iCoeEnv->RootWin())
   832     aLeftSideOfBaseLine+=iEdwin.DrawableWindow()->InquireOffset(iEdwin.iCoeEnv->RootWin()); // make position "absolute" (i.e. not relative to the window that iEdwin is using) - note that *any* group window can be passed into InquireOffset to return the desired result, it doesn't have to be an ancestor of the window being used by iEdwin (i.e. this line of code does *not* make the assumption that iEdwin is (even indirectly) attached to iCoeEnv->RootWin())
   714     iEdwin.iLayout->GetCharacterHeightAndAscentL(aDocumentPosition,aHeight,aAscent);
   833     iEdwin.iLayout->GetCharacterHeightAndAscentL(aDocumentPosition,aHeight,aAscent);
   715     }
   834     }
   722 
   841 
   723 void CEikEdwinFepSupport::DoCommitFepInlineEditL()
   842 void CEikEdwinFepSupport::DoCommitFepInlineEditL()
   724     {
   843     {
   725     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing
   844     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing
   726     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10));
   845     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10));
   727     iEdwin.iEdwinExtension->iInlineEditing = EFalse;
       
   728     iCharsInserted = 0;
   846     iCharsInserted = 0;
   729     iCharsDeleted = 0;
   847     iCharsDeleted = 0;
   730     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   848     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   731     TInt numberOfCharactersSuccessfullyDeleted=0;
   849     TInt numberOfCharactersSuccessfullyDeleted=0;
   732     TInt numberOfCharactersSuccessfullyInserted=0;
   850     TInt numberOfCharactersSuccessfullyInserted=0;
   736         numberOfCharactersSuccessfullyInserted, iPositionOfInlineTextInDocument );
   854         numberOfCharactersSuccessfullyInserted, iPositionOfInlineTextInDocument );
   737     if (iEdwin.iUndoStore!=NULL)
   855     if (iEdwin.iUndoStore!=NULL)
   738         {
   856         {
   739         iEdwin.iUndoStore->SetNewText( select );
   857         iEdwin.iUndoStore->SetNewText( select );
   740         }    
   858         }    
       
   859 
       
   860     iEdwin.iEdwinExtension->iInlineEditing = EFalse;
       
   861 
   741     if ( iEdwin.IsSmileyEnabled() )
   862     if ( iEdwin.IsSmileyEnabled() )
   742         {
   863         {
   743         CAknEdwinState* state( iEdwin.EditorState() );
   864         CAknEdwinState* state( iEdwin.EditorState() );
   744         TCursorSelection inlineSpan( state->CurrentInlineEditSpan() );
   865         TCursorSelection inlineSpan( state->CurrentInlineEditSpan() );
   745         if ( inlineSpan.Length() == 0 || iShowCursor )
   866         if ( inlineSpan.Length() == 0 || iShowCursor )
   756                     {
   877                     {
   757                     iEdwin.HandleSelectionForSmiley( iEdwin.Selection() );
   878                     iEdwin.HandleSelectionForSmiley( iEdwin.Selection() );
   758                     }
   879                     }
   759                 }
   880                 }
   760             iEdwin.SetAmountToFormatL( EFalse, ETrue );
   881             iEdwin.SetAmountToFormatL( EFalse, ETrue );
   761             iEdwin.DrawDeferred();
   882 
       
   883             CAknEdwinState* edwinState = 
       
   884                     static_cast<CAknEdwinState*>( iEdwin.iEdwinFepSupport->State( KNullUid ) );
       
   885             
       
   886             if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
       
   887                 {
       
   888                 iEdwin.DrawDeferred();
       
   889                 }
   762             }
   890             }
   763         }
   891         }
   764     iOriginalSelection.SetSelection(-1,-1);
   892     iOriginalSelection.SetSelection(-1,-1);
   765     iPositionOfInsertionPointInDocument=-1;
   893     iPositionOfInsertionPointInDocument=-1;
   766     iPositionOfInlineTextInDocument=-1;
   894     iPositionOfInlineTextInDocument=-1;
   865 
   993 
   866 void CEikEdwinFepSupport::MCoeFepSpecificExtensions_Reserved_2()
   994 void CEikEdwinFepSupport::MCoeFepSpecificExtensions_Reserved_2()
   867     {
   995     {
   868     }
   996     }
   869 
   997 
       
   998 // Update start position of text window, when cursor pos is out of current 
       
   999 // text window or it is in trigger range, the text window position needs to 
       
  1000 // be changed and notify FEP the text change.
       
  1001 void CEikEdwinFepSupport::UpdateDocPosOffsetL( TInt aCursorPos )
       
  1002     {
       
  1003     if ( FepRequireWholeTextData() )
       
  1004         {
       
  1005         return;
       
  1006         }
       
  1007     if ( iEdwin.TextLength() > KMaxSegmentLength )
       
  1008         {
       
  1009         TInt halfSegment( KMaxSegmentLength / 2 );
       
  1010         TBool validDocPosOffset( iDocPosOffset >= 0 && aCursorPos > iDocPosOffset &&
       
  1011             aCursorPos - iDocPosOffset < KMaxSegmentLength );
       
  1012         TBool cursorInHead( validDocPosOffset && 
       
  1013             aCursorPos - iDocPosOffset < KSegmentUpdateTrigger );
       
  1014         TBool cursorInTail( validDocPosOffset && 
       
  1015             iDocPosOffset + KMaxSegmentLength - aCursorPos < KSegmentUpdateTrigger &&
       
  1016             iDocPosOffset + KMaxSegmentLength < iEdwin.TextLength() );
       
  1017         if  ( !validDocPosOffset || cursorInHead || cursorInTail )
       
  1018             {
       
  1019             if ( iEdwin.TextLength() - aCursorPos < halfSegment )
       
  1020                 {
       
  1021                 iDocPosOffset = iEdwin.TextLength() - KMaxSegmentLength;
       
  1022                 }
       
  1023             else
       
  1024                 {
       
  1025                 iDocPosOffset = aCursorPos - halfSegment;
       
  1026                 iDocPosOffset = iDocPosOffset >= 0 ? iDocPosOffset : 0;
       
  1027                 }            
       
  1028             static_cast<CAknEdwinState*>( State( KNullUid ) )->ReportAknEdStateEventL( 
       
  1029                 MAknEdStateObserver::EAknCursorPositionChanged );
       
  1030             }
       
  1031         }
       
  1032     }
       
  1033 
       
  1034 // Check if FEP set the flag to indicate it wants to get information of whole
       
  1035 // text, not the text window.
       
  1036 TBool CEikEdwinFepSupport::FepRequireWholeTextData() const
       
  1037     {
       
  1038     CAknEdwinState* state( static_cast<CAknEdwinState*>( 
       
  1039         const_cast<CEikEdwinFepSupport*>( this )->State(KNullUid) ) );
       
  1040     return ( state->Flags() & EAknEditorFlagNeedWholeTextData );
       
  1041     }
   870 
  1042 
   871 //
  1043 //
   872 //  CEikEdwinExtension
  1044 //  CEikEdwinExtension
   873 //
  1045 //
   874 CEikEdwin::CEikEdwinExtension* CEikEdwin::CEikEdwinExtension::NewL(CEikEdwin* aEdwin)
  1046 CEikEdwin::CEikEdwinExtension* CEikEdwin::CEikEdwinExtension::NewL(CEikEdwin* aEdwin)
  1040 
  1212 
  1041         iCenRepNotifyHandler->StartListeningL();
  1213         iCenRepNotifyHandler->StartListeningL();
  1042         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1214         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1043         }
  1215         }
  1044     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
  1216     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
       
  1217     iSkinInstance = AknsUtils::SkinInstance();
  1045     }
  1218     }
  1046 
  1219 
  1047 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1220 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1048     {
  1221     {
  1049     if ( !iFormExtendedInterfaceProvider )
  1222     if ( !iFormExtendedInterfaceProvider )
  1132     }
  1305     }
  1133 
  1306 
  1134 // ---------------------------------------------------------------------------
  1307 // ---------------------------------------------------------------------------
  1135 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  1308 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  1136 // ---------------------------------------------------------------------------
  1309 // ---------------------------------------------------------------------------
  1137 //   
  1310 //
  1138 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL()
  1311 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL( CAknPhysics* aPhysics )
  1139     {
  1312     {
  1140     iFlags.Set( EKineticScrollingEnabled );
  1313     iFlags.Set( EKineticScrollingEnabled );
  1141     EnablePhysicsL();
  1314     EnablePhysicsL( aPhysics );
  1142     }
  1315     }
  1143 
  1316 
  1144 // ---------------------------------------------------------------------------
  1317 // ---------------------------------------------------------------------------
  1145 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL
  1318 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL
  1146 // ---------------------------------------------------------------------------
  1319 // ---------------------------------------------------------------------------
  1147 //   
  1320 //   
  1148 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL()
  1321 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL( CAknPhysics* aPhysics )
  1149     {
  1322     {
  1150     if ( iFlags.IsSet( EKineticScrollingEnabled )
  1323     if ( iFlags.IsSet( EKineticScrollingEnabled )
  1151         && !iPhysicsHandler && iEdwin->DrawableWindow() )
  1324         && !iPhysicsHandler && iEdwin->DrawableWindow() )
  1152         {
  1325         {
  1153         iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin );
  1326         iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin, aPhysics );
  1154         
  1327         
  1155         InitPhysicsL();   
  1328         InitPhysicsL();   
  1156         if ( iEdwin->iLayout )
  1329         if ( iEdwin->iLayout )
  1157             {
  1330             {
  1158             iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse );
  1331             iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse );
  1585                         : CGlobalText::NewL(aParaFormatLayer,aCharFormatLayer,storage,granularity);
  1758                         : CGlobalText::NewL(aParaFormatLayer,aCharFormatLayer,storage,granularity);
  1586     iText=globalText;
  1759     iText=globalText;
  1587     CreateLayoutL(globalText);
  1760     CreateLayoutL(globalText);
  1588     SetHeightForNumOfLinesL();
  1761     SetHeightForNumOfLinesL();
  1589     DoCreateCustomDrawL();
  1762     DoCreateCustomDrawL();
  1590     if ( iEdwinExtension->iSmiley )
  1763     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  1591         {
  1764         {
  1592         TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
  1765         TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
  1593         }
  1766         }
  1594     }
  1767     }
  1595 
  1768 
  1826             return EKeyWasNotConsumed;
  1999             return EKeyWasNotConsumed;
  1827             }
  2000             }
  1828         }
  2001         }
  1829     if (iEdwinUserFlags&EDisplayOnly)
  2002     if (iEdwinUserFlags&EDisplayOnly)
  1830         return EKeyWasConsumed;
  2003         return EKeyWasConsumed;
  1831     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  2004     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  1832         {
  2005         {
  1833         PerformRecordedOperationL();
  2006         PerformRecordedOperationL();
  1834         }
  2007         }
  1835     const TInt modifiers=aKeyEvent.iModifiers;
  2008     const TInt modifiers=aKeyEvent.iModifiers;
  1836     TBool navigation=EFalse;
  2009     TBool navigation=EFalse;
  2111             DeleteHighlightL(formatHasChanged,code==EKeyBackspace);
  2284             DeleteHighlightL(formatHasChanged,code==EKeyBackspace);
  2112             const TInt lower=toDelete.LowerPos();
  2285             const TInt lower=toDelete.LowerPos();
  2113             const TCursorSelection sel(lower,lower);
  2286             const TCursorSelection sel(lower,lower);
  2114             iTextView->SetPendingSelection(sel);
  2287             iTextView->SetPendingSelection(sel);
  2115             iTextView->HandleInsertDeleteL(sel,toDelete.Length(),formatHasChanged);
  2288             iTextView->HandleInsertDeleteL(sel,toDelete.Length(),formatHasChanged);
       
  2289             cursorPos = lower;
  2116             reportChange=ETrue;
  2290             reportChange=ETrue;
  2117             }
  2291             }
  2118         else if ( replaceSelection ) // All neutral protection cases 
  2292         else if ( replaceSelection ) // All neutral protection cases 
  2119             {
  2293             {
  2120             if ( !deleteSelection ) // selection has not been set yet
  2294             if ( !deleteSelection ) // selection has not been set yet
  2173                 iTextView->HandleCharEditL(charEditType,formatHasChanged);
  2347                 iTextView->HandleCharEditL(charEditType,formatHasChanged);
  2174                 reportChange=ETrue;
  2348                 reportChange=ETrue;
  2175                 formatChange=formatHasChanged;
  2349                 formatChange=formatHasChanged;
  2176                 }
  2350                 }
  2177             }
  2351             }
  2178         if ( reportChange && iEdwinExtension->iSmiley )
  2352         if ( reportChange && iEdwinExtension && iEdwinExtension->iSmiley )
  2179             {
  2353             {
  2180             ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2354             ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2181                 ETrue );          
  2355                 ETrue );          
  2182             if ( deleteSelection || replaceSelection )
  2356             if ( deleteSelection || replaceSelection )
  2183                 {
  2357                 {
  2227             ret=EKeyWasNotConsumed;
  2401             ret=EKeyWasNotConsumed;
  2228             break;
  2402             break;
  2229             }
  2403             }
  2230 InChar: CheckNotReadOnlyL();
  2404 InChar: CheckNotReadOnlyL();
  2231         TChar character(code);
  2405         TChar character(code);
  2232         if ( selectionLength && IsValidNumericCharL(character) )
  2406         if ( selectionLength )
  2233             {
  2407             {
  2234             TInt pos=DeleteHighlightL(formatHasChanged);
  2408             TInt pos=DeleteHighlightL(formatHasChanged);
  2235             TRAPD(err,iText->InsertL(pos,character));
  2409             TRAPD(err,iText->InsertL(pos,character));
  2236             if ( iEdwinExtension->iSmiley )
  2410             if ( iEdwinExtension && iEdwinExtension->iSmiley )
  2237                 {
  2411                 {
  2238                 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 );
  2412                 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 );
  2239                 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue );
  2413                 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue );
  2240                 }
  2414                 }
  2241             TCursorSelection selection=iTextView->Selection();
  2415             TCursorSelection selection=iTextView->Selection();
  2251             User::LeaveIfError(err);
  2425             User::LeaveIfError(err);
  2252             reportChange=ETrue;
  2426             reportChange=ETrue;
  2253             formatChange=formatHasChanged;
  2427             formatChange=formatHasChanged;
  2254             break;
  2428             break;
  2255             }
  2429             }
  2256         if ( (!iTextLimit || TextLength()<iTextLimit) && IsValidNumericCharL(character) )
  2430         if ( !iTextLimit || TextLength()<iTextLimit )
  2257             {
  2431             {
  2258             iText->InsertL(CursorPos(),character);
  2432             iText->InsertL(CursorPos(),character);
  2259             ClearUndo();
  2433             ClearUndo();
  2260             if ( iEdwinExtension->iSmiley )
  2434             if ( iEdwinExtension && iEdwinExtension->iSmiley )
  2261                 {
  2435                 {
  2262                 TInt cursorPos( CursorPos() );
  2436                 TInt cursorPos( CursorPos() );
  2263                 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 );
  2437                 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 );
  2264                 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2438                 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2265                     ETrue );
  2439                     ETrue );
  2276         }
  2450         }
  2277     if (reportChange)
  2451     if (reportChange)
  2278         {
  2452         {
  2279         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  2453         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  2280         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  2454         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  2281         if ( iEdwinExtension->iSmiley )
  2455         if ( iEdwinExtension && iEdwinExtension->iSmiley )
  2282             {            
  2456             {            
  2283             TInt docPos( CursorPos() );
  2457             TInt docPos( CursorPos() );
  2284             iEdwinExtension->iSmiley->HandleSetCursor( docPos, 
  2458             iEdwinExtension->iSmiley->HandleSetCursor( docPos, 
  2285                 docPos );
  2459                 docPos );
  2286             if ( docPos != CursorPos() )
  2460             if ( docPos != CursorPos() )
  2287                 {
  2461                 {
  2288                 SetCursorPosL( docPos, SelectionLength() > 0 );
  2462                 SetCursorPosL( docPos, SelectionLength() > 0 );
  2289                 }
  2463                 }
  2290             }
  2464             }
  2291         }
  2465         }
  2292     if (navigation)
  2466     if ( navigation && iEdwinExtension )
  2293         { 
  2467         { 
  2294         iEdwinExtension->iThumbPos = KErrNotFound;
  2468         iEdwinExtension->iThumbPos = KErrNotFound;
  2295         ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
  2469         ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
  2296         }
  2470         }
  2297     if (formatChange)
  2471     if (formatChange)
  2391              {
  2565              {
  2392              return;
  2566              return;
  2393              }
  2567              }
  2394          }
  2568          }
  2395     
  2569     
  2396     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  2570     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  2397         {
  2571         {
  2398         PerformRecordedOperationL();
  2572         PerformRecordedOperationL();
  2399         }
  2573         }
  2400     TCursorSelection selectionBefore = iTextView->Selection();
  2574     TCursorSelection selectionBefore = iTextView->Selection();
  2401     if (IsDimmed())
  2575     if (IsDimmed())
  2481                     }                   
  2655                     }                   
  2482                 }
  2656                 }
  2483             }
  2657             }
  2484         
  2658         
  2485         TBool shouldReturn( EFalse );
  2659         TBool shouldReturn( EFalse );
  2486         iEdwinExtension->iPhysicsHandler->HandleKineticScrolling(
  2660         if ( iEdwinExtension )
  2487             aPointerEvent, shouldReturn );
  2661         	{
       
  2662 			iEdwinExtension->iPhysicsHandler->HandleKineticScrolling(
       
  2663                 aPointerEvent, shouldReturn );
       
  2664         	}
  2488         
  2665         
  2489         if ( shouldReturn )
  2666         if ( shouldReturn )
  2490             {
  2667             {
  2491             return;
  2668             return;
  2492             }
  2669             }
  2497      
  2674      
  2498     // Display only mode, don't handle selection but return here.
  2675     // Display only mode, don't handle selection but return here.
  2499     if ( iEdwinUserFlags & EDisplayOnly )
  2676     if ( iEdwinUserFlags & EDisplayOnly )
  2500         {
  2677         {
  2501         return;
  2678         return;
       
  2679         }
       
  2680     
       
  2681     // If text selection is not visible, don't allow user to select any text
       
  2682     // or scroll during selection ( if kinetic scrolling enabled ).
       
  2683     if ( kineticScrollingEnabled && iEdwinFepSupport )
       
  2684         {
       
  2685         CAknEdwinState* edwinState( EditorState() );
       
  2686         if ( edwinState && !( edwinState->Flags() & EAknEditorFlagSelectionVisible ) )
       
  2687             {
       
  2688             return;
       
  2689             }
  2502         }
  2690         }
  2503     
  2691     
  2504     const TCursorSelection selection( iTextView->Selection() );
  2692     const TCursorSelection selection( iTextView->Selection() );
  2505     const TPoint pointerPos( aPointerEvent.iPosition );
  2693     const TPoint pointerPos( aPointerEvent.iPosition );
  2506     
  2694     
  2531                     }
  2719                     }
  2532                 }
  2720                 }
  2533             } 
  2721             } 
  2534         } // Kinetic scrolling not enabled  
  2722         } // Kinetic scrolling not enabled  
  2535     
  2723     
  2536     if ( iEdwinExtension->iPtSuppressor->SuppressPointerEvent( aPointerEvent ) )
  2724     if ( iEdwinExtension && iEdwinExtension->iPtSuppressor->SuppressPointerEvent( aPointerEvent ) )
  2537         {
  2725         {
  2538         return;
  2726         return;
  2539         }
  2727         }
  2540     if ( IsFocused() )
  2728     if ( IsFocused() )
  2541         {
  2729         {
  2674             iLastPointerDocPos=newCursorPos;
  2862             iLastPointerDocPos=newCursorPos;
  2675             iLastPointerAnchorPos=newAnchorPos;
  2863             iLastPointerAnchorPos=newAnchorPos;
  2676             iEdwinInternalFlags&=(~ELeftDownInViewRect);
  2864             iEdwinInternalFlags&=(~ELeftDownInViewRect);
  2677 
  2865 
  2678             // We can't open cut-copy-paste menu if dragging started
  2866             // We can't open cut-copy-paste menu if dragging started
  2679             if ( IsReadOnly() && IsSelectionVisible() && !( kineticScrollingEnabled
  2867             if ( IsReadOnly() && IsSelectionVisible() && IsFocused() && !( kineticScrollingEnabled
  2680                 && iEdwinExtension->iPhysicsHandler->DraggingStarted() ) )
  2868                 && iEdwinExtension->iPhysicsHandler->DraggingStarted() ) )
  2681                 {
  2869                 {
  2682                 iEdwinFepSupport->iFeedback->InstantFeedback(
  2870                 iEdwinFepSupport->iFeedback->InstantFeedback(
  2683                                                          this,
  2871                                                          this,
  2684                                                          ETouchFeedbackPopUp,
  2872                                                          ETouchFeedbackPopUp,
  2703                     if ( !IsReadOnly() && !iEdwinExtension->iDragging &&
  2891                     if ( !IsReadOnly() && !iEdwinExtension->iDragging &&
  2704                         !iEdwinExtension->iPhysicsHandler->DraggingStarted()   
  2892                         !iEdwinExtension->iPhysicsHandler->DraggingStarted()   
  2705                         )
  2893                         )
  2706                         {
  2894                         {
  2707                         iEdwinFepSupport->iFeedback->InstantFeedback( this,
  2895                         iEdwinFepSupport->iFeedback->InstantFeedback( this,
  2708                             ETouchFeedbackEditor, ETouchFeedbackVibra,
  2896                             ETouchFeedbackEdit, ETouchFeedbackVibra,
  2709                             aPointerEvent );
  2897                             aPointerEvent );
  2710                         }
  2898                         }
  2711                     }
  2899                     }
  2712                 else // Kinetic scrolling not enabled
  2900                 else // Kinetic scrolling not enabled
  2713                     {
  2901                     {
  2718                             iEdwinUserFlags & CEikEdwin::EReadOnly |
  2906                             iEdwinUserFlags & CEikEdwin::EReadOnly |
  2719                             iEdwinUserFlags & CEikEdwin::EAvkonNotEditable ) ) ) )
  2907                             iEdwinUserFlags & CEikEdwin::EAvkonNotEditable ) ) ) )
  2720                         {
  2908                         {
  2721                         iEdwinFepSupport->iFeedback->InstantFeedback(
  2909                         iEdwinFepSupport->iFeedback->InstantFeedback(
  2722                             this,
  2910                             this,
  2723                             ETouchFeedbackEditor,
  2911                             ETouchFeedbackEdit,
  2724                             ETouchFeedbackVibra,
  2912                             ETouchFeedbackVibra,
  2725                             aPointerEvent );
  2913                             aPointerEvent );
  2726                         iEdwinFepSupport->iSelectionIsCancel = EFalse;
  2914                         iEdwinFepSupport->iSelectionIsCancel = EFalse;
  2727                         }
  2915                         }
  2728                     } 
  2916                     } 
  2770                 MoveCursorL(TCursorPosition::EFLineUp,select);
  2958                 MoveCursorL(TCursorPosition::EFLineUp,select);
  2771                 rect.Move(0,-(viewRect.Height()+2000));
  2959                 rect.Move(0,-(viewRect.Height()+2000));
  2772                 }
  2960                 }
  2773             Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect);
  2961             Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect);
  2774             navigation = ETrue;
  2962             navigation = ETrue;
  2775             iEdwinExtension->iThumbPos = KErrNotFound;
  2963             if ( iLayout && !iLayout->IsFormattingBand() )
       
  2964                 {
       
  2965                 iEdwinExtension->iThumbPos = KErrNotFound;
       
  2966                 }
  2776             }
  2967             }
  2777         else if (iEdwinInternalFlags&EDragDouble)
  2968         else if (iEdwinInternalFlags&EDragDouble)
  2778             {
  2969             {
  2779             TInt newWordStartPos,newWordLength;
  2970             TInt newWordStartPos,newWordLength;
  2780             GetWordInfo(newCursorPos,newWordStartPos,newWordLength);
  2971             GetWordInfo(newCursorPos,newWordStartPos,newWordLength);
  2864                 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && editingEnabled )
  3055                 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && editingEnabled )
  2865                     {
  3056                     {
  2866                     // on down event feedback is given if cursor/selection changes
  3057                     // on down event feedback is given if cursor/selection changes
  2867                     if ( paintingPossible && !readOnly || editorWillGetFocus )
  3058                     if ( paintingPossible && !readOnly || editorWillGetFocus )
  2868                         {
  3059                         {
  2869                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBasic );
  3060                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackEdit );
  2870                         }
  3061                         }
  2871                     }
  3062                     }
  2872                 else  if ( selectionChanged && 
  3063                 else  if ( selectionChanged && 
  2873                        ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
  3064                          ( selectionAfter.iAnchorPos != selectionAfter.iCursorPos ) &&
       
  3065                          ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
  2874                          ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) )
  3066                          ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) )
  2875                     {
  3067                     {
  2876                     
       
  2877                     // selectionAfter.iCursorPos-1 below is because we need to select the previous char
       
  2878                     TBool ltr = ( selectionAfter.iCursorPos >= selectionBefore.iCursorPos );
       
  2879                     TInt readPos = selectionAfter.iCursorPos;
  3068                     TInt readPos = selectionAfter.iCursorPos;
  2880                     if (ltr && readPos > 0)
  3069                     if ( selectionAfter.iCursorPos > selectionAfter.iAnchorPos )
  2881                         {
  3070                         {
  2882                         readPos -= 1; // read previous char
  3071                         readPos -= 1;//drag backword
  2883                         }
  3072                         }
  2884                     TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; 
  3073                     TChar currentSelectedChar = Text()->Read( readPos, 1 )[0];
  2885                     TBool isSpace = currentSelectedChar.IsSpace();
  3074                     TBool isSpace = currentSelectedChar.IsSpace();
  2886                     TBool isText = currentSelectedChar.IsAlpha() 
  3075                     TBool isSmiley = CSmileyManager::IsSmileyCode(currentSelectedChar);
  2887                                 || currentSelectedChar.IsDigit();
  3076                     TBool isText = currentSelectedChar.IsGraph();
  2888                     
  3077                     
  2889                     // case line
  3078                     // case line
  2890                     TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos);
  3079                     TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos);
  2891                     TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos);
  3080                     TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos);
  2892                     if ( prevLineNr != lineNr && ( selection.Length() != 0 ) )
  3081                     if ( prevLineNr != lineNr )
  2893                         {
  3082                         {
  2894                         TInt group = ( currentSelectedChar.GetCategory() & 0xF0 );
  3083                         TInt group = currentSelectedChar.GetCategory();
  2895                         TBool isEmptyLine = ( group == TChar::ESeparatorGroup );
  3084                         TBool isEmptyLine = ( group == TChar::EZpCategory );
  2896                         TTouchLogicalFeedback fType = ( isEmptyLine ? 
  3085                         TTouchLogicalFeedback fType = ( isEmptyLine ? 
  2897                             ETouchFeedbackEmptyLineSelection : ETouchFeedbackLineSelection );
  3086                             ETouchFeedbackEmptyLineSelection : ETouchFeedbackLineSelection );
  2898                         iEdwinFepSupport->iFeedback->InstantFeedback( this, fType );
  3087                         iEdwinFepSupport->iFeedback->InstantFeedback( this, fType );
  2899                         }
  3088                         }
  2900                     // case space
  3089                     // case space
  2901                     else if (isSpace)
  3090                     else if (isSpace)
  2902                         {
  3091                         {
  2903                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection );
  3092                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection );
  2904                         }
  3093                         }
  2905                     // case text
  3094                     // case text
  2906                     else if (isText)    
  3095                     else if ( isText || isSmiley )    
  2907                         {
  3096                         {
  2908                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection );
  3097                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection );
  2909                         }
  3098                         }
  2910                     }
  3099                     }
  2911                 }
  3100                 }
  2960             {
  3149             {
  2961             if ( !focused )
  3150             if ( !focused )
  2962                 {
  3151                 {
  2963                 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  3152                 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  2964                     MAknEdStateObserver::EAknSyncEdwinState ) );
  3153                     MAknEdStateObserver::EAknSyncEdwinState ) );
       
  3154                 // if text view is already hidden and editor loses focus, display text view.
       
  3155 				if ( ( edwinState->Flags() & EAknEditorFlagHideTextView ) &&
       
  3156                      ( iEdwinExtension && iEdwinExtension->iTextViewHidden ) )
       
  3157                     {
       
  3158                     iTextView->MakeVisible( ETrue );
       
  3159                     edwinState->SetFlags( edwinState->Flags() & 
       
  3160                         ~EAknEditorFlagHideTextView );
       
  3161                     iEdwinExtension->iTextViewHidden = EFalse;                    
       
  3162                     DrawDeferred();
       
  3163                     }
  2965                 }
  3164                 }
  2966             else
  3165             else
  2967                 {
  3166                 {
  2968                 if ( edwinState->Flags() & EAknEditorFlagLaunchPenInputAutomatic &&
  3167                 if ( edwinState->Flags() & EAknEditorFlagLaunchPenInputAutomatic &&
  2969                     !IsReadOnly() && !IsDimmed() && !( iEdwinUserFlags & EDisplayOnly ) )
  3168                     !IsReadOnly() && !IsDimmed() && !( iEdwinUserFlags & EDisplayOnly ) )
  3059         }
  3258         }
  3060             
  3259             
  3061     DoCreateCustomDrawL(); //  Done after TextView is created so that optimized drawer is constructed
  3260     DoCreateCustomDrawL(); //  Done after TextView is created so that optimized drawer is constructed
  3062 
  3261 
  3063     // Create the required formatters according to the editor set-up
  3262     // Create the required formatters according to the editor set-up
  3064     if ( IsPurePhoneNumberEditor() )
  3263     if ( IsPurePhoneNumberEditor() && iEdwinExtension )
  3065         {
  3264         {
  3066         if ( phoneNumberGroupingSupported )
  3265         if ( phoneNumberGroupingSupported )
  3067             {            
  3266             {            
  3068             CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) );            
  3267             CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) );            
  3069             edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping );                    
  3268             edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping );                    
  3070             iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText );
  3269             iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText );
  3071             }
  3270             }
  3072         }
  3271         }
  3073     else // Make approximation that all other editors have no matches indicator functionality
  3272     else if ( iEdwinExtension )// Make approximation that all other editors have no matches indicator functionality
  3074         {
  3273         {
  3075         iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout );
  3274         iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout );
  3076         }
  3275         }
  3077 
  3276 
  3078     // Rich text editors that have been configured for phone number grouping
  3277     // Rich text editors that have been configured for phone number grouping
  3079     if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping &&
  3278     if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping &&
  3080         phoneNumberGroupingSupported )
  3279         phoneNumberGroupingSupported && iEdwinExtension )
  3081         {        
  3280         {        
  3082         CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) );            
  3281         CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) );            
  3083         edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping );                
  3282         edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping );                
  3084         iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) );
  3283         iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) );
  3085         }
  3284         }
  3086 
  3285 
  3087     // Install the custom formatter system if needed
  3286     // Install the custom formatter system if needed
  3088     if ( iEdwinExtension->FormExtendedInferfaceProvider() )
  3287     if ( iEdwinExtension && iEdwinExtension->FormExtendedInferfaceProvider() )
  3089         TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() );
  3288         TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() );
  3090 
  3289 
  3091     UpdateScrollBarsL();
  3290     UpdateScrollBarsL();
  3092     ForceScrollBarUpdateL();
  3291     ForceScrollBarUpdateL();
  3093 
  3292 
  3221     if ( condition )
  3420     if ( condition )
  3222         {
  3421         {
  3223         SetCursorVisibilityL( ETrue );
  3422         SetCursorVisibilityL( ETrue );
  3224         }
  3423         }
  3225     // View size changed, Initialize physics here
  3424     // View size changed, Initialize physics here
  3226     iEdwinExtension->InitPhysicsL();        
  3425     if ( iEdwinExtension )
       
  3426     	{
       
  3427 		iEdwinExtension->InitPhysicsL();   
       
  3428     	}
  3227     }
  3429     }
  3228 
  3430 
  3229 EXPORT_C TInt CEikEdwin::CountComponentControls() const
  3431 EXPORT_C TInt CEikEdwin::CountComponentControls() const
  3230     {
  3432     {
  3231     TInt count=CEikBorderedControl::CountComponentControls();
  3433     TInt count=CEikBorderedControl::CountComponentControls();
  3246 EXPORT_C void CEikEdwin::SetAmountToFormatL(TBool aIsNewDoc)
  3448 EXPORT_C void CEikEdwin::SetAmountToFormatL(TBool aIsNewDoc)
  3247     {
  3449     {
  3248     if (!iTextView)
  3450     if (!iTextView)
  3249         return;
  3451         return;
  3250     const TInt chars=iText->DocumentLength();
  3452     const TInt chars=iText->DocumentLength();
  3251     if ( iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
  3453     if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
  3252         {        
  3454         {        
  3253         if ( chars > KFullFormatLengthForSmiley )
  3455         if ( chars > KFullFormatLengthForSmiley )
  3254             {
  3456             {
  3255             ConvertVisibleTextForSmileyL( ETrue );
  3457             ConvertVisibleTextForSmileyL( ETrue );
  3256             }
  3458             }
  3303         }
  3505         }
  3304         
  3506         
  3305     if (!iTextView)
  3507     if (!iTextView)
  3306         return;
  3508         return;
  3307     const TInt chars=iText->DocumentLength();
  3509     const TInt chars=iText->DocumentLength();
  3308     if ( iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
  3510     if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat )
  3309         {        
  3511         {        
  3310         if ( chars > KFullFormatLengthForSmiley )
  3512         if ( chars > KFullFormatLengthForSmiley )
  3311             {
  3513             {
  3312             ConvertVisibleTextForSmileyL( ETrue );
  3514             ConvertVisibleTextForSmileyL( ETrue );
  3313             }
  3515             }
  3377         {
  3579         {
  3378         const TInt count=iObserverArray->Count();
  3580         const TInt count=iObserverArray->Count();
  3379         for (TInt ii=0;ii<count;ii++)
  3581         for (TInt ii=0;ii<count;ii++)
  3380             (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType);
  3582             (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType);
  3381         }
  3583         }
  3382     if ( aEventType == MEikEdwinObserver::EEventScroll || 
  3584     if ( aEventType == MEikEdwinObserver::EEventTextUpdate && iEdwinExtension )
  3383         aEventType == MEikEdwinObserver::EEventNavigation 
       
  3384         )
       
  3385         {
       
  3386         HandleScrollForSmileyL();        
       
  3387         }
       
  3388     if ( aEventType == MEikEdwinObserver::EEventTextUpdate )
       
  3389         {
  3585         {
  3390         iEdwinExtension->iExtendedInputCapabilities->ReportEventL( 
  3586         iEdwinExtension->iExtendedInputCapabilities->ReportEventL( 
  3391                 CAknExtendedInputCapabilities::
  3587                 CAknExtendedInputCapabilities::
  3392                     MAknEventObserver::EControlContentUpdatedInternally,
  3588                     MAknEventObserver::EControlContentUpdatedInternally,
  3393                 NULL );
  3589                 NULL );
  3439 EXPORT_C void CEikEdwin::SetCursorPosL(TInt aDocPos,TBool aSelect)
  3635 EXPORT_C void CEikEdwin::SetCursorPosL(TInt aDocPos,TBool aSelect)
  3440     {
  3636     {
  3441     // CTextView::SetDocPosL will cause textview to be drawn. This could happen 
  3637     // CTextView::SetDocPosL will cause textview to be drawn. This could happen 
  3442     // before the drawing of editor. So adding following codes to postpone the action to
  3638     // before the drawing of editor. So adding following codes to postpone the action to
  3443     // first drawing of editor.
  3639     // first drawing of editor.
  3444     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  3640     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  3445         {
  3641         {
  3446         iEdwinExtension->iTempCursorPos = aDocPos;
  3642         iEdwinExtension->iTempCursorPos = aDocPos;
  3447         iEdwinExtension->iTempSelect = aSelect;
  3643         iEdwinExtension->iTempSelect = aSelect;
  3448         if ( !aSelect )
  3644         if ( !aSelect )
  3449             {
  3645             {
  3459 
  3655 
  3460     if (!iTextView)
  3656     if (!iTextView)
  3461         CreateTextViewL();
  3657         CreateTextViewL();
  3462     TInt oldPos( CursorPos() );
  3658     TInt oldPos( CursorPos() );
  3463     TInt docPos( aDocPos );
  3659     TInt docPos( aDocPos );
  3464     if ( iEdwinExtension->iSmiley )
  3660     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  3465         {
  3661         {
  3466         iEdwinExtension->iSmiley->HandleSetCursor( oldPos, docPos );
  3662         iEdwinExtension->iSmiley->HandleSetCursor( oldPos, docPos );
  3467         }
  3663         }
  3468     TCursorSelection select( Selection() );
  3664     TCursorSelection select( Selection() );
  3469     select.iCursorPos = docPos;
  3665     select.iCursorPos = docPos;
  3476     ScrollIfAtTopOrBottomL();
  3672     ScrollIfAtTopOrBottomL();
  3477     
  3673     
  3478     if ( iEdwinFepSupport && 
  3674     if ( iEdwinFepSupport && 
  3479         ( aDocPos != oldPos || ( select.Length() > 0 && !aSelect ) ) )
  3675         ( aDocPos != oldPos || ( select.Length() > 0 && !aSelect ) ) )
  3480         {
  3676         {
       
  3677         // Update text window position for cursor change.
       
  3678         iEdwinFepSupport->UpdateDocPosOffsetL( docPos );
  3481         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
  3679         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
  3482         if ( edwinState )
  3680         if ( edwinState )
  3483             {
  3681             {
  3484             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
  3682             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
  3485             }
  3683             }
  3486         }
  3684         }
  3487         
  3685 	// scrollbar:thumb is displayed on the top when editor set cursor position.
       
  3686     iEdwinExtension->iThumbPos = KErrNotFound;    
  3488     UpdateVertScrollBarThumbL();
  3687     UpdateVertScrollBarThumbL();
  3489     UpdateHorizScrollBarThumb();
  3688     UpdateHorizScrollBarThumb();
  3490     }
  3689     }
  3491 
  3690 
  3492 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner)
  3691 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner)
  3503         {
  3702         {
  3504         CancelFepTransaction();
  3703         CancelFepTransaction();
  3505         }
  3704         }
  3506     if (!iTextView)
  3705     if (!iTextView)
  3507         CreateTextViewL();
  3706         CreateTextViewL();
  3508     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  3707     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  3509         {        
  3708         {        
  3510         iEdwinExtension->iTempCursorPos = aCursorPos;
  3709         iEdwinExtension->iTempCursorPos = aCursorPos;
  3511         iEdwinExtension->iTempAnchorPos = aAnchorPos;
  3710         iEdwinExtension->iTempAnchorPos = aAnchorPos;
  3512         return;
  3711         return;
  3513         }
  3712         }
  3517         iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos );
  3716         iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos );
  3518         }
  3717         }
  3519     TCursorSelection select( aCursorPos, aAnchorPos );    
  3718     TCursorSelection select( aCursorPos, aAnchorPos );    
  3520     HandleSelectionForSmiley( select );
  3719     HandleSelectionForSmiley( select );
  3521     iTextView->SetSelectionL( select );
  3720     iTextView->SetSelectionL( select );
  3522     iEdwinExtension->iThumbPos =  KErrNotFound;
  3721     if ( iEdwinExtension )
       
  3722     	{
       
  3723 		iEdwinExtension->iThumbPos =  KErrNotFound;
       
  3724     	}
  3523 
  3725 
  3524     if ( iEdwinFepSupport )
  3726     if ( iEdwinFepSupport )
  3525         {
  3727         {
       
  3728         // Update text window position for cursor change.
       
  3729         iEdwinFepSupport->UpdateDocPosOffsetL( aCursorPos );
  3526         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
  3730         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) );
  3527         if ( edwinState )
  3731         if ( edwinState )
  3528             {
  3732             {
  3529             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
  3733             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) );
  3530             }
  3734             }
  3625     if (iEdwinUserFlags&EOwnsWindow && !OwnsWindow())
  3829     if (iEdwinUserFlags&EOwnsWindow && !OwnsWindow())
  3626         CreateWindowL(&aParent);
  3830         CreateWindowL(&aParent);
  3627     else
  3831     else
  3628         CCoeControl::SetContainerWindowL(aParent);
  3832         CCoeControl::SetContainerWindowL(aParent);
  3629 
  3833 
  3630     iEdwinExtension->EnablePhysicsL();
  3834     if ( iEdwinExtension )
       
  3835     	{
       
  3836 		iEdwinExtension->EnablePhysicsL();
       
  3837     	}
  3631     }
  3838     }
  3632 
  3839 
  3633 EXPORT_C void CEikEdwin::SetContainerWindowL()
  3840 EXPORT_C void CEikEdwin::SetContainerWindowL()
  3634     {
  3841     {
  3635     __ASSERT_DEBUG(iEdwinUserFlags&EOwnsWindow, Panic(EEikPanicEdwinNoWindow));
  3842     __ASSERT_DEBUG(iEdwinUserFlags&EOwnsWindow, Panic(EEikPanicEdwinNoWindow));
  3636     if (!OwnsWindow())
  3843     if (!OwnsWindow())
  3637         CreateWindowL();
  3844         CreateWindowL();
  3638 
  3845 
  3639     iEdwinExtension->EnablePhysicsL();   
  3846     if ( iEdwinExtension )
       
  3847     	{
       
  3848 		iEdwinExtension->EnablePhysicsL();
       
  3849     	}   
  3640     }
  3850     }
  3641 
  3851 
  3642 EXPORT_C TCoeInputCapabilities CEikEdwin::InputCapabilities() const
  3852 EXPORT_C TCoeInputCapabilities CEikEdwin::InputCapabilities() const
  3643     {
  3853     {
  3644     if (IsReadOnly())
  3854     if (IsReadOnly())
  3695  */
  3905  */
  3696 EXPORT_C void CEikEdwin::CreateLayoutL(MLayDoc* aLayDoc)
  3906 EXPORT_C void CEikEdwin::CreateLayoutL(MLayDoc* aLayDoc)
  3697     {
  3907     {
  3698     __ASSERT_DEBUG(aLayDoc,Panic(EEikPanicEdwinNoText));
  3908     __ASSERT_DEBUG(aLayDoc,Panic(EEikPanicEdwinNoText));
  3699 
  3909 
  3700     if ((iEdwinUserFlags&EAvkonEditor))
  3910     if ( iEdwinUserFlags&EAvkonEditor && iEdwinExtension )
  3701         {
  3911         {
  3702         iLayout=CTextLayout::NewL(aLayDoc,KMaxTInt); // supply real wrapping width later
  3912         iLayout=CTextLayout::NewL(aLayDoc,KMaxTInt); // supply real wrapping width later
  3703         iLayout->SetCustomWrap(&(iEdwinExtension->TextWrapper()));
  3913         iLayout->SetCustomWrap(&(iEdwinExtension->TextWrapper()));
  3704         
  3914         
  3705         // This WAS ETrue, then fixed to EFalse, caused regression and now back to
  3915         // This WAS ETrue, then fixed to EFalse, caused regression and now back to
  3870     gc.DiscardFont(); // So the GC will not try to use the font.
  4080     gc.DiscardFont(); // So the GC will not try to use the font.
  3871     }
  4081     }
  3872 
  4082 
  3873 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const
  4083 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const
  3874     {
  4084     {
  3875     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  4085     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  3876         {
  4086         {
  3877         CEikEdwin* edwin( const_cast<CEikEdwin*>( this ) );
  4087         CEikEdwin* edwin( const_cast<CEikEdwin*>( this ) );
  3878         edwin->iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawing;
  4088         edwin->iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawing;
  3879         TRAP_IGNORE( edwin->PerformRecordedOperationL(); );
  4089         TRAP_IGNORE( edwin->PerformRecordedOperationL(); );
  3880         }
  4090         }
  3991             return;
  4201             return;
  3992             }
  4202             }
  3993         }
  4203         }
  3994     TInt oldCursor( CursorPos() );
  4204     TInt oldCursor( CursorPos() );
  3995     TPoint movePoint=iTextView->MoveCursorL( aMovement, aSelect );
  4205     TPoint movePoint=iTextView->MoveCursorL( aMovement, aSelect );
  3996     if ( iEdwinExtension->iSmiley )
  4206     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  3997         {
  4207         {
  3998         TCursorSelection select( 0, 0 );
  4208         TCursorSelection select( 0, 0 );
  3999         if ( AdjustCursorForSmileyL( oldCursor, select ) )
  4209         if ( AdjustCursorForSmileyL( oldCursor, select ) )
  4000             {
  4210             {
  4001             SetSelectionL( select.iCursorPos, select.iAnchorPos );
  4211             SetSelectionL( select.iCursorPos, select.iAnchorPos );
  4011     if ( movePoint.iY )
  4221     if ( movePoint.iY )
  4012         UpdateVertScrollBarThumbL();
  4222         UpdateVertScrollBarThumbL();
  4013 
  4223 
  4014     if ( iEdwinFepSupport )
  4224     if ( iEdwinFepSupport )
  4015         {
  4225         {
       
  4226         // Update text window position for cursor change.
       
  4227         iEdwinFepSupport->UpdateDocPosOffsetL( CursorPos() );
  4016         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( 
  4228         CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( 
  4017             iEdwinFepSupport->State( KNullUid ) );
  4229             iEdwinFepSupport->State( KNullUid ) );
  4018         if ( edwinState )
  4230         if ( edwinState )
  4019             {
  4231             {
  4020             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  4232             TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  4028     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4240     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4029     
  4241     
  4030     // Before scrolling into blank space was allowed, but this eventually
  4242     // Before scrolling into blank space was allowed, but this eventually
  4031     // causes a panic at CTextView::ScrollDisplayL().
  4243     // causes a panic at CTextView::ScrollDisplayL().
  4032     const TInt move=iTextView->ScrollDisplayL(aMovement,CTextLayout::EFDisallowScrollingBlankSpace);
  4244     const TInt move=iTextView->ScrollDisplayL(aMovement,CTextLayout::EFDisallowScrollingBlankSpace);
  4033     if (move)
  4245     if ( move && iEdwinExtension )
  4034         {
  4246         {
  4035         iEdwinExtension->iThumbPos = KErrNotFound;
  4247         iEdwinExtension->iThumbPos = KErrNotFound;
  4036         switch (aMovement)
  4248         switch (aMovement)
  4037             {
  4249             {
  4038         case TCursorPosition::EFLeft:
  4250         case TCursorPosition::EFLeft:
  4083     }
  4295     }
  4084 
  4296 
  4085 EXPORT_C TInt CEikEdwin::CursorPos() const
  4297 EXPORT_C TInt CEikEdwin::CursorPos() const
  4086     {
  4298     {
  4087     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4299     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4088     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4300     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4089         iEdwinExtension->iTempCursorPos != KErrNotFound )
  4301         iEdwinExtension->iTempCursorPos != KErrNotFound )
  4090         {
  4302         {
  4091         return iEdwinExtension->iTempCursorPos;
  4303         return iEdwinExtension->iTempCursorPos;
  4092         }
  4304         }
  4093     else
  4305     else
  4099 
  4311 
  4100 EXPORT_C TInt CEikEdwin::SelectionLength() const
  4312 EXPORT_C TInt CEikEdwin::SelectionLength() const
  4101     {
  4313     {
  4102     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4314     __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView));
  4103     TCursorSelection selection( 0, 0 );
  4315     TCursorSelection selection( 0, 0 );
  4104     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4316     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4105         iEdwinExtension->iTempCursorPos != KErrNotFound && 
  4317         iEdwinExtension->iTempCursorPos != KErrNotFound && 
  4106         iEdwinExtension->iTempAnchorPos != KErrNotFound )
  4318         iEdwinExtension->iTempAnchorPos != KErrNotFound )
  4107         {
  4319         {
  4108         selection.iCursorPos = iEdwinExtension->iTempCursorPos;
  4320         selection.iCursorPos = iEdwinExtension->iTempCursorPos;
  4109         selection.iAnchorPos = iEdwinExtension->iTempAnchorPos;
  4321         selection.iAnchorPos = iEdwinExtension->iTempAnchorPos;
  4159         {
  4371         {
  4160         if (iEdwinInternalFlags&ERichText)
  4372         if (iEdwinInternalFlags&ERichText)
  4161             STATIC_CAST(CRichText*,iText)->CancelInsertCharFormat();
  4373             STATIC_CAST(CRichText*,iText)->CancelInsertCharFormat();
  4162         aChanged=iText->DeleteL(aSelection.LowerPos(),length);
  4374         aChanged=iText->DeleteL(aSelection.LowerPos(),length);
  4163         }
  4375         }
  4164     if ( iEdwinExtension->iSmiley )
  4376     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4165         { 
  4377         { 
  4166         iEdwinExtension->iSmiley->HandleDeleteL( aSelection.LowerPos(), length );
  4378         iEdwinExtension->iSmiley->HandleDeleteL( aSelection.LowerPos(), length );
  4167         }
  4379         }
  4168     CleanupStack::Pop();
  4380     CleanupStack::Pop();
  4169     }
  4381     }
  4191     	return;
  4403     	return;
  4192     if( textCursor != TCursor::EFCursorInvisible )
  4404     if( textCursor != TCursor::EFCursorInvisible )
  4193     	{
  4405     	{
  4194         SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagTextCursorVisible );
  4406         SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagTextCursorVisible );
  4195     	}
  4407     	}
  4196     else
  4408     else if ( iEdwinExtension )
  4197     	{
  4409     	{
  4198     	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagTextCursorVisible );
  4410     	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagTextCursorVisible );
  4199     	
  4411     	
  4200         // If cursor is disabled during kinetic scrolling
  4412         // If cursor is disabled during kinetic scrolling
  4201         // by other party (for any reason), reset flag so that we don't show it again
  4413         // by other party (for any reason), reset flag so that we don't show it again
  4412     if ( iTextLimit && TextLength() > iTextLimit )
  4624     if ( iTextLimit && TextLength() > iTextLimit )
  4413         {
  4625         {
  4414         select.iCursorPos = iTextLimit;
  4626         select.iCursorPos = iTextLimit;
  4415         }
  4627         }
  4416     TBool hasSmiley( EFalse );
  4628     TBool hasSmiley( EFalse );
  4417     if ( iEdwinExtension->iSmiley )
  4629     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4418         {
  4630         {
  4419         hasSmiley = iEdwinExtension->iSmiley->HasSmileyIconsInText();
  4631         hasSmiley = iEdwinExtension->iSmiley->HasSmileyIconsInText();
  4420         }
  4632         }
  4421     if ( hasSmiley )
  4633     if ( hasSmiley )
  4422         {
  4634         {
  4498             }
  4710             }
  4499         segmBufPtr = aDes->Mid( segmStart, insertLength);
  4711         segmBufPtr = aDes->Mid( segmStart, insertLength);
  4500         AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter,
  4712         AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter,
  4501                       TChar(CEditableText::EParagraphDelimiter));
  4713                       TChar(CEditableText::EParagraphDelimiter));
  4502 	    iText->InsertL(oldLength+segmStart,*segmBuf);
  4714 	    iText->InsertL(oldLength+segmStart,*segmBuf);
  4503 	    if ( iEdwinExtension->iSmiley )
  4715 	    if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4504 	        {
  4716 	        {
  4505 	        iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, 
  4717 	        iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, 
  4506 	            insertLength );	        
  4718 	            insertLength );	        
  4507 	        }
  4719 	        }
  4508 	    segmStart = segmEnd;
  4720 	    segmStart = segmEnd;
  4512 	        }
  4724 	        }
  4513 	    }
  4725 	    }
  4514 	    
  4726 	    
  4515 	    CleanupStack::PopAndDestroy(segmBuf);
  4727 	    CleanupStack::PopAndDestroy(segmBuf);
  4516         TRAP(err,iText->DeleteL(0,oldLength));
  4728         TRAP(err,iText->DeleteL(0,oldLength));
  4517         if ( iEdwinExtension->iSmiley )
  4729         if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4518             {
  4730             {
  4519             iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength );
  4731             iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength );
  4520             ConvertTextForSmileyL( TCursorSelection( 0, 
  4732             ConvertTextForSmileyL( TCursorSelection( 0, 
  4521                 iText->DocumentLength() ), ETrue );
  4733                 iText->DocumentLength() ), ETrue );
  4522             }
  4734             }
  4523         }
  4735         }
  4524     else
  4736     else
  4525         {
  4737         {
  4526         iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object
  4738         iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object
  4527         if ( iEdwinExtension->iSmiley )
  4739         if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4528             {
  4740             {
  4529             iEdwinExtension->iSmiley->HandleDeleteL( 0, 
  4741             iEdwinExtension->iSmiley->HandleDeleteL( 0, 
  4530                 iText->DocumentLength() );
  4742                 iText->DocumentLength() );
  4531             }
  4743             }
  4532         }
  4744         }
  4533 
  4745 
  4534     CheckRemovePictures(0,iText->DocumentLength());
  4746     CheckRemovePictures(0,iText->DocumentLength());
  4535     CheckValidityOfChars(0,iText->DocumentLength());
  4747     CheckValidityOfChars(0,iText->DocumentLength());
  4536     iEdwinExtension->iDisableConvertInFormat = ETrue;
  4748     if ( iEdwinExtension )
  4537     SetAmountToFormatL(ETrue); // performs formatting
  4749     	{
  4538     iEdwinExtension->iDisableConvertInFormat = EFalse;
  4750 		iEdwinExtension->iDisableConvertInFormat = ETrue;
       
  4751 		}
       
  4752 	SetAmountToFormatL(ETrue); // performs formatting
       
  4753 	if ( iEdwinExtension )
       
  4754     	{
       
  4755 		iEdwinExtension->iDisableConvertInFormat = EFalse;
       
  4756     	}
  4539 	// Update cursor position as CursorWidth() needs that.
  4757 	// Update cursor position as CursorWidth() needs that.
  4540     if (IsReadyToDraw())
  4758     if (IsReadyToDraw())
  4541         {        
  4759         {        
  4542         ApplyAutoSelectionL();
  4760         ApplyAutoSelectionL();
  4543         }
  4761         }
  4563         if ( iCcpuSupport )
  4781         if ( iCcpuSupport )
  4564             {
  4782             {
  4565             iCcpuSupport->HandleSelectionChangeL();
  4783             iCcpuSupport->HandleSelectionChangeL();
  4566             }
  4784             }
  4567         }
  4785         }
       
  4786     if ( iEdwinExtension )
       
  4787     	{
       
  4788 		iEdwinExtension->iThumbPos = KErrNotFound;
       
  4789     	}
  4568     if (IsReadyToDraw())
  4790     if (IsReadyToDraw())
  4569         {
  4791         {
  4570         UpdateScrollBarsL();
  4792         UpdateScrollBarsL();
  4571         }
  4793         }
  4572 
  4794 
  4573     User::LeaveIfError(err);       
  4795     User::LeaveIfError(err);       
  4574     }
  4796     }
  4575 
  4797 
  4576 EXPORT_C TCursorSelection CEikEdwin::Selection()    const
  4798 EXPORT_C TCursorSelection CEikEdwin::Selection()    const
  4577     {
  4799     {
  4578     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4800     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && 
  4579         iEdwinExtension->iTempCursorPos != KErrNotFound && 
  4801         iEdwinExtension->iTempCursorPos != KErrNotFound && 
  4580         iEdwinExtension->iTempAnchorPos != KErrNotFound )
  4802         iEdwinExtension->iTempAnchorPos != KErrNotFound )
  4581         {        
  4803         {        
  4582         return TCursorSelection( iEdwinExtension->iTempCursorPos,
  4804         return TCursorSelection( iEdwinExtension->iTempCursorPos,
  4583             iEdwinExtension->iTempAnchorPos );
  4805             iEdwinExtension->iTempAnchorPos );
  4628         const TInt lower=newText.LowerPos();
  4850         const TInt lower=newText.LowerPos();
  4629         TInt undoneLength=0;
  4851         TInt undoneLength=0;
  4630         TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower))
  4852         TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower))
  4631         const TInt cursorPos=iUndoStore->OldCursorPos();
  4853         const TInt cursorPos=iUndoStore->OldCursorPos();
  4632         iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos));
  4854         iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos));
  4633         if ( iEdwinExtension->iSmiley )
  4855         if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4634             {
  4856             {
  4635             iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength );
  4857             iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength );
  4636             ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue );
  4858             ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue );
  4637             }
  4859             }
  4638         TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed));
  4860         TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed));
  4706     const TInt cursorPos=CursorPos();
  4928     const TInt cursorPos=CursorPos();
  4707     iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds
  4929     iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds
  4708     iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation);
  4930     iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation);
  4709     TInt insertLength( iText->DocumentLength() - oldLength );
  4931     TInt insertLength( iText->DocumentLength() - oldLength );
  4710     CheckValidityOfChars( oldLength, insertLength );
  4932     CheckValidityOfChars( oldLength, insertLength );
  4711     if ( iEdwinExtension->iSmiley )
  4933     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4712         {
  4934         {
  4713         iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength );
  4935         iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength );
  4714         ConvertTextForSmileyL( TCursorSelection( cursorPos, 
  4936         ConvertTextForSmileyL( TCursorSelection( cursorPos, 
  4715             cursorPos + insertLength ), ETrue );
  4937             cursorPos + insertLength ), ETrue );
  4716         }
  4938         }
  4824     if ( KineticScrollingEnabled() )
  5046     if ( KineticScrollingEnabled() )
  4825         {
  5047         {
  4826         // If we have deleted some text and previous position (before delete) is
  5048         // If we have deleted some text and previous position (before delete) is
  4827         // out of current editor content, we must move back to inside content.
  5049         // out of current editor content, we must move back to inside content.
  4828         TInt formattedHeight( iLayout->FormattedHeightInPixels() );
  5050         TInt formattedHeight( iLayout->FormattedHeightInPixels() );
  4829         if ( prevEndPosition > formattedHeight )
  5051         if ( prevEndPosition > formattedHeight && iEdwinExtension )
  4830            {
  5052            {
  4831            TInt movement( prevEndPosition - formattedHeight );   
  5053            TInt movement( prevEndPosition - formattedHeight );   
  4832            iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement );
  5054            iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement );
  4833            }
  5055            }
  4834         }
  5056         }
  4835     
  5057     
  4836     if (reportChange)
  5058     if ( reportChange && iEdwinExtension )
  4837         {
  5059         {
       
  5060         iEdwinExtension->iThumbPos = KErrNotFound;
  4838         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  5061         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  4839         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  5062         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  4840         NotifyEditorStateObserverOfStateChangeL();
  5063         NotifyEditorStateObserverOfStateChangeL();
  4841         UpdateScrollBarsL();
  5064         UpdateScrollBarsL();
  4842         }
  5065         }
  4881     CancelFepTransaction();
  5104     CancelFepTransaction();
  4882     TCursorSelection selection=Selection();
  5105     TCursorSelection selection=Selection();
  4883     CPlainText* text( iText );
  5106     CPlainText* text( iText );
  4884     TInt start( selection.LowerPos() );
  5107     TInt start( selection.LowerPos() );
  4885     HBufC* buf( NULL );
  5108     HBufC* buf( NULL );
  4886     if ( iEdwinExtension->iSmiley )
  5109     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4887         {
  5110         {
  4888         buf = ExtractTextLC( selection );
  5111         buf = ExtractTextLC( selection );
  4889         text = CPlainText::NewL();
  5112         text = CPlainText::NewL();
  4890         CleanupStack::PushL( text );
  5113         CleanupStack::PushL( text );
  4891         TPtr ptr( buf->Des() );
  5114         TPtr ptr( buf->Des() );
  4893             ptr, EFalse );
  5116             ptr, EFalse );
  4894         start = 0;
  5117         start = 0;
  4895         text->InsertL( start, *buf );                
  5118         text->InsertL( start, *buf );                
  4896         }
  5119         }
  4897     text->CopyToStoreL(aStore, aDict, start, selection.Length() );
  5120     text->CopyToStoreL(aStore, aDict, start, selection.Length() );
  4898     if ( iEdwinExtension->iSmiley )
  5121     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4899         {
  5122         {
  4900         CleanupStack::PopAndDestroy( text );    
  5123         CleanupStack::PopAndDestroy( text );    
  4901         CleanupStack::PopAndDestroy( buf );
  5124         CleanupStack::PopAndDestroy( buf );
  4902         }
  5125         }
  4903     }
  5126     }
  4932         }
  5155         }
  4933     const TInt higher=selection.HigherPos()+newLength-oldTextLength;
  5156     const TInt higher=selection.HigherPos()+newLength-oldTextLength;
  4934     iTextView->SetPendingSelection(TCursorSelection(higher,higher));
  5157     iTextView->SetPendingSelection(TCursorSelection(higher,higher));
  4935     selection.iAnchorPos=selection.LowerPos();
  5158     selection.iAnchorPos=selection.LowerPos();
  4936     selection.iCursorPos=selection.iAnchorPos+pastedLength;
  5159     selection.iCursorPos=selection.iAnchorPos+pastedLength;
  4937     if ( iEdwinExtension->iSmiley )
  5160     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  4938         {
  5161         {
  4939         iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), 
  5162         iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), 
  4940             selection.Length() );
  5163             selection.Length() );
  4941         ConvertTextForSmileyL( selection, ETrue );
  5164         ConvertTextForSmileyL( selection, ETrue );
  4942         } 
  5165         } 
  5626         return;
  5849         return;
  5627         }
  5850         }
  5628     
  5851     
  5629     TRect viewRect( AdjustedViewRect() );
  5852     TRect viewRect( AdjustedViewRect() );
  5630     const TInt formattedLines = Max(1, iLayout->NumFormattedLines());
  5853     const TInt formattedLines = Max(1, iLayout->NumFormattedLines());
  5631     const TInt formattedHeight = iLayout->FormattedHeightInPixels();    
  5854     const TInt formattedHeight = iLayout->FormattedHeightInPixels(); 
       
  5855 	const TBool formattedHeightchanged( iEdwinExtension && 
       
  5856 		( formattedHeight != iEdwinExtension->iRecordFormattedHeight ) );
       
  5857     if ( iEdwinExtension )
       
  5858     	{
       
  5859         iEdwinExtension->iRecordFormattedHeight = formattedHeight;
       
  5860     	}
  5632     const TInt viewRectHeight = viewRect.Height();
  5861     const TInt viewRectHeight = viewRect.Height();
  5633     const TInt totalChars = iText->DocumentLength();    
  5862     const TInt totalChars = iText->DocumentLength();    
  5634     const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() );
  5863     const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() );
  5635     const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand();
  5864     const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand();
  5636     const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : 
  5865     const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : 
  5642     if( AknLayoutUtils::PenEnabled() )
  5871     if( AknLayoutUtils::PenEnabled() )
  5643         {
  5872         {
  5644         if ( !iLayout->IsFormattingBand() )
  5873         if ( !iLayout->IsFormattingBand() )
  5645             {                        
  5874             {                        
  5646             aVertModel.iThumbSpan = viewRectHeight;
  5875             aVertModel.iThumbSpan = viewRectHeight;
  5647             aVertModel.iScrollSpan = formattedHeight;            
  5876             aVertModel.iScrollSpan = formattedHeight; 
  5648             aVertModel.iThumbPosition = iEdwinExtension->iThumbPos;   
  5877             if ( iEdwinExtension )
  5649             if ( aVertModel.iThumbPosition == KErrNotFound )
  5878             	{
       
  5879 				aVertModel.iThumbPosition = iEdwinExtension->iThumbPos;  
       
  5880             	} 
       
  5881             if ( aVertModel.iThumbPosition == KErrNotFound || formattedHeightchanged )
  5650                 {
  5882                 {
  5651                 if ( bottomPos == totalChars )
  5883                 if ( bottomPos == totalChars )
  5652                     {
  5884                     {
  5653                     aVertModel.iThumbPosition = aVertModel.iScrollSpan - 
  5885                     aVertModel.iThumbPosition = aVertModel.iScrollSpan - 
  5654                         aVertModel.iThumbSpan;
  5886                         aVertModel.iThumbSpan;
  5676         else
  5908         else
  5677             {
  5909             {
  5678             aVertModel.iThumbSpan = bottomPos - topPos;
  5910             aVertModel.iThumbSpan = bottomPos - topPos;
  5679             aVertModel.iScrollSpan = totalChars;        
  5911             aVertModel.iScrollSpan = totalChars;        
  5680             aVertModel.iThumbPosition = topPos;
  5912             aVertModel.iThumbPosition = topPos;
       
  5913             if ( iEdwinExtension )
       
  5914             	{
       
  5915 				iEdwinExtension->iThumbPos = topPos;
       
  5916             	}
  5681             }
  5917             }
  5682         return;
  5918         return;
  5683         }
  5919         }
  5684     else
  5920     else
  5685         {
  5921         {
  5833 
  6069 
  5834     const TAknDoubleSpanScrollBarModel* doubleModel =
  6070     const TAknDoubleSpanScrollBarModel* doubleModel =
  5835         static_cast< const TAknDoubleSpanScrollBarModel* >
  6071         static_cast< const TAknDoubleSpanScrollBarModel* >
  5836             ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() );
  6072             ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() );
  5837 
  6073 
  5838     if ( !iEdwinExtension->iUseRateScroll )
  6074     if ( iEdwinExtension && ( !iEdwinExtension->iUseRateScroll ) )
  5839         {
  6075         {
  5840         aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight
  6076         aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight
  5841             + heightAfterFormat;
  6077             + heightAfterFormat;
  5842         aVertModel.iThumbSpan = viewRectHeight;
  6078         aVertModel.iThumbSpan = viewRectHeight;
  5843         }
  6079         }
  5844 
  6080 
  5845     // Rate scrolling
  6081     // Rate scrolling
  5846 
  6082 
  5847     if ( iEdwinExtension->iUseRateScroll )
  6083     if ( iEdwinExtension && iEdwinExtension->iUseRateScroll )
  5848         {
  6084         {
  5849         TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat;
  6085         TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat;
  5850         TInt heightBelowView = formattedHeightBelowView + heightAfterFormat;
  6086         TInt heightBelowView = formattedHeightBelowView + heightAfterFormat;
  5851 
  6087 
  5852         TInt curScrollSpan = aVertModel.iScrollSpan
  6088         TInt curScrollSpan = aVertModel.iScrollSpan
  5895             {
  6131             {
  5896             approxTopVisibleLine = 1;
  6132             approxTopVisibleLine = 1;
  5897             }
  6133             }
  5898         }
  6134         }
  5899     
  6135     
  5900     if ( iEdwinExtension->iUseRateScroll )
  6136     if ( iEdwinExtension && iEdwinExtension->iUseRateScroll )
  5901         {
  6137         {
  5902         aVertModel.iThumbPosition = anchorThumbPos;
  6138         aVertModel.iThumbPosition = anchorThumbPos;
  5903         }
  6139         }
  5904     else
  6140     else
  5905         {
  6141         {
  5906         aVertModel.iThumbPosition = approxTopVisibleLine * avgLineHeight;
  6142         aVertModel.iThumbPosition = approxTopVisibleLine * avgLineHeight;
  5907         }
  6143         }
  5908     iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; 
  6144     if ( iEdwinExtension )
       
  6145     	{
       
  6146 		iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; 
       
  6147     	}
  5909     }
  6148     }
  5910 
  6149 
  5911 // ---------------------------------------------------------------------------
  6150 // ---------------------------------------------------------------------------
  5912 // CEikEdwin::HandleScrollEventWithPhysicsL
  6151 // CEikEdwin::HandleScrollEventWithPhysicsL
  5913 // ---------------------------------------------------------------------------
  6152 // ---------------------------------------------------------------------------
  5923     TInt curScrollSpan = doubleModel->ScrollSpan();
  6162     TInt curScrollSpan = doubleModel->ScrollSpan();
  5924     TInt curThumbSpan = doubleModel->WindowSize();
  6163     TInt curThumbSpan = doubleModel->WindowSize();
  5925     TInt thumbSpaceAbove = aScrollBar->ThumbPosition();
  6164     TInt thumbSpaceAbove = aScrollBar->ThumbPosition();
  5926     TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove;
  6165     TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove;
  5927 
  6166 
  5928     TInt moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition;
  6167     TInt moveOffset = 0;
       
  6168     if ( iEdwinExtension )
       
  6169     	{
       
  6170 		moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition;
       
  6171     	}
  5929 
  6172 
  5930     const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() );
  6173     const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() );
  5931     const TInt formattedHeight = iLayout->FormattedHeightInPixels();
  6174     const TInt formattedHeight = iLayout->FormattedHeightInPixels();
  5932     const TInt viewRectHeight = AdjustedViewRect().Height();
  6175     const TInt viewRectHeight = AdjustedViewRect().Height();
  5933     const TInt totalChars = iText->DocumentLength();
  6176     const TInt totalChars = iText->DocumentLength();
  5961         }
  6204         }
  5962     else
  6205     else
  5963         {
  6206         {
  5964         return;
  6207         return;
  5965         }
  6208         }
  5966     iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
       
  5967 
  6209 
  5968     // If scrollbar thumb is moved to the beginning or end of scrollbar,
  6210     // If scrollbar thumb is moved to the beginning or end of scrollbar,
  5969     // ensure that also editor content is moved also exactly to the beginning
  6211     // ensure that also editor content is moved also exactly to the beginning
  5970     // or end. This is needed because otherwise in some situations editor
  6212     // or end. This is needed because otherwise in some situations editor
  5971     // content is not moved enough. We can't move too much because moving is
  6213     // content is not moved enough. We can't move too much because moving is
  5977     else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan )
  6219     else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan )
  5978         {
  6220         {
  5979         textMovePixels -= KAdditionalPixels;
  6221         textMovePixels -= KAdditionalPixels;
  5980         }
  6222         }
  5981     
  6223     
  5982     iEdwinExtension->iScrolledByScrollBar = ETrue;
  6224     if ( iEdwinExtension )
  5983     
  6225     	{
  5984     // Actual scrolling is done by calling MoveScrollIndex
  6226         iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
  5985     iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
  6227         iEdwinExtension->iScrolledByScrollBar = ETrue;
  5986     
  6228         
  5987     iEdwinExtension->iScrolledByScrollBar = EFalse;
  6229         // Actual scrolling is done by calling MoveScrollIndex
       
  6230         iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
       
  6231         iEdwinExtension->iEndBorderExceeded = EFalse; 
       
  6232         iEdwinExtension->iStartBorderExceeded = EFalse; 
       
  6233         
       
  6234         iEdwinExtension->iScrolledByScrollBar = EFalse;
       
  6235     	}
  5988     }
  6236     }
  5989 
  6237 
  5990 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
  6238 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
  5991     {
  6239     {
  5992     __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText));
  6240     __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText));
  6067             iTextView->SetViewL(docPos, yPos, yPosQ);
  6315             iTextView->SetViewL(docPos, yPos, yPosQ);
  6068             UpdateVertScrollBarThumbL();
  6316             UpdateVertScrollBarThumbL();
  6069             UpdateHorizScrollBarThumb();// can also change horizontally
  6317             UpdateHorizScrollBarThumb();// can also change horizontally
  6070             }
  6318             }
  6071             break;
  6319             break;
       
  6320         case EEikScrollThumbReleaseVert:
       
  6321             {
       
  6322             if ( KineticScrollingEnabled() )
       
  6323                 {
       
  6324                 RestoreCursorState();
       
  6325                 }
       
  6326             }
       
  6327             break;
  6072         case EEikScrollUp:
  6328         case EEikScrollUp:
  6073         case EEikScrollDown:            
  6329         case EEikScrollDown:            
  6074         case EEikScrollPageUp:
  6330         case EEikScrollPageUp:
  6075         case EEikScrollPageDown:            
  6331         case EEikScrollPageDown:            
  6076         case EEikScrollThumbDragVert:
  6332         case EEikScrollThumbDragVert:
  6077             {
  6333             {
  6078             if ( KineticScrollingEnabled() )
  6334             if ( KineticScrollingEnabled() )
  6079                 {
  6335                 {
       
  6336                 StoreCursorState();
  6080                 HandleScrollEventWithPhysics( aScrollBar );
  6337                 HandleScrollEventWithPhysics( aScrollBar );
  6081                 break;
  6338                 break;
  6082                 }
  6339                 }
  6083             
  6340             
  6084             TRect viewRect( AdjustedViewRect() );            
  6341             TRect viewRect( AdjustedViewRect() );            
  6095                 {
  6352                 {
  6096                 TInt topPos( iTextView->XyPosToDocPosL( viewRect.iTl ) );
  6353                 TInt topPos( iTextView->XyPosToDocPosL( viewRect.iTl ) );
  6097                 TInt bottomPos( iTextView->XyPosToDocPosL( viewRect.iBr ) );
  6354                 TInt bottomPos( iTextView->XyPosToDocPosL( viewRect.iBr ) );
  6098                 TInt visibleRange( bottomPos - topPos );
  6355                 TInt visibleRange( bottomPos - topPos );
  6099                 
  6356                 
  6100                 if ( thumbPosition != thumbSpan )                
  6357                 if ( thumbPosition != thumbSpan && iEdwinExtension )                
  6101                     {   
  6358                     {   
  6102                     TInt scrollRange( totalChars - visibleRange );
  6359                     TInt scrollRange( totalChars - visibleRange );
  6103                     docPos = ( TInt )( ( TInt64 )( thumbPosition ) * scrollRange
  6360                     docPos = ( TInt )( ( TInt64 )( thumbPosition ) * scrollRange
  6104                         / thumbSpan );
  6361                         / thumbSpan );
  6105                     if ( iEdwinExtension->iThumbPos > thumbPosition && 
  6362                     if ( iEdwinExtension->iThumbPos > thumbPosition && 
  6121             if ( thumbPosition == thumbSpan )
  6378             if ( thumbPosition == thumbSpan )
  6122                 {
  6379                 {
  6123                 docPos = totalChars;
  6380                 docPos = totalChars;
  6124                 yPos = viewRect.iBr.iY;
  6381                 yPos = viewRect.iBr.iY;
  6125                 }
  6382                 }
  6126             iEdwinExtension->iThumbPos = thumbPosition;
  6383             if ( iEdwinExtension )
       
  6384             	{
       
  6385 				iEdwinExtension->iThumbPos = thumbPosition;
       
  6386             	}
  6127             TViewYPosQualifier yPosQ;
  6387             TViewYPosQualifier yPosQ;
  6128             yPosQ.SetMakeLineFullyVisible();            
  6388             yPosQ.SetMakeLineFullyVisible();            
  6129             iTextView->SetViewL( docPos, yPos, yPosQ,
  6389             iTextView->SetViewL( docPos, yPos, yPosQ,
  6130                 CTextView::EFViewDontDiscardFormat,
  6390                 CTextView::EFViewDontDiscardFormat,
  6131                 CTextView::EFNoHorizontalScroll);
  6391                 CTextView::EFNoHorizontalScroll);
  6492                 STATIC_CAST(CRichText*,iText)->DeleteFromParagraph(aStartPos,1);
  6752                 STATIC_CAST(CRichText*,iText)->DeleteFromParagraph(aStartPos,1);
  6493             else
  6753             else
  6494                 {
  6754                 {
  6495                 TRAP_IGNORE( iText->DeleteL(aStartPos,1));
  6755                 TRAP_IGNORE( iText->DeleteL(aStartPos,1));
  6496                 }
  6756                 }
  6497             if ( iEdwinExtension->iSmiley )
  6757             if ( iEdwinExtension && iEdwinExtension->iSmiley )
  6498                 {
  6758                 {
  6499                 iEdwinExtension->iSmiley->HandleDeleteL( aStartPos, 1 );
  6759                 iEdwinExtension->iSmiley->HandleDeleteL( aStartPos, 1 );
  6500                 }
  6760                 }
  6501             }
  6761             }
  6502         else
  6762         else
  6643 
  6903 
  6644     switch (aType)
  6904     switch (aType)
  6645         {
  6905         {
  6646     case KEikDynamicLayoutVariantSwitch:
  6906     case KEikDynamicLayoutVariantSwitch:
  6647         {
  6907         {
  6648         iEdwinExtension->iThumbPos = KErrNotFound;
  6908         if ( KineticScrollingEnabled() && iEdwinExtension )
       
  6909             {
       
  6910             iEdwinExtension->iPhysicsHandler->DisableDragging();
       
  6911             }
       
  6912         if ( iEdwinExtension )
       
  6913         	{
       
  6914 			iEdwinExtension->iThumbPos = KErrNotFound;
       
  6915 	        iEdwinExtension->iEndBorderExceeded = EFalse; 
       
  6916 	        iEdwinExtension->iStartBorderExceeded = EFalse; 
       
  6917         	}
  6649         SizeChanged();
  6918         SizeChanged();
  6650         if ( !IsReadOnly() && !IsNonFocusing() 
  6919         if ( !IsReadOnly() && !IsNonFocusing() 
  6651                 && !( iEdwinUserFlags & EDisplayOnly ) )
  6920                 && !( iEdwinUserFlags & EDisplayOnly )
       
  6921                 && !KineticScrollingEnabled() )
  6652             {
  6922             {
  6653             TInt docPos = CursorPos();
  6923             TInt docPos = CursorPos();
  6654             TRect viewRect( AdjustedViewRect() );
  6924             TRect viewRect( AdjustedViewRect() );
  6655             TViewYPosQualifier yPosQ;
  6925             TViewYPosQualifier yPosQ;
  6656             TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2;
  6926             TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2;
  6682         }
  6952         }
  6683         break;
  6953         break;
  6684     case KEikInputLanguageChange:
  6954     case KEikInputLanguageChange:
  6685         {
  6955         {
  6686         UpdateCache(KEikInputLanguageChange);
  6956         UpdateCache(KEikInputLanguageChange);
       
  6957         TLanguage language = CAknEnv::Static()->SettingCache().InputLanguage(); 
       
  6958 		if ( language == ELangArabic || language == ELangFarsi || 
       
  6959 			language == ELangUrdu || language == ELangHebrew )
       
  6960 			{
       
  6961 			iEdwinUserFlags &= ~EAvkonEnableSmileySupport;
       
  6962 			EnableSmileySupportL( EFalse );
       
  6963 			}
       
  6964 		else if ( iEdwinExtension->iEnableSmileySupported )
       
  6965 			{
       
  6966 			iEdwinUserFlags |= EAvkonEnableSmileySupport;
       
  6967 			EnableSmileySupportL( ETrue );
       
  6968 			}
  6687         DoAlignment();
  6969         DoAlignment();
  6688         }
  6970         }
  6689         break;
  6971         break;
  6690     default:
  6972     default:
  6691         break;
  6973         break;
  6885         formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length);
  7167         formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length);
  6886         }
  7168         }
  6887     else
  7169     else
  6888         {
  7170         {
  6889         formatChanged=iText->DeleteL(lowerPos,length);
  7171         formatChanged=iText->DeleteL(lowerPos,length);
  6890         if ( iEdwinExtension->iSmiley )
  7172         if ( iEdwinExtension && iEdwinExtension->iSmiley )
  6891             {
  7173             {
  6892             iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length );
  7174             iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length );
  6893             }
  7175             }
  6894         }
  7176         }
  6895     iText->InsertL(aInsertPos,aText);
  7177     iText->InsertL(aInsertPos,aText);
  6896     if ( iEdwinExtension->iSmiley )
  7178     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  6897         {
  7179         {
  6898         iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() );
  7180         iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() );
  6899         ConvertTextForSmileyL( TCursorSelection( aInsertPos, 
  7181         ConvertTextForSmileyL( TCursorSelection( aInsertPos, 
  6900             aInsertPos + aText.Length() ), ETrue );
  7182             aInsertPos + aText.Length() ), ETrue );
  6901         }
  7183         }
  7354             default:
  7636             default:
  7355                 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP;
  7637                 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP;
  7356                 break;
  7638                 break;
  7357             }
  7639             }
  7358 
  7640 
  7359         return iEikonEnv->AllocReadResourceLC(resId);
  7641 	    // get special character table resource ID
       
  7642         TInt sctResourceId = state->SpecialCharacterTableResourceId();
       
  7643 		if ( sctResourceId && ( state->Flags() & EAknEditorFlagUseSCTNumericCharmap ) )
       
  7644 			{
       
  7645 		    // numericSCTBuf containing number and special characters
       
  7646 			HBufC* numericSCTBuf = HBufC::NewLC( KNmericSCTLimit );
       
  7647 			TPtr numericSCTPtr( numericSCTBuf->Des() );
       
  7648 			
       
  7649 			// read number characters and add them to numericSCTBuf
       
  7650 			HBufC* numberResource = iEikonEnv->AllocReadResourceLC( resId );
       
  7651 			TPtr numberResPtr( numberResource->Des() );
       
  7652 			numericSCTPtr.Append( numberResPtr );
       
  7653 			CleanupStack::PopAndDestroy( numberResource ); // numberResource
       
  7654 			
       
  7655 		    // read special characters from SCT by dialog ID
       
  7656 		    ReadSpecialCharFromSCTL( numericSCTPtr, sctResourceId );
       
  7657 		    
       
  7658 		    return numericSCTBuf;
       
  7659 			}
       
  7660 		else
       
  7661 			{
       
  7662 		    return iEikonEnv->AllocReadResourceLC( resId );
       
  7663 			}
  7360         }
  7664         }
  7361     else
  7665     else
  7362         {
  7666         {
  7363         User::Leave(KErrNoMemory);
  7667         User::Leave(KErrNoMemory);
  7364         return NULL;
  7668         return NULL;
  7374     if (iEdwinFepSupport)
  7678     if (iEdwinFepSupport)
  7375         {
  7679         {
  7376         edwinState = STATIC_CAST(CAknEdwinState*, iEdwinFepSupport->State(KNullUid));
  7680         edwinState = STATIC_CAST(CAknEdwinState*, iEdwinFepSupport->State(KNullUid));
  7377         }
  7681         }
  7378 
  7682 
  7379     CAknPictographInterface* pictographInterface = iEdwinExtension->PictographInterface();
  7683     CAknPictographInterface* pictographInterface = NULL;
       
  7684     if ( iEdwinExtension )
       
  7685     	{
       
  7686 		pictographInterface = iEdwinExtension->PictographInterface();
       
  7687     	}
  7380     if (edwinState)
  7688     if (edwinState)
  7381         {
  7689         {
  7382         if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
  7690         if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
  7383             {
  7691             {
  7384             fullWidthCharactersAllowed = edwinState->PermittedInputModes() & (
  7692             fullWidthCharactersAllowed = edwinState->PermittedInputModes() & (
  7555     {
  7863     {
  7556     iEdwinUserFlags|=aFlag;
  7864     iEdwinUserFlags|=aFlag;
  7557     SetVKBStatus(); 
  7865     SetVKBStatus(); 
  7558     if ( aFlag & EAvkonEnableSmileySupport )
  7866     if ( aFlag & EAvkonEnableSmileySupport )
  7559         {
  7867         {
       
  7868         iEdwinExtension->iEnableSmileySupported = ETrue;
  7560         EnableSmileySupportL( ETrue );
  7869         EnableSmileySupportL( ETrue );
  7561         }
  7870         }
  7562     }
  7871     }
  7563 
  7872 
  7564 EXPORT_C void CEikEdwin::RemoveFlagFromUserFlags(TUint32 aFlag)
  7873 EXPORT_C void CEikEdwin::RemoveFlagFromUserFlags(TUint32 aFlag)
  7565     {
  7874     {
  7566     iEdwinUserFlags&=~aFlag;
  7875     iEdwinUserFlags&=~aFlag;
  7567     SetVKBStatus(); 
  7876     SetVKBStatus(); 
  7568     if ( aFlag & EAvkonEnableSmileySupport )
  7877     if ( aFlag & EAvkonEnableSmileySupport )
  7569         {    
  7878         {    
       
  7879         iEdwinExtension->iEnableSmileySupported = EFalse;
  7570         EnableSmileySupportL( EFalse );
  7880         EnableSmileySupportL( EFalse );
  7571         }
  7881         }
  7572     }
  7882     }
  7573 
  7883 
  7574 EXPORT_C TUint32 CEikEdwin::UserFlags() const
  7884 EXPORT_C TUint32 CEikEdwin::UserFlags() const
  7950     return hasStrongCharacter;    
  8260     return hasStrongCharacter;    
  7951     }
  8261     }
  7952 
  8262 
  7953 EXPORT_C void CEikEdwin::SetPictographAnimationCallBack( TCallBack& aCallBack )
  8263 EXPORT_C void CEikEdwin::SetPictographAnimationCallBack( TCallBack& aCallBack )
  7954     {
  8264     {
  7955     iEdwinExtension->SetPictoCallBack( aCallBack );
  8265 	if ( iEdwinExtension )
       
  8266 		{
       
  8267 		iEdwinExtension->SetPictoCallBack( aCallBack );
       
  8268 		}
  7956     }
  8269     }
  7957 
  8270 
  7958 const TCallBack& CEikEdwin::PictographAnimationCallBack() const
  8271 const TCallBack& CEikEdwin::PictographAnimationCallBack() const
  7959     {
  8272     {
  7960     return iEdwinExtension->PictoCallBack();
  8273     return iEdwinExtension->PictoCallBack();
  8034 
  8347 
  8035 EXPORT_C void CEikEdwin::EnableKineticScrollingL( TBool aEnable )
  8348 EXPORT_C void CEikEdwin::EnableKineticScrollingL( TBool aEnable )
  8036     {
  8349     {
  8037     if ( iEdwinExtension && aEnable )
  8350     if ( iEdwinExtension && aEnable )
  8038         {
  8351         {
  8039         iEdwinExtension->EnableKineticScrollingL();
  8352         iEdwinExtension->EnableKineticScrollingL( NULL );
       
  8353         }
       
  8354     }
       
  8355 
       
  8356 EXPORT_C void CEikEdwin::EnableKineticScrollingL( CAknPhysics* aPhysics )
       
  8357     {
       
  8358     if ( iEdwinExtension )
       
  8359         {
       
  8360         iEdwinExtension->EnableKineticScrollingL( aPhysics );
  8040         }
  8361         }
  8041     }
  8362     }
  8042 
  8363 
  8043 TBool CEikEdwin::NeedToChangeFormattingModeL() const
  8364 TBool CEikEdwin::NeedToChangeFormattingModeL() const
  8044     {
  8365     {
  8074     return rect;
  8395     return rect;
  8075     }
  8396     }
  8076     
  8397     
  8077 void CEikEdwin::SetVKBStatus()
  8398 void CEikEdwin::SetVKBStatus()
  8078     {
  8399     {
  8079     TUint cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities();
  8400 	TUint cap = 0;
       
  8401     if ( iEdwinExtension )
       
  8402 		{
       
  8403 		cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities();
       
  8404 		}
  8080     if ( iEdwinUserFlags & EAvkonDisableVKB )
  8405     if ( iEdwinUserFlags & EAvkonDisableVKB )
  8081         {
  8406         {
  8082         cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB;    
  8407         cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB;    
  8083         }
  8408         }
  8084     else
  8409     else
  8085         {
  8410         {
  8086         cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  8411         cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  8087         }   
  8412         } 
  8088     iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap );
  8413     if ( iEdwinExtension )
       
  8414     	{
       
  8415 		iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap );
       
  8416     	}
  8089     }
  8417     }
  8090     
  8418     
  8091 void CEikEdwin::ScrollViewToCursorLineL()
  8419 void CEikEdwin::ScrollViewToCursorLineL()
  8092     {
  8420     {
  8093     TInt cursorPos = CursorPos();
  8421     TInt cursorPos = CursorPos();
  8115     TRAP_IGNORE( SetCursorVisibilityL( aVisible ) );
  8443     TRAP_IGNORE( SetCursorVisibilityL( aVisible ) );
  8116     }
  8444     }
  8117 
  8445 
  8118 void CEikEdwin::PerformRecordedOperationL()
  8446 void CEikEdwin::PerformRecordedOperationL()
  8119     {
  8447     {
  8120     if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ||
  8448     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ||
  8121         iEdwinExtension->iDrawInvoked == CEikEdwinExtension::EDrawing )
  8449         iEdwinExtension->iDrawInvoked == CEikEdwinExtension::EDrawing )
  8122         {        
  8450         {        
  8123         if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  8451         if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  8124             {
  8452             {
  8125             iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawn;
  8453             iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawn;
  8174         {
  8502         {
  8175         iTextView->ScrollDisplayL( TCursorPosition::EFLineDown );
  8503         iTextView->ScrollDisplayL( TCursorPosition::EFLineDown );
  8176         UpdateScrollBarsL();
  8504         UpdateScrollBarsL();
  8177         scroll = ETrue ;
  8505         scroll = ETrue ;
  8178         }
  8506         }
  8179     if ( scroll && iEdwinExtension->iDrawInvoked != 
  8507     if ( scroll && iEdwinExtension && 
  8180         CEikEdwinExtension::EDrawing )
  8508     		iEdwinExtension->iDrawInvoked != CEikEdwinExtension::EDrawing )
  8181         {
  8509         {
  8182         ReportEdwinEventL( MEikEdwinObserver::EEventNavigation );
  8510         ReportEdwinEventL( MEikEdwinObserver::EEventNavigation );
  8183         }
  8511         }
  8184     }
  8512     }
  8185 
  8513 
  8188     // for chinese popup flag
  8516     // for chinese popup flag
  8189     TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup );
  8517     TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup );
  8190     if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) )
  8518     if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) )
  8191         {
  8519         {
  8192         TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) );
  8520         TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) );
  8193         }    
  8521         }
       
  8522     
       
  8523     // To reduce power consumption, text view should be hidden when full screen Touch
       
  8524     // Input is open and editor is covered by it, for user can not see editor in this 
       
  8525     // case. When full screen Touch Input is open, FEP will set flag EAknEditorFlagHideTextView 
       
  8526     // to notify editor the text view should be hidden. But we have to check if the feature 
       
  8527     // of partial screen input is enabled at the same time, for full screen Touch Input window 
       
  8528     // will only occupy part of the screen if the feature is eanbled and editor is still visible 
       
  8529     // to user. So editor can only be hidden in such situation: full screen Touch Input is open 
       
  8530     // and partial screen feature is disabled.
       
  8531     // In the contrary situations (full screen touch input is closed or partial screen 
       
  8532     // feature is enabled), text view has to be shown so editor can work as normal.
       
  8533     if ( iTextView && iEdwinExtension )
       
  8534         {
       
  8535         TBool textViewHideEnabled( ( aNewFlags & EAknEditorFlagHideTextView ) &&
       
  8536             !( aOldFlags & EAknEditorFlagHideTextView ) );
       
  8537 
       
  8538         TBool textViewHideDisabled( !( aNewFlags & EAknEditorFlagHideTextView ) && 
       
  8539             ( aOldFlags & EAknEditorFlagHideTextView ) );
       
  8540 
       
  8541         TBool partialScreenEnabled( ( aNewFlags & EAknEditorFlagEnablePartialScreen ) &&
       
  8542             !( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
       
  8543 
       
  8544         TBool partialScreenDisabled( !( aNewFlags & EAknEditorFlagEnablePartialScreen ) && 
       
  8545             ( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
       
  8546          
       
  8547         if ( ( textViewHideEnabled && 
       
  8548                 !( aNewFlags & EAknEditorFlagEnablePartialScreen ) ) ||
       
  8549              ( partialScreenDisabled && ( aNewFlags & EAknEditorFlagHideTextView ) ) )
       
  8550             {
       
  8551             iTextView->MakeVisible( EFalse );
       
  8552             iEdwinExtension->iTextViewHidden = ETrue;
       
  8553             }
       
  8554         else if ( iEdwinExtension->iTextViewHidden && ( textViewHideDisabled || partialScreenEnabled ) )
       
  8555             {
       
  8556             iTextView->MakeVisible( ETrue );
       
  8557             DrawNow();
       
  8558             iEdwinExtension->iTextViewHidden = EFalse;            
       
  8559             }
       
  8560         }
  8194     }
  8561     }
  8195 
  8562 
  8196 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen )
  8563 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen )
  8197     {
  8564     {
  8198     if ( aChinesePopupOpen )
  8565     if ( aChinesePopupOpen )
  8206     }
  8573     }
  8207 
  8574 
  8208 // for smiley support
  8575 // for smiley support
  8209 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley )
  8576 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley )
  8210     {
  8577     {
  8211     if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() )
  8578     if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() && iEdwinExtension )
  8212         {
  8579         {
  8213         if ( !iEdwinExtension->iSmiley )
  8580         TLanguage language = CAknEnv::Static()->SettingCache().InputLanguage();
  8214             {
  8581 		if ( language != ELangArabic && language != ELangFarsi && 
  8215             iEdwinExtension->iSmiley = CSmileyManager::NewL( *this );
  8582 			language != ELangUrdu && language != ELangHebrew )
  8216             iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes );
  8583 			{
  8217             if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly )
  8584 			if ( !iEdwinExtension->iSmiley )
  8218                 {
  8585 				{
  8219                 iEdwinExtension->iSmiley->SetAnimationPlayTimes( 
  8586 				iEdwinExtension->iSmiley = CSmileyManager::NewL( *this );
  8220                     KInfiniteAnimPlayTimes );
  8587 				iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes );
  8221                 }
  8588 				if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly )
  8222             }        
  8589 					{
  8223         if ( TextLayout() )
  8590 					iEdwinExtension->iSmiley->SetAnimationPlayTimes( 
  8224             {
  8591 						KInfiniteAnimPlayTimes );
  8225             TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
  8592 					}
  8226             }
  8593 				}        
       
  8594 			if ( TextLayout() )
       
  8595 				{
       
  8596 				TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap );
       
  8597 				}
       
  8598 			}
  8227         }    
  8599         }    
  8228     else
  8600     else if ( iEdwinExtension )
  8229         {
  8601         {
  8230         delete iEdwinExtension->iSmiley;
  8602         delete iEdwinExtension->iSmiley;
  8231         iEdwinExtension->iSmiley = NULL;
  8603         iEdwinExtension->iSmiley = NULL;
  8232         if ( TextLayout() )
  8604         if ( TextLayout() )
  8233             {
  8605             {
  8236         }
  8608         }
  8237     }
  8609     }
  8238 
  8610 
  8239 TBool CEikEdwin::IsSmileyEnabled() const
  8611 TBool CEikEdwin::IsSmileyEnabled() const
  8240     {
  8612     {
  8241     return ( iEdwinExtension->iSmiley != NULL );
  8613     TBool ret = EFalse; 
  8242     }
  8614     if ( iEdwinExtension )
  8243 
  8615         {
  8244 void CEikEdwin::DrawSmileyInTextL( CBitmapContext& aGc, CFont& aFont, 
  8616         ret = ( iEdwinExtension->iSmiley != NULL );
  8245         const TDesC& aText, const TPoint& aPt )
  8617         }
       
  8618     return ret;
       
  8619     }
       
  8620 
       
  8621 void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, 
       
  8622     CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt )
  8246     {    
  8623     {    
  8247     TRect viewRect( AdjustedViewRect() );
  8624     TRect viewRect( AdjustedViewRect() );
  8248     TInt topY( aPt.iY - aFont.AscentInPixels() );
  8625     TInt topY( aPt.iY - aFont.AscentInPixels() );
  8249     TInt bottomY( aPt.iY + aFont.DescentInPixels() );
  8626     TInt bottomY( aPt.iY + aFont.DescentInPixels() );
  8250     const TInt KThreshold = 10;
  8627     const TInt KThreshold = 10;
  8267         text.Copy( aText );
  8644         text.Copy( aText );
  8268         TrimText( text );
  8645         TrimText( text );
  8269         TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
  8646         TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
  8270         for ( TInt i( 0 ); i < text.Length(); i++ )
  8647         for ( TInt i( 0 ); i < text.Length(); i++ )
  8271             {
  8648             {
  8272             if ( CSmileyManager::IsSmileyCode( text[i] ) )
  8649             if ( iEdwinExtension && CSmileyManager::IsSmileyCode( text[i] ) )
  8273                 {
  8650                 {
  8274                 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) );
  8651                 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) );
  8275                 TRect rect( x, topY, x + smileyWidth, bottomY );
  8652                 TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, 
  8276                 iEdwinExtension->iSmiley->DrawIconL( aGc, rect, i + pos );
  8653                     aDrawRect.iBr.iY ); 
       
  8654                 rgn.SubRect( clipRect, NULL );
       
  8655                 TRect iconRect( x, topY, x + smileyWidth, bottomY );
       
  8656                 iEdwinExtension->iSmiley->DrawIconL( aGc, iconRect, i + pos );
  8277                 }
  8657                 }
  8278             }
  8658             }
  8279         }
  8659         }
  8280     delete buf;
  8660     delete buf;
  8281     }
  8661     }
  8282 
  8662 
  8283 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode )
  8663 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode )
  8284     {
  8664     {
  8285     if ( !iEdwinExtension->iSmiley && !iTextView )
  8665     if ( iEdwinExtension && !iEdwinExtension->iSmiley && !iTextView )
  8286         {
  8666         {
  8287         return;
  8667         return;
  8288         }
  8668         }
  8289     TCursorSelection visibleRange( GetVisibleTextRangeL() );
  8669     TCursorSelection visibleRange( GetVisibleTextRangeL() );
  8290     ConvertTextForSmileyL( visibleRange, aTextToCode );    
  8670     ConvertTextForSmileyL( visibleRange, aTextToCode );    
  8291     }
  8671     }
  8292 
  8672 
  8293 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, 
  8673 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, 
  8294     TBool aTextToCode, TBool aRedraw )
  8674     TBool aTextToCode, TBool aRedraw )
  8295     {    
  8675     {    
  8296     if ( iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing )
  8676     if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing )
  8297         {
  8677         {
  8298         if ( aTextToCode )
  8678         if ( aTextToCode )
  8299             {
  8679             {
  8300             ExtendedRangeForSmiley( aSelect );
  8680             ExtendedRangeForSmiley( aSelect );
  8301             }
  8681             }
  8311             iText->InsertL( start, ptr );            
  8691             iText->InsertL( start, ptr );            
  8312             }
  8692             }
  8313         CleanupStack::PopAndDestroy( buf );
  8693         CleanupStack::PopAndDestroy( buf );
  8314         if ( aRedraw )
  8694         if ( aRedraw )
  8315             {
  8695             {
  8316             DrawDeferred();
  8696             CAknEdwinState* edwinState = 
       
  8697                 static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) );
       
  8698 
       
  8699             if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
       
  8700                 {
       
  8701                 DrawDeferred();
       
  8702                 }
  8317             }
  8703             }
  8318         }
  8704         }
  8319     }
  8705     }
  8320     
  8706     
  8321 void CEikEdwin::TrimText( TDes& aText )
  8707 void CEikEdwin::TrimText( TDes& aText )
  8363     return buf;
  8749     return buf;
  8364     }
  8750     }
  8365 
  8751 
  8366 void CEikEdwin::ConvertSmileyIconToTextL( TInt aStartPos, TDes& aText )
  8752 void CEikEdwin::ConvertSmileyIconToTextL( TInt aStartPos, TDes& aText )
  8367     {
  8753     {
  8368     if ( iEdwinExtension->iSmiley )
  8754     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  8369         {
  8755         {
  8370         iEdwinExtension->iSmiley->ConvertTextForSmileyL( aStartPos,
  8756         iEdwinExtension->iSmiley->ConvertTextForSmileyL( aStartPos,
  8371             aText, EFalse );
  8757             aText, EFalse );
  8372         }
  8758         }
  8373     }
  8759     }
  8374 
  8760 
  8375 void CEikEdwin::ExtendedRangeForSmiley( TCursorSelection& aSelect )
  8761 void CEikEdwin::ExtendedRangeForSmiley( TCursorSelection& aSelect )
  8376     { 
  8762     { 
  8377     if ( iEdwinExtension->iSmiley )
  8763     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  8378         {
  8764         {
  8379         TInt textLength( TextLength() );
  8765         TInt textLength( TextLength() );
  8380         TInt start = aSelect.LowerPos() - CSmileyManager::KMaxLength;
  8766         TInt start = aSelect.LowerPos() - CSmileyManager::KMaxLength;
  8381         if ( start < 0 )
  8767         if ( start < 0 )
  8382             {
  8768             {
  8392         }
  8778         }
  8393     }
  8779     }
  8394 
  8780 
  8395 TBool CEikEdwin::ConvertSmileyForDeleteL( TInt aDocPos, TBool aBackSpace )
  8781 TBool CEikEdwin::ConvertSmileyForDeleteL( TInt aDocPos, TBool aBackSpace )
  8396     {
  8782     {
  8397     if ( !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || 
  8783     if ( iEdwinExtension && !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || 
  8398         ( aDocPos == TextLength() && !aBackSpace ) )
  8784         ( aDocPos == TextLength() && !aBackSpace ) )
  8399         {
  8785         {
  8400         return EFalse;
  8786         return EFalse;
  8401         }
  8787         }
  8402     TInt checkPos( aDocPos );
  8788     TInt checkPos( aDocPos );
  8403     if ( aBackSpace )
  8789     if ( aBackSpace )
  8404         {
  8790         {
  8405         checkPos--;
  8791         checkPos--;
  8406         checkPos = checkPos >= 0 ? checkPos : 0;
  8792         checkPos = checkPos >= 0 ? checkPos : 0;
  8407         }
  8793         }
  8408     if ( CSmileyManager::IsSmileyCode( iEdwinExtension->iSmiley->
  8794     if ( iEdwinExtension->iSmiley->SmileyCodeByPos( checkPos ) > 0 )
  8409         SmileyCodeByPos( checkPos ) ) && 
       
  8410         !iEdwinExtension->iSmiley->IsDisabledSmileyIcon( checkPos ) )
       
  8411         {
  8795         {
  8412         TInt codeLength( iEdwinExtension->iSmiley->SmileyLength( checkPos ) );
  8796         TInt codeLength( iEdwinExtension->iSmiley->SmileyLength( checkPos ) );
  8413         iEdwinExtension->iSmiley->DisableSmileyIcon( checkPos );
  8797         iEdwinExtension->iSmiley->DisableSmileyIcon( checkPos );
  8414         TCursorSelection select( aDocPos, aDocPos );
  8798         TCursorSelection select( aDocPos, aDocPos );
  8415         if ( aBackSpace )
  8799         if ( aBackSpace )
  8430     return EFalse;
  8814     return EFalse;
  8431     }
  8815     }
  8432 
  8816 
  8433 void CEikEdwin::ConvertSmileyForDeleteL( const TCursorSelection &aSelect )
  8817 void CEikEdwin::ConvertSmileyForDeleteL( const TCursorSelection &aSelect )
  8434     {
  8818     {
  8435     if ( !iEdwinExtension->iSmiley )
  8819     if ( iEdwinExtension && !iEdwinExtension->iSmiley )
  8436         {
  8820         {
  8437         return;
  8821         return;
  8438         }
  8822         }
  8439 
  8823 
  8440     TInt lowerPos( aSelect.LowerPos() );
  8824     TInt lowerPos( aSelect.LowerPos() );
  8456         iText->InsertL( lowerPos, ptr );            
  8840         iText->InsertL( lowerPos, ptr );            
  8457         }
  8841         }
  8458     CleanupStack::PopAndDestroy( buf );
  8842     CleanupStack::PopAndDestroy( buf );
  8459     }
  8843     }
  8460 
  8844 
  8461 void CEikEdwin::HandleScrollForSmileyL()
       
  8462     {
       
  8463     if ( !iEdwinExtension->iSmiley )
       
  8464         {
       
  8465         return;
       
  8466         }
       
  8467     TCursorSelection select( GetVisibleTextRangeL() );
       
  8468     if ( select.LowerPos() != iEdwinExtension->iVisibleRange.LowerPos() ||
       
  8469         select.HigherPos() != iEdwinExtension->iVisibleRange.HigherPos() )
       
  8470         {
       
  8471         iEdwinExtension->iVisibleRange.iCursorPos = select.iCursorPos;
       
  8472         iEdwinExtension->iVisibleRange.iAnchorPos = select.iAnchorPos;
       
  8473         }
       
  8474     iEdwinExtension->iSmiley->SetVisibleRange( select.LowerPos(), 
       
  8475         select.Length() );
       
  8476     }
       
  8477 
       
  8478 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect )
  8845 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect )
  8479     {
  8846     {
  8480     TBool ret( EFalse );
  8847     TBool ret( EFalse );
  8481     TCursorSelection select( Selection() );
  8848     TCursorSelection select( Selection() );
  8482     TInt cursor( select.iCursorPos );
  8849     TInt cursor( select.iCursorPos );
  8483     iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor );
  8850     if ( iEdwinExtension )
       
  8851     	{
       
  8852 		iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor );
       
  8853     	}
  8484     if ( cursor != select.iCursorPos )
  8854     if ( cursor != select.iCursorPos )
  8485         {
  8855         {
  8486         if ( select.iAnchorPos == select.iCursorPos )
  8856         if ( select.iAnchorPos == select.iCursorPos )
  8487             {
  8857             {
  8488             select.iAnchorPos = cursor;
  8858             select.iAnchorPos = cursor;
  8498     {
  8868     {
  8499     TRect viewRect( AdjustedViewRect() );
  8869     TRect viewRect( AdjustedViewRect() );
  8500     return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY );
  8870     return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY );
  8501     }
  8871     }
  8502 
  8872 
  8503 void CEikEdwin::GetClipRegionForSmiley( RRegion& rgn, CFont& aFont, 
       
  8504     const TDesC& aText, const TPoint& aPt, const TRect& aDrawRect ) const
       
  8505     {
       
  8506     TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
       
  8507     TInt topY( aDrawRect.iTl.iY );
       
  8508     TInt bottomY( aDrawRect.iBr.iY );
       
  8509     for ( TInt i( 0 ); i < aText.Length(); i++ )
       
  8510         {
       
  8511         if ( CSmileyManager::IsSmileyCode( aText[i] ) )
       
  8512             {
       
  8513             TInt x( aPt.iX + aFont.TextWidthInPixels( aText.Left( i ) ) );
       
  8514             TRect rect( x, topY, x + smileyWidth, bottomY );
       
  8515             rgn.SubRect( rect, NULL );
       
  8516             }
       
  8517         }
       
  8518     }
       
  8519 
       
  8520 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, 
  8873 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, 
  8521     TBool aSelect )
  8874     TBool aSelect )
  8522     {
  8875     {
  8523     TBool ret( EFalse );
  8876     TBool ret( EFalse );
  8524     if ( iEdwinExtension->iSmiley )
  8877     if ( iEdwinExtension && iEdwinExtension->iSmiley )
  8525         {
  8878         {
  8526         TInt oldPos( CursorPos() );
  8879         TInt oldPos( CursorPos() );
  8527         TInt curPos( oldPos );
  8880         TInt curPos( oldPos );
  8528         if ( aMovement == TCursorPosition::EFLeft )
  8881         if ( aMovement == TCursorPosition::EFLeft )
  8529             {
  8882             {
  8541             }
  8894             }
  8542         }
  8895         }
  8543     return ret;
  8896     return ret;
  8544     }
  8897     }
  8545 
  8898 
  8546 void CEikEdwin::SetSelectionVisibilityL( TBool isVisable )
  8899 void CEikEdwin::SetSelectionVisibilityL( TBool aIsVisable )
  8547     {
  8900     {
  8548     iTextView->SetSelectionVisibilityL(isVisable);
  8901     if ( iEdwinExtension && iEdwinExtension->iSmiley && !aIsVisable )
       
  8902         {
       
  8903         iTextView->SetSelectionVisibilityL( aIsVisable );
       
  8904         HandleSelectionForSmiley( TCursorSelection( 0, 0 ) );
       
  8905         }
       
  8906     else 
       
  8907         {
       
  8908         if ( iEdwinExtension && iEdwinExtension->iSmiley )
       
  8909             {
       
  8910             HandleSelectionForSmiley( Selection() );
       
  8911             }
       
  8912         iTextView->SetSelectionVisibilityL( aIsVisable );
       
  8913         }
       
  8914    
  8549     CAknEdwinState*edwinState = EditorState();
  8915     CAknEdwinState*edwinState = EditorState();
  8550     if( !edwinState )
  8916     if ( edwinState )
  8551     	return;
  8917         {
  8552     if(isVisable)
  8918         if ( aIsVisable )
  8553     	{
  8919             {
  8554         SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
  8920             SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
  8555     	}
  8921             }
  8556     else
  8922         else
  8557     	{
  8923             {
  8558     	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
  8924             SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
  8559     	}
  8925             }
       
  8926         }
  8560     return;
  8927     return;
  8561     }
  8928     }
  8562 TBool CEikEdwin::IsSelectionVisible()
  8929 TBool CEikEdwin::IsSelectionVisible()
  8563 	{
  8930 	{
  8564 	TBool ret = EFalse;
  8931 	TBool ret = EFalse;
  8572 		if (text[i] == ' ')
  8939 		if (text[i] == ' ')
  8573 			return ETrue;
  8940 			return ETrue;
  8574 		
  8941 		
  8575 		TChar::TCategory category = character.GetCategory();
  8942 		TChar::TCategory category = character.GetCategory();
  8576 		
  8943 		
  8577 		if ( !((category&TChar::ESeparatorGroup == TChar::ESeparatorGroup) ||
  8944 		if ( !( ( ( category & TChar::ESeparatorGroup ) == TChar::ESeparatorGroup ) ||
  8578 			   (text[i]>=0x200B && text[i]<=0xFFFC)) )
  8945 			   ( text[i] >= 0x200B && text[i] <= 0xFFFC ) ) )
  8579 			{
  8946 			{
  8580 			ret = ETrue;
  8947 			ret = ETrue;
  8581 			break;
  8948 			break;
  8582 			}
  8949 			}
  8583 		}
  8950 		}
  8602              
  8969              
  8603     if ( scrolledPixels != aPixelsToScroll )
  8970     if ( scrolledPixels != aPixelsToScroll )
  8604         {
  8971         {
  8605         // We can't move enough, we have exceeded the border
  8972         // We can't move enough, we have exceeded the border
  8606         // (at the beginning or end of the document)
  8973         // (at the beginning or end of the document)
  8607         if ( aPixelsToScroll != 0 )
  8974         if ( aPixelsToScroll != 0 && iEdwinExtension )
  8608             {
  8975             {
  8609             if ( aPixelsToScroll < 0 )
  8976             if ( aPixelsToScroll < 0 )
  8610                 {
  8977                 {
  8611                 // End of document. Set flag to tell about that
  8978                 // End of document. Set flag to tell about that
  8612                 iEdwinExtension->iEndBorderExceeded = ETrue;
  8979                 iEdwinExtension->iEndBorderExceeded = ETrue;
  8626             // Set variable how many pixels we are out of border 
  8993             // Set variable how many pixels we are out of border 
  8627             iEdwinExtension->iPixelsOutOfBorder = 0;
  8994             iEdwinExtension->iPixelsOutOfBorder = 0;
  8628             }
  8995             }
  8629         }
  8996         }
  8630        
  8997        
  8631     if ( scrolledPixels != 0 )
  8998     if ( scrolledPixels != 0 && iEdwinExtension )
  8632         {
  8999         {
  8633         iEdwinExtension->iScrolledDelta = scrolledPixels;
  9000         iEdwinExtension->iScrolledDelta = scrolledPixels;
  8634         TRAP_IGNORE( UpdateVertScrollBarThumbL() );
  9001         TRAP_IGNORE( UpdateVertScrollBarThumbL() );
  8635         iEdwinExtension->iScrolledDelta = 0;
  9002         iEdwinExtension->iScrolledDelta = 0;
  8636         }
  9003         }
  8654     // ends (scrolling over the border toward content). In this case we
  9021     // ends (scrolling over the border toward content). In this case we
  8655     // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border.
  9022     // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border.
  8656     // After that we have to move to mode where we use ScrollDisplayPixelsL
  9023     // After that we have to move to mode where we use ScrollDisplayPixelsL
  8657     // to detect if we exceed border again.
  9024     // to detect if we exceed border again.
  8658     TBool adjustScrolling( EFalse );
  9025     TBool adjustScrolling( EFalse );
  8659     if ( aPixelsToScroll > 0  && iEdwinExtension->iEndBorderExceeded )
  9026     if ( iEdwinExtension )
  8660         {
  9027     	{
  8661         if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder )
  9028 		if ( aPixelsToScroll > 0  && iEdwinExtension->iEndBorderExceeded )
  8662             {
  9029 			{
  8663             adjustScrolling = ETrue;
  9030 			if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder )
  8664             }
  9031 				{
  8665         }
  9032 				adjustScrolling = ETrue;
  8666     else if ( aPixelsToScroll < 0 &&  iEdwinExtension->iStartBorderExceeded )
  9033 				}
  8667         {
  9034 			}
  8668         if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder )
  9035 		else if ( aPixelsToScroll < 0 &&  iEdwinExtension->iStartBorderExceeded )
  8669             {            
  9036 			{
  8670             adjustScrolling = ETrue;
  9037 			if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder )
  8671             }
  9038 				{            
  8672         }
  9039 				adjustScrolling = ETrue;
  8673     
  9040 				}
       
  9041 			}
       
  9042     	}
       
  9043 
  8674     if ( adjustScrolling )
  9044     if ( adjustScrolling )
  8675         {
  9045         {
  8676         // we are scrolling over the border, calculate how many
  9046         // we are scrolling over the border, calculate how many
  8677         // pixels we can scroll and how many pixels there is rest
  9047         // pixels we can scroll and how many pixels there is rest
  8678         // after movement
  9048         // after movement
  8681         }
  9051         }
  8682     
  9052     
  8683     // We are out of borders. Call scrolling function that supports bounce-effect
  9053     // We are out of borders. Call scrolling function that supports bounce-effect
  8684     TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) );
  9054     TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) );
  8685 
  9055 
  8686     // Update variable that tells how near the border we are.
  9056     if ( iEdwinExtension )
  8687     iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll;
  9057     	{
  8688                
  9058 		// Update variable that tells how near the border we are.
  8689     if ( iEdwinExtension->iStartBorderExceeded
  9059 		iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll;
  8690         && iEdwinExtension->iPixelsOutOfBorder <= 0 )
  9060 				   
  8691         {
  9061 		if ( iEdwinExtension->iStartBorderExceeded
  8692         // We are inside borders, reset flag and tell to caller
  9062 			&& iEdwinExtension->iPixelsOutOfBorder <= 0 )
  8693         iEdwinExtension->iStartBorderExceeded = EFalse;
  9063 			{
  8694         aEndOfBounce = ETrue;
  9064 			// We are inside borders, reset flag and tell to caller
  8695         }
  9065 			iEdwinExtension->iStartBorderExceeded = EFalse;
  8696     else if ( iEdwinExtension->iEndBorderExceeded
  9066 			aEndOfBounce = ETrue;
  8697         && iEdwinExtension->iPixelsOutOfBorder >= 0 )
  9067 			}
  8698         {
  9068 		else if ( iEdwinExtension->iEndBorderExceeded
  8699         // we are inside borders, reset flag and tell to caller
  9069 			&& iEdwinExtension->iPixelsOutOfBorder >= 0 )
  8700         iEdwinExtension->iEndBorderExceeded = EFalse;
  9070 			{
  8701         aEndOfBounce = ETrue;
  9071 			// we are inside borders, reset flag and tell to caller
  8702         }
  9072 			iEdwinExtension->iEndBorderExceeded = EFalse;
       
  9073 			aEndOfBounce = ETrue;
       
  9074 			}
       
  9075     	}
  8703           
  9076           
  8704     if ( aPixelsToScroll != 0 )
  9077     if ( aPixelsToScroll != 0 )
  8705         {
  9078         {
  8706         TRAP_IGNORE( UpdateVertScrollBarThumbL() );
  9079         TRAP_IGNORE( UpdateVertScrollBarThumbL() );
  8707         }
  9080         }
  8715 // CEikEdwin::PixelsOutOfBorder
  9088 // CEikEdwin::PixelsOutOfBorder
  8716 // ---------------------------------------------------------------------------
  9089 // ---------------------------------------------------------------------------
  8717 //
  9090 //
  8718 TInt CEikEdwin::PixelsOutOfBorder() const
  9091 TInt CEikEdwin::PixelsOutOfBorder() const
  8719     {
  9092     {
  8720     return iEdwinExtension->iPixelsOutOfBorder;
  9093     TInt ret = 0;
       
  9094     if ( iEdwinExtension )
       
  9095         {
       
  9096         ret = iEdwinExtension->iPixelsOutOfBorder;
       
  9097         }
       
  9098     return ret;
  8721     }
  9099     }
  8722 
  9100 
  8723 // ---------------------------------------------------------------------------
  9101 // ---------------------------------------------------------------------------
  8724 // CEikEdwin::EnableRateScrolling
  9102 // CEikEdwin::EnableRateScrolling
  8725 // ---------------------------------------------------------------------------
  9103 // ---------------------------------------------------------------------------
  8732     
  9110     
  8733     // Use this function to change scrolling mode.
  9111     // Use this function to change scrolling mode.
  8734     // If aEnable is EFalse, Position scrolling mode is in use.
  9112     // If aEnable is EFalse, Position scrolling mode is in use.
  8735     // If aEnable is ETrue, Rate scrolling mode is in use.
  9113     // If aEnable is ETrue, Rate scrolling mode is in use.
  8736     
  9114     
  8737     iEdwinExtension->iUseRateScroll = aEnable;
  9115 	if ( iEdwinExtension )
       
  9116 		{
       
  9117 		iEdwinExtension->iUseRateScroll = aEnable;
       
  9118 		}
  8738     }
  9119     }
  8739 
  9120 
  8740 // ---------------------------------------------------------------------------
  9121 // ---------------------------------------------------------------------------
  8741 // CEikEdwin::StoreCursorState
  9122 // CEikEdwin::StoreCursorState
  8742 // ---------------------------------------------------------------------------
  9123 // ---------------------------------------------------------------------------
  8743 //
  9124 //
  8744 void CEikEdwin::StoreCursorState()
  9125 void CEikEdwin::StoreCursorState()
  8745     {
  9126     {
  8746     CAknEdwinState* state( EditorState() );
  9127     CAknEdwinState* state( EditorState() );
  8747     if ( state && state->Flags() & EAknEditorFlagTextCursorVisible )
  9128     if ( iEdwinExtension && state && state->Flags() & EAknEditorFlagTextCursorVisible )
  8748         {
  9129         {
  8749         TRAP_IGNORE( SetCursorVisibilityL( EFalse ) );
  9130         TRAP_IGNORE( SetCursorVisibilityL( EFalse ) );
  8750         iEdwinExtension->iCursorWasVisible = ETrue;
  9131         iEdwinExtension->iCursorWasVisible = ETrue;
  8751         }
  9132         }
  8752     }
  9133     }
  8755 // CEikEdwin::RestoreCursorState
  9136 // CEikEdwin::RestoreCursorState
  8756 // ---------------------------------------------------------------------------
  9137 // ---------------------------------------------------------------------------
  8757 //
  9138 //
  8758 void CEikEdwin::RestoreCursorState()
  9139 void CEikEdwin::RestoreCursorState()
  8759     {
  9140     {
  8760     if ( iEdwinExtension->iCursorWasVisible )
  9141     if ( iEdwinExtension && iEdwinExtension->iCursorWasVisible )
  8761         {
  9142         {
  8762         TRAP_IGNORE( SetCursorVisibilityL( ETrue ) );
  9143         TRAP_IGNORE( SetCursorVisibilityL( ETrue ) );
  8763         iEdwinExtension->iCursorWasVisible = EFalse;
  9144         iEdwinExtension->iCursorWasVisible = EFalse;
  8764         }
  9145         }
  8765     }
  9146     }
  8772     {
  9153     {
  8773     return iEdwinExtension && iEdwinExtension->iPhysicsHandler;
  9154     return iEdwinExtension && iEdwinExtension->iPhysicsHandler;
  8774     }
  9155     }
  8775 
  9156 
  8776 
  9157 
       
  9158 // ---------------------------------------------------------------------------
       
  9159 // CEikEdwin::DrawViewBackground
       
  9160 // ---------------------------------------------------------------------------
       
  9161 //
       
  9162 void CEikEdwin::DrawViewBackground( TBool aStart ) const
       
  9163     {
       
  9164     CWindowGc& gc = SystemGc();
       
  9165     RWindow& window = Window();
       
  9166 
       
  9167     if ( aStart )
       
  9168         {
       
  9169         TRect viewRect( iTextView->ViewRect() );
       
  9170         window.Invalidate( viewRect );
       
  9171         window.BeginRedraw( viewRect );
       
  9172         gc.Activate( window );
       
  9173     
       
  9174         if ( iEdwinExtension && 
       
  9175         		!AknsDrawUtils::DrawBackground( 
       
  9176                 iEdwinExtension->iSkinInstance, 
       
  9177                 SkinBackgroundControlContext(),
       
  9178                 this,
       
  9179                 gc,
       
  9180                 viewRect.iTl,
       
  9181                 viewRect,
       
  9182                 KAknsDrawParamNoClearUnderImage ) )
       
  9183             {
       
  9184             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  9185             gc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  9186     
       
  9187             TRgb dummyColor;
       
  9188             TRgb backgroundColor = EditorBackgroundColor( dummyColor ); 
       
  9189     
       
  9190             gc.SetBrushColor( backgroundColor );
       
  9191             gc.SetPenColor( backgroundColor );
       
  9192             gc.DrawRect( iTextView->ViewRect() );
       
  9193             }
       
  9194         }
       
  9195     else
       
  9196         {
       
  9197         gc.Deactivate();
       
  9198         window.EndRedraw();
       
  9199         }
       
  9200     }
       
  9201 
       
  9202 
  8777 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect )
  9203 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect )
  8778     {
  9204     {
  8779     if ( !iEdwinExtension->iSmiley )
  9205 	if ( iEdwinExtension )
  8780         {
  9206 		{
  8781         return;
  9207 		if ( !iEdwinExtension->iSmiley )
  8782         }
  9208 	        {
  8783     if ( iCustomDrawer )
  9209 	        return;
  8784         {
  9210 	        }
  8785         iEdwinExtension->iSmiley->SetHighlightColor( 
  9211 	    if ( iCustomDrawer )
  8786             iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, 
  9212 	        {
  8787                 KRgbWhite ) );
  9213 	        iEdwinExtension->iSmiley->SetHighlightColor( 
  8788         }
  9214 	            iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, 
  8789     iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), 
  9215 	                KRgbWhite ) );
  8790         aSelect.Length() );
  9216 	        }
       
  9217 	    iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), 
       
  9218 	        aSelect.Length() );
       
  9219 		}
  8791     }
  9220     }
  8792 
  9221 
  8793 // ---------------------------------------------------------------------------
  9222 // ---------------------------------------------------------------------------
  8794 // CEikEdwin::SkipBackgroundDrawer
  9223 // CEikEdwin::SkipBackgroundDrawer
  8795 // ---------------------------------------------------------------------------
  9224 // ---------------------------------------------------------------------------
  8797 TBool CEikEdwin::SkipBackgroundDrawer() const
  9226 TBool CEikEdwin::SkipBackgroundDrawer() const
  8798     {
  9227     {
  8799     return iEdwinInternalFlags & ESkipBackgroundDrawer;
  9228     return iEdwinInternalFlags & ESkipBackgroundDrawer;
  8800     }
  9229     }
  8801 
  9230 
  8802 TBool CEikEdwin::IsValidNumericCharL( TChar aChar )
  9231 
  8803     { 
  9232 // ---------------------------------------------------------------------------
  8804     TBool ret(ETrue);
  9233 // CEikEdwin::ContentFitsToViewRect
  8805     CAknEdwinState* state = static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) );    
  9234 // ---------------------------------------------------------------------------
  8806     if (state && state->CurrentInputMode() == EAknEditorNumericInputMode )
  9235 //
  8807     	{
  9236 TBool CEikEdwin::ContentFitsToViewRect() const
  8808         HBufC* allowedChars = GetAllowedCharsLC();
  9237     {
  8809         if ( (*allowedChars).Length() > 0 && (*allowedChars).Locate( aChar ) == KErrNotFound )
  9238     if ( iLayout && !iLayout->IsFormattingBand() )
  8810             {
  9239         {
  8811             ret = EFalse;
  9240         if ( iLayout->FormattedHeightInPixels()
  8812             }
  9241             <= AdjustedViewRect().Height() + KContentThreshold )
  8813         CleanupStack::PopAndDestroy(1);//allowedChars
  9242             {
  8814         }
  9243             return ETrue;
  8815     return ret;
  9244             }
  8816     }
  9245         }
       
  9246 
       
  9247     return EFalse;
       
  9248     }
       
  9249 
       
  9250 
       
  9251 // ---------------------------------------------------------------------------
       
  9252 // ReadSpecialCharFromSCTL
       
  9253 // ---------------------------------------------------------------------------
       
  9254 //
       
  9255 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId )
       
  9256 	{
       
  9257 	TResourceReader aReader;
       
  9258 	CCoeEnv::Static()->CreateResourceReaderLC( aReader, sctResourceId );
       
  9259 	aReader.Advance( KTInt32Length ); // Diaog Flag
       
  9260 	HBufC* titleBar = aReader.ReadHBufCL(); // title bar
       
  9261 	// for titleBar useless, release it.
       
  9262 	delete titleBar;
       
  9263 	titleBar = NULL;
       
  9264 	// Page Selector Resource Id, Button Group Container Resource Id
       
  9265 	aReader.Advance( KTInt32Length + KTInt32Length );
       
  9266 	TInt lineCount = aReader.ReadInt16(); // line Count
       
  9267 	for ( TInt ii = 0; ii < lineCount; ii++ )
       
  9268 		{
       
  9269         TInt controlType = aReader.ReadInt16(); // control Type
       
  9270 	    if ( controlType == EAknCtPopupHeadingPane )
       
  9271 	    	{
       
  9272 	        // read HeadPane
       
  9273 	    	ReadSCTHeadPane( aReader );
       
  9274 	    	}
       
  9275 	    else if ( controlType == EAknCtSpecialCharacterMap )
       
  9276 	    	{
       
  9277 	        aReader.ReadTPtrC(); // caption text
       
  9278 			aReader.Advance( KTInt16Length + KTInt32Length ); // captioned control ID, item flags
       
  9279 			
       
  9280 			TInt component_count = aReader.ReadInt16();
       
  9281 			for ( TInt jj = 0; jj < component_count; jj++ )
       
  9282 				{
       
  9283 				TInt component_id = aReader.ReadInt16();
       
  9284 				if ( component_id == EAknSCTLowerCase || component_id == EAknSCTUpperCase ||
       
  9285 					component_id == EAknSCTNumeric )
       
  9286 					{
       
  9287 					HBufC* specialChar = aReader.ReadHBufCL();
       
  9288 					ptr.Append( specialChar->Des() );
       
  9289 					delete specialChar;
       
  9290 					}
       
  9291 				}
       
  9292 	    	}
       
  9293 	    else
       
  9294 	    	{
       
  9295 	        break;
       
  9296 	    	}
       
  9297 		}
       
  9298 	CleanupStack::PopAndDestroy(); // aReader
       
  9299 	}
       
  9300 
       
  9301 // ---------------------------------------------------------------------------
       
  9302 // ReadSCTHeadPane
       
  9303 // ---------------------------------------------------------------------------
       
  9304 //
       
  9305 void ReadSCTHeadPane( TResourceReader& aReader )
       
  9306 	{
       
  9307 	aReader.ReadTPtrC(); // caption text
       
  9308 	// captioned control ID, item flags
       
  9309 	aReader.Advance( KTInt16Length + KTInt32Length );
       
  9310 	aReader.ReadTPtrC(); // text of head pane
       
  9311 	aReader.ReadTPtrC(); // bitmap File Name of head pane
       
  9312 	// bitmap Id, bitmap Mask Id,animation Id, layout of head pane
       
  9313 	aReader.Advance( KTInt16Length + KTInt16Length + KTUint32Length + KTUint32Length );
       
  9314 	aReader.ReadTPtrC(); // trailer
       
  9315 	aReader.ReadTPtrC(); // bitmap File Name of captioned control
       
  9316 	// bitmap Id, bitmap Mask Id of captioned control
       
  9317 	aReader.Advance( KTInt16Length + KTInt16Length );
       
  9318 	aReader.ReadTPtrC(); // Process ToolTip
       
  9319 	}
  8817 
  9320 
  8818 // End of File
  9321 // End of File
  8819 
  9322