1574 : CGlobalText::NewL(aParaFormatLayer,aCharFormatLayer,storage,granularity); |
1574 : CGlobalText::NewL(aParaFormatLayer,aCharFormatLayer,storage,granularity); |
1575 iText=globalText; |
1575 iText=globalText; |
1576 CreateLayoutL(globalText); |
1576 CreateLayoutL(globalText); |
1577 SetHeightForNumOfLinesL(); |
1577 SetHeightForNumOfLinesL(); |
1578 DoCreateCustomDrawL(); |
1578 DoCreateCustomDrawL(); |
1579 if ( iEdwinExtension->iSmiley ) |
1579 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
1580 { |
1580 { |
1581 TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap ); |
1581 TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap ); |
1582 } |
1582 } |
1583 } |
1583 } |
1584 |
1584 |
1815 return EKeyWasNotConsumed; |
1815 return EKeyWasNotConsumed; |
1816 } |
1816 } |
1817 } |
1817 } |
1818 if (iEdwinUserFlags&EDisplayOnly) |
1818 if (iEdwinUserFlags&EDisplayOnly) |
1819 return EKeyWasConsumed; |
1819 return EKeyWasConsumed; |
1820 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
1820 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
1821 { |
1821 { |
1822 PerformRecordedOperationL(); |
1822 PerformRecordedOperationL(); |
1823 } |
1823 } |
1824 const TInt modifiers=aKeyEvent.iModifiers; |
1824 const TInt modifiers=aKeyEvent.iModifiers; |
1825 TBool navigation=EFalse; |
1825 TBool navigation=EFalse; |
2162 iTextView->HandleCharEditL(charEditType,formatHasChanged); |
2162 iTextView->HandleCharEditL(charEditType,formatHasChanged); |
2163 reportChange=ETrue; |
2163 reportChange=ETrue; |
2164 formatChange=formatHasChanged; |
2164 formatChange=formatHasChanged; |
2165 } |
2165 } |
2166 } |
2166 } |
2167 if ( reportChange && iEdwinExtension->iSmiley ) |
2167 if ( reportChange && iEdwinExtension && iEdwinExtension->iSmiley ) |
2168 { |
2168 { |
2169 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2169 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2170 ETrue ); |
2170 ETrue ); |
2171 if ( deleteSelection || replaceSelection ) |
2171 if ( deleteSelection || replaceSelection ) |
2172 { |
2172 { |
2220 TChar character(code); |
2220 TChar character(code); |
2221 if ( selectionLength ) |
2221 if ( selectionLength ) |
2222 { |
2222 { |
2223 TInt pos=DeleteHighlightL(formatHasChanged); |
2223 TInt pos=DeleteHighlightL(formatHasChanged); |
2224 TRAPD(err,iText->InsertL(pos,character)); |
2224 TRAPD(err,iText->InsertL(pos,character)); |
2225 if ( iEdwinExtension->iSmiley ) |
2225 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2226 { |
2226 { |
2227 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 ); |
2227 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 ); |
2228 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue ); |
2228 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue ); |
2229 } |
2229 } |
2230 TCursorSelection selection=iTextView->Selection(); |
2230 TCursorSelection selection=iTextView->Selection(); |
2244 } |
2244 } |
2245 if ( !iTextLimit || TextLength()<iTextLimit ) |
2245 if ( !iTextLimit || TextLength()<iTextLimit ) |
2246 { |
2246 { |
2247 iText->InsertL(CursorPos(),character); |
2247 iText->InsertL(CursorPos(),character); |
2248 ClearUndo(); |
2248 ClearUndo(); |
2249 if ( iEdwinExtension->iSmiley ) |
2249 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2250 { |
2250 { |
2251 TInt cursorPos( CursorPos() ); |
2251 TInt cursorPos( CursorPos() ); |
2252 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 ); |
2252 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 ); |
2253 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2253 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2254 ETrue ); |
2254 ETrue ); |
2265 } |
2265 } |
2266 if (reportChange) |
2266 if (reportChange) |
2267 { |
2267 { |
2268 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
2268 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
2269 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
2269 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
2270 if ( iEdwinExtension->iSmiley ) |
2270 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2271 { |
2271 { |
2272 TInt docPos( CursorPos() ); |
2272 TInt docPos( CursorPos() ); |
2273 iEdwinExtension->iSmiley->HandleSetCursor( docPos, |
2273 iEdwinExtension->iSmiley->HandleSetCursor( docPos, |
2274 docPos ); |
2274 docPos ); |
2275 if ( docPos != CursorPos() ) |
2275 if ( docPos != CursorPos() ) |
2276 { |
2276 { |
2277 SetCursorPosL( docPos, SelectionLength() > 0 ); |
2277 SetCursorPosL( docPos, SelectionLength() > 0 ); |
2278 } |
2278 } |
2279 } |
2279 } |
2280 } |
2280 } |
2281 if (navigation) |
2281 if ( navigation && iEdwinExtension ) |
2282 { |
2282 { |
2283 iEdwinExtension->iThumbPos = KErrNotFound; |
2283 iEdwinExtension->iThumbPos = KErrNotFound; |
2284 ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
2284 ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
2285 } |
2285 } |
2286 if (formatChange) |
2286 if (formatChange) |
2674 iLastPointerDocPos=newCursorPos; |
2677 iLastPointerDocPos=newCursorPos; |
2675 iLastPointerAnchorPos=newAnchorPos; |
2678 iLastPointerAnchorPos=newAnchorPos; |
2676 iEdwinInternalFlags&=(~ELeftDownInViewRect); |
2679 iEdwinInternalFlags&=(~ELeftDownInViewRect); |
2677 |
2680 |
2678 // We can't open cut-copy-paste menu if dragging started |
2681 // We can't open cut-copy-paste menu if dragging started |
2679 if ( IsReadOnly() && IsSelectionVisible() && !( iEdwinUserFlags&ENoAutoSelection ) && !( kineticScrollingEnabled |
2682 if ( IsReadOnly() && IsSelectionVisible() && IsFocused() && !( kineticScrollingEnabled |
2680 && iEdwinExtension->iPhysicsHandler->DraggingStarted() ) ) |
2683 && iEdwinExtension->iPhysicsHandler->DraggingStarted() ) ) |
2681 { |
2684 { |
2682 iEdwinFepSupport->iFeedback->InstantFeedback( |
2685 iEdwinFepSupport->iFeedback->InstantFeedback( |
2683 this, |
2686 this, |
2684 ETouchFeedbackPopUp, |
2687 ETouchFeedbackPopUp, |
3056 } |
3059 } |
3057 |
3060 |
3058 DoCreateCustomDrawL(); // Done after TextView is created so that optimized drawer is constructed |
3061 DoCreateCustomDrawL(); // Done after TextView is created so that optimized drawer is constructed |
3059 |
3062 |
3060 // Create the required formatters according to the editor set-up |
3063 // Create the required formatters according to the editor set-up |
3061 if ( IsPurePhoneNumberEditor() ) |
3064 if ( IsPurePhoneNumberEditor() && iEdwinExtension ) |
3062 { |
3065 { |
3063 if ( phoneNumberGroupingSupported ) |
3066 if ( phoneNumberGroupingSupported ) |
3064 { |
3067 { |
3065 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3068 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3066 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3069 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3067 iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText ); |
3070 iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText ); |
3068 } |
3071 } |
3069 } |
3072 } |
3070 else // Make approximation that all other editors have no matches indicator functionality |
3073 else if ( iEdwinExtension )// Make approximation that all other editors have no matches indicator functionality |
3071 { |
3074 { |
3072 iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout ); |
3075 iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout ); |
3073 } |
3076 } |
3074 |
3077 |
3075 // Rich text editors that have been configured for phone number grouping |
3078 // Rich text editors that have been configured for phone number grouping |
3076 if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping && |
3079 if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping && |
3077 phoneNumberGroupingSupported ) |
3080 phoneNumberGroupingSupported && iEdwinExtension ) |
3078 { |
3081 { |
3079 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3082 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3080 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3083 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3081 iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) ); |
3084 iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) ); |
3082 } |
3085 } |
3083 |
3086 |
3084 // Install the custom formatter system if needed |
3087 // Install the custom formatter system if needed |
3085 if ( iEdwinExtension->FormExtendedInferfaceProvider() ) |
3088 if ( iEdwinExtension && iEdwinExtension->FormExtendedInferfaceProvider() ) |
3086 TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() ); |
3089 TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() ); |
3087 |
3090 |
3088 UpdateScrollBarsL(); |
3091 UpdateScrollBarsL(); |
3089 ForceScrollBarUpdateL(); |
3092 ForceScrollBarUpdateL(); |
3090 |
3093 |
3218 if ( condition ) |
3221 if ( condition ) |
3219 { |
3222 { |
3220 SetCursorVisibilityL( ETrue ); |
3223 SetCursorVisibilityL( ETrue ); |
3221 } |
3224 } |
3222 // View size changed, Initialize physics here |
3225 // View size changed, Initialize physics here |
3223 iEdwinExtension->InitPhysicsL(); |
3226 if ( iEdwinExtension ) |
|
3227 { |
|
3228 iEdwinExtension->InitPhysicsL(); |
|
3229 } |
3224 } |
3230 } |
3225 |
3231 |
3226 EXPORT_C TInt CEikEdwin::CountComponentControls() const |
3232 EXPORT_C TInt CEikEdwin::CountComponentControls() const |
3227 { |
3233 { |
3228 TInt count=CEikBorderedControl::CountComponentControls(); |
3234 TInt count=CEikBorderedControl::CountComponentControls(); |
3243 EXPORT_C void CEikEdwin::SetAmountToFormatL(TBool aIsNewDoc) |
3249 EXPORT_C void CEikEdwin::SetAmountToFormatL(TBool aIsNewDoc) |
3244 { |
3250 { |
3245 if (!iTextView) |
3251 if (!iTextView) |
3246 return; |
3252 return; |
3247 const TInt chars=iText->DocumentLength(); |
3253 const TInt chars=iText->DocumentLength(); |
3248 if ( iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat ) |
3254 if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iDisableConvertInFormat ) |
3249 { |
3255 { |
3250 if ( chars > KFullFormatLengthForSmiley ) |
3256 if ( chars > KFullFormatLengthForSmiley ) |
3251 { |
3257 { |
3252 ConvertVisibleTextForSmileyL( ETrue ); |
3258 ConvertVisibleTextForSmileyL( ETrue ); |
3253 } |
3259 } |
3374 { |
3380 { |
3375 const TInt count=iObserverArray->Count(); |
3381 const TInt count=iObserverArray->Count(); |
3376 for (TInt ii=0;ii<count;ii++) |
3382 for (TInt ii=0;ii<count;ii++) |
3377 (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType); |
3383 (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType); |
3378 } |
3384 } |
3379 if ( aEventType == MEikEdwinObserver::EEventTextUpdate ) |
3385 if ( aEventType == MEikEdwinObserver::EEventTextUpdate && iEdwinExtension ) |
3380 { |
3386 { |
3381 iEdwinExtension->iExtendedInputCapabilities->ReportEventL( |
3387 iEdwinExtension->iExtendedInputCapabilities->ReportEventL( |
3382 CAknExtendedInputCapabilities:: |
3388 CAknExtendedInputCapabilities:: |
3383 MAknEventObserver::EControlContentUpdatedInternally, |
3389 MAknEventObserver::EControlContentUpdatedInternally, |
3384 NULL ); |
3390 NULL ); |
3430 EXPORT_C void CEikEdwin::SetCursorPosL(TInt aDocPos,TBool aSelect) |
3436 EXPORT_C void CEikEdwin::SetCursorPosL(TInt aDocPos,TBool aSelect) |
3431 { |
3437 { |
3432 // CTextView::SetDocPosL will cause textview to be drawn. This could happen |
3438 // CTextView::SetDocPosL will cause textview to be drawn. This could happen |
3433 // before the drawing of editor. So adding following codes to postpone the action to |
3439 // before the drawing of editor. So adding following codes to postpone the action to |
3434 // first drawing of editor. |
3440 // first drawing of editor. |
3435 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
3441 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
3436 { |
3442 { |
3437 iEdwinExtension->iTempCursorPos = aDocPos; |
3443 iEdwinExtension->iTempCursorPos = aDocPos; |
3438 iEdwinExtension->iTempSelect = aSelect; |
3444 iEdwinExtension->iTempSelect = aSelect; |
3439 if ( !aSelect ) |
3445 if ( !aSelect ) |
3440 { |
3446 { |
3450 |
3456 |
3451 if (!iTextView) |
3457 if (!iTextView) |
3452 CreateTextViewL(); |
3458 CreateTextViewL(); |
3453 TInt oldPos( CursorPos() ); |
3459 TInt oldPos( CursorPos() ); |
3454 TInt docPos( aDocPos ); |
3460 TInt docPos( aDocPos ); |
3455 if ( iEdwinExtension->iSmiley ) |
3461 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
3456 { |
3462 { |
3457 iEdwinExtension->iSmiley->HandleSetCursor( oldPos, docPos ); |
3463 iEdwinExtension->iSmiley->HandleSetCursor( oldPos, docPos ); |
3458 } |
3464 } |
3459 TCursorSelection select( Selection() ); |
3465 TCursorSelection select( Selection() ); |
3460 select.iCursorPos = docPos; |
3466 select.iCursorPos = docPos; |
3473 if ( edwinState ) |
3479 if ( edwinState ) |
3474 { |
3480 { |
3475 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3481 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3476 } |
3482 } |
3477 } |
3483 } |
3478 |
3484 // scrollbar:thumb is displayed on the top when editor set cursor position. |
|
3485 iEdwinExtension->iThumbPos = KErrNotFound; |
3479 UpdateVertScrollBarThumbL(); |
3486 UpdateVertScrollBarThumbL(); |
3480 UpdateHorizScrollBarThumb(); |
3487 UpdateHorizScrollBarThumb(); |
3481 } |
3488 } |
3482 |
3489 |
3483 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner) |
3490 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner) |
3508 iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos ); |
3515 iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos ); |
3509 } |
3516 } |
3510 TCursorSelection select( aCursorPos, aAnchorPos ); |
3517 TCursorSelection select( aCursorPos, aAnchorPos ); |
3511 HandleSelectionForSmiley( select ); |
3518 HandleSelectionForSmiley( select ); |
3512 iTextView->SetSelectionL( select ); |
3519 iTextView->SetSelectionL( select ); |
3513 iEdwinExtension->iThumbPos = KErrNotFound; |
3520 if ( iEdwinExtension ) |
|
3521 { |
|
3522 iEdwinExtension->iThumbPos = KErrNotFound; |
|
3523 } |
3514 |
3524 |
3515 if ( iEdwinFepSupport ) |
3525 if ( iEdwinFepSupport ) |
3516 { |
3526 { |
3517 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3527 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3518 if ( edwinState ) |
3528 if ( edwinState ) |
3616 if (iEdwinUserFlags&EOwnsWindow && !OwnsWindow()) |
3626 if (iEdwinUserFlags&EOwnsWindow && !OwnsWindow()) |
3617 CreateWindowL(&aParent); |
3627 CreateWindowL(&aParent); |
3618 else |
3628 else |
3619 CCoeControl::SetContainerWindowL(aParent); |
3629 CCoeControl::SetContainerWindowL(aParent); |
3620 |
3630 |
3621 iEdwinExtension->EnablePhysicsL(); |
3631 if ( iEdwinExtension ) |
|
3632 { |
|
3633 iEdwinExtension->EnablePhysicsL(); |
|
3634 } |
3622 } |
3635 } |
3623 |
3636 |
3624 EXPORT_C void CEikEdwin::SetContainerWindowL() |
3637 EXPORT_C void CEikEdwin::SetContainerWindowL() |
3625 { |
3638 { |
3626 __ASSERT_DEBUG(iEdwinUserFlags&EOwnsWindow, Panic(EEikPanicEdwinNoWindow)); |
3639 __ASSERT_DEBUG(iEdwinUserFlags&EOwnsWindow, Panic(EEikPanicEdwinNoWindow)); |
3627 if (!OwnsWindow()) |
3640 if (!OwnsWindow()) |
3628 CreateWindowL(); |
3641 CreateWindowL(); |
3629 |
3642 |
3630 iEdwinExtension->EnablePhysicsL(); |
3643 if ( iEdwinExtension ) |
|
3644 { |
|
3645 iEdwinExtension->EnablePhysicsL(); |
|
3646 } |
3631 } |
3647 } |
3632 |
3648 |
3633 EXPORT_C TCoeInputCapabilities CEikEdwin::InputCapabilities() const |
3649 EXPORT_C TCoeInputCapabilities CEikEdwin::InputCapabilities() const |
3634 { |
3650 { |
3635 if (IsReadOnly()) |
3651 if (IsReadOnly()) |
3686 */ |
3702 */ |
3687 EXPORT_C void CEikEdwin::CreateLayoutL(MLayDoc* aLayDoc) |
3703 EXPORT_C void CEikEdwin::CreateLayoutL(MLayDoc* aLayDoc) |
3688 { |
3704 { |
3689 __ASSERT_DEBUG(aLayDoc,Panic(EEikPanicEdwinNoText)); |
3705 __ASSERT_DEBUG(aLayDoc,Panic(EEikPanicEdwinNoText)); |
3690 |
3706 |
3691 if ((iEdwinUserFlags&EAvkonEditor)) |
3707 if ( iEdwinUserFlags&EAvkonEditor && iEdwinExtension ) |
3692 { |
3708 { |
3693 iLayout=CTextLayout::NewL(aLayDoc,KMaxTInt); // supply real wrapping width later |
3709 iLayout=CTextLayout::NewL(aLayDoc,KMaxTInt); // supply real wrapping width later |
3694 iLayout->SetCustomWrap(&(iEdwinExtension->TextWrapper())); |
3710 iLayout->SetCustomWrap(&(iEdwinExtension->TextWrapper())); |
3695 |
3711 |
3696 // This WAS ETrue, then fixed to EFalse, caused regression and now back to |
3712 // This WAS ETrue, then fixed to EFalse, caused regression and now back to |
3861 gc.DiscardFont(); // So the GC will not try to use the font. |
3877 gc.DiscardFont(); // So the GC will not try to use the font. |
3862 } |
3878 } |
3863 |
3879 |
3864 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const |
3880 EXPORT_C void CEikEdwin::TrappedDraw(const TRect& aViewRect) const |
3865 { |
3881 { |
3866 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
3882 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
3867 { |
3883 { |
3868 CEikEdwin* edwin( const_cast<CEikEdwin*>( this ) ); |
3884 CEikEdwin* edwin( const_cast<CEikEdwin*>( this ) ); |
3869 edwin->iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawing; |
3885 edwin->iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawing; |
3870 TRAP_IGNORE( edwin->PerformRecordedOperationL(); ); |
3886 TRAP_IGNORE( edwin->PerformRecordedOperationL(); ); |
3871 } |
3887 } |
3982 return; |
3998 return; |
3983 } |
3999 } |
3984 } |
4000 } |
3985 TInt oldCursor( CursorPos() ); |
4001 TInt oldCursor( CursorPos() ); |
3986 TPoint movePoint=iTextView->MoveCursorL( aMovement, aSelect ); |
4002 TPoint movePoint=iTextView->MoveCursorL( aMovement, aSelect ); |
3987 if ( iEdwinExtension->iSmiley ) |
4003 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
3988 { |
4004 { |
3989 TCursorSelection select( 0, 0 ); |
4005 TCursorSelection select( 0, 0 ); |
3990 if ( AdjustCursorForSmileyL( oldCursor, select ) ) |
4006 if ( AdjustCursorForSmileyL( oldCursor, select ) ) |
3991 { |
4007 { |
3992 SetSelectionL( select.iCursorPos, select.iAnchorPos ); |
4008 SetSelectionL( select.iCursorPos, select.iAnchorPos ); |
4019 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4035 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4020 |
4036 |
4021 // Before scrolling into blank space was allowed, but this eventually |
4037 // Before scrolling into blank space was allowed, but this eventually |
4022 // causes a panic at CTextView::ScrollDisplayL(). |
4038 // causes a panic at CTextView::ScrollDisplayL(). |
4023 const TInt move=iTextView->ScrollDisplayL(aMovement,CTextLayout::EFDisallowScrollingBlankSpace); |
4039 const TInt move=iTextView->ScrollDisplayL(aMovement,CTextLayout::EFDisallowScrollingBlankSpace); |
4024 if (move) |
4040 if ( move && iEdwinExtension ) |
4025 { |
4041 { |
4026 iEdwinExtension->iThumbPos = KErrNotFound; |
4042 iEdwinExtension->iThumbPos = KErrNotFound; |
4027 switch (aMovement) |
4043 switch (aMovement) |
4028 { |
4044 { |
4029 case TCursorPosition::EFLeft: |
4045 case TCursorPosition::EFLeft: |
4074 } |
4090 } |
4075 |
4091 |
4076 EXPORT_C TInt CEikEdwin::CursorPos() const |
4092 EXPORT_C TInt CEikEdwin::CursorPos() const |
4077 { |
4093 { |
4078 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4094 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4079 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4095 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4080 iEdwinExtension->iTempCursorPos != KErrNotFound ) |
4096 iEdwinExtension->iTempCursorPos != KErrNotFound ) |
4081 { |
4097 { |
4082 return iEdwinExtension->iTempCursorPos; |
4098 return iEdwinExtension->iTempCursorPos; |
4083 } |
4099 } |
4084 else |
4100 else |
4090 |
4106 |
4091 EXPORT_C TInt CEikEdwin::SelectionLength() const |
4107 EXPORT_C TInt CEikEdwin::SelectionLength() const |
4092 { |
4108 { |
4093 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4109 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4094 TCursorSelection selection( 0, 0 ); |
4110 TCursorSelection selection( 0, 0 ); |
4095 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4111 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4096 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4112 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4097 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4113 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4098 { |
4114 { |
4099 selection.iCursorPos = iEdwinExtension->iTempCursorPos; |
4115 selection.iCursorPos = iEdwinExtension->iTempCursorPos; |
4100 selection.iAnchorPos = iEdwinExtension->iTempAnchorPos; |
4116 selection.iAnchorPos = iEdwinExtension->iTempAnchorPos; |
4150 { |
4166 { |
4151 if (iEdwinInternalFlags&ERichText) |
4167 if (iEdwinInternalFlags&ERichText) |
4152 STATIC_CAST(CRichText*,iText)->CancelInsertCharFormat(); |
4168 STATIC_CAST(CRichText*,iText)->CancelInsertCharFormat(); |
4153 aChanged=iText->DeleteL(aSelection.LowerPos(),length); |
4169 aChanged=iText->DeleteL(aSelection.LowerPos(),length); |
4154 } |
4170 } |
4155 if ( iEdwinExtension->iSmiley ) |
4171 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4156 { |
4172 { |
4157 iEdwinExtension->iSmiley->HandleDeleteL( aSelection.LowerPos(), length ); |
4173 iEdwinExtension->iSmiley->HandleDeleteL( aSelection.LowerPos(), length ); |
4158 } |
4174 } |
4159 CleanupStack::Pop(); |
4175 CleanupStack::Pop(); |
4160 } |
4176 } |
4182 return; |
4198 return; |
4183 if( textCursor != TCursor::EFCursorInvisible ) |
4199 if( textCursor != TCursor::EFCursorInvisible ) |
4184 { |
4200 { |
4185 SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagTextCursorVisible ); |
4201 SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagTextCursorVisible ); |
4186 } |
4202 } |
4187 else |
4203 else if ( iEdwinExtension ) |
4188 { |
4204 { |
4189 SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagTextCursorVisible ); |
4205 SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagTextCursorVisible ); |
4190 |
4206 |
4191 // If cursor is disabled during kinetic scrolling |
4207 // If cursor is disabled during kinetic scrolling |
4192 // by other party (for any reason), reset flag so that we don't show it again |
4208 // by other party (for any reason), reset flag so that we don't show it again |
4489 } |
4505 } |
4490 segmBufPtr = aDes->Mid( segmStart, insertLength); |
4506 segmBufPtr = aDes->Mid( segmStart, insertLength); |
4491 AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter, |
4507 AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter, |
4492 TChar(CEditableText::EParagraphDelimiter)); |
4508 TChar(CEditableText::EParagraphDelimiter)); |
4493 iText->InsertL(oldLength+segmStart,*segmBuf); |
4509 iText->InsertL(oldLength+segmStart,*segmBuf); |
4494 if ( iEdwinExtension->iSmiley ) |
4510 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4495 { |
4511 { |
4496 iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, |
4512 iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, |
4497 insertLength ); |
4513 insertLength ); |
4498 } |
4514 } |
4499 segmStart = segmEnd; |
4515 segmStart = segmEnd; |
4503 } |
4519 } |
4504 } |
4520 } |
4505 |
4521 |
4506 CleanupStack::PopAndDestroy(segmBuf); |
4522 CleanupStack::PopAndDestroy(segmBuf); |
4507 TRAP(err,iText->DeleteL(0,oldLength)); |
4523 TRAP(err,iText->DeleteL(0,oldLength)); |
4508 if ( iEdwinExtension->iSmiley ) |
4524 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4509 { |
4525 { |
4510 iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength ); |
4526 iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength ); |
4511 ConvertTextForSmileyL( TCursorSelection( 0, |
4527 ConvertTextForSmileyL( TCursorSelection( 0, |
4512 iText->DocumentLength() ), ETrue ); |
4528 iText->DocumentLength() ), ETrue ); |
4513 } |
4529 } |
4514 } |
4530 } |
4515 else |
4531 else |
4516 { |
4532 { |
4517 iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object |
4533 iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object |
4518 if ( iEdwinExtension->iSmiley ) |
4534 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4519 { |
4535 { |
4520 iEdwinExtension->iSmiley->HandleDeleteL( 0, |
4536 iEdwinExtension->iSmiley->HandleDeleteL( 0, |
4521 iText->DocumentLength() ); |
4537 iText->DocumentLength() ); |
4522 } |
4538 } |
4523 } |
4539 } |
4524 |
4540 |
4525 CheckRemovePictures(0,iText->DocumentLength()); |
4541 CheckRemovePictures(0,iText->DocumentLength()); |
4526 CheckValidityOfChars(0,iText->DocumentLength()); |
4542 CheckValidityOfChars(0,iText->DocumentLength()); |
4527 iEdwinExtension->iDisableConvertInFormat = ETrue; |
4543 if ( iEdwinExtension ) |
4528 SetAmountToFormatL(ETrue); // performs formatting |
4544 { |
4529 iEdwinExtension->iDisableConvertInFormat = EFalse; |
4545 iEdwinExtension->iDisableConvertInFormat = ETrue; |
|
4546 } |
|
4547 SetAmountToFormatL(ETrue); // performs formatting |
|
4548 if ( iEdwinExtension ) |
|
4549 { |
|
4550 iEdwinExtension->iDisableConvertInFormat = EFalse; |
|
4551 } |
4530 // Update cursor position as CursorWidth() needs that. |
4552 // Update cursor position as CursorWidth() needs that. |
4531 if (IsReadyToDraw()) |
4553 if (IsReadyToDraw()) |
4532 { |
4554 { |
4533 ApplyAutoSelectionL(); |
4555 ApplyAutoSelectionL(); |
4534 } |
4556 } |
4554 if ( iCcpuSupport ) |
4576 if ( iCcpuSupport ) |
4555 { |
4577 { |
4556 iCcpuSupport->HandleSelectionChangeL(); |
4578 iCcpuSupport->HandleSelectionChangeL(); |
4557 } |
4579 } |
4558 } |
4580 } |
4559 iEdwinExtension->iThumbPos = KErrNotFound; |
4581 if ( iEdwinExtension ) |
|
4582 { |
|
4583 iEdwinExtension->iThumbPos = KErrNotFound; |
|
4584 } |
4560 if (IsReadyToDraw()) |
4585 if (IsReadyToDraw()) |
4561 { |
4586 { |
4562 UpdateScrollBarsL(); |
4587 UpdateScrollBarsL(); |
4563 } |
4588 } |
4564 |
4589 |
4565 User::LeaveIfError(err); |
4590 User::LeaveIfError(err); |
4566 } |
4591 } |
4567 |
4592 |
4568 EXPORT_C TCursorSelection CEikEdwin::Selection() const |
4593 EXPORT_C TCursorSelection CEikEdwin::Selection() const |
4569 { |
4594 { |
4570 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4595 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4571 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4596 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4572 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4597 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4573 { |
4598 { |
4574 return TCursorSelection( iEdwinExtension->iTempCursorPos, |
4599 return TCursorSelection( iEdwinExtension->iTempCursorPos, |
4575 iEdwinExtension->iTempAnchorPos ); |
4600 iEdwinExtension->iTempAnchorPos ); |
4620 const TInt lower=newText.LowerPos(); |
4645 const TInt lower=newText.LowerPos(); |
4621 TInt undoneLength=0; |
4646 TInt undoneLength=0; |
4622 TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower)) |
4647 TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower)) |
4623 const TInt cursorPos=iUndoStore->OldCursorPos(); |
4648 const TInt cursorPos=iUndoStore->OldCursorPos(); |
4624 iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos)); |
4649 iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos)); |
4625 if ( iEdwinExtension->iSmiley ) |
4650 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4626 { |
4651 { |
4627 iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength ); |
4652 iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength ); |
4628 ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue ); |
4653 ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue ); |
4629 } |
4654 } |
4630 TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed)); |
4655 TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed)); |
4698 const TInt cursorPos=CursorPos(); |
4723 const TInt cursorPos=CursorPos(); |
4699 iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds |
4724 iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds |
4700 iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation); |
4725 iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation); |
4701 TInt insertLength( iText->DocumentLength() - oldLength ); |
4726 TInt insertLength( iText->DocumentLength() - oldLength ); |
4702 CheckValidityOfChars( oldLength, insertLength ); |
4727 CheckValidityOfChars( oldLength, insertLength ); |
4703 if ( iEdwinExtension->iSmiley ) |
4728 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4704 { |
4729 { |
4705 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength ); |
4730 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength ); |
4706 ConvertTextForSmileyL( TCursorSelection( cursorPos, |
4731 ConvertTextForSmileyL( TCursorSelection( cursorPos, |
4707 cursorPos + insertLength ), ETrue ); |
4732 cursorPos + insertLength ), ETrue ); |
4708 } |
4733 } |
4816 if ( KineticScrollingEnabled() ) |
4841 if ( KineticScrollingEnabled() ) |
4817 { |
4842 { |
4818 // If we have deleted some text and previous position (before delete) is |
4843 // If we have deleted some text and previous position (before delete) is |
4819 // out of current editor content, we must move back to inside content. |
4844 // out of current editor content, we must move back to inside content. |
4820 TInt formattedHeight( iLayout->FormattedHeightInPixels() ); |
4845 TInt formattedHeight( iLayout->FormattedHeightInPixels() ); |
4821 if ( prevEndPosition > formattedHeight ) |
4846 if ( prevEndPosition > formattedHeight && iEdwinExtension ) |
4822 { |
4847 { |
4823 TInt movement( prevEndPosition - formattedHeight ); |
4848 TInt movement( prevEndPosition - formattedHeight ); |
4824 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement ); |
4849 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement ); |
4825 } |
4850 } |
4826 } |
4851 } |
4827 |
4852 |
4828 if (reportChange) |
4853 if ( reportChange && iEdwinExtension ) |
4829 { |
4854 { |
4830 iEdwinExtension->iThumbPos = KErrNotFound; |
4855 iEdwinExtension->iThumbPos = KErrNotFound; |
4831 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
4856 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
4832 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
4857 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
4833 NotifyEditorStateObserverOfStateChangeL(); |
4858 NotifyEditorStateObserverOfStateChangeL(); |
4874 CancelFepTransaction(); |
4899 CancelFepTransaction(); |
4875 TCursorSelection selection=Selection(); |
4900 TCursorSelection selection=Selection(); |
4876 CPlainText* text( iText ); |
4901 CPlainText* text( iText ); |
4877 TInt start( selection.LowerPos() ); |
4902 TInt start( selection.LowerPos() ); |
4878 HBufC* buf( NULL ); |
4903 HBufC* buf( NULL ); |
4879 if ( iEdwinExtension->iSmiley ) |
4904 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4880 { |
4905 { |
4881 buf = ExtractTextLC( selection ); |
4906 buf = ExtractTextLC( selection ); |
4882 text = CPlainText::NewL(); |
4907 text = CPlainText::NewL(); |
4883 CleanupStack::PushL( text ); |
4908 CleanupStack::PushL( text ); |
4884 TPtr ptr( buf->Des() ); |
4909 TPtr ptr( buf->Des() ); |
4886 ptr, EFalse ); |
4911 ptr, EFalse ); |
4887 start = 0; |
4912 start = 0; |
4888 text->InsertL( start, *buf ); |
4913 text->InsertL( start, *buf ); |
4889 } |
4914 } |
4890 text->CopyToStoreL(aStore, aDict, start, selection.Length() ); |
4915 text->CopyToStoreL(aStore, aDict, start, selection.Length() ); |
4891 if ( iEdwinExtension->iSmiley ) |
4916 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4892 { |
4917 { |
4893 CleanupStack::PopAndDestroy( text ); |
4918 CleanupStack::PopAndDestroy( text ); |
4894 CleanupStack::PopAndDestroy( buf ); |
4919 CleanupStack::PopAndDestroy( buf ); |
4895 } |
4920 } |
4896 } |
4921 } |
4925 } |
4950 } |
4926 const TInt higher=selection.HigherPos()+newLength-oldTextLength; |
4951 const TInt higher=selection.HigherPos()+newLength-oldTextLength; |
4927 iTextView->SetPendingSelection(TCursorSelection(higher,higher)); |
4952 iTextView->SetPendingSelection(TCursorSelection(higher,higher)); |
4928 selection.iAnchorPos=selection.LowerPos(); |
4953 selection.iAnchorPos=selection.LowerPos(); |
4929 selection.iCursorPos=selection.iAnchorPos+pastedLength; |
4954 selection.iCursorPos=selection.iAnchorPos+pastedLength; |
4930 if ( iEdwinExtension->iSmiley ) |
4955 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4931 { |
4956 { |
4932 iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), |
4957 iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), |
4933 selection.Length() ); |
4958 selection.Length() ); |
4934 ConvertTextForSmileyL( selection, ETrue ); |
4959 ConvertTextForSmileyL( selection, ETrue ); |
4935 } |
4960 } |
5619 return; |
5644 return; |
5620 } |
5645 } |
5621 |
5646 |
5622 TRect viewRect( AdjustedViewRect() ); |
5647 TRect viewRect( AdjustedViewRect() ); |
5623 const TInt formattedLines = Max(1, iLayout->NumFormattedLines()); |
5648 const TInt formattedLines = Max(1, iLayout->NumFormattedLines()); |
5624 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5649 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5625 const TBool formattedHeightchanged( formattedHeight != iEdwinExtension->iRecordFormattedHeight ); |
5650 const TBool formattedHeightchanged( iEdwinExtension && |
5626 iEdwinExtension->iRecordFormattedHeight = formattedHeight; |
5651 ( formattedHeight != iEdwinExtension->iRecordFormattedHeight ) ); |
|
5652 if ( iEdwinExtension ) |
|
5653 { |
|
5654 iEdwinExtension->iRecordFormattedHeight = formattedHeight; |
|
5655 } |
5627 const TInt viewRectHeight = viewRect.Height(); |
5656 const TInt viewRectHeight = viewRect.Height(); |
5628 const TInt totalChars = iText->DocumentLength(); |
5657 const TInt totalChars = iText->DocumentLength(); |
5629 const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() ); |
5658 const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() ); |
5630 const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand(); |
5659 const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand(); |
5631 const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : |
5660 const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : |
5637 if( AknLayoutUtils::PenEnabled() ) |
5666 if( AknLayoutUtils::PenEnabled() ) |
5638 { |
5667 { |
5639 if ( !iLayout->IsFormattingBand() ) |
5668 if ( !iLayout->IsFormattingBand() ) |
5640 { |
5669 { |
5641 aVertModel.iThumbSpan = viewRectHeight; |
5670 aVertModel.iThumbSpan = viewRectHeight; |
5642 aVertModel.iScrollSpan = formattedHeight; |
5671 aVertModel.iScrollSpan = formattedHeight; |
5643 aVertModel.iThumbPosition = iEdwinExtension->iThumbPos; |
5672 if ( iEdwinExtension ) |
|
5673 { |
|
5674 aVertModel.iThumbPosition = iEdwinExtension->iThumbPos; |
|
5675 } |
5644 if ( aVertModel.iThumbPosition == KErrNotFound || formattedHeightchanged ) |
5676 if ( aVertModel.iThumbPosition == KErrNotFound || formattedHeightchanged ) |
5645 { |
5677 { |
5646 if ( bottomPos == totalChars ) |
5678 if ( bottomPos == totalChars ) |
5647 { |
5679 { |
5648 aVertModel.iThumbPosition = aVertModel.iScrollSpan - |
5680 aVertModel.iThumbPosition = aVertModel.iScrollSpan - |
5829 |
5864 |
5830 const TAknDoubleSpanScrollBarModel* doubleModel = |
5865 const TAknDoubleSpanScrollBarModel* doubleModel = |
5831 static_cast< const TAknDoubleSpanScrollBarModel* > |
5866 static_cast< const TAknDoubleSpanScrollBarModel* > |
5832 ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() ); |
5867 ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() ); |
5833 |
5868 |
5834 if ( !iEdwinExtension->iUseRateScroll ) |
5869 if ( iEdwinExtension && ( !iEdwinExtension->iUseRateScroll ) ) |
5835 { |
5870 { |
5836 aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight |
5871 aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight |
5837 + heightAfterFormat; |
5872 + heightAfterFormat; |
5838 aVertModel.iThumbSpan = viewRectHeight; |
5873 aVertModel.iThumbSpan = viewRectHeight; |
5839 } |
5874 } |
5840 |
5875 |
5841 // Rate scrolling |
5876 // Rate scrolling |
5842 |
5877 |
5843 if ( iEdwinExtension->iUseRateScroll ) |
5878 if ( iEdwinExtension && iEdwinExtension->iUseRateScroll ) |
5844 { |
5879 { |
5845 TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat; |
5880 TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat; |
5846 TInt heightBelowView = formattedHeightBelowView + heightAfterFormat; |
5881 TInt heightBelowView = formattedHeightBelowView + heightAfterFormat; |
5847 |
5882 |
5848 TInt curScrollSpan = aVertModel.iScrollSpan |
5883 TInt curScrollSpan = aVertModel.iScrollSpan |
5891 { |
5926 { |
5892 approxTopVisibleLine = 1; |
5927 approxTopVisibleLine = 1; |
5893 } |
5928 } |
5894 } |
5929 } |
5895 |
5930 |
5896 if ( iEdwinExtension->iUseRateScroll ) |
5931 if ( iEdwinExtension && iEdwinExtension->iUseRateScroll ) |
5897 { |
5932 { |
5898 aVertModel.iThumbPosition = anchorThumbPos; |
5933 aVertModel.iThumbPosition = anchorThumbPos; |
5899 } |
5934 } |
5900 else |
5935 else |
5901 { |
5936 { |
5902 aVertModel.iThumbPosition = approxTopVisibleLine * avgLineHeight; |
5937 aVertModel.iThumbPosition = approxTopVisibleLine * avgLineHeight; |
5903 } |
5938 } |
5904 iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; |
5939 if ( iEdwinExtension ) |
|
5940 { |
|
5941 iEdwinExtension->iScrollbarPosition = aVertModel.iThumbPosition; |
|
5942 } |
5905 } |
5943 } |
5906 |
5944 |
5907 // --------------------------------------------------------------------------- |
5945 // --------------------------------------------------------------------------- |
5908 // CEikEdwin::HandleScrollEventWithPhysicsL |
5946 // CEikEdwin::HandleScrollEventWithPhysicsL |
5909 // --------------------------------------------------------------------------- |
5947 // --------------------------------------------------------------------------- |
5919 TInt curScrollSpan = doubleModel->ScrollSpan(); |
5957 TInt curScrollSpan = doubleModel->ScrollSpan(); |
5920 TInt curThumbSpan = doubleModel->WindowSize(); |
5958 TInt curThumbSpan = doubleModel->WindowSize(); |
5921 TInt thumbSpaceAbove = aScrollBar->ThumbPosition(); |
5959 TInt thumbSpaceAbove = aScrollBar->ThumbPosition(); |
5922 TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove; |
5960 TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove; |
5923 |
5961 |
5924 TInt moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition; |
5962 TInt moveOffset = 0; |
|
5963 if ( iEdwinExtension ) |
|
5964 { |
|
5965 moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition; |
|
5966 } |
5925 |
5967 |
5926 const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() ); |
5968 const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() ); |
5927 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5969 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5928 const TInt viewRectHeight = AdjustedViewRect().Height(); |
5970 const TInt viewRectHeight = AdjustedViewRect().Height(); |
5929 const TInt totalChars = iText->DocumentLength(); |
5971 const TInt totalChars = iText->DocumentLength(); |
5957 } |
5999 } |
5958 else |
6000 else |
5959 { |
6001 { |
5960 return; |
6002 return; |
5961 } |
6003 } |
5962 iEdwinExtension->iScrollbarPosition = thumbSpaceAbove; |
|
5963 |
6004 |
5964 // If scrollbar thumb is moved to the beginning or end of scrollbar, |
6005 // If scrollbar thumb is moved to the beginning or end of scrollbar, |
5965 // ensure that also editor content is moved also exactly to the beginning |
6006 // ensure that also editor content is moved also exactly to the beginning |
5966 // or end. This is needed because otherwise in some situations editor |
6007 // or end. This is needed because otherwise in some situations editor |
5967 // content is not moved enough. We can't move too much because moving is |
6008 // content is not moved enough. We can't move too much because moving is |
5973 else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan ) |
6014 else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan ) |
5974 { |
6015 { |
5975 textMovePixels -= KAdditionalPixels; |
6016 textMovePixels -= KAdditionalPixels; |
5976 } |
6017 } |
5977 |
6018 |
5978 iEdwinExtension->iScrolledByScrollBar = ETrue; |
6019 if ( iEdwinExtension ) |
5979 |
6020 { |
5980 // Actual scrolling is done by calling MoveScrollIndex |
6021 iEdwinExtension->iScrollbarPosition = thumbSpaceAbove; |
5981 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels ); |
6022 iEdwinExtension->iScrolledByScrollBar = ETrue; |
5982 |
6023 |
5983 iEdwinExtension->iScrolledByScrollBar = EFalse; |
6024 // Actual scrolling is done by calling MoveScrollIndex |
|
6025 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels ); |
|
6026 |
|
6027 iEdwinExtension->iScrolledByScrollBar = EFalse; |
|
6028 } |
5984 } |
6029 } |
5985 |
6030 |
5986 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType) |
6031 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType) |
5987 { |
6032 { |
5988 __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText)); |
6033 __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText)); |
6100 { |
6145 { |
6101 TInt topPos( iTextView->XyPosToDocPosL( viewRect.iTl ) ); |
6146 TInt topPos( iTextView->XyPosToDocPosL( viewRect.iTl ) ); |
6102 TInt bottomPos( iTextView->XyPosToDocPosL( viewRect.iBr ) ); |
6147 TInt bottomPos( iTextView->XyPosToDocPosL( viewRect.iBr ) ); |
6103 TInt visibleRange( bottomPos - topPos ); |
6148 TInt visibleRange( bottomPos - topPos ); |
6104 |
6149 |
6105 if ( thumbPosition != thumbSpan ) |
6150 if ( thumbPosition != thumbSpan && iEdwinExtension ) |
6106 { |
6151 { |
6107 TInt scrollRange( totalChars - visibleRange ); |
6152 TInt scrollRange( totalChars - visibleRange ); |
6108 docPos = ( TInt )( ( TInt64 )( thumbPosition ) * scrollRange |
6153 docPos = ( TInt )( ( TInt64 )( thumbPosition ) * scrollRange |
6109 / thumbSpan ); |
6154 / thumbSpan ); |
6110 if ( iEdwinExtension->iThumbPos > thumbPosition && |
6155 if ( iEdwinExtension->iThumbPos > thumbPosition && |
6126 if ( thumbPosition == thumbSpan ) |
6171 if ( thumbPosition == thumbSpan ) |
6127 { |
6172 { |
6128 docPos = totalChars; |
6173 docPos = totalChars; |
6129 yPos = viewRect.iBr.iY; |
6174 yPos = viewRect.iBr.iY; |
6130 } |
6175 } |
6131 iEdwinExtension->iThumbPos = thumbPosition; |
6176 if ( iEdwinExtension ) |
|
6177 { |
|
6178 iEdwinExtension->iThumbPos = thumbPosition; |
|
6179 } |
6132 TViewYPosQualifier yPosQ; |
6180 TViewYPosQualifier yPosQ; |
6133 yPosQ.SetMakeLineFullyVisible(); |
6181 yPosQ.SetMakeLineFullyVisible(); |
6134 iTextView->SetViewL( docPos, yPos, yPosQ, |
6182 iTextView->SetViewL( docPos, yPos, yPosQ, |
6135 CTextView::EFViewDontDiscardFormat, |
6183 CTextView::EFViewDontDiscardFormat, |
6136 CTextView::EFNoHorizontalScroll); |
6184 CTextView::EFNoHorizontalScroll); |
6497 STATIC_CAST(CRichText*,iText)->DeleteFromParagraph(aStartPos,1); |
6545 STATIC_CAST(CRichText*,iText)->DeleteFromParagraph(aStartPos,1); |
6498 else |
6546 else |
6499 { |
6547 { |
6500 TRAP_IGNORE( iText->DeleteL(aStartPos,1)); |
6548 TRAP_IGNORE( iText->DeleteL(aStartPos,1)); |
6501 } |
6549 } |
6502 if ( iEdwinExtension->iSmiley ) |
6550 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
6503 { |
6551 { |
6504 iEdwinExtension->iSmiley->HandleDeleteL( aStartPos, 1 ); |
6552 iEdwinExtension->iSmiley->HandleDeleteL( aStartPos, 1 ); |
6505 } |
6553 } |
6506 } |
6554 } |
6507 else |
6555 else |
6648 |
6696 |
6649 switch (aType) |
6697 switch (aType) |
6650 { |
6698 { |
6651 case KEikDynamicLayoutVariantSwitch: |
6699 case KEikDynamicLayoutVariantSwitch: |
6652 { |
6700 { |
6653 if ( KineticScrollingEnabled() ) |
6701 if ( KineticScrollingEnabled() && iEdwinExtension ) |
6654 { |
6702 { |
6655 iEdwinExtension->iPhysicsHandler->DisableDragging(); |
6703 iEdwinExtension->iPhysicsHandler->DisableDragging(); |
6656 } |
6704 } |
6657 |
6705 if ( iEdwinExtension ) |
6658 iEdwinExtension->iThumbPos = KErrNotFound; |
6706 { |
|
6707 iEdwinExtension->iThumbPos = KErrNotFound; |
|
6708 } |
6659 SizeChanged(); |
6709 SizeChanged(); |
6660 if ( !IsReadOnly() && !IsNonFocusing() |
6710 if ( !IsReadOnly() && !IsNonFocusing() |
6661 && !( iEdwinUserFlags & EDisplayOnly ) |
6711 && !( iEdwinUserFlags & EDisplayOnly ) |
6662 && !KineticScrollingEnabled() ) |
6712 && !KineticScrollingEnabled() ) |
6663 { |
6713 { |
6896 formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length); |
6946 formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length); |
6897 } |
6947 } |
6898 else |
6948 else |
6899 { |
6949 { |
6900 formatChanged=iText->DeleteL(lowerPos,length); |
6950 formatChanged=iText->DeleteL(lowerPos,length); |
6901 if ( iEdwinExtension->iSmiley ) |
6951 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
6902 { |
6952 { |
6903 iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length ); |
6953 iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length ); |
6904 } |
6954 } |
6905 } |
6955 } |
6906 iText->InsertL(aInsertPos,aText); |
6956 iText->InsertL(aInsertPos,aText); |
6907 if ( iEdwinExtension->iSmiley ) |
6957 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
6908 { |
6958 { |
6909 iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() ); |
6959 iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() ); |
6910 ConvertTextForSmileyL( TCursorSelection( aInsertPos, |
6960 ConvertTextForSmileyL( TCursorSelection( aInsertPos, |
6911 aInsertPos + aText.Length() ), ETrue ); |
6961 aInsertPos + aText.Length() ), ETrue ); |
6912 } |
6962 } |
7385 if (iEdwinFepSupport) |
7435 if (iEdwinFepSupport) |
7386 { |
7436 { |
7387 edwinState = STATIC_CAST(CAknEdwinState*, iEdwinFepSupport->State(KNullUid)); |
7437 edwinState = STATIC_CAST(CAknEdwinState*, iEdwinFepSupport->State(KNullUid)); |
7388 } |
7438 } |
7389 |
7439 |
7390 CAknPictographInterface* pictographInterface = iEdwinExtension->PictographInterface(); |
7440 CAknPictographInterface* pictographInterface = NULL; |
|
7441 if ( iEdwinExtension ) |
|
7442 { |
|
7443 pictographInterface = iEdwinExtension->PictographInterface(); |
|
7444 } |
7391 if (edwinState) |
7445 if (edwinState) |
7392 { |
7446 { |
7393 if (FeatureManager::FeatureSupported(KFeatureIdJapanese)) |
7447 if (FeatureManager::FeatureSupported(KFeatureIdJapanese)) |
7394 { |
7448 { |
7395 fullWidthCharactersAllowed = edwinState->PermittedInputModes() & ( |
7449 fullWidthCharactersAllowed = edwinState->PermittedInputModes() & ( |
7961 return hasStrongCharacter; |
8015 return hasStrongCharacter; |
7962 } |
8016 } |
7963 |
8017 |
7964 EXPORT_C void CEikEdwin::SetPictographAnimationCallBack( TCallBack& aCallBack ) |
8018 EXPORT_C void CEikEdwin::SetPictographAnimationCallBack( TCallBack& aCallBack ) |
7965 { |
8019 { |
7966 iEdwinExtension->SetPictoCallBack( aCallBack ); |
8020 if ( iEdwinExtension ) |
|
8021 { |
|
8022 iEdwinExtension->SetPictoCallBack( aCallBack ); |
|
8023 } |
7967 } |
8024 } |
7968 |
8025 |
7969 const TCallBack& CEikEdwin::PictographAnimationCallBack() const |
8026 const TCallBack& CEikEdwin::PictographAnimationCallBack() const |
7970 { |
8027 { |
7971 return iEdwinExtension->PictoCallBack(); |
8028 return iEdwinExtension->PictoCallBack(); |
8093 return rect; |
8150 return rect; |
8094 } |
8151 } |
8095 |
8152 |
8096 void CEikEdwin::SetVKBStatus() |
8153 void CEikEdwin::SetVKBStatus() |
8097 { |
8154 { |
8098 TUint cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities(); |
8155 TUint cap = 0; |
|
8156 if ( iEdwinExtension ) |
|
8157 { |
|
8158 cap = iEdwinExtension->iExtendedInputCapabilities->Capabilities(); |
|
8159 } |
8099 if ( iEdwinUserFlags & EAvkonDisableVKB ) |
8160 if ( iEdwinUserFlags & EAvkonDisableVKB ) |
8100 { |
8161 { |
8101 cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
8162 cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
8102 } |
8163 } |
8103 else |
8164 else |
8104 { |
8165 { |
8105 cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
8166 cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB; |
8106 } |
8167 } |
8107 iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
8168 if ( iEdwinExtension ) |
|
8169 { |
|
8170 iEdwinExtension->iExtendedInputCapabilities->SetCapabilities( cap ); |
|
8171 } |
8108 } |
8172 } |
8109 |
8173 |
8110 void CEikEdwin::ScrollViewToCursorLineL() |
8174 void CEikEdwin::ScrollViewToCursorLineL() |
8111 { |
8175 { |
8112 TInt cursorPos = CursorPos(); |
8176 TInt cursorPos = CursorPos(); |
8134 TRAP_IGNORE( SetCursorVisibilityL( aVisible ) ); |
8198 TRAP_IGNORE( SetCursorVisibilityL( aVisible ) ); |
8135 } |
8199 } |
8136 |
8200 |
8137 void CEikEdwin::PerformRecordedOperationL() |
8201 void CEikEdwin::PerformRecordedOperationL() |
8138 { |
8202 { |
8139 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw || |
8203 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw || |
8140 iEdwinExtension->iDrawInvoked == CEikEdwinExtension::EDrawing ) |
8204 iEdwinExtension->iDrawInvoked == CEikEdwinExtension::EDrawing ) |
8141 { |
8205 { |
8142 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
8206 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw ) |
8143 { |
8207 { |
8144 iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawn; |
8208 iEdwinExtension->iDrawInvoked = CEikEdwinExtension::EDrawn; |
8225 } |
8289 } |
8226 |
8290 |
8227 // for smiley support |
8291 // for smiley support |
8228 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley ) |
8292 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley ) |
8229 { |
8293 { |
8230 if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() ) |
8294 if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() && iEdwinExtension ) |
8231 { |
8295 { |
8232 if ( !iEdwinExtension->iSmiley ) |
8296 if ( !iEdwinExtension->iSmiley ) |
8233 { |
8297 { |
8234 iEdwinExtension->iSmiley = CSmileyManager::NewL( *this ); |
8298 iEdwinExtension->iSmiley = CSmileyManager::NewL( *this ); |
8235 iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes ); |
8299 iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes ); |
8255 } |
8319 } |
8256 } |
8320 } |
8257 |
8321 |
8258 TBool CEikEdwin::IsSmileyEnabled() const |
8322 TBool CEikEdwin::IsSmileyEnabled() const |
8259 { |
8323 { |
8260 return ( iEdwinExtension->iSmiley != NULL ); |
8324 TBool ret = EFalse; |
|
8325 if ( iEdwinExtension ) |
|
8326 { |
|
8327 ret = ( iEdwinExtension->iSmiley != NULL ); |
|
8328 } |
|
8329 return ret; |
8261 } |
8330 } |
8262 |
8331 |
8263 void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, |
8332 void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, |
8264 CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt ) |
8333 CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt ) |
8265 { |
8334 { |
8286 text.Copy( aText ); |
8355 text.Copy( aText ); |
8287 TrimText( text ); |
8356 TrimText( text ); |
8288 TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) ); |
8357 TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) ); |
8289 for ( TInt i( 0 ); i < text.Length(); i++ ) |
8358 for ( TInt i( 0 ); i < text.Length(); i++ ) |
8290 { |
8359 { |
8291 if ( CSmileyManager::IsSmileyCode( text[i] ) ) |
8360 if ( iEdwinExtension && CSmileyManager::IsSmileyCode( text[i] ) ) |
8292 { |
8361 { |
8293 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) ); |
8362 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) ); |
8294 TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, |
8363 TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, |
8295 aDrawRect.iBr.iY ); |
8364 aDrawRect.iBr.iY ); |
8296 rgn.SubRect( clipRect, NULL ); |
8365 rgn.SubRect( clipRect, NULL ); |
8302 delete buf; |
8371 delete buf; |
8303 } |
8372 } |
8304 |
8373 |
8305 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode ) |
8374 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode ) |
8306 { |
8375 { |
8307 if ( !iEdwinExtension->iSmiley && !iTextView ) |
8376 if ( iEdwinExtension && !iEdwinExtension->iSmiley && !iTextView ) |
8308 { |
8377 { |
8309 return; |
8378 return; |
8310 } |
8379 } |
8311 TCursorSelection visibleRange( GetVisibleTextRangeL() ); |
8380 TCursorSelection visibleRange( GetVisibleTextRangeL() ); |
8312 ConvertTextForSmileyL( visibleRange, aTextToCode ); |
8381 ConvertTextForSmileyL( visibleRange, aTextToCode ); |
8313 } |
8382 } |
8314 |
8383 |
8315 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, |
8384 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, |
8316 TBool aTextToCode, TBool aRedraw ) |
8385 TBool aTextToCode, TBool aRedraw ) |
8317 { |
8386 { |
8318 if ( iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing ) |
8387 if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing ) |
8319 { |
8388 { |
8320 if ( aTextToCode ) |
8389 if ( aTextToCode ) |
8321 { |
8390 { |
8322 ExtendedRangeForSmiley( aSelect ); |
8391 ExtendedRangeForSmiley( aSelect ); |
8323 } |
8392 } |
8385 return buf; |
8454 return buf; |
8386 } |
8455 } |
8387 |
8456 |
8388 void CEikEdwin::ConvertSmileyIconToTextL( TInt aStartPos, TDes& aText ) |
8457 void CEikEdwin::ConvertSmileyIconToTextL( TInt aStartPos, TDes& aText ) |
8389 { |
8458 { |
8390 if ( iEdwinExtension->iSmiley ) |
8459 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
8391 { |
8460 { |
8392 iEdwinExtension->iSmiley->ConvertTextForSmileyL( aStartPos, |
8461 iEdwinExtension->iSmiley->ConvertTextForSmileyL( aStartPos, |
8393 aText, EFalse ); |
8462 aText, EFalse ); |
8394 } |
8463 } |
8395 } |
8464 } |
8396 |
8465 |
8397 void CEikEdwin::ExtendedRangeForSmiley( TCursorSelection& aSelect ) |
8466 void CEikEdwin::ExtendedRangeForSmiley( TCursorSelection& aSelect ) |
8398 { |
8467 { |
8399 if ( iEdwinExtension->iSmiley ) |
8468 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
8400 { |
8469 { |
8401 TInt textLength( TextLength() ); |
8470 TInt textLength( TextLength() ); |
8402 TInt start = aSelect.LowerPos() - CSmileyManager::KMaxLength; |
8471 TInt start = aSelect.LowerPos() - CSmileyManager::KMaxLength; |
8403 if ( start < 0 ) |
8472 if ( start < 0 ) |
8404 { |
8473 { |
8483 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect ) |
8552 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect ) |
8484 { |
8553 { |
8485 TBool ret( EFalse ); |
8554 TBool ret( EFalse ); |
8486 TCursorSelection select( Selection() ); |
8555 TCursorSelection select( Selection() ); |
8487 TInt cursor( select.iCursorPos ); |
8556 TInt cursor( select.iCursorPos ); |
8488 iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor ); |
8557 if ( iEdwinExtension ) |
|
8558 { |
|
8559 iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor ); |
|
8560 } |
8489 if ( cursor != select.iCursorPos ) |
8561 if ( cursor != select.iCursorPos ) |
8490 { |
8562 { |
8491 if ( select.iAnchorPos == select.iCursorPos ) |
8563 if ( select.iAnchorPos == select.iCursorPos ) |
8492 { |
8564 { |
8493 select.iAnchorPos = cursor; |
8565 select.iAnchorPos = cursor; |
8507 |
8579 |
8508 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, |
8580 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, |
8509 TBool aSelect ) |
8581 TBool aSelect ) |
8510 { |
8582 { |
8511 TBool ret( EFalse ); |
8583 TBool ret( EFalse ); |
8512 if ( iEdwinExtension->iSmiley ) |
8584 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
8513 { |
8585 { |
8514 TInt oldPos( CursorPos() ); |
8586 TInt oldPos( CursorPos() ); |
8515 TInt curPos( oldPos ); |
8587 TInt curPos( oldPos ); |
8516 if ( aMovement == TCursorPosition::EFLeft ) |
8588 if ( aMovement == TCursorPosition::EFLeft ) |
8517 { |
8589 { |
8531 return ret; |
8603 return ret; |
8532 } |
8604 } |
8533 |
8605 |
8534 void CEikEdwin::SetSelectionVisibilityL( TBool aIsVisable ) |
8606 void CEikEdwin::SetSelectionVisibilityL( TBool aIsVisable ) |
8535 { |
8607 { |
8536 if ( iEdwinExtension->iSmiley && !aIsVisable ) |
8608 if ( iEdwinExtension && iEdwinExtension->iSmiley && !aIsVisable ) |
8537 { |
8609 { |
8538 iTextView->SetSelectionVisibilityL( aIsVisable ); |
8610 iTextView->SetSelectionVisibilityL( aIsVisable ); |
8539 HandleSelectionForSmiley( TCursorSelection( 0, 0 ) ); |
8611 HandleSelectionForSmiley( TCursorSelection( 0, 0 ) ); |
8540 } |
8612 } |
8541 else |
8613 else |
8542 { |
8614 { |
8543 if ( iEdwinExtension->iSmiley ) |
8615 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
8544 { |
8616 { |
8545 HandleSelectionForSmiley( Selection() ); |
8617 HandleSelectionForSmiley( Selection() ); |
8546 } |
8618 } |
8547 iTextView->SetSelectionVisibilityL( aIsVisable ); |
8619 iTextView->SetSelectionVisibilityL( aIsVisable ); |
8548 } |
8620 } |
8604 |
8676 |
8605 if ( scrolledPixels != aPixelsToScroll ) |
8677 if ( scrolledPixels != aPixelsToScroll ) |
8606 { |
8678 { |
8607 // We can't move enough, we have exceeded the border |
8679 // We can't move enough, we have exceeded the border |
8608 // (at the beginning or end of the document) |
8680 // (at the beginning or end of the document) |
8609 if ( aPixelsToScroll != 0 ) |
8681 if ( aPixelsToScroll != 0 && iEdwinExtension ) |
8610 { |
8682 { |
8611 if ( aPixelsToScroll < 0 ) |
8683 if ( aPixelsToScroll < 0 ) |
8612 { |
8684 { |
8613 // End of document. Set flag to tell about that |
8685 // End of document. Set flag to tell about that |
8614 iEdwinExtension->iEndBorderExceeded = ETrue; |
8686 iEdwinExtension->iEndBorderExceeded = ETrue; |
8628 // Set variable how many pixels we are out of border |
8700 // Set variable how many pixels we are out of border |
8629 iEdwinExtension->iPixelsOutOfBorder = 0; |
8701 iEdwinExtension->iPixelsOutOfBorder = 0; |
8630 } |
8702 } |
8631 } |
8703 } |
8632 |
8704 |
8633 if ( scrolledPixels != 0 ) |
8705 if ( scrolledPixels != 0 && iEdwinExtension ) |
8634 { |
8706 { |
8635 iEdwinExtension->iScrolledDelta = scrolledPixels; |
8707 iEdwinExtension->iScrolledDelta = scrolledPixels; |
8636 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
8708 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
8637 iEdwinExtension->iScrolledDelta = 0; |
8709 iEdwinExtension->iScrolledDelta = 0; |
8638 } |
8710 } |
8656 // ends (scrolling over the border toward content). In this case we |
8728 // ends (scrolling over the border toward content). In this case we |
8657 // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border. |
8729 // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border. |
8658 // After that we have to move to mode where we use ScrollDisplayPixelsL |
8730 // After that we have to move to mode where we use ScrollDisplayPixelsL |
8659 // to detect if we exceed border again. |
8731 // to detect if we exceed border again. |
8660 TBool adjustScrolling( EFalse ); |
8732 TBool adjustScrolling( EFalse ); |
8661 if ( aPixelsToScroll > 0 && iEdwinExtension->iEndBorderExceeded ) |
8733 if ( iEdwinExtension ) |
8662 { |
8734 { |
8663 if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder ) |
8735 if ( aPixelsToScroll > 0 && iEdwinExtension->iEndBorderExceeded ) |
8664 { |
8736 { |
8665 adjustScrolling = ETrue; |
8737 if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder ) |
8666 } |
8738 { |
8667 } |
8739 adjustScrolling = ETrue; |
8668 else if ( aPixelsToScroll < 0 && iEdwinExtension->iStartBorderExceeded ) |
8740 } |
8669 { |
8741 } |
8670 if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder ) |
8742 else if ( aPixelsToScroll < 0 && iEdwinExtension->iStartBorderExceeded ) |
8671 { |
8743 { |
8672 adjustScrolling = ETrue; |
8744 if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder ) |
8673 } |
8745 { |
8674 } |
8746 adjustScrolling = ETrue; |
8675 |
8747 } |
|
8748 } |
|
8749 } |
|
8750 |
8676 if ( adjustScrolling ) |
8751 if ( adjustScrolling ) |
8677 { |
8752 { |
8678 // we are scrolling over the border, calculate how many |
8753 // we are scrolling over the border, calculate how many |
8679 // pixels we can scroll and how many pixels there is rest |
8754 // pixels we can scroll and how many pixels there is rest |
8680 // after movement |
8755 // after movement |
8683 } |
8758 } |
8684 |
8759 |
8685 // We are out of borders. Call scrolling function that supports bounce-effect |
8760 // We are out of borders. Call scrolling function that supports bounce-effect |
8686 TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) ); |
8761 TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) ); |
8687 |
8762 |
8688 // Update variable that tells how near the border we are. |
8763 if ( iEdwinExtension ) |
8689 iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll; |
8764 { |
8690 |
8765 // Update variable that tells how near the border we are. |
8691 if ( iEdwinExtension->iStartBorderExceeded |
8766 iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll; |
8692 && iEdwinExtension->iPixelsOutOfBorder <= 0 ) |
8767 |
8693 { |
8768 if ( iEdwinExtension->iStartBorderExceeded |
8694 // We are inside borders, reset flag and tell to caller |
8769 && iEdwinExtension->iPixelsOutOfBorder <= 0 ) |
8695 iEdwinExtension->iStartBorderExceeded = EFalse; |
8770 { |
8696 aEndOfBounce = ETrue; |
8771 // We are inside borders, reset flag and tell to caller |
8697 } |
8772 iEdwinExtension->iStartBorderExceeded = EFalse; |
8698 else if ( iEdwinExtension->iEndBorderExceeded |
8773 aEndOfBounce = ETrue; |
8699 && iEdwinExtension->iPixelsOutOfBorder >= 0 ) |
8774 } |
8700 { |
8775 else if ( iEdwinExtension->iEndBorderExceeded |
8701 // we are inside borders, reset flag and tell to caller |
8776 && iEdwinExtension->iPixelsOutOfBorder >= 0 ) |
8702 iEdwinExtension->iEndBorderExceeded = EFalse; |
8777 { |
8703 aEndOfBounce = ETrue; |
8778 // we are inside borders, reset flag and tell to caller |
8704 } |
8779 iEdwinExtension->iEndBorderExceeded = EFalse; |
|
8780 aEndOfBounce = ETrue; |
|
8781 } |
|
8782 } |
8705 |
8783 |
8706 if ( aPixelsToScroll != 0 ) |
8784 if ( aPixelsToScroll != 0 ) |
8707 { |
8785 { |
8708 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
8786 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
8709 } |
8787 } |
8717 // CEikEdwin::PixelsOutOfBorder |
8795 // CEikEdwin::PixelsOutOfBorder |
8718 // --------------------------------------------------------------------------- |
8796 // --------------------------------------------------------------------------- |
8719 // |
8797 // |
8720 TInt CEikEdwin::PixelsOutOfBorder() const |
8798 TInt CEikEdwin::PixelsOutOfBorder() const |
8721 { |
8799 { |
8722 return iEdwinExtension->iPixelsOutOfBorder; |
8800 TInt ret = 0; |
|
8801 if ( iEdwinExtension ) |
|
8802 { |
|
8803 ret = iEdwinExtension->iPixelsOutOfBorder; |
|
8804 } |
|
8805 return ret; |
8723 } |
8806 } |
8724 |
8807 |
8725 // --------------------------------------------------------------------------- |
8808 // --------------------------------------------------------------------------- |
8726 // CEikEdwin::EnableRateScrolling |
8809 // CEikEdwin::EnableRateScrolling |
8727 // --------------------------------------------------------------------------- |
8810 // --------------------------------------------------------------------------- |
8734 |
8817 |
8735 // Use this function to change scrolling mode. |
8818 // Use this function to change scrolling mode. |
8736 // If aEnable is EFalse, Position scrolling mode is in use. |
8819 // If aEnable is EFalse, Position scrolling mode is in use. |
8737 // If aEnable is ETrue, Rate scrolling mode is in use. |
8820 // If aEnable is ETrue, Rate scrolling mode is in use. |
8738 |
8821 |
8739 iEdwinExtension->iUseRateScroll = aEnable; |
8822 if ( iEdwinExtension ) |
|
8823 { |
|
8824 iEdwinExtension->iUseRateScroll = aEnable; |
|
8825 } |
8740 } |
8826 } |
8741 |
8827 |
8742 // --------------------------------------------------------------------------- |
8828 // --------------------------------------------------------------------------- |
8743 // CEikEdwin::StoreCursorState |
8829 // CEikEdwin::StoreCursorState |
8744 // --------------------------------------------------------------------------- |
8830 // --------------------------------------------------------------------------- |
8745 // |
8831 // |
8746 void CEikEdwin::StoreCursorState() |
8832 void CEikEdwin::StoreCursorState() |
8747 { |
8833 { |
8748 CAknEdwinState* state( EditorState() ); |
8834 CAknEdwinState* state( EditorState() ); |
8749 if ( state && state->Flags() & EAknEditorFlagTextCursorVisible ) |
8835 if ( iEdwinExtension && state && state->Flags() & EAknEditorFlagTextCursorVisible ) |
8750 { |
8836 { |
8751 TRAP_IGNORE( SetCursorVisibilityL( EFalse ) ); |
8837 TRAP_IGNORE( SetCursorVisibilityL( EFalse ) ); |
8752 iEdwinExtension->iCursorWasVisible = ETrue; |
8838 iEdwinExtension->iCursorWasVisible = ETrue; |
8753 } |
8839 } |
8754 } |
8840 } |
8757 // CEikEdwin::RestoreCursorState |
8843 // CEikEdwin::RestoreCursorState |
8758 // --------------------------------------------------------------------------- |
8844 // --------------------------------------------------------------------------- |
8759 // |
8845 // |
8760 void CEikEdwin::RestoreCursorState() |
8846 void CEikEdwin::RestoreCursorState() |
8761 { |
8847 { |
8762 if ( iEdwinExtension->iCursorWasVisible ) |
8848 if ( iEdwinExtension && iEdwinExtension->iCursorWasVisible ) |
8763 { |
8849 { |
8764 TRAP_IGNORE( SetCursorVisibilityL( ETrue ) ); |
8850 TRAP_IGNORE( SetCursorVisibilityL( ETrue ) ); |
8765 iEdwinExtension->iCursorWasVisible = EFalse; |
8851 iEdwinExtension->iCursorWasVisible = EFalse; |
8766 } |
8852 } |
8767 } |
8853 } |
8790 TRect viewRect( iTextView->ViewRect() ); |
8876 TRect viewRect( iTextView->ViewRect() ); |
8791 window.Invalidate( viewRect ); |
8877 window.Invalidate( viewRect ); |
8792 window.BeginRedraw( viewRect ); |
8878 window.BeginRedraw( viewRect ); |
8793 gc.Activate( window ); |
8879 gc.Activate( window ); |
8794 |
8880 |
8795 if ( !AknsDrawUtils::DrawBackground( |
8881 if ( iEdwinExtension && |
|
8882 !AknsDrawUtils::DrawBackground( |
8796 iEdwinExtension->iSkinInstance, |
8883 iEdwinExtension->iSkinInstance, |
8797 SkinBackgroundControlContext(), |
8884 SkinBackgroundControlContext(), |
8798 this, |
8885 this, |
8799 gc, |
8886 gc, |
8800 viewRect.iTl, |
8887 viewRect.iTl, |
8820 } |
8907 } |
8821 |
8908 |
8822 |
8909 |
8823 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect ) |
8910 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect ) |
8824 { |
8911 { |
8825 if ( !iEdwinExtension->iSmiley ) |
8912 if ( iEdwinExtension ) |
8826 { |
8913 { |
8827 return; |
8914 if ( !iEdwinExtension->iSmiley ) |
8828 } |
8915 { |
8829 if ( iCustomDrawer ) |
8916 return; |
8830 { |
8917 } |
8831 iEdwinExtension->iSmiley->SetHighlightColor( |
8918 if ( iCustomDrawer ) |
8832 iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, |
8919 { |
8833 KRgbWhite ) ); |
8920 iEdwinExtension->iSmiley->SetHighlightColor( |
8834 } |
8921 iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, |
8835 iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), |
8922 KRgbWhite ) ); |
8836 aSelect.Length() ); |
8923 } |
|
8924 iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), |
|
8925 aSelect.Length() ); |
|
8926 } |
8837 } |
8927 } |
8838 |
8928 |
8839 // --------------------------------------------------------------------------- |
8929 // --------------------------------------------------------------------------- |
8840 // CEikEdwin::SkipBackgroundDrawer |
8930 // CEikEdwin::SkipBackgroundDrawer |
8841 // --------------------------------------------------------------------------- |
8931 // --------------------------------------------------------------------------- |