uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 72 a5e7a4f63858
parent 64 85902f042028
equal deleted inserted replaced
64:85902f042028 72:a5e7a4f63858
    95 #include <eikrted.h>
    95 #include <eikrted.h>
    96 #include <NumberGroupingCRKeys.h>
    96 #include <NumberGroupingCRKeys.h>
    97 #include <aknpointereventsuppressor.h>
    97 #include <aknpointereventsuppressor.h>
    98 #include <aknnotedialog.h>
    98 #include <aknnotedialog.h>
    99 #include <AknFepGlobalEnums.h>
    99 #include <AknFepGlobalEnums.h>
   100 #include <AknSmileyUtils.h>
   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 
       
   105 // for supporting TapToWrite
       
   106 #include <AvkonInternalCRKeys.h>
       
   107 #include <e32property.h>
       
   108 #include <AknFepInternalPSKeys.h>
       
   109 #include <AknFontAccess.h>
       
   110 #include <AvkonInternalCRKeys.h>  // KAknQwertyInputModeActive
       
   111 
   104 
   112 // declare function
   105 // declare function
   113 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId );
   106 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId );
   114 void ReadSCTHeadPane( TResourceReader& aReader );
   107 void ReadSCTHeadPane( TResourceReader& aReader );
   115 
   108 
   162 
   155 
   163 const TInt KNmericSCTLimit( 256 );
   156 const TInt KNmericSCTLimit( 256 );
   164 const TInt KTInt16Length( sizeof( TInt16 ) );
   157 const TInt KTInt16Length( sizeof( TInt16 ) );
   165 const TInt KTInt32Length( sizeof( TInt32 ) );
   158 const TInt KTInt32Length( sizeof( TInt32 ) );
   166 const TInt KTUint32Length( sizeof( TUint32 ) );
   159 const TInt KTUint32Length( sizeof( TUint32 ) );
   167 const TInt KBlackMap( 179 );
       
   168 const TInt KWhiteMap( 76 );
       
   169 _LIT( KParagraphSeparator, "\x2029" );
       
   170 TRgb FadeRgb( TRgb aColor, TUint8 aBlackMap, TUint8 aWhiteMap );
       
   171 
   160 
   172 //
   161 //
   173 // class CEikEdwin::CUndoBuffer
   162 // class CEikEdwin::CUndoBuffer
   174 //
   163 //
   175 
   164 
   515                 }
   504                 }
   516             }
   505             }
   517         }
   506         }
   518     iEdwin.iTextView->HandleInsertDeleteL( select, aNumberOfCharactersSuccessfullyDeleted,
   507     iEdwin.iTextView->HandleInsertDeleteL( select, aNumberOfCharactersSuccessfullyDeleted,
   519         aParagraphContainingStartPositionOfInlineTextHasChangedFormat );
   508         aParagraphContainingStartPositionOfInlineTextHasChangedFormat );
   520     // try to draw "tap to write"
       
   521     iEdwin.TryToDrawT2W();
       
   522     
       
   523     User::LeaveIfError(aError);
   509     User::LeaveIfError(aError);
   524     iEdwin.SetScrollBarsL();
   510     iEdwin.SetScrollBarsL();
   525     iEdwin.DoReportEventL(MCoeControlObserver::EEventStateChanged);
   511     iEdwin.DoReportEventL(MCoeControlObserver::EEventStateChanged);
   526     if (aParagraphContainingStartPositionOfInlineTextHasChangedFormat)
   512     if (aParagraphContainingStartPositionOfInlineTextHasChangedFormat)
   527         {
   513         {
   810         // Replace all 'i' following smiley code to invisbile placeholder for
   796         // Replace all 'i' following smiley code to invisbile placeholder for
   811         // Touch Input can not recognize it as part of smiley code string.
   797         // Touch Input can not recognize it as part of smiley code string.
   812         TInt smileyEndPos( 0 );
   798         TInt smileyEndPos( 0 );
   813         for ( TInt i( 0 ); i < length; i++ )
   799         for ( TInt i( 0 ); i < length; i++ )
   814             {
   800             {
   815             if ( aEditorContent[i] == CAknSmileyManager::KCompensateChar )
   801             if ( aEditorContent[i] == CSmileyManager::KCompensateChar )
   816                 {
   802                 {
   817                 // when 'i' is the first character, it is unkonwn whether it is
   803                 // when 'i' is the first character, it is unkonwn whether it is
   818                 // part of a smiley code string or not, so we have to use another 
   804                 // part of a smiley code string or not, so we have to use another 
   819                 // function to decide.
   805                 // function to decide.
   820                 if ( ( i > 0 && i < smileyEndPos ) ||
   806                 if ( ( i > 0 && i < smileyEndPos ) ||
   821                      ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) )
   807                      ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) )
   822                     {
   808                     {
   823                     aEditorContent[i] = CAknSmileyManager::KPlaceHolder;
   809                     aEditorContent[i] = CSmileyManager::KPlaceHolder;
   824                     }
   810                     }
   825                 }
   811                 }
   826             else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
   812             else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
   827                 {
   813                 {
   828                 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
   814                 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
  1075         {
  1061         {
  1076         iCenRepNotifyHandler->StopListening();
  1062         iCenRepNotifyHandler->StopListening();
  1077         }
  1063         }
  1078     delete iCenRepNotifyHandler;
  1064     delete iCenRepNotifyHandler;
  1079     delete iCenRep;
  1065     delete iCenRep;
  1080     
       
  1081     // Stop listening CenRep for qwerty key board.
       
  1082     if ( iCenRepNotifyHandlerForQwerty )
       
  1083         {
       
  1084         iCenRepNotifyHandlerForQwerty->StopListening();
       
  1085         }
       
  1086     delete iCenRepNotifyHandlerForQwerty;
       
  1087     delete iCenRepForQwerty;
       
  1088 
  1066 
  1089     delete iFormAccessor;
  1067     delete iFormAccessor;
  1090     delete iFormCursorModifier;
  1068     delete iFormCursorModifier;
  1091     delete iFormExtendedInterfaceProvider;
  1069     delete iFormExtendedInterfaceProvider;
  1092     delete iPictographInterface;
  1070     delete iPictographInterface;
  1096         {
  1074         {
  1097         // Mark the object as destroyed.
  1075         // Mark the object as destroyed.
  1098         *iDestroyedPtr = ETrue;
  1076         *iDestroyedPtr = ETrue;
  1099         iDestroyedPtr = NULL;
  1077         iDestroyedPtr = NULL;
  1100         }
  1078         }
  1101     delete iT2WBuf;
       
  1102     delete iSmiley;
  1079     delete iSmiley;
  1103     delete iSmileyWrap;
  1080     delete iSmileyWrap;
  1104     }
  1081     }
  1105 
  1082 
  1106 EXPORT_C CAknEdwinFormAccessor* CEikEdwin::CEikEdwinExtension::FormAccessor() const
  1083 EXPORT_C CAknEdwinFormAccessor* CEikEdwin::CEikEdwinExtension::FormAccessor() const
  1234             KAknFepClearDirection);
  1211             KAknFepClearDirection);
  1235 
  1212 
  1236         iCenRepNotifyHandler->StartListeningL();
  1213         iCenRepNotifyHandler->StartListeningL();
  1237         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1214         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1238         }
  1215         }
  1239     // Start listening a CenRep key indicating whether qwerty input mode is active.
       
  1240     TRAPD( error, iCenRepForQwerty = CRepository::NewL( KCRUidAvkon ) );
       
  1241     if ( error == KErrNone )
       
  1242         {
       
  1243         iCenRepNotifyHandlerForQwerty = CCenRepNotifyHandler::NewL( *this,
       
  1244             *iCenRepForQwerty,
       
  1245             CCenRepNotifyHandler::EIntKey,
       
  1246             KAknQwertyInputModeActive );
       
  1247 
       
  1248         iCenRepNotifyHandlerForQwerty->StartListeningL();
       
  1249         iCenRepForQwerty->Get( KAknQwertyInputModeActive, iQwertyStatus );
       
  1250         }
       
  1251     
       
  1252     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
  1216     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
  1253     iSkinInstance = AknsUtils::SkinInstance();
  1217     iSkinInstance = AknsUtils::SkinInstance();
  1254     }
  1218     }
  1255 
  1219 
  1256 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1220 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1335 void CEikEdwin::CEikEdwinExtension::HandleNotifyInt(TUint32 aId, TInt aNewValue)
  1299 void CEikEdwin::CEikEdwinExtension::HandleNotifyInt(TUint32 aId, TInt aNewValue)
  1336     {
  1300     {
  1337     if (aId == KAknFepClearDirection)
  1301     if (aId == KAknFepClearDirection)
  1338         {
  1302         {
  1339         iClearDirection = (TBool)aNewValue;
  1303         iClearDirection = (TBool)aNewValue;
  1340         }
       
  1341     //If qwerty key board is opened clean the "tap to write", if qwerty key board is closed display the "tap to write"
       
  1342     else if ( aId == KAknQwertyInputModeActive )
       
  1343         {
       
  1344         iQwertyStatus = ( TBool )aNewValue;
       
  1345         iEdwin->TryToDrawT2W( iQwertyStatus );
       
  1346         }
  1304         }
  1347     }
  1305     }
  1348 
  1306 
  1349 // ---------------------------------------------------------------------------
  1307 // ---------------------------------------------------------------------------
  1350 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  1308 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  2326             DeleteHighlightL(formatHasChanged,code==EKeyBackspace);
  2284             DeleteHighlightL(formatHasChanged,code==EKeyBackspace);
  2327             const TInt lower=toDelete.LowerPos();
  2285             const TInt lower=toDelete.LowerPos();
  2328             const TCursorSelection sel(lower,lower);
  2286             const TCursorSelection sel(lower,lower);
  2329             iTextView->SetPendingSelection(sel);
  2287             iTextView->SetPendingSelection(sel);
  2330             iTextView->HandleInsertDeleteL(sel,toDelete.Length(),formatHasChanged);
  2288             iTextView->HandleInsertDeleteL(sel,toDelete.Length(),formatHasChanged);
  2331             // try to draw "tap to write"
       
  2332             TryToDrawT2W();
       
  2333             cursorPos = lower;
  2289             cursorPos = lower;
  2334             reportChange=ETrue;
  2290             reportChange=ETrue;
  2335             }
  2291             }
  2336         else if ( replaceSelection ) // All neutral protection cases 
  2292         else if ( replaceSelection ) // All neutral protection cases 
  2337             {
  2293             {
  2387                 TCursorSelection selection=(isPicture? TCursorSelection(cursorPos,cursorPos+1) : TCursorSelection(cursorPos,cursorPos));
  2343                 TCursorSelection selection=(isPicture? TCursorSelection(cursorPos,cursorPos+1) : TCursorSelection(cursorPos,cursorPos));
  2388                 DeleteL(formatHasChanged,selection,code==EKeyBackspace,isPicture);
  2344                 DeleteL(formatHasChanged,selection,code==EKeyBackspace,isPicture);
  2389                 if (!isPicture)
  2345                 if (!isPicture)
  2390                     ClearUndo();
  2346                     ClearUndo();
  2391                 iTextView->HandleCharEditL(charEditType,formatHasChanged);
  2347                 iTextView->HandleCharEditL(charEditType,formatHasChanged);
  2392                 TryToDrawT2W();
       
  2393                 reportChange=ETrue;
  2348                 reportChange=ETrue;
  2394                 formatChange=formatHasChanged;
  2349                 formatChange=formatHasChanged;
  2395                 }
  2350                 }
  2396             }
  2351             }
  2397         if ( reportChange && iEdwinExtension && iEdwinExtension->iSmiley )
  2352         if ( reportChange && iEdwinExtension && iEdwinExtension->iSmiley )
  2439 TestMagnify:
  2394 TestMagnify:
  2440         if (magnify && !(modifiers&EModifierPureKeycode))
  2395         if (magnify && !(modifiers&EModifierPureKeycode))
  2441             break; // prevent eg Ctrl-I inserting a tab
  2396             break; // prevent eg Ctrl-I inserting a tab
  2442         goto InChar;
  2397         goto InChar;
  2443     default:
  2398     default:
  2444         // If ctrl + key is not hotkey return not consume. 
       
  2445         if ( magnify )
       
  2446             {
       
  2447             return EKeyWasNotConsumed;
       
  2448             }
       
  2449         if (code>=ENonCharacterKeyBase || !TChar(code).IsPrint() || (!IsValidChar(code)))
  2399         if (code>=ENonCharacterKeyBase || !TChar(code).IsPrint() || (!IsValidChar(code)))
  2450             {
  2400             {
  2451             ret=EKeyWasNotConsumed;
  2401             ret=EKeyWasNotConsumed;
  2452             break;
  2402             break;
  2453             }
  2403             }
  2470             pending.iAnchorPos=pending.iCursorPos;
  2420             pending.iAnchorPos=pending.iCursorPos;
  2471             iTextView->SetPendingSelection(pending);
  2421             iTextView->SetPendingSelection(pending);
  2472             selection=pending;
  2422             selection=pending;
  2473             --selection.iAnchorPos;
  2423             --selection.iAnchorPos;
  2474             iTextView->HandleInsertDeleteL(selection,selectionLength,formatHasChanged);
  2424             iTextView->HandleInsertDeleteL(selection,selectionLength,formatHasChanged);
  2475             // try to draw "tap to write"
       
  2476             TryToDrawT2W();
       
  2477             User::LeaveIfError(err);
  2425             User::LeaveIfError(err);
  2478             reportChange=ETrue;
  2426             reportChange=ETrue;
  2479             formatChange=formatHasChanged;
  2427             formatChange=formatHasChanged;
  2480             break;
  2428             break;
  2481             }
  2429             }
  2489                 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 );
  2437                 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 );
  2490                 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2438                 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), 
  2491                     ETrue );
  2439                     ETrue );
  2492                 }
  2440                 }
  2493             iTextView->HandleCharEditL(charEditType);
  2441             iTextView->HandleCharEditL(charEditType);
  2494             TryToDrawT2W();
       
  2495             reportChange=ETrue;
  2442             reportChange=ETrue;
  2496             }
  2443             }
  2497         else
  2444         else
  2498             {
  2445             {
  2499             ClearUndo();
  2446             ClearUndo();
  2596 paragraph the cursor was on before the edit, EFalse if from the start of the
  2543 paragraph the cursor was on before the edit, EFalse if from the start of the
  2597 line the cursor was on before the edit.
  2544 line the cursor was on before the edit.
  2598 @return The number of pixels scrolled horizontally and vertically. ( Ignored )
  2545 @return The number of pixels scrolled horizontally and vertically. ( Ignored )
  2599 */
  2546 */
  2600     (void)iTextView->HandleInsertDeleteL( selection, deletedChars, aFormatHasChanged);
  2547     (void)iTextView->HandleInsertDeleteL( selection, deletedChars, aFormatHasChanged);
  2601     // try to draw "tap to write"
       
  2602     TryToDrawT2W();
       
  2603     User::LeaveIfError(err);
  2548     User::LeaveIfError(err);
  2604     }
  2549     }
  2605 
  2550 
  2606 EXPORT_C void* CEikEdwin::ExtensionInterface( TUid /*aInterface*/ )
  2551 EXPORT_C void* CEikEdwin::ExtensionInterface( TUid /*aInterface*/ )
  2607     {
  2552     {
  2655             params.iDocPos = posInfo.iDocPos.iPos;   
  2600             params.iDocPos = posInfo.iDocPos.iPos;   
  2656             }
  2601             }
  2657         else // Need to call this method for the case where the pen is beyond the last line of text
  2602         else // Need to call this method for the case where the pen is beyond the last line of text
  2658             {
  2603             {
  2659             params.iDocPos = iTextView->XyPosToDocPosL( pos );
  2604             params.iDocPos = iTextView->XyPosToDocPosL( pos );
       
  2605             }
       
  2606 
       
  2607         // To check if user taps on inline editing text in partial screen mode,
       
  2608         // if so, the event has to be passed to FEP handler so FEP can display 
       
  2609         // candidate words list.
       
  2610         TInt checkedFlags( EAknEditorFlagEnablePartialScreen | 
       
  2611             EAknEditorFlagTouchInputModeOpened );
       
  2612         if ( ( AknEditorFlags() & checkedFlags ) == checkedFlags )
       
  2613             {
       
  2614             TCursorSelection inlineRange( InlineTextRange() );
       
  2615             if ( params.iDocPos >= inlineRange.LowerPos() && 
       
  2616                 params.iDocPos < inlineRange.HigherPos() )                
       
  2617                 {
       
  2618                 // Only pass EButton1up event to FEP handler to improve performance.
       
  2619                 // Ignore other events on inline text, otherwise they will cancel
       
  2620                 // inline editing status.
       
  2621                 if ( aPointerEvent.iType == TPointerEvent::EButton1Up && 
       
  2622                     iEdwinFepSupport && iEdwinFepSupport->iPointerEventHandlerDuringInlineEdit )
       
  2623                     {
       
  2624                     iEdwinFepSupport->iPointerEventHandlerDuringInlineEdit->
       
  2625                         HandlePointerEventInInlineTextL( TPointerEvent::EButton1Up, 
       
  2626                             aPointerEvent.iModifiers, 
       
  2627                             params.iDocPos - inlineRange.LowerPos() );
       
  2628                     }
       
  2629                 return;
       
  2630                 }            
  2660             }
  2631             }
  2661         
  2632         
  2662         /** The local @c destroyed variable keeps track of the object destroyed state. */
  2633         /** The local @c destroyed variable keeps track of the object destroyed state. */
  2663         TBool destroyed = EFalse;
  2634         TBool destroyed = EFalse;
  2664         iEdwinExtension->iDestroyedPtr = &destroyed;
  2635         iEdwinExtension->iDestroyedPtr = &destroyed;
  3177     {
  3148     {
  3178     if (!iTextView)
  3149     if (!iTextView)
  3179         return;
  3150         return;
  3180     const TBool focused=IsFocused();
  3151     const TBool focused=IsFocused();
  3181     TRAP_IGNORE(SetCursorVisibilityL(focused));
  3152     TRAP_IGNORE(SetCursorVisibilityL(focused));
  3182     if ( iEdwinExtension )
       
  3183         {
       
  3184         if ( focused )
       
  3185             {
       
  3186             iEdwinExtension->iT2WState |= CEikEdwinExtension::EFocusOn;
       
  3187             TryToDrawT2W();
       
  3188             }
       
  3189         else 
       
  3190             {
       
  3191             TBool change = ( TextLength() == 0 && IsT2WEnabled() );
       
  3192             iEdwinExtension->iT2WState &= ~CEikEdwinExtension::EFocusOn;
       
  3193             if ( change )
       
  3194                 {
       
  3195                 TryToDrawT2W( ETrue );
       
  3196                 }
       
  3197             }
       
  3198         }
       
  3199     if (!focused && iEdwinUserFlags&EAlwaysShowSelection)
  3153     if (!focused && iEdwinUserFlags&EAlwaysShowSelection)
  3200         ;
  3154         ;
  3201     else
  3155     else
  3202         {
  3156         {
  3203         TRAP_IGNORE( SetSelectionVisibilityL( focused ) );// !! inefficient
  3157         TRAP_IGNORE( SetSelectionVisibilityL( focused ) );// !! inefficient
  3474 
  3428 
  3475     if ( displayRect.Height() <= 0 )
  3429     if ( displayRect.Height() <= 0 )
  3476         {
  3430         {
  3477         displayRect.iBr.iY = displayRect.iTl.iY + displayRectHeight;
  3431         displayRect.iBr.iY = displayRect.iTl.iY + displayRectHeight;
  3478         }
  3432         }
  3479 
  3433     // Check if the width of view rect is changed, if it is not changed no need to global reformat.
  3480 
  3434     const TBool differentWidth = ( iTextView->ViewRect().Width() != displayRect.Width() );
  3481     iTextView->SetViewRect(displayRect);
  3435     iTextView->SetViewRect( displayRect );
  3482     iLayout->SetWrapWidth(LayoutWidth());
  3436     if ( differentWidth )
       
  3437     	{
       
  3438         iLayout->SetWrapWidth( LayoutWidth() );
       
  3439     	}
  3483     TViewYPosQualifier yPosQualifier;
  3440     TViewYPosQualifier yPosQualifier;
  3484     yPosQualifier.SetFillScreen();
  3441     yPosQualifier.SetFillScreen();
  3485     yPosQualifier.SetMakeLineFullyVisible();
  3442     yPosQualifier.SetMakeLineFullyVisible();
  3486     SetAmountToFormatL( EFalse, EFalse ); // Not a new doc; Do not reformat
  3443     SetAmountToFormatL( EFalse, EFalse ); // Not a new doc; Do not reformat
  3487     if (!(iEdwinInternalFlags & ESuppressFormatting))
  3444     if ( !( iEdwinInternalFlags & ESuppressFormatting ) && 
  3488         iTextView->HandleGlobalChangeNoRedrawL(yPosQualifier); // This does the reformat
  3445          ( differentWidth || iLayout->DocumentLength() < KFullFormattingUpperThreshold ) )
       
  3446     	{
       
  3447         iTextView->HandleGlobalChangeNoRedrawL( yPosQualifier ); // This does the reformat
       
  3448     	}
  3489     CalculateLineMetricsForBandFormattingL();
  3449     CalculateLineMetricsForBandFormattingL();
  3490     SetScrollBarsL();
  3450     SetScrollBarsL();
  3491     UpdateScrollBarsL();
  3451     UpdateScrollBarsL();
  3492     if ( condition )
  3452     if ( condition )
  3493         {
  3453         {
  4058             // Text view may not occupy the whole control area.  So we need to draw in the gaps
  4018             // Text view may not occupy the whole control area.  So we need to draw in the gaps
  4059             DrawBackgroundAroundTextView( gc, rect, viewRect, backgroundColor );
  4019             DrawBackgroundAroundTextView( gc, rect, viewRect, backgroundColor );
  4060             }
  4020             }
  4061 
  4021 
  4062         TrappedDraw(viewRect);
  4022         TrappedDraw(viewRect);
  4063         
       
  4064         // try to draw "tap to write"
       
  4065         if ( TextLength() == 0 && IsT2WEnabled() )
       
  4066             {
       
  4067             TRAP_IGNORE( DrawT2WTextL() );
       
  4068             }
       
  4069 
  4023 
  4070     #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
  4024     #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
  4071         // Workaround for clipping rect problem in multiline queries with text
  4025         // Workaround for clipping rect problem in multiline queries with text
  4072         // entries.  Because of differences between CRemoteGc and CWindowGc, 
  4026         // entries.  Because of differences between CRemoteGc and CWindowGc, 
  4073         // parts of the query wouldn't be drawn by CRemoteGc.  The Reset() call
  4027         // parts of the query wouldn't be drawn by CRemoteGc.  The Reset() call
  4084     {
  4038     {
  4085     CFont** fontPtr = (CFont**)aFont;
  4039     CFont** fontPtr = (CFont**)aFont;
  4086     CEikonEnv::Static()->ScreenDevice()->ReleaseFont(*fontPtr);
  4040     CEikonEnv::Static()->ScreenDevice()->ReleaseFont(*fontPtr);
  4087     }
  4041     }
  4088 
  4042 
  4089 void CEikEdwin::DrawT2WTextL() const
  4043 void CEikEdwin::DrawFirstLineTextL() const
  4090     {
  4044     {
  4091     if ( iEdwinExtension && iEdwinExtension->iT2WBuf )
  4045    
  4092         {
  4046     HBufC* clipbuf = GetTextInHBufL();
  4093         // rect
  4047     CleanupStack::PushL(clipbuf);
  4094         TRect edwinRect = RectForFirstLineText();
  4048 
  4095         
  4049     TPtrC clipbufPtr = clipbuf->Des();
  4096         // font
       
  4097         TAknTextLineLayout textLayout =
       
  4098                 AknLayoutScalable_Avkon::data_form_wide_pane_t1(0).LayoutLine();
       
  4099         const CAknLayoutFont* font = AknLayoutUtils::LayoutFontFromId(
       
  4100                 textLayout.FontId());
       
  4101         TFontSpec fontSpec = CursorFontSpec();
       
  4102         fontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal );
       
  4103 
       
  4104         CGraphicsDevice* screenDevice = iEikonEnv->ScreenDevice();
       
  4105         CFbsFont* customFont( NULL );
       
  4106         TInt err = screenDevice->GetNearestFontInTwips((CFont*&) customFont,
       
  4107                 fontSpec);
       
  4108         
       
  4109         //color
       
  4110         TRgb textColor = iEikonEnv->ControlColor(EColorControlText, *this);
       
  4111         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  4112         if ( skin && SkinColorId() != KErrNotFound )
       
  4113             {
       
  4114             AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, 
       
  4115                     SkinColorId() );
       
  4116             }
       
  4117         
       
  4118         // reorder the buffer
       
  4119         TPtrC clipbufPtr = iEdwinExtension->iT2WBuf->Des();
       
  4120         AknBidiTextUtils::PrepareRunInfoArray( clipbufPtr );
       
  4121         HBufC* reorderedText = HBufC::NewLC( clipbufPtr.Length() + TBidiLogicalToVisual::KMinCharAvailable);
       
  4122         TPtr reorderedTextPtr = reorderedText->Des();
       
  4123         TInt width = edwinRect.Size().iWidth;
       
  4124         AknBidiTextUtils::ConvertToVisualAndClip( clipbufPtr, reorderedTextPtr, *font, width, width );
       
  4125         
       
  4126         CWindowGc& gc = SystemGc();
       
  4127         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
  4128         gc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  4129         gc.SetPenColor( FadeRgb( textColor, KBlackMap , KWhiteMap ) );
       
  4130         gc.UseFont( customFont );
       
  4131         gc.DrawText( reorderedTextPtr, edwinRect, font->TextPaneTopToBaseline(),
       
  4132                      AlignForFirstLineText( reorderedTextPtr ) );
       
  4133         gc.DiscardFont();
       
  4134         screenDevice->ReleaseFont( customFont );
       
  4135         CleanupStack::PopAndDestroy( reorderedText );
       
  4136         }
       
  4137     }
       
  4138 
       
  4139 TRect CEikEdwin::RectForFirstLineText() const
       
  4140     {
       
  4141     TMargins8 margins = Margins();
  4050     TMargins8 margins = Margins();
  4142     const TRect rect(Rect());
  4051     const TRect rect(Rect());
  4143     TInt cursorWidth = CursorWidth(); // need to add cursor width to right hand margin
  4052     TInt cursorWidth = CursorWidth(); // need to add cursor width to right hand margin
  4144     TRect edwinRect = AknLayoutUtils::RectFromCoords(rect, margins.iLeft, margins.iTop, margins.iRight+cursorWidth, 
  4053     TRect edwinRect = AknLayoutUtils::RectFromCoords(rect, margins.iLeft, margins.iTop, margins.iRight+cursorWidth, margins.iBottom, ELayoutEmpty, ELayoutEmpty);
  4145             margins.iBottom, ELayoutEmpty, ELayoutEmpty);
  4054 
  4146     return edwinRect;
  4055     TAknTextLineLayout textLayout = AknLayoutScalable_Avkon::data_form_wide_pane_t1(0).LayoutLine();
  4147     }
  4056     const CAknLayoutFont* font = AknLayoutUtils::LayoutFontFromId( textLayout.FontId());
  4148 
  4057 
  4149 CGraphicsContext::TTextAlign CEikEdwin::AlignForFirstLineText( const TPtr & aReorderedTextPtr ) const
  4058     // reorder the text
  4150     {
  4059     AknBidiTextUtils::PrepareRunInfoArray(clipbufPtr);
       
  4060 
       
  4061     HBufC* reorderedText = HBufC::NewLC(clipbufPtr.Length() + TBidiLogicalToVisual::KMinCharAvailable);
       
  4062     TPtr reorderedTextPtr = reorderedText->Des();
       
  4063     TInt width = edwinRect.Size().iWidth;
       
  4064     AknBidiTextUtils::ConvertToVisualAndClip(clipbufPtr, reorderedTextPtr, *font, width, width);
       
  4065     AknTextUtils::ReplaceCharacters( reorderedTextPtr, _L("\x2029"), TChar(' ') );
       
  4066     CleanupStack::Pop(reorderedText);   
       
  4067     CleanupStack::PopAndDestroy(clipbuf);   
       
  4068     CleanupStack::PushL(reorderedText);
       
  4069 
  4151     CGraphicsContext::TTextAlign alignment = CGraphicsContext::ELeft;
  4070     CGraphicsContext::TTextAlign alignment = CGraphicsContext::ELeft;
  4152     switch(CurrentAlignment())
  4071     switch(CurrentAlignment())
  4153         {
  4072         {
  4154         case EAknEditorAlignLeft:
  4073         case EAknEditorAlignLeft:
  4155             alignment = CGraphicsContext::ELeft;
  4074             alignment = CGraphicsContext::ELeft;
  4162             break;
  4081             break;
  4163         case EAknEditorAlignNone: // drop through to default
  4082         case EAknEditorAlignNone: // drop through to default
  4164         case EAknEditorAlignBidi: // drop through to default
  4083         case EAknEditorAlignBidi: // drop through to default
  4165         default:
  4084         default:
  4166             {
  4085             {
  4167             if ( TBidiText::TextDirectionality( aReorderedTextPtr ) == TBidiText::ELeftToRight )
  4086             if (TBidiText::TextDirectionality(reorderedTextPtr) == TBidiText::ELeftToRight)
  4168                 alignment = CGraphicsContext::ELeft;
  4087                 alignment = CGraphicsContext::ELeft;
  4169             else
  4088             else
  4170                 alignment = CGraphicsContext::ERight;
  4089                 alignment = CGraphicsContext::ERight;
  4171             }
  4090             }
  4172             break;
  4091             break;
  4173         }
  4092         }
  4174     return alignment;
       
  4175     }
       
  4176 void CEikEdwin::DrawFirstLineTextL() const
       
  4177     {
       
  4178     // rect
       
  4179     TRect edwinRect = RectForFirstLineText();
       
  4180     // font
       
  4181     TAknTextLineLayout textLayout = AknLayoutScalable_Avkon::data_form_wide_pane_t1(0).LayoutLine();
       
  4182     const CAknLayoutFont* font = AknLayoutUtils::LayoutFontFromId( textLayout.FontId());
       
  4183     // reorder the text
       
  4184     HBufC* clipbuf = GetTextInHBufL();
       
  4185     CleanupStack::PushL(clipbuf);
       
  4186     TPtrC clipbufPtr = clipbuf->Des();
       
  4187     AknBidiTextUtils::PrepareRunInfoArray( clipbufPtr );
       
  4188     HBufC* reorderedText = HBufC::NewLC( clipbufPtr.Length() + TBidiLogicalToVisual::KMinCharAvailable );
       
  4189     TPtr reorderedTextPtr = reorderedText->Des();
       
  4190     TInt width = edwinRect.Size().iWidth;
       
  4191     AknBidiTextUtils::ConvertToVisualAndClip( clipbufPtr, reorderedTextPtr, *font, width, width );
       
  4192     AknTextUtils::ReplaceCharacters( reorderedTextPtr, KParagraphSeparator, TChar(' ') );
       
  4193     CleanupStack::Pop( reorderedText );   
       
  4194     CleanupStack::PopAndDestroy( clipbuf );   
       
  4195     CleanupStack::PushL( reorderedText );
       
  4196         
  4093         
  4197     CWindowGc& gc=SystemGc();               
  4094     CWindowGc& gc=SystemGc();               
  4198     gc.UseFont( font );
  4095     gc.UseFont(font);
  4199     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
  4096 
  4200     gc.SetPenStyle( CGraphicsContext::ESolidPen );
  4097     // Following patching up of the GC are now necessary after calling LafCustomDrawerfor background
  4201     gc.SetPenColor( iEikonEnv->ControlColor( EColorControlText, *this ) );  // Text color
  4098     gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  4202     gc.DrawText( reorderedTextPtr, edwinRect, font->TextPaneTopToBaseline(), 
  4099     gc.SetPenStyle(CGraphicsContext::ESolidPen);
  4203             AlignForFirstLineText( reorderedTextPtr ) );
  4100     TRgb textColor=iEikonEnv->ControlColor(EColorControlText,*this);
  4204     CleanupStack::PopAndDestroy(reorderedText); 
  4101 
  4205     gc.DiscardFont();
  4102     gc.SetPenColor(textColor);  // Text color
       
  4103 
       
  4104     // Edwin is assumed to be laid out already with LayoutEdwin. In that case
       
  4105     // the textpane top is the top of the edwin
       
  4106     TInt ascent = font->TextPaneTopToBaseline();
       
  4107     
       
  4108     gc.DrawText(reorderedTextPtr, edwinRect, ascent, alignment);
       
  4109 
       
  4110     CleanupStack::PopAndDestroy(reorderedText);
       
  4111     
       
  4112     gc.DiscardFont(); // So the GC will not try to use the font.
  4206     }
  4113     }
  4207 
  4114 
  4208 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const
  4115 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const
  4209     {
  4116     {
  4210     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  4117     if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw )
  4509     {
  4416     {
  4510     __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText));
  4417     __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText));
  4511     return(iText->DocumentLength());
  4418     return(iText->DocumentLength());
  4512     }
  4419     }
  4513 
  4420 
  4514 TBool CEikEdwin::IsT2WEnabled() const
       
  4515     {
       
  4516     /**
       
  4517      * 1,If the editor is read only or it is display only "tap to write" is disabled
       
  4518      * 2,If iEdwinExtension->iT2WBuf is NULL, "tap to write" is disabled. 
       
  4519      * 3,If Qwerty key borad is opened, "tap to write" is disabled
       
  4520      * 4,If focus off, "tap to write" is disabled
       
  4521      * 5,If split input is enabled, "tap to write" is disabled 
       
  4522      */ 
       
  4523     return iEdwinExtension && !( iEdwinUserFlags & EReadOnly ) && 
       
  4524          !( iEdwinUserFlags & EDisplayOnly ) && iEdwinExtension->iT2WBuf && 
       
  4525          ( iEdwinExtension->iT2WState & CEikEdwinExtension::EFocusOn ) &&
       
  4526          !( iEdwinExtension->iT2WState & CEikEdwinExtension::ESplitInputEnabled ) && 
       
  4527          !( iEdwinExtension->iQwertyStatus );
       
  4528     }
       
  4529 
       
  4530 void CEikEdwin::SetCursorVisibilityL(TBool aEmphasis)
  4421 void CEikEdwin::SetCursorVisibilityL(TBool aEmphasis)
  4531     {
  4422     {
  4532     TCursor::TVisibility textCursor=(aEmphasis? TCursor::EFCursorFlashing : TCursor::EFCursorInvisible);
  4423     TCursor::TVisibility textCursor=(aEmphasis? TCursor::EFCursorFlashing : TCursor::EFCursorInvisible);
  4533     TCursor::TVisibility lineCursor=((iEdwinUserFlags&ELineCursor && aEmphasis)? 
  4424     TCursor::TVisibility lineCursor=((iEdwinUserFlags&ELineCursor && aEmphasis)? 
  4534                                         TCursor::EFCursorVisible : TCursor::EFCursorInvisible);
  4425                                         TCursor::EFCursorVisible : TCursor::EFCursorInvisible);
  4536         { 
  4427         { 
  4537         textCursor = TCursor::EFCursorInvisible;
  4428         textCursor = TCursor::EFCursorInvisible;
  4538         lineCursor = TCursor::EFCursorInvisible;
  4429         lineCursor = TCursor::EFCursorInvisible;
  4539         }
  4430         }
  4540     
  4431     
  4541     if ( iEdwinExtension && ( iEdwinExtension->iT2WState & CEikEdwinExtension::ERecordCursor ) )
       
  4542         {
       
  4543         if ( aEmphasis )
       
  4544             {
       
  4545             iEdwinExtension->iT2WState |= CEikEdwinExtension::ECursorVisible;
       
  4546             }
       
  4547         else 
       
  4548             {
       
  4549             iEdwinExtension->iT2WState &= ~CEikEdwinExtension::ECursorVisible;
       
  4550             }
       
  4551         }
       
  4552     
       
  4553     if ( TextLength() == 0 && IsT2WEnabled() )
       
  4554         {
       
  4555         textCursor = TCursor::EFCursorInvisible;
       
  4556         }
       
  4557     iTextView->SetCursorVisibilityL(lineCursor,textCursor);
  4432     iTextView->SetCursorVisibilityL(lineCursor,textCursor);
  4558     CAknEdwinState*edwinState = EditorState();
  4433     CAknEdwinState*edwinState = EditorState();
  4559     if( !edwinState )
  4434     if( !edwinState )
  4560     	return;
  4435     	return;
  4561     if( textCursor != TCursor::EFCursorInvisible )
  4436     if( textCursor != TCursor::EFCursorInvisible )
  5013             {
  4888             {
  5014             iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength );
  4889             iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength );
  5015             ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue );
  4890             ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue );
  5016             }
  4891             }
  5017         TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed));
  4892         TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed));
  5018         // try to draw "tap to write"
       
  5019         TryToDrawT2W();
       
  5020         ClearUndo();
  4893         ClearUndo();
  5021         if (NeedToChangeFormattingModeL())
  4894         if (NeedToChangeFormattingModeL())
  5022             SetAmountToFormatL();
  4895             SetAmountToFormatL();
  5023         ForceScrollBarUpdateL();
  4896         ForceScrollBarUpdateL();
  5024         User::LeaveIfError(err);
  4897         User::LeaveIfError(err);
  5097         }
  4970         }
  5098     const TInt newLength=iText->DocumentLength();
  4971     const TInt newLength=iText->DocumentLength();
  5099     const TInt newCursorPos=cursorPos+newLength-oldLength;
  4972     const TInt newCursorPos=cursorPos+newLength-oldLength;
  5100     iTextView->SetPendingSelection(TCursorSelection(newCursorPos,newCursorPos));
  4973     iTextView->SetPendingSelection(TCursorSelection(newCursorPos,newCursorPos));
  5101     if (NeedToChangeFormattingModeL())
  4974     if (NeedToChangeFormattingModeL())
  5102         {
       
  5103         SetAmountToFormatL();
  4975         SetAmountToFormatL();
  5104         }
       
  5105     else
  4976     else
  5106         {
       
  5107         iTextView->HandleInsertDeleteL(TCursorSelection(newCursorPos,cursorPos),0,ETrue);
  4977         iTextView->HandleInsertDeleteL(TCursorSelection(newCursorPos,cursorPos),0,ETrue);
  5108         // try to draw "tap to write"
       
  5109         TryToDrawT2W();
       
  5110         }
       
  5111     DrawContents();
  4978     DrawContents();
  5112     UpdateScrollBarsL();
  4979     UpdateScrollBarsL();
  5113     ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  4980     ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  5114     DoReportEventL( MCoeControlObserver::EEventStateChanged );
  4981     DoReportEventL( MCoeControlObserver::EEventStateChanged );
  5115     iEikonEnv->BusyMsgCancel();
  4982     iEikonEnv->BusyMsgCancel();
  5186                 const TCursorSelection pending(lower,lower);
  5053                 const TCursorSelection pending(lower,lower);
  5187                 iTextView->SetPendingSelection(pending);
  5054                 iTextView->SetPendingSelection(pending);
  5188                 selection.iAnchorPos=lower;
  5055                 selection.iAnchorPos=lower;
  5189                 selection.iCursorPos=lower;
  5056                 selection.iCursorPos=lower;
  5190                 iTextView->HandleInsertDeleteL(selection,selLength,formatHasChanged);
  5057                 iTextView->HandleInsertDeleteL(selection,selLength,formatHasChanged);
  5191                 // try to draw "tap to write"
       
  5192                 TryToDrawT2W();
       
  5193                 reportChange=ETrue;
  5058                 reportChange=ETrue;
  5194                 }
  5059                 }
  5195             CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog();
  5060             CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog();
  5196             dlg->SetTimeout( CAknNoteDialog::EShortTimeout );
  5061             dlg->SetTimeout( CAknNoteDialog::EShortTimeout );
  5197             dlg->SetTone( CAknNoteDialog::ENoTone );
  5062             dlg->SetTone( CAknNoteDialog::ENoTone );
  5336         {
  5201         {
  5337         SetAmountToFormatL();
  5202         SetAmountToFormatL();
  5338         DrawContents();
  5203         DrawContents();
  5339         }
  5204         }
  5340     else
  5205     else
  5341         {
       
  5342         iTextView->HandleInsertDeleteL(selection,selLength,formatHasChanged);
  5206         iTextView->HandleInsertDeleteL(selection,selLength,formatHasChanged);
  5343         // try to draw "tap to write"
       
  5344         TryToDrawT2W();
       
  5345         }
       
  5346     iEikonEnv->BusyMsgCancel();
  5207     iEikonEnv->BusyMsgCancel();
  5347     User::LeaveIfError(err);
  5208     User::LeaveIfError(err);
  5348     }
  5209     }
  5349 
  5210 
  5350 void CEikEdwin::DoPasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDict)
  5211 void CEikEdwin::DoPasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDict)
  6687         selection.iCursorPos=selection.iAnchorPos+aModel->iReplaceText.Length();
  6548         selection.iCursorPos=selection.iAnchorPos+aModel->iReplaceText.Length();
  6688         }
  6549         }
  6689     const TCursorSelection pending(selection.iCursorPos,selection.iCursorPos);
  6550     const TCursorSelection pending(selection.iCursorPos,selection.iCursorPos);
  6690     iTextView->SetPendingSelection(pending);
  6551     iTextView->SetPendingSelection(pending);
  6691     iTextView->HandleInsertDeleteL(selection,aModel->iText.Length(),formatHasChanged);
  6552     iTextView->HandleInsertDeleteL(selection,aModel->iText.Length(),formatHasChanged);
  6692     // try to draw "tap to write"
       
  6693     TryToDrawT2W();
       
  6694     if ( NeedToChangeFormattingModeL())
  6553     if ( NeedToChangeFormattingModeL())
  6695         SetAmountToFormatL();
  6554         SetAmountToFormatL();
  6696     ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  6555     ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  6697     DoReportEventL( MCoeControlObserver::EEventStateChanged );
  6556     DoReportEventL( MCoeControlObserver::EEventStateChanged );
  6698     User::LeaveIfError(err);
  6557     User::LeaveIfError(err);
  6996         selection.iAnchorPos=anchor;
  6855         selection.iAnchorPos=anchor;
  6997         selection.iCursorPos=anchor+fieldLength;
  6856         selection.iCursorPos=anchor+fieldLength;
  6998         if (iUndoStore)
  6857         if (iUndoStore)
  6999             iUndoStore->SetNewText(selection);
  6858             iUndoStore->SetNewText(selection);
  7000         iTextView->HandleInsertDeleteL(selection,selectionLength,formatHasChanged);
  6859         iTextView->HandleInsertDeleteL(selection,selectionLength,formatHasChanged);
  7001         // try to draw "tap to write"
       
  7002         TryToDrawT2W();
       
  7003         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  6860         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  7004         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  6861         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  7005         User::LeaveIfError(err);
  6862         User::LeaveIfError(err);
  7006         }
  6863         }
  7007     }
  6864     }
  7101             TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2;
  6958             TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2;
  7102             yPosQ.SetMakeLineFullyVisible();
  6959             yPosQ.SetMakeLineFullyVisible();
  7103             yPosQ.SetFillScreen();
  6960             yPosQ.SetFillScreen();
  7104             TRAP_IGNORE( iTextView->SetViewL( docPos, yPos, yPosQ ) ); 
  6961             TRAP_IGNORE( iTextView->SetViewL( docPos, yPos, yPosQ ) ); 
  7105             }                
  6962             }                
  7106         TRAP_IGNORE( MoveViewToCursorLineL() );
       
  7107         }
  6963         }
  7108         break;
  6964         break;
  7109     case KEikMessageVirtualCursorStateChange:
  6965     case KEikMessageVirtualCursorStateChange:
  7110         {
  6966         {
  7111         TEikVirtualCursor& cursor=iEikonEnv->VirtualCursor();
  6967         TEikVirtualCursor& cursor=iEikonEnv->VirtualCursor();
  7143 			EnableSmileySupportL( ETrue );
  6999 			EnableSmileySupportL( ETrue );
  7144 			}
  7000 			}
  7145         DoAlignment();
  7001         DoAlignment();
  7146         }
  7002         }
  7147         break;
  7003         break;
  7148     case KAknSplitInputEnabled:
       
  7149     	{
       
  7150         if ( iEdwinExtension )
       
  7151             {
       
  7152             TBool change = ( TextLength() == 0 && IsT2WEnabled() );
       
  7153             iEdwinExtension->iT2WState |= CEikEdwinExtension::ESplitInputEnabled;           
       
  7154             if ( change )
       
  7155                 {
       
  7156                 TryToDrawT2W( ETrue );
       
  7157                 }
       
  7158             }
       
  7159     	}
       
  7160     	break;
       
  7161     case KAknSplitInputDisabled:
       
  7162     	{
       
  7163         if ( iEdwinExtension )
       
  7164             {
       
  7165             iEdwinExtension->iT2WState &= ~CEikEdwinExtension::ESplitInputEnabled;
       
  7166             TryToDrawT2W();
       
  7167             }
       
  7168     	}
       
  7169     	break;
       
  7170     default:
  7004     default:
  7171         break;
  7005         break;
  7172         }
  7006         }
  7173     }
  7007     }
  7174 
  7008 
  7378         iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() );
  7212         iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() );
  7379         ConvertTextForSmileyL( TCursorSelection( aInsertPos, 
  7213         ConvertTextForSmileyL( TCursorSelection( aInsertPos, 
  7380             aInsertPos + aText.Length() ), ETrue );
  7214             aInsertPos + aText.Length() ), ETrue );
  7381         }
  7215         }
  7382     iTextView->HandleInsertDeleteL(TCursorSelection(aInsertPos,aInsertPos+aText.Length()),length,formatChanged);
  7216     iTextView->HandleInsertDeleteL(TCursorSelection(aInsertPos,aInsertPos+aText.Length()),length,formatChanged);
  7383     // try to draw "tap to write"
       
  7384     TryToDrawT2W();
       
  7385     }
  7217     }
  7386 
  7218 
  7387 EXPORT_C void CEikEdwin::SetNonPrintingCharsVisibility(TNonPrintingCharVisibility aVisibility)
  7219 EXPORT_C void CEikEdwin::SetNonPrintingCharsVisibility(TNonPrintingCharVisibility aVisibility)
  7388     {
  7220     {
  7389     __ASSERT_DEBUG(iLayout,Panic(EEikPanicEdwinNoLayout));
  7221     __ASSERT_DEBUG(iLayout,Panic(EEikPanicEdwinNoLayout));
  8101             }
  7933             }
  8102         }
  7934         }
  8103     return TTypeUid::Null();
  7935     return TTypeUid::Null();
  8104     }
  7936     }
  8105 
  7937 
  8106 EXPORT_C void CEikEdwin::SetAlignment(TInt aAlignment)
  7938 EXPORT_C void CEikEdwin::SetAlignment( TInt aAlignment )
  8107     {
  7939     {
  8108     if (iEdwinExtension)
  7940 	TBool alignmentChange( ETrue );
  8109         iEdwinExtension->SetAlignment(aAlignment);
  7941     if ( iEdwinExtension )
  8110     DoAlignment();
  7942     	{
       
  7943         alignmentChange = ( iEdwinExtension->CurrentAlignment() != aAlignment );
       
  7944         iEdwinExtension->SetAlignment( aAlignment );
       
  7945     	}
       
  7946     // If alignment is not changed, no need to reformat.
       
  7947     if ( alignmentChange )
       
  7948     	{
       
  7949         DoAlignment();
       
  7950     	}
  8111     }
  7951     }
  8112 
  7952 
  8113 void CEikEdwin::NewParagraphL()
  7953 void CEikEdwin::NewParagraphL()
  8114     {
  7954     {
  8115     CheckEdwinExtensionL(); // checks if iEdwinExtension is NULL and constucts it if necessary
  7955     CheckEdwinExtensionL(); // checks if iEdwinExtension is NULL and constucts it if necessary
  8167         {
  8007         {
  8168         paraFormatLayer = CParaFormatLayer::NewL(&paraFormat,paraFormatMask);
  8008         paraFormatLayer = CParaFormatLayer::NewL(&paraFormat,paraFormatMask);
  8169         SetParaFormatLayer(paraFormatLayer);
  8009         SetParaFormatLayer(paraFormatLayer);
  8170         if (iTextView)
  8010         if (iTextView)
  8171             {
  8011             {
  8172             NotifyNewFormatL();
  8012             if ( ( iEdwinInternalFlags & ESuppressFormatting ) == 0 )
       
  8013             	{
       
  8014                 NotifyNewFormatL();
       
  8015             	}
  8173             }
  8016             }
  8174         else
  8017         else
  8175             {
  8018             {
  8176             alignNull = ETrue;
  8019             alignNull = ETrue;
  8177             }
  8020             }
  8635     if ( scroll )
  8478     if ( scroll )
  8636         {
  8479         {
  8637         UpdateScrollBarsL();
  8480         UpdateScrollBarsL();
  8638         }
  8481         }
  8639     }
  8482     }
  8640 
       
  8641 // ---------------------------------------------------------------------------
       
  8642 // CEikEdwin::MoveViewToCursorLineL
       
  8643 // ---------------------------------------------------------------------------
       
  8644 //
       
  8645 void CEikEdwin::MoveViewToCursorLineL()
       
  8646     {
       
  8647     if ( !iTextView )
       
  8648         {
       
  8649         return;
       
  8650         }
       
  8651 
       
  8652     const TInt cursorPos ( CursorPos() );
       
  8653     const TRect viewRect( AdjustedViewRect() );
       
  8654 
       
  8655     const TPoint startPoint ( viewRect.iTl );
       
  8656     const TPoint endPoint ( viewRect.iBr );
       
  8657 
       
  8658     TPoint cursorPoint;
       
  8659     iTextView->DocPosToXyPosL( cursorPos, cursorPoint );
       
  8660 
       
  8661     if ( cursorPoint.iY > endPoint.iY )
       
  8662         {
       
  8663         TBool exceed ( EFalse ) ;
       
  8664         TInt rest ( 0 );
       
  8665         ScrollView ( endPoint.iY - cursorPoint.iY, exceed, rest );
       
  8666         }
       
  8667     else if ( cursorPoint.iY < startPoint.iY )
       
  8668         {
       
  8669         TBool exceed ( EFalse ) ;
       
  8670         TInt rest ( 0 );
       
  8671         ScrollView ( startPoint.iY - cursorPoint.iY, exceed, rest );
       
  8672         }
       
  8673     }
       
  8674     
  8483     
  8675 EXPORT_C void CEikEdwin::SetCursorVisible(TBool aVisible)
  8484 EXPORT_C void CEikEdwin::SetCursorVisible(TBool aVisible)
  8676     {
  8485     {
  8677     TRAP_IGNORE( SetCursorVisibilityL( aVisible ) );
  8486     TRAP_IGNORE( SetCursorVisibilityL( aVisible ) );
  8678     }
  8487     }
  8775         TBool partialScreenEnabled( ( aNewFlags & EAknEditorFlagEnablePartialScreen ) &&
  8584         TBool partialScreenEnabled( ( aNewFlags & EAknEditorFlagEnablePartialScreen ) &&
  8776             !( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
  8585             !( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
  8777 
  8586 
  8778         TBool partialScreenDisabled( !( aNewFlags & EAknEditorFlagEnablePartialScreen ) && 
  8587         TBool partialScreenDisabled( !( aNewFlags & EAknEditorFlagEnablePartialScreen ) && 
  8779             ( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
  8588             ( aOldFlags & EAknEditorFlagEnablePartialScreen ) );
  8780 
  8589         
  8781         if ( IsActivated() && 
  8590         if (IsActivated() && 
  8782             ( ( textViewHideEnabled && !( aNewFlags & EAknEditorFlagEnablePartialScreen ) ) ||
  8591             ( (textViewHideEnabled && !(aNewFlags & EAknEditorFlagEnablePartialScreen)) ||
  8783               ( partialScreenDisabled && ( aNewFlags & EAknEditorFlagHideTextView ) ) )
  8592               (partialScreenDisabled && (aNewFlags & EAknEditorFlagHideTextView)) )
  8784             )
  8593             )
  8785             {
  8594             {
  8786             iTextView->MakeVisible( EFalse );
  8595             iTextView->MakeVisible( EFalse );
  8787             iEdwinExtension->iTextViewHidden = ETrue;
  8596             iEdwinExtension->iTextViewHidden = ETrue;
  8788             }
  8597             }
  9169 		return ret;
  8978 		return ret;
  9170 	TPtrC text = iText->Read( selection.LowerPos(), selection.Length() );
  8979 	TPtrC text = iText->Read( selection.LowerPos(), selection.Length() );
  9171 	for (TInt i = 0; i < text.Length(); i++)
  8980 	for (TInt i = 0; i < text.Length(); i++)
  9172 		{
  8981 		{
  9173 		TChar character(text[i]);
  8982 		TChar character(text[i]);
  9174         if ( character.IsPrint() )
  8983 		if (text[i] == ' ')
       
  8984 			return ETrue;
       
  8985 		
       
  8986 		TChar::TCategory category = character.GetCategory();
       
  8987 		
       
  8988 		if ( !( ( ( category & TChar::ESeparatorGroup ) == TChar::ESeparatorGroup ) ||
       
  8989 			   ( text[i] >= 0x200B && text[i] <= 0xFFFC ) ) )
  9175 			{
  8990 			{
  9176 			ret = ETrue;
  8991 			ret = ETrue;
  9177 			break;
  8992 			break;
  9178 			}
  8993 			}
  9179 		}
  8994 		}
  9472             return ETrue;
  9287             return ETrue;
  9473             }
  9288             }
  9474         }
  9289         }
  9475 
  9290 
  9476     return EFalse;
  9291     return EFalse;
       
  9292     }
       
  9293 
       
  9294 // ---------------------------------------------------------------------------
       
  9295 // CEikEdwin::InlineTextRange
       
  9296 // ---------------------------------------------------------------------------
       
  9297 //
       
  9298 TCursorSelection CEikEdwin::InlineTextRange() const
       
  9299     {
       
  9300     TInt startPosOfInline( 0 );
       
  9301     TInt endPosOfInline( 0 );
       
  9302     if ( iEdwinFepSupport )
       
  9303         {           
       
  9304         startPosOfInline = iEdwinFepSupport->iPositionOfInlineTextInDocument;
       
  9305         endPosOfInline = iEdwinFepSupport->iPositionOfInlineTextInDocument + 
       
  9306             iEdwinFepSupport->iLengthOfInlineText;
       
  9307         if ( iEdwinFepSupport->iLengthOfInlineText <= 0 )
       
  9308             {
       
  9309             CAknEdwinState* state( EditorState() );
       
  9310             if ( state && state->CurrentInlineEditSpan().Length() > 0 )
       
  9311                 {
       
  9312                 startPosOfInline = state->CurrentInlineEditSpan().LowerPos();
       
  9313                 endPosOfInline = state->CurrentInlineEditSpan().HigherPos();
       
  9314                 }
       
  9315             }
       
  9316         }
       
  9317     return TCursorSelection( startPosOfInline, endPosOfInline );
  9477     }
  9318     }
  9478 
  9319 
  9479 
  9320 
  9480 // ---------------------------------------------------------------------------
  9321 // ---------------------------------------------------------------------------
  9481 // ReadSpecialCharFromSCTL
  9322 // ReadSpecialCharFromSCTL
  9545 	// bitmap Id, bitmap Mask Id of captioned control
  9386 	// bitmap Id, bitmap Mask Id of captioned control
  9546 	aReader.Advance( KTInt16Length + KTInt16Length );
  9387 	aReader.Advance( KTInt16Length + KTInt16Length );
  9547 	aReader.ReadTPtrC(); // Process ToolTip
  9388 	aReader.ReadTPtrC(); // Process ToolTip
  9548 	}
  9389 	}
  9549 
  9390 
  9550 // returns the faded color of aColor
       
  9551 // aWhiteMap and aBlackMap parameters control the amount of fading
       
  9552 TRgb FadeRgb(TRgb aColor, TUint8 aBlackMap,TUint8 aWhiteMap)
       
  9553     {
       
  9554     TUint8 fadeMapFactor = aWhiteMap - aBlackMap + 1;
       
  9555     TUint8 fadeMapOffset = aBlackMap;
       
  9556     TInt value = aColor.Internal();
       
  9557     TInt b = (((value & 0x000000ff) * fadeMapFactor) >> 8)  + fadeMapOffset;
       
  9558     TInt g = (((value & 0x0000ff00) * fadeMapFactor) >> 16) + fadeMapOffset;
       
  9559     //the multiplication by iFadeMapFactor can overflow into the sign bit, so we shift down in two steps
       
  9560     TInt r = ((((value & 0x00ff0000) >> 16) * fadeMapFactor) >> 8) + fadeMapOffset;
       
  9561     TInt a = aColor.Alpha();
       
  9562     return TRgb(r,g,b,a );
       
  9563     }
       
  9564 
       
  9565 // ---------------------------------------------------------------------------
       
  9566 // CEikEdwin::EnableT2WL
       
  9567 // ---------------------------------------------------------------------------
       
  9568 //
       
  9569 EXPORT_C void CEikEdwin::EnableT2WL( TBool aEnable )
       
  9570     {
       
  9571     if ( iEdwinExtension )
       
  9572         {
       
  9573         if ( !aEnable && iEdwinExtension->iT2WBuf )
       
  9574             {
       
  9575             delete iEdwinExtension->iT2WBuf;
       
  9576             iEdwinExtension->iT2WBuf = NULL;
       
  9577             if ( iTextView ) 
       
  9578                 {
       
  9579                 TryToDrawT2W( ETrue );
       
  9580                 }
       
  9581             }
       
  9582         else if ( aEnable && !iEdwinExtension->iT2WBuf )
       
  9583             {
       
  9584             CRepository* cenrep = NULL;
       
  9585             TInt supportT2W = 0;
       
  9586             TRAPD(error, cenrep = CRepository::NewL(KCRUidAvkon));
       
  9587             if ( error == KErrNone )
       
  9588                 {
       
  9589                 error = cenrep->Get( KAknEdwinTapToWrite, supportT2W );
       
  9590                 }
       
  9591             delete cenrep;
       
  9592             if ( supportT2W && !iEdwinExtension->iT2WBuf )
       
  9593                 {
       
  9594                 iEdwinExtension->iT2WBuf = iEikonEnv->AllocReadResourceLC( R_AVKON_TAP_TO_WRITE ); 
       
  9595                 CleanupStack::Pop( iEdwinExtension->iT2WBuf );
       
  9596                 if ( iTextView )
       
  9597                     {
       
  9598                     TryToDrawT2W();
       
  9599                     }
       
  9600                 }
       
  9601             }
       
  9602         } 
       
  9603     }
       
  9604 
       
  9605 // ---------------------------------------------------------------------------
       
  9606 // CEikEdwin::TryToDrawT2W
       
  9607 // ---------------------------------------------------------------------------
       
  9608 //
       
  9609 void CEikEdwin::TryToDrawT2W( TBool aClean )
       
  9610     {
       
  9611     CAknEdwinState* edwinState = EditorState();
       
  9612     TBool cursorVisible( EFalse );
       
  9613     if ( edwinState )
       
  9614         {
       
  9615         cursorVisible = ( edwinState->Flags() | EAknEditorFlagTextCursorVisible );
       
  9616         }
       
  9617     
       
  9618     if ( iEdwinExtension )
       
  9619         {
       
  9620         // When "tap to write" is enabled( started ) we should record the status of cursor.
       
  9621         if ( TextLength() == 0 && IsT2WEnabled() )
       
  9622             {
       
  9623             SetCursorVisible( EFalse );
       
  9624             iEdwinExtension->iT2WState |= CEikEdwinExtension::ERecordCursor;
       
  9625             if ( cursorVisible )
       
  9626                 {
       
  9627                 iEdwinExtension->iT2WState |= CEikEdwinExtension::ECursorVisible;
       
  9628                 }
       
  9629             else 
       
  9630                 {
       
  9631                 iEdwinExtension->iT2WState &= ~CEikEdwinExtension::ECursorVisible;
       
  9632                 }
       
  9633             DrawDeferred();
       
  9634             }
       
  9635         // When "tap to write" is disabled ( ended ) we need to recover the status of cursor.
       
  9636         else if ( IsFocused() && 
       
  9637                   ( iEdwinExtension->iT2WState & CEikEdwinExtension::ERecordCursor ) ) 
       
  9638             {
       
  9639             iEdwinExtension->iT2WState &= ~CEikEdwinExtension::ERecordCursor;
       
  9640             SetCursorVisible( iEdwinExtension->iT2WState & CEikEdwinExtension::ECursorVisible );
       
  9641             }
       
  9642         // When focus off, we don't need to record the status anymore. So clean it.
       
  9643         else if ( !IsFocused() ) 
       
  9644             {
       
  9645             iEdwinExtension->iT2WState &= ~CEikEdwinExtension::ERecordCursor;
       
  9646             }
       
  9647         }
       
  9648     
       
  9649     if ( aClean && TextLength() == 0 )
       
  9650         {
       
  9651         DrawDeferred();
       
  9652         }  
       
  9653     }
       
  9654 
       
  9655 // End of File
  9391 // End of File
  9656 
  9392