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