textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutmultilineicfeditor.cpp
branchRCL_3
changeset 50 5a1685599b76
parent 44 ecbabf52600f
child 56 8152b1f1763a
equal deleted inserted replaced
46:bd83ceabce89 50:5a1685599b76
   641 
   641 
   642     //iInsertionPoint->SetOn( EFalse );
   642     //iInsertionPoint->SetOn( EFalse );
   643     	
   643     	
   644     iLeadingEdge = icfdata.iLeadingEdge;
   644     iLeadingEdge = icfdata.iLeadingEdge;
   645 
   645 
       
   646     TInt draw = icfdata.iCmd == EPeninputICFSetCurSel ? 0 : 1;
       
   647     
   646     if (icfdata.iFlag != EFepICFDataInlineNoMatch && iNoMatchState)
   648     if (icfdata.iFlag != EFepICFDataInlineNoMatch && iNoMatchState)
   647         {
   649         {
   648         UpdateNoMatchTextL(iPreInlineEndPos, KNullDesC, EFalse);
   650         draw += UpdateNoMatchTextL(iPreInlineEndPos, KNullDesC, EFalse);
   649         }
   651         }
   650 
   652 
   651     switch (icfdata.iCmd)
   653     switch (icfdata.iCmd)
   652         {
   654         {
   653         case EPeninputICFInitial:
   655         case EPeninputICFInitial:
   681             
   683             
   682             AdjustSelectionL( icfdata.iCurSel );
   684             AdjustSelectionL( icfdata.iCurSel );
   683             RecalcualteTextPositionL();
   685             RecalcualteTextPositionL();
   684             //SetMsgBubbleRect();
   686             //SetMsgBubbleRect();
   685             SetMsgBubbleRectAccordingToLanguage();
   687             SetMsgBubbleRectAccordingToLanguage();
   686             Draw();
   688 //            Draw();
   687             }
   689             }
   688             break;
   690             break;
   689         case EPeninputICFReplace:
   691         case EPeninputICFReplace:
   690             {
   692             {
   691             if (( icfdata.iStartPos < 0 ) || 
   693             if (( icfdata.iStartPos < 0 ) || 
   742             {
   744             {
   743             return;
   745             return;
   744             }
   746             }
   745         }
   747         }
   746         
   748         
   747     UpdateTextL(icfdata);    
   749     draw += UpdateTextL(icfdata);    
   748     
   750     
   749     // Need to set selection visible before set selection for textview
   751     // Need to set selection visible before set selection for textview
   750     SetCursorSelVisibility( icfdata.iCursorSelVisible );    
   752     SetCursorSelVisibility( icfdata.iCursorSelVisible );    
   751     
   753     
   752     SetSelectionL(icfdata.iCurSel);
   754     draw += SetSelectionL(icfdata.iCurSel);
   753     ResetViewHeightL();
   755     draw += ResetViewHeightL();
   754     
   756     
   755     if (icfdata.iMidPos == 0)
   757     if (icfdata.iMidPos == 0)
   756         {
   758         {
   757         // inline state
   759         // inline state
   758         // if there is paragraph separater inside icfdata's iText, then should not
   760         // if there is paragraph separater inside icfdata's iText, then should not
   759         // set to inline state
   761         // set to inline state
   760         if (icfdata.iText.Locate(KParagraphSeperator) == KErrNotFound)
   762         if (icfdata.iText.Locate(KParagraphSeperator) == KErrNotFound)
   761             {
   763             {
   762             SetAutoCompleteStateL(EFalse);
   764             draw += SetAutoCompleteStateL(EFalse);
   763             icfdata.iFlag == EFepICFDataInlineNoMatch ? 
   765             icfdata.iFlag == EFepICFDataInlineNoMatch ? 
   764                                                       SetInlineStateL(ETrue, icfdata.iStartPos, 
   766                     draw += SetInlineStateL( ETrue, icfdata.iStartPos, 
   765                                                                       icfdata.iCurSel.iCursorPos, 
   767                                              icfdata.iCurSel.iCursorPos, 
   766                                                                       ETrue, icfdata.iText) :
   768 							                 ETrue, icfdata.iText) :
   767                                                       SetInlineStateL(ETrue, icfdata.iStartPos, 
   769                     draw += SetInlineStateL(ETrue, icfdata.iStartPos, 
   768                                                                       icfdata.iCurSel.iCursorPos);
   770                                             icfdata.iCurSel.iCursorPos);
   769             }
   771             }
   770         }
   772         }
   771     else if (icfdata.iMidPos > 0)
   773     else if (icfdata.iMidPos > 0)
   772         {
   774         {
   773         // auto complete state
   775         // auto complete state
   774         // Q: does insertion point need to be shown when auto complete?
   776         // Q: does insertion point need to be shown when auto complete?
   775         // on the assumption that insertion point do not shown
   777         // on the assumption that insertion point do not shown
   776         SetAutoCompleteStateL( ETrue, icfdata.iStartPos, 
   778         draw += SetAutoCompleteStateL( ETrue, icfdata.iStartPos, 
   777                                icfdata.iStartPos + icfdata.iText.Length() - icfdata.iMidPos, 
   779                                icfdata.iStartPos + icfdata.iText.Length() - icfdata.iMidPos, 
   778                                icfdata.iCurSel.iCursorPos );
   780                                icfdata.iCurSel.iCursorPos );
   779         }
   781         }
   780     else
   782     else
   781         {
   783         {
   782         // icfdata.iMidPos < 0, normal state
   784         // icfdata.iMidPos < 0, normal state
   783         //
   785         //
   784         SetInlineStateL(EFalse, icfdata.iStartPos, icfdata.iCurSel.iCursorPos);
   786         draw += SetInlineStateL(EFalse, icfdata.iStartPos, icfdata.iCurSel.iCursorPos);
   785         SetAutoCompleteStateL(EFalse);
   787         draw += SetAutoCompleteStateL(EFalse);
   786         
       
   787         }    
   788         }    
   788 
   789 
   789     // after inline adjust, cusor position may be updated
   790     // after inline adjust, cusor position may be updated
   790     if( bScroll )
   791     if( bScroll )
   791         {
   792         {
   792         TryDisplayMaxTextL(iCursorSel.iCursorPos);
   793         draw += TryDisplayMaxTextL(iCursorSel.iCursorPos);
   793         }
   794         }
   794     
       
   795     iTextView->DrawL(iViewRect);    
       
   796     //if(iMsgBubble)    
       
   797 //        iMsgBubble->Draw();   
       
   798 
   795 
   799     iInsertionPoint->SetVisible( EFalse ); 
   796     iInsertionPoint->SetVisible( EFalse ); 
   800 
   797 
   801     SetCursorVisible(icfdata.iCursorVisibility);
   798     SetCursorVisible(icfdata.iCursorVisibility);
   802     
   799     
   803     if (AbleToDraw())
   800     if ( AbleToDraw() )
   804         {
   801         {
   805         UpdateAreaImmed(Rect(),EFalse);    
   802         if(draw > 0)
   806         }
   803         	{
   807     }
   804             iTextView->DrawL(iViewRect);        	
   808 
   805         	}
   809 void CFepLayoutMultiLineIcfEditor::SetSelectionL(TCursorSelection aCurSel)
   806         	
   810     {
   807         UpdateAreaImmed(iViewRect,EFalse);    
       
   808         }
       
   809     }
       
   810 
       
   811 TBool CFepLayoutMultiLineIcfEditor::SetSelectionL(TCursorSelection aCurSel)
       
   812     {
       
   813     TBool changed = EFalse;
       
   814     
   811     if ( !IsTextPosValid(aCurSel.LowerPos()) || 
   815     if ( !IsTextPosValid(aCurSel.LowerPos()) || 
   812          !IsTextPosValid(aCurSel.HigherPos()) )
   816          !IsTextPosValid(aCurSel.HigherPos()) )
   813         {
   817         {
   814         return;
   818         return changed;
   815         }
   819         }
   816     
   820     
   817     AdjustSelectionL( aCurSel );
   821     changed = AdjustSelectionL( aCurSel );
   818     
   822     
   819     if ( iLayout->FirstLineInBand() != 0 && iLineMaxCount > 1 &&
   823     if ( iLayout->FirstLineInBand() != 0 && iLineMaxCount > 1 &&
   820         iPromptTextLen > 0 && aCurSel.iCursorPos == iPromptTextLen )
   824         iPromptTextLen > 0 && aCurSel.iCursorPos == iPromptTextLen )
   821     	{
   825     	{
   822         iTextView->SetViewLineAtTopL( 1 );	
   826         if ( iTextView->SetViewLineAtTopL( 1 ) != TPoint( 0, 0 ) )
       
   827             {
       
   828             changed = ETrue;
       
   829             }
   823     	}
   830     	}
   824         
   831 
   825     RecalcualteTextPositionL();
   832     RecalcualteTextPositionL();
   826     
   833     
   827     if ( iCursorSel.Length() > 0 )
   834     if ( iCursorSel.Length() > 0 )
   828         {
   835         {
   829         if ( iMsgBubble->IsShowing() && HighlightOverlapWithBubble( iMsgBubble->Rect() )  ) 
   836         if ( iMsgBubble->IsShowing() && HighlightOverlapWithBubble( iMsgBubble->Rect() )  ) 
   839     else
   846     else
   840         {
   847         {
   841         //SetMsgBubbleRect();
   848         //SetMsgBubbleRect();
   842 		SetMsgBubbleRectAccordingToLanguage();
   849 		SetMsgBubbleRectAccordingToLanguage();
   843         SetInfoBubbleRect();
   850         SetInfoBubbleRect();
   844         }    
   851         }   
       
   852     
       
   853     return changed;
   845     }
   854     }
   846 
   855 
   847 TBool CFepLayoutMultiLineIcfEditor::HighlightOverlapWithBubble( const TRect& aRect )
   856 TBool CFepLayoutMultiLineIcfEditor::HighlightOverlapWithBubble( const TRect& aRect )
   848     {
   857     {
   849     TBool ret = EFalse;
   858     TBool ret = EFalse;
   890     HideBubble();
   899     HideBubble();
   891     iHideBubbleTemp = ETrue;
   900     iHideBubbleTemp = ETrue;
   892     }
   901     }
   893     
   902     
   894 // for secret editor
   903 // for secret editor
   895 void CFepLayoutMultiLineIcfEditor::UpdateTextL(const TFepInputContextFieldData& aData)
   904 TBool CFepLayoutMultiLineIcfEditor::UpdateTextL(const TFepInputContextFieldData& aData)
   896     {
   905     {
   897     if (!iTextIsSecret)
   906     if (!iTextIsSecret)
   898         {
   907         {
   899         return;
   908         return EFalse;
   900         }
   909         }
   901 
   910 
   902     switch (aData.iCmd)
   911     switch (aData.iCmd)
   903         {
   912         {
   904         case EPeninputICFInitial:
   913         case EPeninputICFInitial:
   913                                             delLen );
   922                                             delLen );
   914             iRichText->InsertL(iRichText->DocumentLength(), buf);
   923             iRichText->InsertL(iRichText->DocumentLength(), buf);
   915             iTextView->HandleInsertDeleteL
   924             iTextView->HandleInsertDeleteL
   916                 ( TCursorSelection( iRichText->DocumentLength(), iPromptTextLen ), 0 );
   925                 ( TCursorSelection( iRichText->DocumentLength(), iPromptTextLen ), 0 );
   917             }
   926             }
   918             break;
   927             return ETrue;
   919         case EPeninputICFReplace:
   928         case EPeninputICFReplace:
   920             {                    
   929             {                    
   921             if (iSecretTextTimer->IsActive())
   930             if (iSecretTextTimer->IsActive())
   922                 {
   931                 {
   923                 iSecretTextTimer->Cancel();
   932                 iSecretTextTimer->Cancel();
   959                 }
   968                 }
   960             iSecretTextTimer->Start(
   969             iSecretTextTimer->Start(
   961                                  aData.iText.Length()>1?KSecretInstantShowTimer:KSecretUpdateTimer,
   970                                  aData.iText.Length()>1?KSecretInstantShowTimer:KSecretUpdateTimer,
   962                                  KSecretUpdateTimer, TCallBack(UpdateSecretTextL, this));
   971                                  KSecretUpdateTimer, TCallBack(UpdateSecretTextL, this));
   963             }
   972             }
   964             break;
   973             return ETrue;
   965         case EPeninputICFSetCurSel:
   974         case EPeninputICFSetCurSel:
   966         default:
   975         default:
   967             {
   976             {
   968             break;
   977             break;
   969             }
   978             }
   970         }
   979         }
       
   980     
       
   981     return EFalse;
   971     }
   982     }
   972 
   983 
   973 TInt CFepLayoutMultiLineIcfEditor::UpdateSecretTextL(TAny* aEditArea)
   984 TInt CFepLayoutMultiLineIcfEditor::UpdateSecretTextL(TAny* aEditArea)
   974     {
   985     {
   975     CFepLayoutMultiLineIcfEditor* editArea = static_cast<CFepLayoutMultiLineIcfEditor*>(aEditArea);
   986     CFepLayoutMultiLineIcfEditor* editArea = static_cast<CFepLayoutMultiLineIcfEditor*>(aEditArea);
  1331     
  1342     
  1332     //SetMsgBubbleRect();
  1343     //SetMsgBubbleRect();
  1333     SetMsgBubbleRectAccordingToLanguage();
  1344     SetMsgBubbleRectAccordingToLanguage();
  1334     }
  1345     }
  1335 
  1346 
  1336 void CFepLayoutMultiLineIcfEditor::ResetViewHeightL()
  1347 TBool CFepLayoutMultiLineIcfEditor::ResetViewHeightL()
  1337     {
  1348     {
       
  1349     const TInt lineCount=iLayout->NumFormattedLines();
       
  1350 
       
  1351     if ( lineCount <= 0 )
       
  1352         {
       
  1353         return EFalse;
       
  1354         }
       
  1355         
  1338     const TInt height = iLayout->FormattedHeightInPixels();
  1356     const TInt height = iLayout->FormattedHeightInPixels();
  1339     const TInt lineCount=iLayout->NumFormattedLines();
       
  1340     if ( lineCount <= 0 )
       
  1341         {
       
  1342         return;
       
  1343         }
       
  1344         
       
  1345     TInt lineHeight = (height+lineCount-1) / lineCount;
  1357     TInt lineHeight = (height+lineCount-1) / lineCount;
  1346     
  1358     
  1347     if ( iFormatLineHeight == lineHeight )
  1359     if ( iFormatLineHeight == lineHeight )
  1348         {
  1360         {
  1349         return;
  1361         return EFalse;
  1350         }
  1362         }
  1351         
  1363         
  1352     if ( lineHeight > iMaxIcfEditorHeight )
  1364     if ( lineHeight > iMaxIcfEditorHeight )
  1353         {
  1365         {
  1354         lineHeight = iMaxIcfEditorHeight;
  1366         lineHeight = iMaxIcfEditorHeight;
  1378     else
  1390     else
  1379     	{
  1391     	{
  1380     	iViewRect.iBr.iY -= margin;
  1392     	iViewRect.iBr.iY -= margin;
  1381     	}
  1393     	}
  1382     iTextView->SetViewRect(iViewRect);
  1394     iTextView->SetViewRect(iViewRect);
       
  1395     
       
  1396     return ETrue;
  1383     }
  1397     }
  1384 
  1398 
  1385 void CFepLayoutMultiLineIcfEditor::SetMsgBubbleRectAccordingToLanguage()
  1399 void CFepLayoutMultiLineIcfEditor::SetMsgBubbleRectAccordingToLanguage()
  1386 	{
  1400 	{
  1387 	if ( iPreLanguageID == ELangPrcChinese || 
  1401 	if ( iPreLanguageID == ELangPrcChinese || 
  2510 TBool CFepLayoutMultiLineIcfEditor::IsTextPosValid(TInt aPos)
  2524 TBool CFepLayoutMultiLineIcfEditor::IsTextPosValid(TInt aPos)
  2511     {
  2525     {
  2512     return (aPos >= 0 && aPos <= iRichText->DocumentLength());
  2526     return (aPos >= 0 && aPos <= iRichText->DocumentLength());
  2513     }
  2527     }
  2514 
  2528 
  2515 void CFepLayoutMultiLineIcfEditor::UpdateNoMatchTextL(TInt aPos, const TDesC& aNoMatchText, 
  2529 TBool CFepLayoutMultiLineIcfEditor::UpdateNoMatchTextL(TInt aPos, const TDesC& aNoMatchText, 
  2516                                                       TBool aNoMatchState)
  2530                                                       TBool aNoMatchState)
  2517     {
  2531     {
  2518     if ( iNoMatchState == aNoMatchState )
  2532     if ( iNoMatchState == aNoMatchState )
  2519         {
  2533         {
  2520         return;
  2534         return EFalse;
  2521         }
  2535         }
  2522         
  2536         
  2523     if (aNoMatchState)
  2537     if (aNoMatchState)
  2524         {
  2538         {
  2525         iNoMatchState = aNoMatchState;
  2539         iNoMatchState = aNoMatchState;
  2532         iNoMatchState = aNoMatchState;
  2546         iNoMatchState = aNoMatchState;
  2533 
  2547 
  2534         iRichText->DeleteL(aPos, 1);
  2548         iRichText->DeleteL(aPos, 1);
  2535         iTextView->HandleInsertDeleteL(TCursorSelection(aPos, aPos),1);
  2549         iTextView->HandleInsertDeleteL(TCursorSelection(aPos, aPos),1);
  2536         SetSelectionL( TCursorSelection( aPos - 1, aPos - 1 ) );
  2550         SetSelectionL( TCursorSelection( aPos - 1, aPos - 1 ) );
  2537         }         
  2551         }     
       
  2552     
       
  2553     return ETrue;
  2538     }
  2554     }
  2539 
  2555 
  2540 void CFepLayoutMultiLineIcfEditor::SetPromptTextFormatL(TInt aPromptTextLen)
  2556 void CFepLayoutMultiLineIcfEditor::SetPromptTextFormatL(TInt aPromptTextLen)
  2541     {
  2557     {
  2542     if ( aPromptTextLen <= 0 )
  2558     if ( aPromptTextLen <= 0 )
  2641         aPreStartPos = aStartPos;
  2657         aPreStartPos = aStartPos;
  2642         aPreEndPos = aEndPos;
  2658         aPreEndPos = aEndPos;
  2643         }
  2659         }
  2644     }
  2660     }
  2645 
  2661 
  2646 void CFepLayoutMultiLineIcfEditor::SetInlineStateL(TBool aInline, 
  2662 TBool CFepLayoutMultiLineIcfEditor::SetInlineStateL(TBool aInline, 
  2647                                              TInt aStartPos, 
  2663                                              TInt aStartPos, 
  2648                                              TInt aEndPos, 
  2664                                              TInt aEndPos, 
  2649                                              TBool aNoMatchState, 
  2665                                              TBool aNoMatchState, 
  2650                                              const TDesC& aNoMatchText)
  2666                                              const TDesC& aNoMatchText)
  2651     {
  2667     {
  2652     if (aInline)
  2668     TInt oldState = iState;
       
  2669     
       
  2670     if ( aInline )
       
  2671         {
  2653         iState = CFepLayoutMultiLineIcf::EIcfInline;
  2672         iState = CFepLayoutMultiLineIcf::EIcfInline;
       
  2673         }
  2654     else
  2674     else
  2655         {
  2675         {
  2656         iState = CFepLayoutMultiLineIcf::EIcfNormal;
  2676         iState = CFepLayoutMultiLineIcf::EIcfNormal;
  2657         UpdateNoMatchTextL(iPreInlineEndPos, KNullDesC, EFalse);
  2677         }
  2658         }
  2678     
  2659 
  2679     TBool changed = ( oldState != iState );
  2660     SetSpecialStateL(aInline, 
  2680     
  2661                      aStartPos, 
  2681     if ( changed )
  2662                      aEndPos, 
  2682         {
  2663                      iPreInlineStartPos, 
  2683         if ( iState == CFepLayoutMultiLineIcf::EIcfNormal )
  2664                      iPreInlineEndPos, 
  2684             {
  2665                      EAttFontUnderline, 
  2685             UpdateNoMatchTextL(iPreInlineEndPos, KNullDesC, EFalse);
  2666                      aNoMatchState, 
  2686             }
  2667                      aNoMatchText);
  2687 
  2668     }
  2688         SetSpecialStateL(aInline, 
  2669 
  2689                          aStartPos, 
  2670 void CFepLayoutMultiLineIcfEditor::SetAutoCompleteStateL(TBool aAutoComplete, 
  2690                          aEndPos, 
       
  2691                          iPreInlineStartPos, 
       
  2692                          iPreInlineEndPos, 
       
  2693                          EAttFontUnderline, 
       
  2694                          aNoMatchState, 
       
  2695                          aNoMatchText);
       
  2696         }
       
  2697     
       
  2698     return changed;
       
  2699     }
       
  2700 
       
  2701 TBool CFepLayoutMultiLineIcfEditor::SetAutoCompleteStateL(TBool aAutoComplete, 
  2671                                                    TInt aStartPos, 
  2702                                                    TInt aStartPos, 
  2672                                                    TInt aMidPos,
  2703                                                    TInt aMidPos,
  2673                                                    TInt aEndPos)
  2704                                                    TInt aEndPos)
  2674     {
  2705     {
       
  2706     TBool changed = ( iAutoComplete != aAutoComplete );
       
  2707     // If auto is on, we need draw every time, as grey part is not making the text changed
       
  2708     // if we use traditional way to check change, auto part is not turn to black when grey part is there.
       
  2709     changed = iAutoComplete; 
  2675     iAutoComplete = aAutoComplete;
  2710     iAutoComplete = aAutoComplete;
  2676     
  2711     
  2677     if ( aAutoComplete )
  2712     if ( aAutoComplete )
  2678         {
  2713         {
  2679         iState = CFepLayoutMultiLineIcf::EIcfAutoComplete;
  2714         iState = CFepLayoutMultiLineIcf::EIcfAutoComplete;
  2681     else
  2716     else
  2682         {
  2717         {
  2683         iState = CFepLayoutMultiLineIcf::EIcfNormal;
  2718         iState = CFepLayoutMultiLineIcf::EIcfNormal;
  2684         }
  2719         }
  2685         
  2720         
  2686     SetSpecialStateL(aAutoComplete, 
  2721     if ( changed )
  2687                      aStartPos, 
  2722         {
  2688                      aMidPos, 
  2723         SetSpecialStateL(aAutoComplete, 
  2689                      iPreInlineStartPos, 
  2724                          aStartPos, 
  2690                      iPreInlineEndPos, 
  2725                          aMidPos, 
  2691                      EAttFontUnderline);
  2726                          iPreInlineStartPos, 
  2692                      
  2727                          iPreInlineEndPos, 
  2693     SetSpecialStateL(aAutoComplete, 
  2728                          EAttFontUnderline);
  2694                      aMidPos, 
  2729                          
  2695                      aEndPos, 
  2730         SetSpecialStateL(aAutoComplete, 
  2696                      iPreAutoStartPos, 
  2731                          aMidPos, 
  2697                      iPreAutoEndPos, 
  2732                          aEndPos, 
  2698                      EAttColor);
  2733                          iPreAutoStartPos, 
       
  2734                          iPreAutoEndPos, 
       
  2735                          EAttColor);
       
  2736         }
       
  2737     
       
  2738     return changed;
  2699     }
  2739     }
  2700 
  2740 
  2701 TAknsItemID CFepLayoutMultiLineIcfEditor::BgImgSkinId() const
  2741 TAknsItemID CFepLayoutMultiLineIcfEditor::BgImgSkinId() const
  2702     {
  2742     {
  2703     if (iSkinIdSet)
  2743     if (iSkinIdSet)
  2829     
  2869     
  2830     iFontHeight = 0;
  2870     iFontHeight = 0;
  2831     TRAP_IGNORE(SetFontL(font));
  2871     TRAP_IGNORE(SetFontL(font));
  2832     }
  2872     }
  2833 
  2873 
  2834 void CFepLayoutMultiLineIcfEditor::TryDisplayMaxTextL( TInt aCursorPos )
  2874 TBool CFepLayoutMultiLineIcfEditor::TryDisplayMaxTextL( TInt aCursorPos )
  2835     {
  2875     {
       
  2876     TBool scrolled = EFalse;
       
  2877     
  2836     iTextView->FinishBackgroundFormattingL();
  2878     iTextView->FinishBackgroundFormattingL();
  2837     TInt lineIndex = iLayout->GetLineNumber( aCursorPos );
  2879     TInt lineIndex = iLayout->GetLineNumber( aCursorPos );
  2838 
  2880 
  2839     if ( aCursorPos >= 0 )
  2881     if ( aCursorPos >= 0 )
  2840         {
  2882         {
  2841         TPoint cursorPt;
  2883         TPoint cursorPt;
  2842         TRAP_IGNORE(iTextView->DocPosToXyPosL(iCursorSel.iCursorPos, cursorPt));
  2884         TRAP_IGNORE(iTextView->DocPosToXyPosL(iCursorSel.iCursorPos, cursorPt));
  2843         CalculateCursorPos(cursorPt);
  2885         CalculateCursorPos(cursorPt);
  2844         if ( !iViewRect.Contains( cursorPt ) && ( lineIndex + 1 ) > ( iLineMaxCount - 1 ) )
  2886         if ( !iViewRect.Contains( cursorPt ) && ( lineIndex + 1 ) > ( iLineMaxCount - 1 ) )
  2845             {
  2887             {
  2846             iTextView->SetViewLineAtTopL(( lineIndex + 1 ) - ( iLineMaxCount - 1 ));
  2888             if ( iTextView->SetViewLineAtTopL(( lineIndex + 1 ) - ( iLineMaxCount - 1 )) != TPoint( 0, 0 ) )
  2847             RecalcualteTextPositionL();
  2889                 {
  2848             //SetMsgBubbleRect();
  2890                 scrolled = ETrue;
  2849             SetMsgBubbleRectAccordingToLanguage();
  2891                 RecalcualteTextPositionL();
       
  2892                 SetMsgBubbleRectAccordingToLanguage();
       
  2893                 }
  2850             }
  2894             }
  2851         }
  2895         }
  2852     
  2896     
  2853     const TInt lineCount = iLayout->NumFormattedLines();
  2897     const TInt lineCount = iLayout->NumFormattedLines();
  2854    
  2898    
  2858         TPoint ptCursor = iInsertionPoint->Position() ;
  2902         TPoint ptCursor = iInsertionPoint->Position() ;
  2859         TInt lineCursor = ( ptCursor.iY + iInsertionPoint->Height() / 2 
  2903         TInt lineCursor = ( ptCursor.iY + iInsertionPoint->Height() / 2 
  2860                             - iViewRect.iTl.iY) / iFormatLineHeight + 1;
  2904                             - iViewRect.iTl.iY) / iFormatLineHeight + 1;
  2861         if( lineCursor < pageCount )
  2905         if( lineCursor < pageCount )
  2862             {
  2906             {
  2863             
  2907             if ( iTextView->SetViewLineAtTopL(
  2864             iTextView->SetViewLineAtTopL( 
  2908                     lineCount - pageCount + 1 < 1 ? 1 : lineCount - pageCount + 1 ) 
  2865                                    lineCount - pageCount + 1 < 1 ? 1 : lineCount - pageCount + 1 );
  2909                     != TPoint( 0, 0 ) )
  2866             
  2910                 {
  2867             RecalcualteTextPositionL();
  2911                 scrolled = ETrue;
  2868             //SetMsgBubbleRect();
  2912                 RecalcualteTextPositionL();
  2869             SetMsgBubbleRectAccordingToLanguage();
  2913                 SetMsgBubbleRectAccordingToLanguage();
  2870             }
  2914                 }
  2871         }
  2915             }
       
  2916         }
       
  2917     
       
  2918     return scrolled;
  2872     }
  2919     }
  2873     
  2920     
  2874 void CFepLayoutMultiLineIcfEditor::DrawIcfBackground( CFbsBitGc& /*aGc*/, const TRect& aDrawnRect, 
  2921 void CFepLayoutMultiLineIcfEditor::DrawIcfBackground( CFbsBitGc& /*aGc*/, const TRect& aDrawnRect, 
  2875                                                       TBool /*aBmpStretchFlag*/ )
  2922                                                       TBool /*aBmpStretchFlag*/ )
  2876 	{
  2923 	{
  2890         return;
  2937         return;
  2891         }
  2938         }
  2892     iRichText->Extract( aBuf, aPos + iPromptTextLen, aLength);
  2939     iRichText->Extract( aBuf, aPos + iPromptTextLen, aLength);
  2893     } 
  2940     } 
  2894 
  2941 
  2895 void CFepLayoutMultiLineIcfEditor::AdjustSelectionL( const TCursorSelection& aCurSel )
  2942 TBool CFepLayoutMultiLineIcfEditor::AdjustSelectionL( const TCursorSelection& aCurSel )
  2896     {
  2943     {
  2897     if (!IsTextPosValid(aCurSel.LowerPos()) || 
  2944     if (!IsTextPosValid(aCurSel.LowerPos()) || 
  2898     !IsTextPosValid(aCurSel.HigherPos()) )
  2945     !IsTextPosValid(aCurSel.HigherPos()) )
  2899 		{
  2946 		{
  2900 		return;
  2947 		return EFalse;
  2901 		}
  2948 		}
  2902 
  2949     if (iCursorSel.iAnchorPos == aCurSel.iAnchorPos
       
  2950         && iCursorSel.iCursorPos == aCurSel.iCursorPos)
       
  2951         {
       
  2952         return EFalse;
       
  2953         }
  2903     iCursorSel = aCurSel;   
  2954     iCursorSel = aCurSel;   
  2904    
  2955    
  2905     if ( BelongToPromptText(aCurSel.iCursorPos) )
  2956     if ( BelongToPromptText(aCurSel.iCursorPos) )
  2906         {
  2957         {
  2907         //why to use iPromptText->Length() instead of iPromptTextLen 
  2958         //why to use iPromptText->Length() instead of iPromptTextLen 
  2915         iCursorSel.iAnchorPos = iPromptText->Length();
  2966         iCursorSel.iAnchorPos = iPromptText->Length();
  2916         }
  2967         }
  2917  
  2968  
  2918     iTextView->SetSelectionL( iCursorSel );
  2969     iTextView->SetSelectionL( iCursorSel );
  2919     iTextView->SetSelectionVisibilityL( iCursorSelVisible );
  2970     iTextView->SetSelectionVisibilityL( iCursorSelVisible );
       
  2971 	
       
  2972 	return ETrue;
  2920     }  
  2973     }  
  2921 
  2974 
  2922 void CFepLayoutMultiLineIcfEditor::ReDrawRect(const TRect& aRect)
  2975 void CFepLayoutMultiLineIcfEditor::ReDrawRect(const TRect& aRect)
  2923     {
  2976     {
  2924     Draw();
  2977     Draw();