51 const TInt KSecretInstantShowTimer = 100000; // 100ms |
51 const TInt KSecretInstantShowTimer = 100000; // 100ms |
52 |
52 |
53 const TUint16 KSegment = 0x0020; |
53 const TUint16 KSegment = 0x0020; |
54 // separator between prompt text and normal text, |
54 // separator between prompt text and normal text, |
55 // should use localized character soon |
55 // should use localized character soon |
56 const TUint16 KSeparator = 0x003a; |
56 //const TUint16 KSeparator = 0x003a; |
57 const TUint16 KSeparatorcn = 0xff1a; |
57 //const TUint16 KSeparatorcn = 0xff1a; |
|
58 const TUint16 KColon = 0x003a; |
|
59 const TUint16 KColoncn = 0xff1a; |
58 _LIT(KLineSeparator, "\n"); |
60 _LIT(KLineSeparator, "\n"); |
59 const TInt KStar = '*'; |
61 const TInt KStar = '*'; |
60 |
62 |
61 const TInt KMaxMfneDataLen = 30; |
63 const TInt KMaxMfneDataLen = 30; |
62 // Message bubble position adjust |
64 // Message bubble position adjust |
63 const TInt KMsgBubblePosAdjustValueX = 3; |
65 const TInt KMsgBubblePosAdjustValueX = 3; |
64 const TInt KMsgBubblePosAdjustValueY = 2; |
66 const TInt KMsgBubblePosAdjustValueY = 2; |
65 const TInt KPromptAdjustLen = 5; |
67 const TInt KPromptAdjustLen = 5; |
|
68 // Tooltip position adjust |
|
69 const TInt KTooltipPosAdjustValueY = 5; |
|
70 |
66 EXPORT_C CFepLayoutMultiLineIcfEditor* CFepLayoutMultiLineIcfEditor::NewL(TRect aRect, |
71 EXPORT_C CFepLayoutMultiLineIcfEditor* CFepLayoutMultiLineIcfEditor::NewL(TRect aRect, |
67 CFepUiLayout* aUiLayout, |
72 CFepUiLayout* aUiLayout, |
68 TInt aControlId, |
73 TInt aControlId, |
69 TInt aFontHeight, |
74 TInt aFontHeight, |
70 TInt aMaxFontHeight, |
75 TInt aMaxFontHeight, |
145 if(iFormExtendedInterfaceProvider) |
150 if(iFormExtendedInterfaceProvider) |
146 { |
151 { |
147 delete iFormExtendedInterfaceProvider; |
152 delete iFormExtendedInterfaceProvider; |
148 iFormExtendedInterfaceProvider = NULL; |
153 iFormExtendedInterfaceProvider = NULL; |
149 } |
154 } |
150 |
155 iCoeEnv->ScreenDevice()->ReleaseFont(CONST_CAST(CFont*, iFont)); |
151 delete iSmileyManager; |
156 delete iSmileyManager; |
152 } |
157 } |
153 |
158 |
154 void CFepLayoutMultiLineIcfEditor::InitTextLayoutL() |
159 void CFepLayoutMultiLineIcfEditor::InitTextLayoutL(const CFont *aFont) |
155 { |
160 { |
156 iParaFormatLayer=CParaFormatLayer::NewL(); |
161 iParaFormatLayer=CParaFormatLayer::NewL(); |
157 iCharFormatLayer=CCharFormatLayer::NewL(); |
162 iCharFormatLayer=CCharFormatLayer::NewL(); |
158 |
163 |
159 iRichText = CRichText::NewL(iParaFormatLayer, iCharFormatLayer); |
164 iRichText = CRichText::NewL(iParaFormatLayer, iCharFormatLayer); |
179 // when (screen resolution changed) |
184 // when (screen resolution changed) |
180 //iCtrl = new (ELeave) CCoeControl; |
185 //iCtrl = new (ELeave) CCoeControl; |
181 //iCtrl->SetContainerWindowL(*iWin); |
186 //iCtrl->SetContainerWindowL(*iWin); |
182 //iWin->Construct(iCoeEnv->RootWin(),reinterpret_cast<TInt>(iCtrl)); |
187 //iWin->Construct(iCoeEnv->RootWin(),reinterpret_cast<TInt>(iCtrl)); |
183 //ctrl->SetExtent(iViewRect.iTl, iViewRect.Size()); |
188 //ctrl->SetExtent(iViewRect.iTl, iViewRect.Size()); |
184 |
189 SetFontL(aFont); |
185 iTextView = CTextView::NewL(iLayout, |
190 iTextView = CTextView::NewL(iLayout, |
186 iViewRect, |
191 iViewRect, |
187 BitmapDevice(), |
192 BitmapDevice(), |
188 iCoeEnv->ScreenDevice(), |
193 iCoeEnv->ScreenDevice(), |
189 iWin, |
194 iWin, |
266 CleanupStack::PopAndDestroy(paraFormat); |
271 CleanupStack::PopAndDestroy(paraFormat); |
267 |
272 |
268 iAlignment = aAlignment; |
273 iAlignment = aAlignment; |
269 } |
274 } |
270 |
275 |
271 void CFepLayoutMultiLineIcfEditor::BaseConstructL(TInt aFontHeight, |
276 void CFepLayoutMultiLineIcfEditor::BaseConstructL(TInt /*aFontHeight*/, |
272 TInt aMaxFontHeight, |
277 TInt /*aMaxFontHeight*/, |
273 const CFont* aFont) |
278 const CFont* aFont) |
274 { |
279 { |
275 CFepUiBaseCtrl::BaseConstructL(); |
280 CFepUiBaseCtrl::BaseConstructL(); |
276 |
281 |
277 iCoeEnv = CCoeEnv::Static(); |
282 iCoeEnv = CCoeEnv::Static(); |
278 //iMaxFontHeight = aMaxFontHeight; |
283 //iMaxFontHeight = aMaxFontHeight; |
279 //iFontHeight = aFontHeight; |
284 //iFontHeight = aFontHeight; |
280 //iFont = aFont; |
285 //iFont = aFont; |
281 InitTextLayoutL(); |
286 InitTextLayoutL(aFont); |
282 iInsertionPoint = UiLayout()->CreateCursor(); |
287 iInsertionPoint = UiLayout()->CreateCursor(); |
283 iInsertionPoint->SetOwner(this); |
288 iInsertionPoint->SetOwner(this); |
284 SetFontL(aFontHeight, aMaxFontHeight, aFont); |
289 //SetFontL(aFont); |
285 |
290 |
286 iSecretTextTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
291 iSecretTextTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
287 |
292 |
288 SetAutoCompleteTextColor(KRgbGray); |
293 SetAutoCompleteTextColor(KRgbGray); |
289 |
294 |
428 prompttextLen = aPromptText.Length() + TBidiLogicalToVisual::KMinCharAvailable + 3 : |
433 prompttextLen = aPromptText.Length() + TBidiLogicalToVisual::KMinCharAvailable + 3 : |
429 prompttextLen = aPromptText.Length() + TBidiLogicalToVisual::KMinCharAvailable + 2; |
434 prompttextLen = aPromptText.Length() + TBidiLogicalToVisual::KMinCharAvailable + 2; |
430 iPromptText = HBufC::NewL(prompttextLen); |
435 iPromptText = HBufC::NewL(prompttextLen); |
431 TPtr text = iPromptText->Des(); |
436 TPtr text = iPromptText->Des(); |
432 |
437 |
433 TBuf<1> ptr0; |
438 TBuf<1> ptrEllipsis; |
434 ptr0.Append( KEllipsis ); |
439 ptrEllipsis.Append( KEllipsis ); |
435 |
440 |
436 TPtrC ptr1(&KSegment, 1); |
441 TPtrC ptrSpace(&KSegment, 1); |
437 TPtrC ptr2(&KSeparator, 1); |
442 TPtrC ptrColon(&KColon, 1); |
438 |
443 |
439 TInt separatorLen = TextWidth(ptr1) + TextWidth(ptr2) + TextWidth(ptr0); |
444 TInt separatorLen = TextWidth(ptrSpace) + TextWidth(ptrColon) + TextWidth(ptrEllipsis); |
440 TInt textWidth = TextWidth(aPromptText) + separatorLen; |
445 TInt textWidth = TextWidth(aPromptText); |
441 TBool ret = EFalse; |
446 |
442 |
447 if ((aPromptText.LocateReverse(KColon) != aPromptText.Length() - 1) && |
443 if (textWidth >= iViewRect.Width() ) |
448 (aPromptText.LocateReverse(KColoncn) != aPromptText.Length() - 1)) |
444 { |
449 { |
445 ret = ETrue; |
450 textWidth += TextWidth(ptrSpace) + TextWidth(ptrColon); |
|
451 } |
|
452 |
|
453 else |
|
454 { |
|
455 textWidth += TextWidth(ptrSpace); |
|
456 } |
|
457 |
|
458 TBool truncated = EFalse; |
|
459 |
|
460 if (textWidth > iViewRect.Width() ) |
|
461 { |
|
462 truncated = ETrue; |
446 AknBidiTextUtils::ConvertToVisualAndClip(aPromptText, |
463 AknBidiTextUtils::ConvertToVisualAndClip(aPromptText, |
447 text, |
464 text, |
448 *iFont, |
465 *iFont, |
449 iViewRect.Width() - separatorLen - KPromptAdjustLen, |
466 iViewRect.Width() - separatorLen - KPromptAdjustLen, |
450 iViewRect.Width() - separatorLen - KPromptAdjustLen, |
467 iViewRect.Width() - separatorLen - KPromptAdjustLen, |
462 for ( ;(text.Length() > 0 && text.LocateReverse(KSegment) == text.Length()-1 ); ) |
479 for ( ;(text.Length() > 0 && text.LocateReverse(KSegment) == text.Length()-1 ); ) |
463 { |
480 { |
464 text.Delete( text.Length()-1, 1 ); |
481 text.Delete( text.Length()-1, 1 ); |
465 } |
482 } |
466 |
483 |
467 if ((text.LocateReverse(KSeparator) != text.Length() - 1) && |
484 if ((text.LocateReverse(KColon) != text.Length() - 1) && |
468 (text.LocateReverse(KSeparatorcn) != text.Length() - 1)) |
485 (text.LocateReverse(KColoncn) != text.Length() - 1)) |
469 { |
486 { |
470 // if sent prompt text already include separator, then no need to |
487 // if sent prompt text already include separator, then no need to |
471 // append it again |
488 // append it again |
472 if ( ret ) |
489 if (truncated) |
473 { |
490 { |
474 text.Append( ptr0 ); |
491 text.Append( ptrEllipsis ); |
475 } |
492 } |
476 text.Append(ptr2); |
493 text.Append(ptrColon); |
477 } |
494 } |
478 else if ( ret ) |
495 else if (truncated) |
479 { |
496 { |
480 text.Insert( text.Length()-1, ptr0 ); |
497 text.Insert( text.Length()-1, ptrEllipsis ); |
481 } |
498 } |
482 |
499 |
483 text.Append(ptr1); // segment between prompt text and official text |
500 text.Append(ptrSpace); // segment between prompt text and official text |
484 textWidth = TextWidth(text); |
501 textWidth = TextWidth(text); |
485 |
502 |
486 iRichText->InsertL(0, text); |
503 iRichText->InsertL(0, text); |
487 iTextView->HandleInsertDeleteL(TCursorSelection(0, text.Length()), |
504 iTextView->HandleInsertDeleteL(TCursorSelection(0, text.Length()), |
488 0); |
505 0); |
991 void CFepLayoutMultiLineIcfEditor::SetDimmed(TBool aDimFlag) |
1008 void CFepLayoutMultiLineIcfEditor::SetDimmed(TBool aDimFlag) |
992 { |
1009 { |
993 iDimmed = aDimFlag; |
1010 iDimmed = aDimFlag; |
994 } |
1011 } |
995 |
1012 |
996 void CFepLayoutMultiLineIcfEditor::SetFontL(TInt aFontHeight, |
1013 void CFepLayoutMultiLineIcfEditor::SetFontL(const CFont* aFont) |
997 TInt aMaxFontHeight, |
1014 { |
998 const CFont* aFont) |
1015 TInt newHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(aFont->HeightInPixels()); |
999 { |
|
1000 TInt newHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(aFontHeight); |
|
1001 TInt OldHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(iFontHeight); |
1016 TInt OldHeightInPixel = iCoeEnv->ScreenDevice()->VerticalPixelsToTwips(iFontHeight); |
1002 |
1017 |
1003 if( newHeightInPixel == OldHeightInPixel ) |
1018 if( newHeightInPixel == OldHeightInPixel ) |
1004 { |
1019 { |
1005 return; |
1020 return; |
1007 else |
1022 else |
1008 { |
1023 { |
1009 iFormatChange = ETrue; |
1024 iFormatChange = ETrue; |
1010 } |
1025 } |
1011 |
1026 |
1012 iMaxFontHeight = aMaxFontHeight; |
1027 TFontSpec fontSpec; |
1013 iFontHeight = aFontHeight; |
1028 fontSpec.iHeight = aFont->HeightInPixels(); |
1014 iFont = aFont; |
1029 CFont* font; |
|
1030 iCoeEnv->ScreenDevice()->ReleaseFont(CONST_CAST(CFont*, iFont)); |
|
1031 iCoeEnv->ScreenDevice()->GetNearestFontInPixels((CFont*&)font,fontSpec); |
|
1032 |
|
1033 iMaxFontHeight = font->FontMaxHeight(); |
|
1034 iFontHeight = font->HeightInPixels(); |
|
1035 iFont = font; |
1015 |
1036 |
1016 |
1037 |
1017 iCharFormatMask.ClearAttrib( EAttFontUnderline ); |
1038 iCharFormatMask.ClearAttrib( EAttFontUnderline ); |
1018 iCharFormatMask.SetAttrib(EAttFontHeight); |
1039 iCharFormatMask.SetAttrib(EAttFontHeight); |
1019 iCharFormatMask.SetAttrib(EAttFontStrokeWeight); |
1040 iCharFormatMask.SetAttrib(EAttFontStrokeWeight); |
1564 { |
1585 { |
1565 TPoint leftTop = TPoint(Rect().iBr.iX-iInfoBubble->Rect().Width(),Rect().iTl.iY); |
1586 TPoint leftTop = TPoint(Rect().iBr.iX-iInfoBubble->Rect().Width(),Rect().iTl.iY); |
1566 iInfoBubble->SetRect( TRect(leftTop,aSize) ) ; |
1587 iInfoBubble->SetRect( TRect(leftTop,aSize) ) ; |
1567 } |
1588 } |
1568 |
1589 |
1569 void CFepLayoutMultiLineIcfEditor::ShowTooltipL(const TDesC& aText) |
1590 void CFepLayoutMultiLineIcfEditor::ShowTooltipL( const TDesC& aText, |
|
1591 const TRect& aRect ) |
1570 { |
1592 { |
1571 if ( !iTooltip ) |
1593 if ( !iTooltip ) |
1572 { |
1594 { |
1573 return; |
1595 return; |
1574 } |
1596 } |
1575 |
1597 |
1576 iTooltip->SetTextL( aText ); |
1598 iTooltip->SetTextL( aText ); |
1577 TPoint tl = iInsertionPoint->Position(); |
1599 TPoint tl( 0, 0 ), br( 0, 0 ); |
|
1600 InlineTextPos( tl, br ); |
|
1601 |
1578 if ( iLineMaxCount > 1 ) |
1602 if ( iLineMaxCount > 1 ) |
1579 { |
1603 { |
1580 TBool firstLine = iLayout->FirstLineInBand() == iLineNumber; |
1604 TBool firstLine = iLayout->FirstLineInBand() == iLineNumber; |
1581 if ( firstLine ) |
1605 if ( firstLine ) |
1582 { |
1606 { |
1583 tl.iY += iInsertionPoint->Height(); |
1607 tl.iY += KTooltipPosAdjustValueY; |
1584 } |
1608 } |
1585 else |
1609 else |
1586 { |
1610 { |
1587 tl.iY -= iTooltip->Rect().Height(); |
1611 tl.iY -= ( iFormatLineHeight + aRect.Height() - KTooltipPosAdjustValueY ); |
1588 } |
1612 } |
1589 } |
1613 } |
1590 TRect tooltipRect = TRect( tl, iTooltip->Rect().Size() ); |
1614 |
1591 |
1615 TRect tooltipRect = TRect( tl, aRect.Size() ); |
|
1616 |
|
1617 // Make sure the right border of tooltip isn't be out of icf rect |
1592 TInt moveX = tooltipRect.iBr.iX - Rect().iBr.iX; |
1618 TInt moveX = tooltipRect.iBr.iX - Rect().iBr.iX; |
1593 if ( moveX > 0 ) |
1619 if ( moveX > 0 ) |
1594 { |
1620 { |
1595 tooltipRect.iBr.iX -= moveX; |
1621 tooltipRect.iBr.iX -= moveX; |
1596 tooltipRect.iTl.iX -= moveX; |
1622 tooltipRect.iTl.iX -= moveX; |
1597 } |
1623 } |
1598 |
1624 |
|
1625 // Make sure tooltip isn't overlapped by msg bubble. |
1599 if ( tooltipRect.Intersects( iMsgBubble->Rect() ) ) |
1626 if ( tooltipRect.Intersects( iMsgBubble->Rect() ) ) |
1600 { |
1627 { |
1601 moveX = tooltipRect.iBr.iX - iMsgBubble->Rect().iTl.iX; |
1628 moveX = tooltipRect.iBr.iX - iMsgBubble->Rect().iTl.iX; |
1602 if ( moveX > 0 && tooltipRect.iTl.iX - moveX >= Rect().iTl.iX ) |
1629 if ( moveX > 0 && tooltipRect.iTl.iX - moveX >= Rect().iTl.iX ) |
1603 { |
1630 { |
1608 if ( moveX > 0 && tooltipRect.iBr.iX + moveX <= Rect().iBr.iX ) |
1635 if ( moveX > 0 && tooltipRect.iBr.iX + moveX <= Rect().iBr.iX ) |
1609 { |
1636 { |
1610 tooltipRect.iBr.iX += moveX; |
1637 tooltipRect.iBr.iX += moveX; |
1611 tooltipRect.iTl.iX += moveX; |
1638 tooltipRect.iTl.iX += moveX; |
1612 } |
1639 } |
1613 } |
1640 } |
1614 iTooltip->Popup( tooltipRect ); |
1641 iTooltip->Popup( tooltipRect ); |
1615 } |
1642 } |
1616 |
1643 |
1617 void CFepLayoutMultiLineIcfEditor::HideTooltip() |
1644 void CFepLayoutMultiLineIcfEditor::HideTooltip() |
1618 { |
1645 { |
1813 |
1840 |
1814 } |
1841 } |
1815 break; |
1842 break; |
1816 case CFepLayoutMultiLineIcf::EIcfAutoComplete: |
1843 case CFepLayoutMultiLineIcf::EIcfAutoComplete: |
1817 { |
1844 { |
1818 if (iTextView->Selection().iCursorPos >= iPreInlineStartPos && |
1845 if ( iTextView->Selection().iCursorPos >= iPreInlineStartPos |
1819 iTextView->Selection().iCursorPos < iPreInlineEndPos ) |
1846 && iTextView->Selection().iCursorPos < iPreAutoEndPos ) |
1820 { |
1847 { |
1821 iPntDownOnInline = ETrue; |
1848 iPntDownOnInline = ETrue; |
1822 CapturePointer(EFalse); |
1849 CapturePointer(EFalse); |
1823 if (iTooltip && iTooltip->IsShowing()) |
1850 if (iTooltip && iTooltip->IsShowing()) |
1824 { |
1851 { |
1827 else |
1854 else |
1828 { |
1855 { |
1829 ReportEvent(EEventPointerDownOnInline); |
1856 ReportEvent(EEventPointerDownOnInline); |
1830 } |
1857 } |
1831 } |
1858 } |
1832 else |
|
1833 { |
|
1834 // do nothing |
|
1835 //submit autocomplete when set text |
|
1836 if (iTooltip && !iTooltip->IsShowing()) |
|
1837 { |
|
1838 ReportEvent( EEventControlFocusGained ); |
|
1839 UiLayout()->SignalOwner( ESignalCommitITIInlineText ); |
|
1840 SetInlineStateL( EFalse, iPreInlineStartPos, iPreInlineEndPos ); |
|
1841 SetAutoCompleteStateL( EFalse ); |
|
1842 } |
|
1843 } |
|
1844 } |
1859 } |
1845 break; |
1860 break; |
1846 case CFepLayoutMultiLineIcf::EIcfNormal: |
1861 case CFepLayoutMultiLineIcf::EIcfNormal: |
1847 { |
1862 { |
1848 if (preCursorPos != iCursorSel.iCursorPos) |
1863 if (preCursorPos != iCursorSel.iCursorPos) |
2490 return; |
2501 return; |
2491 } |
2502 } |
2492 |
2503 |
2493 iCharFormatMask.SetAttrib(aAttribute); |
2504 iCharFormatMask.SetAttrib(aAttribute); |
2494 |
2505 |
2495 if (IsTextPosValid(aPreStartPos) && IsTextPosValid(aPreEndPos)) |
2506 // comment for updating format anyway. |
2496 { |
2507 //if (IsTextPosValid(aPreStartPos) && IsTextPosValid(aPreEndPos)) |
2497 iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, |
2508 //{ |
|
2509 iRichText->ApplyCharFormatL(iCharFormat, iCharFormatMask, 0, |
2498 iRichText->DocumentLength()); |
2510 iRichText->DocumentLength()); |
2499 //iTextView->HandleRangeFormatChangeL(TCursorSelection(aPreStartPos, aPreEndPos), ETrue); |
2511 //iTextView->HandleRangeFormatChangeL(TCursorSelection(aPreStartPos, aPreEndPos), ETrue); |
2500 } |
2512 //} |
2501 |
2513 |
2502 aPreStartPos = 0; |
2514 aPreStartPos = 0; |
2503 aPreEndPos = 0; |
2515 aPreEndPos = 0; |
2504 |
2516 |
2505 if (aStateOn) |
2517 if (aStateOn) |
2714 } |
2726 } |
2715 } |
2727 } |
2716 |
2728 |
2717 void CFepLayoutMultiLineIcfEditor::ResetApplyFont() |
2729 void CFepLayoutMultiLineIcfEditor::ResetApplyFont() |
2718 { |
2730 { |
2719 TInt fontHeight = iFontHeight; |
2731 //TInt fontHeight = iFontHeight; |
2720 TInt maxFontHeight = iMaxFontHeight; |
2732 //TInt maxFontHeight = iMaxFontHeight; |
2721 const CFont *font = iFont; |
2733 const CFont *font = iFont; |
2722 |
2734 |
2723 iFontHeight = 0; |
2735 iFontHeight = 0; |
2724 TRAP_IGNORE(SetFontL(fontHeight, maxFontHeight, font)); |
2736 TRAP_IGNORE(SetFontL(font)); |
2725 } |
2737 } |
2726 |
2738 |
2727 void CFepLayoutMultiLineIcfEditor::TryDisplayMaxTextL( TInt aCursorPos ) |
2739 void CFepLayoutMultiLineIcfEditor::TryDisplayMaxTextL( TInt aCursorPos ) |
2728 { |
2740 { |
2729 iTextView->FinishBackgroundFormattingL(); |
2741 iTextView->FinishBackgroundFormattingL(); |