textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutmultilineicfeditor.cpp
branchRCL_3
changeset 44 ecbabf52600f
parent 43 ebd48d2de13c
child 50 5a1685599b76
--- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutmultilineicfeditor.cpp	Tue Aug 31 15:31:50 2010 +0300
+++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutmultilineicfeditor.cpp	Wed Sep 01 12:23:33 2010 +0100
@@ -46,6 +46,10 @@
 #include "peninputlayoutsmiley.h"
 
 #include <gdi.h>
+
+#include <e32std.h>
+#include <e32const.h>
+
 const TInt KParagraphSeperator = 0x2029;
 const TInt KSecretUpdateTimer = 1000000; // 1s
 const TInt KSecretInstantShowTimer = 100000; // 100ms
@@ -53,8 +57,10 @@
 const TUint16 KSegment = 0x0020;
 // separator between prompt text and normal text,
 // should use localized character soon
-const TUint16 KSeparator = 0x003a;
-const TUint16 KSeparatorcn = 0xff1a;
+//const TUint16 KSeparator = 0x003a;
+//const TUint16 KSeparatorcn = 0xff1a;
+const TUint16 KColon = 0x003a;
+const TUint16 KColoncn = 0xff1a; 
 _LIT(KLineSeparator, "\n");
 const TInt KStar = '*';
 
@@ -63,6 +69,9 @@
 const TInt KMsgBubblePosAdjustValueX = 3;
 const TInt KMsgBubblePosAdjustValueY = 2;
 const TInt KPromptAdjustLen = 5;
+// Tooltip position adjust
+const TInt KTooltipPosAdjustValueY = 5;
+
 EXPORT_C CFepLayoutMultiLineIcfEditor* CFepLayoutMultiLineIcfEditor::NewL(TRect aRect,
                                                               CFepUiLayout* aUiLayout,
                                                               TInt aControlId,
@@ -108,8 +117,8 @@
     if(aUiLayout)
     	{
     	//Advanced Tactile feedback REQ417-47932
-    	SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);    	
-    	aUiLayout->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveKeypad);
+    	SetTactileFeedbackType(ETouchFeedbackSensitiveInput);    	
+    	aUiLayout->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveInput);
     	}
 #endif //RD_TACTILE_FEEDBACK     
     }
@@ -147,11 +156,11 @@
         delete iFormExtendedInterfaceProvider;
         iFormExtendedInterfaceProvider = NULL;
         }
-    
+    iCoeEnv->ScreenDevice()->ReleaseFont(CONST_CAST(CFont*, iFont));
     delete iSmileyManager;
     }
 
-void CFepLayoutMultiLineIcfEditor::InitTextLayoutL()
+void CFepLayoutMultiLineIcfEditor::InitTextLayoutL(const CFont *aFont)
     {
 	iParaFormatLayer=CParaFormatLayer::NewL();
 	iCharFormatLayer=CCharFormatLayer::NewL();
@@ -181,7 +190,7 @@
     //iCtrl->SetContainerWindowL(*iWin);    
     //iWin->Construct(iCoeEnv->RootWin(),reinterpret_cast<TInt>(iCtrl));
     //ctrl->SetExtent(iViewRect.iTl, iViewRect.Size());
-
+    SetFontL(aFont);
 	iTextView = CTextView::NewL(iLayout, 
 	                            iViewRect,
                         		BitmapDevice(),
@@ -268,8 +277,8 @@
     iAlignment = aAlignment;
     }
 
-void CFepLayoutMultiLineIcfEditor::BaseConstructL(TInt aFontHeight, 
-                                            TInt aMaxFontHeight, 
+void CFepLayoutMultiLineIcfEditor::BaseConstructL(TInt /*aFontHeight*/, 
+                                            TInt /*aMaxFontHeight*/, 
                                             const CFont* aFont)
     {
     CFepUiBaseCtrl::BaseConstructL();
@@ -278,10 +287,10 @@
     //iMaxFontHeight = aMaxFontHeight;
     //iFontHeight = aFontHeight;
     //iFont = aFont;
-    InitTextLayoutL();
+    InitTextLayoutL(aFont);
     iInsertionPoint = UiLayout()->CreateCursor();
     iInsertionPoint->SetOwner(this);
-    SetFontL(aFontHeight, aMaxFontHeight, aFont);
+    //SetFontL(aFont);
 
     iSecretTextTimer = CPeriodic::NewL(CActive::EPriorityStandard);
 
@@ -340,7 +349,6 @@
 
 void CFepLayoutMultiLineIcfEditor::RecalculatePosByNewPromptTextL(const TDesC& aNewPromptText)
     {
-    // recalculate cursor pos
     AdjustSelectionL(TCursorSelection(iTextView->Selection().iCursorPos + aNewPromptText.Length() - iPromptTextLen,
                      iTextView->Selection().iAnchorPos + aNewPromptText.Length() - iPromptTextLen));
 
@@ -352,7 +360,6 @@
     iPreAutoEndPos += (aNewPromptText.Length() - iPromptTextLen);
     iPreTextSelStartPos += (aNewPromptText.Length() - iPromptTextLen);
     iPreTextSelEndPos += (aNewPromptText.Length() - iPromptTextLen);
-
     }
 
 const HBufC* CFepLayoutMultiLineIcfEditor::PromptText()
@@ -362,7 +369,6 @@
 	
 void CFepLayoutMultiLineIcfEditor::SetPromptTextL(const TDesC& aPromptText, TBool aCleanContent)
     {
-    
     if ( aCleanContent )
     	{
     	//clean all the content (include prompt text) on the ICF
@@ -374,15 +380,24 @@
         iNoMatchState = EFalse;
     	}
     else 
-        {
-        /*if ( ( ( !iInitPromptText && aPromptText.Length() == 0 ) )|| 
+        {   
+        if ( ( ( !iInitPromptText && aPromptText.Length() == 0 ) )|| 
             ( iInitPromptText && *iInitPromptText == aPromptText && 
             iPromptText && TextWidth(*iPromptText) <= iViewRect.Width()) )
     	    {
     	    //prompt text has not been change then need not to be reset
     	    //but iLineSeparator may be changed, need reset prompt text
-    	    return;
-            }*/
+            TBool newLineSeparator = iLineSeparator;
+            if ( !iLineSeparator )
+                {
+                newLineSeparator = ( TBidiText::TextDirectionality( aPromptText )
+                                                     == TBidiText:: ERightToLeft );
+                }
+            if ( newLineSeparator == iLineSeparator )
+                {
+                return;
+                }
+            }
         //prompt text need to be reset and not clean the content
         iRichText->DeleteL( 0,  iPromptTextLen );
         iTextView->HandleInsertDeleteL(TCursorSelection(0, 0), iPromptTextLen );
@@ -430,19 +445,31 @@
     iPromptText = HBufC::NewL(prompttextLen);
     TPtr text = iPromptText->Des();
 
-    TBuf<1> ptr0;
-    ptr0.Append( KEllipsis );
+        TBuf<1> ptrEllipsis;
+        ptrEllipsis.Append( KEllipsis );
 
-    TPtrC ptr1(&KSegment, 1);
-    TPtrC ptr2(&KSeparator, 1);
+        TPtrC ptrSpace(&KSegment, 1);
+        TPtrC ptrColon(&KColon, 1);
     
-    TInt separatorLen = TextWidth(ptr1) + TextWidth(ptr2) + TextWidth(ptr0);
-    TInt textWidth = TextWidth(aPromptText) + separatorLen;
-    TBool ret = EFalse;
+        TInt separatorLen = TextWidth(ptrSpace) + TextWidth(ptrColon) + TextWidth(ptrEllipsis);     
+        TInt textWidth = TextWidth(aPromptText);
+
+        if ((aPromptText.LocateReverse(KColon) != aPromptText.Length() - 1) && 
+           (aPromptText.LocateReverse(KColoncn) != aPromptText.Length() - 1))
+           {
+            textWidth += TextWidth(ptrSpace) + TextWidth(ptrColon);
+            }
+
+        else
+                {
+                textWidth += TextWidth(ptrSpace);
+                }     
+
+        TBool truncated = EFalse;
     
-    if (textWidth >= iViewRect.Width() )
-        {
-        ret = ETrue;
+        if (textWidth > iViewRect.Width() )
+            {
+            truncated = ETrue;
         AknBidiTextUtils::ConvertToVisualAndClip(aPromptText,
                                                  text,
                                                  *iFont,
@@ -464,23 +491,23 @@
 		text.Delete( text.Length()-1, 1 );
 	    }
 		
-    if ((text.LocateReverse(KSeparator) != text.Length() - 1) && 
-        (text.LocateReverse(KSeparatorcn) != text.Length() - 1))
+        if ((text.LocateReverse(KColon) != text.Length() - 1) && 
+            (text.LocateReverse(KColoncn) != text.Length() - 1))
         {
         // if sent prompt text already include separator, then no need to 
         // append it again
-        if ( ret )
+            if (truncated)
+                {
+                text.Append( ptrEllipsis );
+                }
+            text.Append(ptrColon);
+           }
+        else if (truncated)
             {
-            text.Append( ptr0 );
-            }
-        text.Append(ptr2);
-        }
-    else if ( ret )
-        {
-        text.Insert( text.Length()-1, ptr0 );
-        }        
+            text.Insert( text.Length()-1, ptrEllipsis );
+            }        
 
-    text.Append(ptr1); // segment between prompt text and official text
+    text.Append(ptrSpace); // segment between prompt text and official text
     textWidth = TextWidth(text);
     
     iRichText->InsertL(0, text);
@@ -532,6 +559,7 @@
                 iRichText->DeleteL(iPromptTextLen, delLen );
                 iTextView->HandleInsertDeleteL(TCursorSelection(iPromptTextLen, iPromptTextLen), 
                                                delLen);
+                iTextView->SetSelectionL(TCursorSelection(iPromptTextLen, iPromptTextLen));
                 }
             ptr.Copy(icfdata.iText);
             }
@@ -565,6 +593,7 @@
         iCursorSel.iAnchorPos = icfdata.iCurSel.iAnchorPos + iPromptTextLen;
         DrawMfneText();
         iSynCursor = EFalse;
+        iOldMfneText.Close();
         iOldMfneText.CreateL(ptr);
         }
         
@@ -652,7 +681,8 @@
             
             AdjustSelectionL( icfdata.iCurSel );
             RecalcualteTextPositionL();
-            SetMsgBubbleRect();
+            //SetMsgBubbleRect();
+            SetMsgBubbleRectAccordingToLanguage();
             Draw();
             }
             break;
@@ -808,7 +838,8 @@
         }
     else
         {
-        SetMsgBubbleRect();
+        //SetMsgBubbleRect();
+		SetMsgBubbleRectAccordingToLanguage();
         SetInfoBubbleRect();
         }    
     }
@@ -950,26 +981,40 @@
         }
     TPtrC icftext = editArea->iRichText->Read(editArea->iPromptTextLen, 
                                               editArea->iRichText->DocumentLength());
-    TInt startPos = icftext.LocateReverse(KStar) + 1 + editArea->iPromptTextLen;
-
-    TBuf<1> buf;
-    buf.Append(KStar);
-
-    TInt textlen = editArea->iRichText->DocumentLength();
-
-    if (startPos < textlen)
+    
+    for (TInt i = 0; i < icftext.Length(); i++)
         {
-        editArea->iRichText->DeleteL(startPos, 1);
-        editArea->iTextView->HandleInsertDeleteL(TCursorSelection(startPos, startPos), 1);
-        editArea->iRichText->InsertL(startPos, buf);
-        editArea->iTextView->HandleInsertDeleteL(TCursorSelection(startPos, startPos+buf.Length()),
-                                                 0);
+        if (icftext[i] != KStar)//find only one none-star char
+            {
+            TInt startPos = i + editArea->iPromptTextLen;
+            TBuf<1> buf;
+            buf.Append(KStar);
+
+            TInt textlen = editArea->iRichText->DocumentLength();
 
-        if (startPos == textlen - 1)
-            {
-            editArea->iSecretTextTimer->Cancel();
+            if (startPos < textlen)
+                {
+                editArea->iRichText->DeleteL(startPos, 1);
+                editArea->iTextView->HandleInsertDeleteL(TCursorSelection(
+                        startPos, startPos), 1);
+                editArea->iRichText->InsertL(startPos, buf);
+                editArea->iTextView->HandleInsertDeleteL(TCursorSelection(
+                        startPos, startPos + buf.Length()), 0);
+
+                if (startPos == textlen - 1)
+                    {
+                    editArea->iSecretTextTimer->Cancel();
+                    }
+                }
+            break;
             }
         }
+    
+    if ( editArea->iCursorVisible )
+    	{
+        editArea->SetSelectionL( editArea->iCursorSel );
+        editArea->Draw();
+    	}
     editArea->UpdateArea(editArea->Rect(),EFalse);
     return KErrNone;
     }
@@ -993,11 +1038,9 @@
     iDimmed = aDimFlag;
     }
 
-void CFepLayoutMultiLineIcfEditor::SetFontL(TInt aFontHeight, 
-                                            TInt aMaxFontHeight, 
-                                            const CFont* aFont)
+void CFepLayoutMultiLineIcfEditor::SetFontL(const CFont* aFont)
     {
-    TInt newHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(aFontHeight);
+    TInt newHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(aFont->HeightInPixels());
     TInt OldHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(iFontHeight);
     
     if( newHeightInPixel == OldHeightInPixel )
@@ -1009,9 +1052,16 @@
         iFormatChange = ETrue;
         }    
     
-    iMaxFontHeight = aMaxFontHeight;
-    iFontHeight = aFontHeight;
-    iFont = aFont;
+    TFontSpec fontSpec;
+    fontSpec = aFont->FontSpecInTwips();
+    fontSpec.iHeight = aFont->HeightInPixels();
+    CFont*  font;
+    iCoeEnv->ScreenDevice()->ReleaseFont(CONST_CAST(CFont*, iFont));
+    iCoeEnv->ScreenDevice()->GetNearestFontInPixels((CFont*&)font,fontSpec);
+    
+    iMaxFontHeight = font->FontMaxHeight();
+    iFontHeight = font->HeightInPixels();
+    iFont = font;
     
         
     iCharFormatMask.ClearAttrib( EAttFontUnderline );
@@ -1022,6 +1072,7 @@
     iCharFormat.iFontSpec.iHeight = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(iFontHeight);
     iCharFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
     iCharFormat.iFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
+    iCharFormat.iFontSpec.iTypeface = iFont->FontSpecInTwips().iTypeface;
 
     iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, iRichText->DocumentLength());    
     if( InlineStateOn() || AutoCompletionStateOn() )
@@ -1029,8 +1080,11 @@
         iCharFormatMask.ClearAll();
         iCharFormatMask.SetAttrib( EAttFontUnderline );        
         iCharFormat.iFontPresentation.iUnderline = EUnderlineOn ;
-        iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, iPreInlineStartPos, 
-                                    iPreInlineEndPos - iPreInlineStartPos);
+        if( iPreInlineStartPos >= 0 && iPreInlineEndPos <= iRichText->DocumentLength() + 1 )
+            {
+            iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, iPreInlineStartPos, 
+                                        iPreInlineEndPos - iPreInlineStartPos);
+            }
         }
     
     //iRichText->SetInsertCharFormatL(iCharFormat, iCharFormatMask, iRichText->DocumentLength() - iPromptTextLen);
@@ -1097,7 +1151,7 @@
         TRect innerrect = Rect();
   	    //innerrect.Shrink(4, 4);
 
-        AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
+        AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), 
    		                         *gc, 
    		                         Rect(), 
    		                         innerrect,
@@ -1154,7 +1208,7 @@
     TInt baseLine = iFont->AscentInPixels()/2 + rect.Height()/2;
     
     TRect clipRect = 
-        TRect( TPoint(Rect().iTl.iX, rect.iTl.iY), TPoint( Rect().iBr.iX, rect.iBr.iY));    
+        TRect( TPoint(Rect().iTl.iX + 1, rect.iTl.iY), TPoint( Rect().iBr.iX - 1, rect.iBr.iY));
     
     gc->SetClippingRect( clipRect );
     gc->Clear( clipRect );
@@ -1164,7 +1218,7 @@
 
     if (iSkinIdSet)
         {
-   		AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
+   		AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), 
     	                         *gc, 
     	                         Rect(), 
     	                         Rect(),
@@ -1274,7 +1328,9 @@
         }
 
     TRAP_IGNORE(RecalcualteTextPositionL());        
-    SetMsgBubbleRect();
+    
+    //SetMsgBubbleRect();
+    SetMsgBubbleRectAccordingToLanguage();
     }
 
 void CFepLayoutMultiLineIcfEditor::ResetViewHeightL()
@@ -1326,6 +1382,31 @@
     iTextView->SetViewRect(iViewRect);
     }
 
+void CFepLayoutMultiLineIcfEditor::SetMsgBubbleRectAccordingToLanguage()
+	{
+	if ( iPreLanguageID == ELangPrcChinese || 
+		 iPreLanguageID == ELangHongKongChinese ||
+		 iPreLanguageID == ELangTaiwanChinese ||
+		 iPreLanguageID == ELangKorean )
+		{
+		SetMsgBubbleRect();
+		return;
+		}
+	else
+		{
+		if(( !iMsgBubble->IsShowing() && !iHideBubbleTemp ) ||
+				iLineMaxCount < 1 || iCursorSel.iCursorPos < 0 )
+			{
+			return;
+			}
+		
+		iMsgBubble->Popup( iMsgBubble->Rect());		        
+		iHideBubbleTemp = EFalse;
+		
+		return;
+		}
+	}
+
 void CFepLayoutMultiLineIcfEditor::SetMsgBubbleRect()
     {
     if( ( !iMsgBubble->IsShowing() && !iHideBubbleTemp ) ||
@@ -1566,7 +1647,9 @@
     iInfoBubble->SetRect( TRect(leftTop,aSize) ) ;        
     }
 
-void CFepLayoutMultiLineIcfEditor::ShowTooltipL(const TDesC& aText)
+void CFepLayoutMultiLineIcfEditor::ShowTooltipL( const TDesC& aText, 
+		                                         const TRect& aRect,
+		                                         TInt aLangCode )
 	{
 	if ( !iTooltip )
 	    {
@@ -1574,28 +1657,34 @@
 	    }
 
     iTooltip->SetTextL( aText );
-    TPoint tl = iInsertionPoint->Position();
+    iTooltip->SetLangCode( aLangCode );
+    TPoint tl( 0, 0 ), br( 0, 0 );
+    InlineTextPos( tl, br );    
+    
     if ( iLineMaxCount > 1 )
 	    {
 		TBool firstLine =  iLayout->FirstLineInBand() == iLineNumber;
 		if ( firstLine )
-		    {
-			tl.iY += iInsertionPoint->Height();
+		    {				
+		    tl.iY += KTooltipPosAdjustValueY;
 			}
 		else
 		    {
-			tl.iY -= iTooltip->Rect().Height();
+			tl.iY -= ( iFormatLineHeight + aRect.Height() - KTooltipPosAdjustValueY );			
 			}
-		}
-    TRect tooltipRect = TRect( tl, iTooltip->Rect().Size() );
+		}       
     
+    TRect tooltipRect = TRect( tl, aRect.Size() );
+    
+    // Make sure the right border of tooltip isn't be out of icf rect
     TInt moveX = tooltipRect.iBr.iX - Rect().iBr.iX;
     if ( moveX > 0 )
     	{
     	tooltipRect.iBr.iX -= moveX;
     	tooltipRect.iTl.iX -= moveX;
     	}
-		
+    
+    // Make sure tooltip isn't overlapped by msg bubble.
 	if ( tooltipRect.Intersects( iMsgBubble->Rect() ) )
 	    {
 		moveX = tooltipRect.iBr.iX - iMsgBubble->Rect().iTl.iX;
@@ -1610,7 +1699,13 @@
 	    	tooltipRect.iBr.iX += moveX;
 	    	tooltipRect.iTl.iX += moveX;
 	    	}
+	    }		
+
+	if (( iTooltip->Rect().iTl != tooltipRect.iTl ) && ( iTooltip->Rect().iBr != tooltipRect.iBr ))
+	    {
+        iTooltip->Close();
 	    }
+
     iTooltip->Popup( tooltipRect );
 	}
 
@@ -1634,15 +1729,15 @@
     }
 
 void CFepLayoutMultiLineIcfEditor::SizeChangedL(const TRect& aRect,
-                                                TInt aFontHeight,
-                                                TInt aMaxFontHeight,
+                                                TInt /*aFontHeight*/,
+                                                TInt /*aMaxFontHeight*/,
                                                 const CFont* aFont)
     {   
     TRect oriRect = Rect();
     
     AdjustBmpDeviceIfNeeded();
     // apply font formats 
-    SetFontL(aFontHeight, aMaxFontHeight, aFont);
+    SetFontL( aFont);
     
     if ( !iFormatChange && oriRect == aRect )
         {
@@ -1669,10 +1764,10 @@
 
     iLayout->SetAmountToFormat(CTextLayout::EFFormatAllText);    
     
-    if ( iFormatChange )
-        {
-        iTextView->HandleGlobalChangeNoRedrawL();
-        }
+//    if ( iFormatChange )
+//        {
+//        iTextView->HandleGlobalChangeNoRedrawL();
+//        }
     
     TBool ready = Ready();
     if( ready )
@@ -1686,13 +1781,19 @@
 	    SetReady( ETrue );    
 	    }
 
-    if ( iFormatChange )	    
-        {
-        iTextView->SetSelectionL( iTextView->Selection() );
-        RecalcualteTextPositionL();
-        SetMsgBubbleRect();
-        Draw();
-        }
+//    if ( iFormatChange )	    
+//        {
+//        iTextView->SetSelectionL( iTextView->Selection() );
+//        RecalcualteTextPositionL();
+//        SetMsgBubbleRect();
+//        Draw();
+//        }
+		iTextView->HandleGlobalChangeNoRedrawL();
+		iTextView->SetSelectionL( iTextView->Selection() );
+		RecalcualteTextPositionL();
+		//SetMsgBubbleRect();
+		SetMsgBubbleRectAccordingToLanguage();
+		Draw();
     }
 
 TBool CFepLayoutMultiLineIcfEditor::BelongToPromptText(TInt aPos)
@@ -1815,8 +1916,8 @@
             break;
         case CFepLayoutMultiLineIcf::EIcfAutoComplete:
             {
-            if (iTextView->Selection().iCursorPos >= iPreInlineStartPos && 
-                iTextView->Selection().iCursorPos < iPreInlineEndPos )
+            if ( iTextView->Selection().iCursorPos >= iPreInlineStartPos 
+                 && iTextView->Selection().iCursorPos < iPreAutoEndPos )
                 {
                 iPntDownOnInline = ETrue;
                 CapturePointer(EFalse);                 
@@ -1829,18 +1930,6 @@
                     ReportEvent(EEventPointerDownOnInline);
                     }
                 }
-            else
-                {
-                // do nothing
-                //submit autocomplete when set text
-                if (iTooltip && !iTooltip->IsShowing())
-                    {
-    	            ReportEvent( EEventControlFocusGained );
-                    UiLayout()->SignalOwner( ESignalCommitITIInlineText );
-			        SetInlineStateL( EFalse, iPreInlineStartPos, iPreInlineEndPos );
-			        SetAutoCompleteStateL( EFalse );
-                    }
-                }
             }
             break;
         case CFepLayoutMultiLineIcf::EIcfNormal:
@@ -1898,6 +1987,19 @@
         iCursorSel = TCursorSelection(cursorPos+iPromptTextLen, 
                                       iCursorSel.iAnchorPos);
         AdjustFepCursorPosForPromptText( ETrue );
+        
+        TAmPmName amName(EAm);
+        TAmPmName pmName(EPm);
+        TInt offset = iMfneIcfData->Find(amName)!= KErrNotFound?
+                        iMfneIcfData->Find(amName):iMfneIcfData->Find(pmName);
+	    //if current is 12-hour format and touch on correct position
+        if(offset != KErrNotFound &&
+           iCursorSel.LowerPos()-iPromptTextLen>= offset &&
+           iCursorSel.LowerPos()-iPromptTextLen<= offset+amName.Length())
+            {
+            UiLayout()->SignalOwner(ESignalChangeAmPm);
+            }
+
         return this;
         }
         
@@ -1926,10 +2028,6 @@
         else
             {
             AdjustFepCursorPosForPromptText( !iPntDownOnInline );
-            if(iState != CFepLayoutMultiLineIcf::EIcfNormal)
-                {
-                UiLayout()->SignalOwner( ESignalStartInlineText );
-                }
             }
         }
 
@@ -2066,7 +2164,7 @@
         {
         if ( iLastCursorPos != iCursorSel.iCursorPos ) 
             {
-            UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad);
+            UiLayout()->DoTactileFeedback(ETouchFeedbackEdit);
             iLastCursorPos = iCursorSel.iCursorPos;
             }
         }
@@ -2454,7 +2552,10 @@
     iCharFormat.iFontPresentation.iTextColor = iTextColor;
 
     // set prompt text as bold
-    iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, aPromptTextLen );//- 1
+    if( aPromptTextLen <= iRichText->DocumentLength() + 1)
+        {
+        iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, aPromptTextLen );//- 1
+        }
     iTextView->HandleRangeFormatChangeL(TCursorSelection(0, aPromptTextLen ), ETrue);//- 1
 
     // set remain text as non-bold
@@ -2492,12 +2593,13 @@
         
     iCharFormatMask.SetAttrib(aAttribute);
 
-    if (IsTextPosValid(aPreStartPos) && IsTextPosValid(aPreEndPos))
-        {
-        iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, 
+    // comment for updating format anyway.
+    //if (IsTextPosValid(aPreStartPos) && IsTextPosValid(aPreEndPos))
+        //{
+    iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, 
                                     iRichText->DocumentLength());
         //iTextView->HandleRangeFormatChangeL(TCursorSelection(aPreStartPos, aPreEndPos), ETrue);    
-        } 
+        //} 
 
     aPreStartPos = 0;
     aPreEndPos = 0;
@@ -2517,17 +2619,23 @@
             }
         iCharFormatMask.SetAttrib(aAttribute);
 
+        TInt aPos = Min( aStartPos, aEndPos );
+        TInt aLength = Abs( aEndPos - aStartPos );
         if (aNoMatchState)
             {
-            iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 
-                                        Min(aStartPos,aEndPos), Abs( aEndPos - aStartPos ) + 1);
-            iTextView->HandleRangeFormatChangeL(TCursorSelection(aStartPos, aEndPos + 1), ETrue);
+            if ( aPos >= 0 && aPos + aLength <= iRichText->DocumentLength())
+                {
+                iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, aPos, aLength + 1);
+                iTextView->HandleRangeFormatChangeL(TCursorSelection(aStartPos, aEndPos + 1), ETrue);
+                }
             }
         else
             {
-            iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 
-                                        Min(aStartPos,aEndPos), Abs( aEndPos - aStartPos ) );
-            iTextView->HandleRangeFormatChangeL(TCursorSelection(aStartPos, aEndPos), ETrue);
+            if ( aPos >= 0 && aPos + aLength <= iRichText->DocumentLength() + 1 )
+                {
+                iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, aStartPos, aLength );
+                iTextView->HandleRangeFormatChangeL(TCursorSelection(aStartPos, aEndPos), ETrue);
+                }
             }
 
         aPreStartPos = aStartPos;
@@ -2636,17 +2744,16 @@
     {
     TRAP_IGNORE(iMsgBubble->SetTextL(aText));
     iHideBubbleTemp = ETrue;
-    SetMsgBubbleRect();
+    //SetMsgBubbleRect();
+    SetMsgBubbleRectAccordingToLanguage();
     }
     
 void CFepLayoutMultiLineIcfEditor::ShowByteWarningBubble(const TDesC& aInfo)
     {
     TSize size = iInfoBubble->Rect().Size();
-    CFont::TMeasureTextInput*  input = new (ELeave) CFont::TMeasureTextInput;
-    CleanupStack::PushL(input);
-    input->iMaxBounds = iRect.Width();
-    TInt width = iFont->MeasureText(aInfo, input, NULL);
-    CleanupStack::PopAndDestroy();
+    CFont::TMeasureTextInput input;// = new (ELeave) CFont::TMeasureTextInput;
+    input.iMaxBounds = iRect.Width();
+    TInt width = iFont->MeasureText(aInfo, &input, NULL);
     size.SetSize(width, size.iHeight);
     SetInfoBubbleCtrlSize(size);
     TRAP_IGNORE(iInfoBubble->SetTextL(aInfo));
@@ -2674,7 +2781,7 @@
     {
     if( !iFormatChange )
         {
-        return;
+        return ;
         }
     //apply line space
     CParaFormat* paraFormat=CParaFormat::NewL();
@@ -2716,12 +2823,12 @@
     
 void CFepLayoutMultiLineIcfEditor::ResetApplyFont()
     {
-    TInt fontHeight = iFontHeight; 
-    TInt maxFontHeight = iMaxFontHeight;
+    //TInt fontHeight = iFontHeight; 
+    //TInt maxFontHeight = iMaxFontHeight;
     const CFont *font = iFont;
     
     iFontHeight = 0;
-    TRAP_IGNORE(SetFontL(fontHeight, maxFontHeight, font));
+    TRAP_IGNORE(SetFontL(font));
     }
 
 void CFepLayoutMultiLineIcfEditor::TryDisplayMaxTextL( TInt aCursorPos )
@@ -2738,7 +2845,8 @@
             {
             iTextView->SetViewLineAtTopL(( lineIndex + 1 ) - ( iLineMaxCount - 1 ));
             RecalcualteTextPositionL();
-            SetMsgBubbleRect();
+            //SetMsgBubbleRect();
+            SetMsgBubbleRectAccordingToLanguage();
             }
         }
     
@@ -2757,7 +2865,8 @@
                                    lineCount - pageCount + 1 < 1 ? 1 : lineCount - pageCount + 1 );
             
             RecalcualteTextPositionL();
-            SetMsgBubbleRect();
+            //SetMsgBubbleRect();
+            SetMsgBubbleRectAccordingToLanguage();
             }
         }
     }
@@ -2795,13 +2904,13 @@
    
     if ( BelongToPromptText(aCurSel.iCursorPos) )
         {
-        //pls refer to bug: ELWG-7MZ5EZ, why to use iPromptText->Length() instead of iPromptTextLen 
+        //why to use iPromptText->Length() instead of iPromptTextLen 
         //iCursorSel.iCursorPos = iPromptTextLen;
         iCursorSel.iCursorPos = iPromptText->Length();
         }
     if ( BelongToPromptText(aCurSel.iAnchorPos) )
         {
-        //pls refer to bug: ELWG-7MZ5EZ, why to use iPromptText->Length() instead of iPromptTextLen
+        //why to use iPromptText->Length() instead of iPromptTextLen
         //iCursorSel.iAnchorPos = iPromptTextLen;
         iCursorSel.iAnchorPos = iPromptText->Length();
         }
@@ -2885,7 +2994,7 @@
     }
 
 void CFepLayoutMultiLineIcfEditor::CalcSmileyClipRegionL( RRegion& aRgn, 
-                                                          CGraphicsContext& aGc, 
+                                                          CGraphicsContext& /*aGc*/, 
                                                           CFont& aFont,  
                                                           const TDesC& aText, 
                                                           TPoint& aBasePoint, 
@@ -2961,7 +3070,6 @@
             CPeninputSmileyImage* smiley = iSmileyManager->SmileyImage( code );
             if ( smiley )
                 {
-                gc.SetBrushColor( TRgb(255,0,0) );
                 gc.SetBrushStyle( CGraphicsContext::ENullBrush );
                 
                 smiley->SetImageSize( rect.Size() );