141 |
137 |
142 // Unicode for euro sign |
138 // Unicode for euro sign |
143 const TInt KEuroSign = 0x20AC; |
139 const TInt KEuroSign = 0x20AC; |
144 const TInt KSegmSize = 1024; |
140 const TInt KSegmSize = 1024; |
145 |
141 |
146 |
142 const TInt KMicroSecondsDelay = 500000; |
147 |
143 |
148 const TInt KNormalAnimPlayTimes = 2; |
144 const TInt KNormalAnimPlayTimes = 2; |
149 const TInt KInfiniteAnimPlayTimes = 0x7ffff; |
145 const TInt KInfiniteAnimPlayTimes = 0x7ffff; |
150 const TInt KAdditionalPixels = 0x400; |
146 const TInt KAdditionalPixels = 0x400; |
151 |
147 |
152 const TInt KFullFormatLengthForSmiley = 5000; |
148 const TInt KFullFormatLengthForSmiley = 5000; |
153 |
|
154 const TInt KContentThreshold = 8; |
|
155 |
|
156 const TInt KNmericSCTLimit( 256 ); |
|
157 const TInt KTInt16Length( sizeof( TInt16 ) ); |
|
158 const TInt KTInt32Length( sizeof( TInt32 ) ); |
|
159 const TInt KTUint32Length( sizeof( TUint32 ) ); |
|
160 |
149 |
161 // |
150 // |
162 // class CEikEdwin::CUndoBuffer |
151 // class CEikEdwin::CUndoBuffer |
163 // |
152 // |
164 |
153 |
226 |
215 |
227 NONSHARABLE_CLASS(CEikEdwinFepSupport) : public CBase, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, public TCoeInputCapabilities::MCoeFepSpecificExtensions |
216 NONSHARABLE_CLASS(CEikEdwinFepSupport) : public CBase, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, public TCoeInputCapabilities::MCoeFepSpecificExtensions |
228 { |
217 { |
229 friend class CEikEdwin; |
218 friend class CEikEdwin; |
230 public: |
219 public: |
231 // The length of text window |
|
232 const static TInt KMaxSegmentLength = 10000; |
|
233 // The threshold for text window position change |
|
234 const static TInt KSegmentUpdateTrigger = 100; |
|
235 |
|
236 static CEikEdwinFepSupport* New(CEikEdwin& aEdwin); |
220 static CEikEdwinFepSupport* New(CEikEdwin& aEdwin); |
237 virtual ~CEikEdwinFepSupport(); |
221 virtual ~CEikEdwinFepSupport(); |
238 TBool IsHandledByFepL(TPointerEvent::TType aType, TUint aModifiers, TInt aDocumentPosition); |
222 TBool IsHandledByFepL(TPointerEvent::TType aType, TUint aModifiers, TInt aDocumentPosition); |
239 /** |
223 /** |
240 * Set the input capabilities in the edwin fep support object. A copy of the input capabilities |
224 * Set the input capabilities in the edwin fep support object. A copy of the input capabilities |
246 const TCoeInputCapabilities* InputCapabilities() const; |
230 const TCoeInputCapabilities* InputCapabilities() const; |
247 void ConstructStateHolder(); |
231 void ConstructStateHolder(); |
248 // from MCoeFepAwareTextEditor_Extension1 |
232 // from MCoeFepAwareTextEditor_Extension1 |
249 void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid); |
233 void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid); |
250 CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership |
234 CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership |
251 |
235 |
252 // New functions for Touch Input sync performance improvement. A sliding window method is used |
|
253 // here to show only part of text of editor to Touch Input, so the text sync between Touch input and |
|
254 // editor can be faster. |
|
255 /** |
|
256 * To update start position of text window according to cursor position. The cursor position has to |
|
257 * be in the visible text window. |
|
258 */ |
|
259 void UpdateDocPosOffsetL( TInt aCursorPos ); |
|
260 |
|
261 /** |
|
262 * To check if FEP wants to get information of whole text, not the text window. |
|
263 */ |
|
264 TBool FepRequireWholeTextData() const; |
|
265 |
|
266 private: |
236 private: |
267 enum TPointerState |
237 enum TPointerState |
268 { |
238 { |
269 EPointerIsUp, |
239 EPointerIsUp, |
270 EPointerIsDownStartingInsideInlineText, |
240 EPointerIsDownStartingInsideInlineText, |
550 iPositionOfInlineTextInDocument=selection.LowerPos(); |
518 iPositionOfInlineTextInDocument=selection.LowerPos(); |
551 iPointerEventHandlerDuringInlineEdit=&aPointerEventHandlerDuringInlineEdit; |
519 iPointerEventHandlerDuringInlineEdit=&aPointerEventHandlerDuringInlineEdit; |
552 TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
520 TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
553 TInt numberOfCharactersSuccessfullyDeleted=0; |
521 TInt numberOfCharactersSuccessfullyDeleted=0; |
554 TInt numberOfCharactersSuccessfullyInserted=0; |
522 TInt numberOfCharactersSuccessfullyInserted=0; |
555 |
|
556 iEdwin.ConvertSmileyForDeleteL( selection ); |
|
557 |
|
558 // handle extended highlights |
523 // handle extended highlights |
559 |
524 |
560 /* |
525 /* |
561 WARNING. do not insert any leaving function calls after the iEdwin.iText->StartFepInlineEditL unless they are trapped |
526 WARNING. do not insert any leaving function calls after the iEdwin.iText->StartFepInlineEditL unless they are trapped |
562 as this will call update-state problems. |
527 as this will call update-state problems. |
605 TInt numberOfCharactersSuccessfullyDeleted=0; |
570 TInt numberOfCharactersSuccessfullyDeleted=0; |
606 TInt numberOfCharactersSuccessfullyInserted=0; |
571 TInt numberOfCharactersSuccessfullyInserted=0; |
607 TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText)); |
572 TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText)); |
608 iLengthOfInlineText=numberOfCharactersSuccessfullyInserted; |
573 iLengthOfInlineText=numberOfCharactersSuccessfullyInserted; |
609 UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error); |
574 UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error); |
|
575 iEdwin.ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
610 } |
576 } |
611 |
577 |
612 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility) |
578 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility) |
613 { |
579 { |
|
580 __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState7)); // assert that we're currently inline editing |
|
581 __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState8)); |
614 iEdwin.SetCursorVisibilityL(aCursorVisibility); |
582 iEdwin.SetCursorVisibilityL(aCursorVisibility); |
615 iShowCursor = aCursorVisibility; |
583 iShowCursor = aCursorVisibility; |
616 } |
584 } |
617 |
585 |
618 void CEikEdwinFepSupport::CancelFepInlineEdit() |
586 void CEikEdwinFepSupport::CancelFepInlineEdit() |
654 #endif |
622 #endif |
655 } |
623 } |
656 |
624 |
657 TInt CEikEdwinFepSupport::DocumentLengthForFep() const |
625 TInt CEikEdwinFepSupport::DocumentLengthForFep() const |
658 { |
626 { |
659 // If the length between text window start position and text end is shorter |
|
660 // than length of text window, return the short length, otherwise return |
|
661 // text window length. |
|
662 if ( !FepRequireWholeTextData() && iEdwin.TextLength() > KMaxSegmentLength ) |
|
663 { |
|
664 TInt lengthToEnd( iEdwin.TextLength() - iDocPosOffset ); |
|
665 if ( lengthToEnd < KMaxSegmentLength ) |
|
666 { |
|
667 return lengthToEnd; |
|
668 } |
|
669 return KMaxSegmentLength; |
|
670 } |
|
671 return iEdwin.TextLength(); |
627 return iEdwin.TextLength(); |
672 } |
628 } |
673 |
629 |
674 TInt CEikEdwinFepSupport::DocumentMaximumLengthForFep() const |
630 TInt CEikEdwinFepSupport::DocumentMaximumLengthForFep() const |
675 { |
631 { |
676 // return the length between textlimit and text window start position |
|
677 if ( !FepRequireWholeTextData() && KMaxSegmentLength < iEdwin.iTextLimit ) |
|
678 { |
|
679 return iEdwin.iTextLimit - iDocPosOffset; |
|
680 } |
|
681 return iEdwin.iTextLimit; |
632 return iEdwin.iTextLimit; |
682 } |
633 } |
683 |
634 |
684 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection) |
635 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection) |
685 { |
636 { |
686 // if text window is enabled, the pos of parameter selection are relative to |
|
687 // text window start position, so convert them back to actual doc pos. |
|
688 TInt cursorPos( aCursorSelection.iCursorPos ); |
637 TInt cursorPos( aCursorSelection.iCursorPos ); |
689 TInt anchorPos( aCursorSelection.iAnchorPos ); |
638 TInt anchorPos( aCursorSelection.iAnchorPos ); |
690 TInt textLength( iEdwin.TextLength() ); |
|
691 if ( !FepRequireWholeTextData() ) |
|
692 { |
|
693 cursorPos += iDocPosOffset; |
|
694 anchorPos += iDocPosOffset; |
|
695 cursorPos = cursorPos > textLength ? textLength : cursorPos; |
|
696 anchorPos = anchorPos > textLength ? textLength : anchorPos; |
|
697 if ( cursorPos != anchorPos ) |
|
698 { |
|
699 TCursorSelection select( iEdwin.Selection() ); |
|
700 if ( ( anchorPos == iDocPosOffset || anchorPos == iDocPosOffset + |
|
701 KMaxSegmentLength ) && anchorPos >= select.LowerPos() && |
|
702 anchorPos <= select.HigherPos() ) |
|
703 { |
|
704 anchorPos = cursorPos > anchorPos ? select.LowerPos() : |
|
705 select.HigherPos(); |
|
706 } |
|
707 } |
|
708 } |
|
709 // Selection position can not be in smiley code string, so check if |
|
710 // the position needs to be changed. |
|
711 if ( iEdwin.IsSmileyEnabled() ) |
639 if ( iEdwin.IsSmileyEnabled() ) |
712 { |
640 { |
713 CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley ); |
641 CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley ); |
714 TInt oldPos = ( cursorPos == anchorPos ) ? iEdwin.CursorPos() : anchorPos; |
642 TInt oldPos = ( cursorPos == anchorPos ) ? iEdwin.CursorPos() : anchorPos; |
715 smiley->HandleSetCursor( oldPos, cursorPos ); |
643 smiley->HandleSetCursor( oldPos, cursorPos ); |
720 else |
648 else |
721 { |
649 { |
722 smiley->HandleSetCursor( cursorPos, anchorPos ); |
650 smiley->HandleSetCursor( cursorPos, anchorPos ); |
723 } |
651 } |
724 } |
652 } |
725 iEdwin.SetSelectionL( cursorPos, anchorPos ); |
653 iEdwin.SetSelectionL( cursorPos, anchorPos ); |
726 // Cursor pos is changed, so update text window position. |
|
727 UpdateDocPosOffsetL( cursorPos ); |
|
728 iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
654 iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
729 } |
655 } |
730 |
656 |
731 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const |
657 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const |
732 { |
658 { |
733 aCursorSelection=iEdwin.Selection(); |
659 aCursorSelection=iEdwin.Selection(); |
734 // To use text window, FEP can not access text view of editor directly but |
|
735 // FEP needs to know some information which can not be provided by current |
|
736 // interface. So use below method to transfer the information to FEP. |
|
737 CAknEdwinState* state( iEdwin.EditorState() ); |
|
738 if ( state ) |
|
739 { |
|
740 TInt flag( state->Flags() ); |
|
741 TTmDocPos docPos; |
|
742 iEdwin.TextView()->GetCursorPos( docPos ); |
|
743 if ( docPos.iLeadingEdge ) |
|
744 { |
|
745 flag |= EAknEditorFlagCursorLedingEdge; |
|
746 } |
|
747 else |
|
748 { |
|
749 flag &= ~EAknEditorFlagCursorLedingEdge; |
|
750 } |
|
751 state->SetFlags( flag ); |
|
752 } |
|
753 // If text window is enabled, convert the actual doc pos to relative doc pos. |
|
754 if ( !FepRequireWholeTextData() ) |
|
755 { |
|
756 if ( aCursorSelection.iAnchorPos < iDocPosOffset ) |
|
757 { |
|
758 aCursorSelection.iAnchorPos = iDocPosOffset; |
|
759 } |
|
760 else if ( aCursorSelection.iAnchorPos > iDocPosOffset + KMaxSegmentLength ) |
|
761 { |
|
762 aCursorSelection.iAnchorPos = iDocPosOffset + KMaxSegmentLength; |
|
763 } |
|
764 aCursorSelection.iCursorPos -= iDocPosOffset; |
|
765 aCursorSelection.iAnchorPos -= iDocPosOffset; |
|
766 } |
|
767 } |
660 } |
768 |
661 |
769 void CEikEdwinFepSupport::GetEditorContentForFep(TDes& aEditorContent,TInt aDocumentPosition,TInt aLengthToRetrieve) const |
662 void CEikEdwinFepSupport::GetEditorContentForFep(TDes& aEditorContent,TInt aDocumentPosition,TInt aLengthToRetrieve) const |
770 { |
663 { |
771 // If text window is enabled, convert relative doc pos to actual doc pos. |
|
772 if ( !FepRequireWholeTextData() ) |
|
773 { |
|
774 aDocumentPosition += iDocPosOffset; |
|
775 } |
|
776 TInt length( Min( aLengthToRetrieve, iEdwin.TextLength() - aDocumentPosition ) ); |
664 TInt length( Min( aLengthToRetrieve, iEdwin.TextLength() - aDocumentPosition ) ); |
777 if ( !FepRequireWholeTextData() ) |
|
778 { |
|
779 length = Min( length, KMaxSegmentLength ); |
|
780 } |
|
781 iEdwin.iText->Extract( aEditorContent, aDocumentPosition, length ); |
665 iEdwin.iText->Extract( aEditorContent, aDocumentPosition, length ); |
782 CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley ); |
666 if ( iEdwin.IsSmileyEnabled() ) |
783 if ( smiley && smiley->HasSmileyIconsInText() ) |
667 { |
784 { |
668 CSmileyManager* smiley( iEdwin.iEdwinExtension->iSmiley ); |
785 CAknEdwinState* state( iEdwin.EditorState() ); |
669 CAknEdwinState* state( iEdwin.EditorState() ); |
786 if ( state ) |
670 if ( state ) |
787 { |
671 { |
788 TCursorSelection inlineText( state->CurrentInlineEditSpan() ); |
672 TCursorSelection inlineText( state->CurrentInlineEditSpan() ); |
789 if ( aDocumentPosition >= inlineText.LowerPos() && |
673 if ( aDocumentPosition >= inlineText.LowerPos() && |
790 aDocumentPosition + length <= inlineText.HigherPos() ) |
674 aDocumentPosition + length <= inlineText.HigherPos() ) |
791 { |
675 { |
792 TRAP_IGNORE( smiley->ConvertTextForSmileyL( aDocumentPosition, aEditorContent, |
676 iEdwin.iEdwinExtension->iSmiley->ConvertTextForSmileyL( |
793 EFalse ); ) |
677 aDocumentPosition, aEditorContent, EFalse ); |
794 } |
678 } |
795 } |
679 } |
796 // Replace all 'i' following smiley code to invisbile placeholder for |
680 TBool prevIsCode( EFalse ); |
797 // Touch Input can not recognize it as part of smiley code string. |
|
798 TInt smileyEndPos( 0 ); |
|
799 for ( TInt i( 0 ); i < length; i++ ) |
681 for ( TInt i( 0 ); i < length; i++ ) |
800 { |
682 { |
801 if ( aEditorContent[i] == CSmileyManager::KCompensateChar ) |
683 if ( aEditorContent[i] == CSmileyManager::KCompensateChar ) |
802 { |
684 { |
803 // when 'i' is the first character, it is unkonwn whether it is |
685 if ( i == 0 ) |
804 // part of a smiley code string or not, so we have to use another |
686 { |
805 // function to decide. |
687 prevIsCode = ( CSmileyManager::IsSmileyCode( |
806 if ( ( i > 0 && i < smileyEndPos ) || |
688 smiley->SmileyCodeByPos( aDocumentPosition ) ) ); |
807 ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) ) |
689 } |
|
690 if ( prevIsCode ) |
808 { |
691 { |
809 aEditorContent[i] = CSmileyManager::KPlaceHolder; |
692 aEditorContent[i] = CSmileyManager::KPlaceHolder; |
810 } |
693 } |
811 } |
694 } |
812 else if ( smiley->IsSmileyCode( aEditorContent[i] ) ) |
695 else |
813 { |
696 { |
814 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i ); |
697 prevIsCode = CSmileyManager::IsSmileyCode( aEditorContent[i] ); |
815 } |
698 } |
816 } |
699 } |
817 } |
700 } |
818 } |
701 } |
819 |
702 |
823 STATIC_CAST(CGlobalText*,iEdwin.iText)->GetCharFormat(aFormat,notUsed,aDocumentPosition,(aDocumentPosition==iEdwin.TextLength())? 0: 1); |
706 STATIC_CAST(CGlobalText*,iEdwin.iText)->GetCharFormat(aFormat,notUsed,aDocumentPosition,(aDocumentPosition==iEdwin.TextLength())? 0: 1); |
824 } |
707 } |
825 |
708 |
826 void CEikEdwinFepSupport::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,TInt& aHeight,TInt& aAscent,TInt aDocumentPosition) const |
709 void CEikEdwinFepSupport::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine,TInt& aHeight,TInt& aAscent,TInt aDocumentPosition) const |
827 { |
710 { |
828 // If text window is enabled, convert relative doc pos to actual doc pos. |
|
829 aDocumentPosition += iDocPosOffset; |
|
830 aDocumentPosition %= ( iEdwin.iText->DocumentLength() + 1 ); |
711 aDocumentPosition %= ( iEdwin.iText->DocumentLength() + 1 ); |
831 iEdwin.iTextView->DocPosToXyPosL(aDocumentPosition,aLeftSideOfBaseLine); |
712 iEdwin.iTextView->DocPosToXyPosL(aDocumentPosition,aLeftSideOfBaseLine); |
832 aLeftSideOfBaseLine+=iEdwin.DrawableWindow()->InquireOffset(iEdwin.iCoeEnv->RootWin()); // make position "absolute" (i.e. not relative to the window that iEdwin is using) - note that *any* group window can be passed into InquireOffset to return the desired result, it doesn't have to be an ancestor of the window being used by iEdwin (i.e. this line of code does *not* make the assumption that iEdwin is (even indirectly) attached to iCoeEnv->RootWin()) |
713 aLeftSideOfBaseLine+=iEdwin.DrawableWindow()->InquireOffset(iEdwin.iCoeEnv->RootWin()); // make position "absolute" (i.e. not relative to the window that iEdwin is using) - note that *any* group window can be passed into InquireOffset to return the desired result, it doesn't have to be an ancestor of the window being used by iEdwin (i.e. this line of code does *not* make the assumption that iEdwin is (even indirectly) attached to iCoeEnv->RootWin()) |
833 iEdwin.iLayout->GetCharacterHeightAndAscentL(aDocumentPosition,aHeight,aAscent); |
714 iEdwin.iLayout->GetCharacterHeightAndAscentL(aDocumentPosition,aHeight,aAscent); |
834 } |
715 } |
841 |
722 |
842 void CEikEdwinFepSupport::DoCommitFepInlineEditL() |
723 void CEikEdwinFepSupport::DoCommitFepInlineEditL() |
843 { |
724 { |
844 __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing |
725 __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing |
845 __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10)); |
726 __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10)); |
|
727 iEdwin.iEdwinExtension->iInlineEditing = EFalse; |
846 iCharsInserted = 0; |
728 iCharsInserted = 0; |
847 iCharsDeleted = 0; |
729 iCharsDeleted = 0; |
848 TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
730 TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse; |
849 TInt numberOfCharactersSuccessfullyDeleted=0; |
731 TInt numberOfCharactersSuccessfullyDeleted=0; |
850 TInt numberOfCharactersSuccessfullyInserted=0; |
732 TInt numberOfCharactersSuccessfullyInserted=0; |
993 |
865 |
994 void CEikEdwinFepSupport::MCoeFepSpecificExtensions_Reserved_2() |
866 void CEikEdwinFepSupport::MCoeFepSpecificExtensions_Reserved_2() |
995 { |
867 { |
996 } |
868 } |
997 |
869 |
998 // Update start position of text window, when cursor pos is out of current |
|
999 // text window or it is in trigger range, the text window position needs to |
|
1000 // be changed and notify FEP the text change. |
|
1001 void CEikEdwinFepSupport::UpdateDocPosOffsetL( TInt aCursorPos ) |
|
1002 { |
|
1003 if ( FepRequireWholeTextData() ) |
|
1004 { |
|
1005 return; |
|
1006 } |
|
1007 if ( iEdwin.TextLength() > KMaxSegmentLength ) |
|
1008 { |
|
1009 TInt halfSegment( KMaxSegmentLength / 2 ); |
|
1010 TBool validDocPosOffset( iDocPosOffset >= 0 && aCursorPos > iDocPosOffset && |
|
1011 aCursorPos - iDocPosOffset < KMaxSegmentLength ); |
|
1012 TBool cursorInHead( validDocPosOffset && |
|
1013 aCursorPos - iDocPosOffset < KSegmentUpdateTrigger ); |
|
1014 TBool cursorInTail( validDocPosOffset && |
|
1015 iDocPosOffset + KMaxSegmentLength - aCursorPos < KSegmentUpdateTrigger && |
|
1016 iDocPosOffset + KMaxSegmentLength < iEdwin.TextLength() ); |
|
1017 if ( !validDocPosOffset || cursorInHead || cursorInTail ) |
|
1018 { |
|
1019 if ( iEdwin.TextLength() - aCursorPos < halfSegment ) |
|
1020 { |
|
1021 iDocPosOffset = iEdwin.TextLength() - KMaxSegmentLength; |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 iDocPosOffset = aCursorPos - halfSegment; |
|
1026 iDocPosOffset = iDocPosOffset >= 0 ? iDocPosOffset : 0; |
|
1027 } |
|
1028 static_cast<CAknEdwinState*>( State( KNullUid ) )->ReportAknEdStateEventL( |
|
1029 MAknEdStateObserver::EAknCursorPositionChanged ); |
|
1030 } |
|
1031 } |
|
1032 } |
|
1033 |
|
1034 // Check if FEP set the flag to indicate it wants to get information of whole |
|
1035 // text, not the text window. |
|
1036 TBool CEikEdwinFepSupport::FepRequireWholeTextData() const |
|
1037 { |
|
1038 CAknEdwinState* state( static_cast<CAknEdwinState*>( |
|
1039 const_cast<CEikEdwinFepSupport*>( this )->State(KNullUid) ) ); |
|
1040 return ( state->Flags() & EAknEditorFlagNeedWholeTextData ); |
|
1041 } |
|
1042 |
870 |
1043 // |
871 // |
1044 // CEikEdwinExtension |
872 // CEikEdwinExtension |
1045 // |
873 // |
1046 CEikEdwin::CEikEdwinExtension* CEikEdwin::CEikEdwinExtension::NewL(CEikEdwin* aEdwin) |
874 CEikEdwin::CEikEdwinExtension* CEikEdwin::CEikEdwinExtension::NewL(CEikEdwin* aEdwin) |
1305 } |
1132 } |
1306 |
1133 |
1307 // --------------------------------------------------------------------------- |
1134 // --------------------------------------------------------------------------- |
1308 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL |
1135 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL |
1309 // --------------------------------------------------------------------------- |
1136 // --------------------------------------------------------------------------- |
1310 // |
1137 // |
1311 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL( CAknPhysics* aPhysics ) |
1138 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL() |
1312 { |
1139 { |
1313 iFlags.Set( EKineticScrollingEnabled ); |
1140 iFlags.Set( EKineticScrollingEnabled ); |
1314 EnablePhysicsL( aPhysics ); |
1141 EnablePhysicsL(); |
1315 } |
1142 } |
1316 |
1143 |
1317 // --------------------------------------------------------------------------- |
1144 // --------------------------------------------------------------------------- |
1318 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL |
1145 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL |
1319 // --------------------------------------------------------------------------- |
1146 // --------------------------------------------------------------------------- |
1320 // |
1147 // |
1321 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL( CAknPhysics* aPhysics ) |
1148 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL() |
1322 { |
1149 { |
1323 if ( iFlags.IsSet( EKineticScrollingEnabled ) |
1150 if ( iFlags.IsSet( EKineticScrollingEnabled ) |
1324 && !iPhysicsHandler && iEdwin->DrawableWindow() ) |
1151 && !iPhysicsHandler && iEdwin->DrawableWindow() ) |
1325 { |
1152 { |
1326 iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin, aPhysics ); |
1153 iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin ); |
1327 |
1154 |
1328 InitPhysicsL(); |
1155 InitPhysicsL(); |
1329 if ( iEdwin->iLayout ) |
1156 if ( iEdwin->iLayout ) |
1330 { |
1157 { |
1331 iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse ); |
1158 iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse ); |
2401 ret=EKeyWasNotConsumed; |
2227 ret=EKeyWasNotConsumed; |
2402 break; |
2228 break; |
2403 } |
2229 } |
2404 InChar: CheckNotReadOnlyL(); |
2230 InChar: CheckNotReadOnlyL(); |
2405 TChar character(code); |
2231 TChar character(code); |
2406 if ( selectionLength ) |
2232 if ( selectionLength && IsValidNumericCharL(character) ) |
2407 { |
2233 { |
2408 TInt pos=DeleteHighlightL(formatHasChanged); |
2234 TInt pos=DeleteHighlightL(formatHasChanged); |
2409 TRAPD(err,iText->InsertL(pos,character)); |
2235 TRAPD(err,iText->InsertL(pos,character)); |
2410 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2236 if ( iEdwinExtension->iSmiley ) |
2411 { |
2237 { |
2412 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 ); |
2238 iEdwinExtension->iSmiley->HandleInsertL( pos, 1 ); |
2413 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue ); |
2239 ConvertTextForSmileyL( TCursorSelection( pos, pos ), ETrue ); |
2414 } |
2240 } |
2415 TCursorSelection selection=iTextView->Selection(); |
2241 TCursorSelection selection=iTextView->Selection(); |
2425 User::LeaveIfError(err); |
2251 User::LeaveIfError(err); |
2426 reportChange=ETrue; |
2252 reportChange=ETrue; |
2427 formatChange=formatHasChanged; |
2253 formatChange=formatHasChanged; |
2428 break; |
2254 break; |
2429 } |
2255 } |
2430 if ( !iTextLimit || TextLength()<iTextLimit ) |
2256 if ( (!iTextLimit || TextLength()<iTextLimit) && IsValidNumericCharL(character) ) |
2431 { |
2257 { |
2432 iText->InsertL(CursorPos(),character); |
2258 iText->InsertL(CursorPos(),character); |
2433 ClearUndo(); |
2259 ClearUndo(); |
2434 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2260 if ( iEdwinExtension->iSmiley ) |
2435 { |
2261 { |
2436 TInt cursorPos( CursorPos() ); |
2262 TInt cursorPos( CursorPos() ); |
2437 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 ); |
2263 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, 1 ); |
2438 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2264 ConvertTextForSmileyL( TCursorSelection( cursorPos, cursorPos ), |
2439 ETrue ); |
2265 ETrue ); |
2450 } |
2276 } |
2451 if (reportChange) |
2277 if (reportChange) |
2452 { |
2278 { |
2453 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
2279 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
2454 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
2280 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
2455 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
2281 if ( iEdwinExtension->iSmiley ) |
2456 { |
2282 { |
2457 TInt docPos( CursorPos() ); |
2283 TInt docPos( CursorPos() ); |
2458 iEdwinExtension->iSmiley->HandleSetCursor( docPos, |
2284 iEdwinExtension->iSmiley->HandleSetCursor( docPos, |
2459 docPos ); |
2285 docPos ); |
2460 if ( docPos != CursorPos() ) |
2286 if ( docPos != CursorPos() ) |
2461 { |
2287 { |
2462 SetCursorPosL( docPos, SelectionLength() > 0 ); |
2288 SetCursorPosL( docPos, SelectionLength() > 0 ); |
2463 } |
2289 } |
2464 } |
2290 } |
2465 } |
2291 } |
2466 if ( navigation && iEdwinExtension ) |
2292 if (navigation) |
2467 { |
2293 { |
2468 iEdwinExtension->iThumbPos = KErrNotFound; |
2294 iEdwinExtension->iThumbPos = KErrNotFound; |
2469 ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
2295 ReportEdwinEventL(MEikEdwinObserver::EEventNavigation); |
2470 } |
2296 } |
2471 if (formatChange) |
2297 if (formatChange) |
2958 MoveCursorL(TCursorPosition::EFLineUp,select); |
2770 MoveCursorL(TCursorPosition::EFLineUp,select); |
2959 rect.Move(0,-(viewRect.Height()+2000)); |
2771 rect.Move(0,-(viewRect.Height()+2000)); |
2960 } |
2772 } |
2961 Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect); |
2773 Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect); |
2962 navigation = ETrue; |
2774 navigation = ETrue; |
2963 if ( iLayout && !iLayout->IsFormattingBand() ) |
2775 iEdwinExtension->iThumbPos = KErrNotFound; |
2964 { |
|
2965 iEdwinExtension->iThumbPos = KErrNotFound; |
|
2966 } |
|
2967 } |
2776 } |
2968 else if (iEdwinInternalFlags&EDragDouble) |
2777 else if (iEdwinInternalFlags&EDragDouble) |
2969 { |
2778 { |
2970 TInt newWordStartPos,newWordLength; |
2779 TInt newWordStartPos,newWordLength; |
2971 GetWordInfo(newCursorPos,newWordStartPos,newWordLength); |
2780 GetWordInfo(newCursorPos,newWordStartPos,newWordLength); |
3055 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && editingEnabled ) |
2864 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && editingEnabled ) |
3056 { |
2865 { |
3057 // on down event feedback is given if cursor/selection changes |
2866 // on down event feedback is given if cursor/selection changes |
3058 if ( paintingPossible && !readOnly || editorWillGetFocus ) |
2867 if ( paintingPossible && !readOnly || editorWillGetFocus ) |
3059 { |
2868 { |
3060 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackEdit ); |
2869 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBasic ); |
3061 } |
2870 } |
3062 } |
2871 } |
3063 else if ( selectionChanged && |
2872 else if ( selectionChanged && |
3064 ( selectionAfter.iAnchorPos != selectionAfter.iCursorPos ) && |
2873 ( ( aPointerEvent.iType == TPointerEvent::EDrag ) || |
3065 ( ( aPointerEvent.iType == TPointerEvent::EDrag ) || |
|
3066 ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) ) |
2874 ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) ) |
3067 { |
2875 { |
|
2876 |
|
2877 // selectionAfter.iCursorPos-1 below is because we need to select the previous char |
|
2878 TBool ltr = ( selectionAfter.iCursorPos >= selectionBefore.iCursorPos ); |
3068 TInt readPos = selectionAfter.iCursorPos; |
2879 TInt readPos = selectionAfter.iCursorPos; |
3069 if ( selectionAfter.iCursorPos > selectionAfter.iAnchorPos ) |
2880 if (ltr && readPos > 0) |
3070 { |
2881 { |
3071 readPos -= 1;//drag backword |
2882 readPos -= 1; // read previous char |
3072 } |
2883 } |
3073 TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; |
2884 TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; |
3074 TBool isSpace = currentSelectedChar.IsSpace(); |
2885 TBool isSpace = currentSelectedChar.IsSpace(); |
3075 TBool isSmiley = CSmileyManager::IsSmileyCode(currentSelectedChar); |
2886 TBool isText = currentSelectedChar.IsAlpha() |
3076 TBool isText = currentSelectedChar.IsGraph(); |
2887 || currentSelectedChar.IsDigit(); |
3077 |
2888 |
3078 // case line |
2889 // case line |
3079 TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos); |
2890 TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos); |
3080 TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos); |
2891 TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos); |
3081 if ( prevLineNr != lineNr ) |
2892 if ( prevLineNr != lineNr && ( selection.Length() != 0 ) ) |
3082 { |
2893 { |
3083 TInt group = currentSelectedChar.GetCategory(); |
2894 TInt group = ( currentSelectedChar.GetCategory() & 0xF0 ); |
3084 TBool isEmptyLine = ( group == TChar::EZpCategory ); |
2895 TBool isEmptyLine = ( group == TChar::ESeparatorGroup ); |
3085 TTouchLogicalFeedback fType = ( isEmptyLine ? |
2896 TTouchLogicalFeedback fType = ( isEmptyLine ? |
3086 ETouchFeedbackEmptyLineSelection : ETouchFeedbackLineSelection ); |
2897 ETouchFeedbackEmptyLineSelection : ETouchFeedbackLineSelection ); |
3087 iEdwinFepSupport->iFeedback->InstantFeedback( this, fType ); |
2898 iEdwinFepSupport->iFeedback->InstantFeedback( this, fType ); |
3088 } |
2899 } |
3089 // case space |
2900 // case space |
3090 else if (isSpace) |
2901 else if (isSpace) |
3091 { |
2902 { |
3092 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection ); |
2903 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection ); |
3093 } |
2904 } |
3094 // case text |
2905 // case text |
3095 else if ( isText || isSmiley ) |
2906 else if (isText) |
3096 { |
2907 { |
3097 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection ); |
2908 iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection ); |
3098 } |
2909 } |
3099 } |
2910 } |
3100 } |
2911 } |
3258 } |
3059 } |
3259 |
3060 |
3260 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 |
3261 |
3062 |
3262 // Create the required formatters according to the editor set-up |
3063 // Create the required formatters according to the editor set-up |
3263 if ( IsPurePhoneNumberEditor() && iEdwinExtension ) |
3064 if ( IsPurePhoneNumberEditor() ) |
3264 { |
3065 { |
3265 if ( phoneNumberGroupingSupported ) |
3066 if ( phoneNumberGroupingSupported ) |
3266 { |
3067 { |
3267 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3068 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3268 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3069 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3269 iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText ); |
3070 iEdwinExtension->CreatePurePhoneNumberFormatterL( *iLayout, *iText ); |
3270 } |
3071 } |
3271 } |
3072 } |
3272 else if ( iEdwinExtension )// Make approximation that all other editors have no matches indicator functionality |
3073 else // Make approximation that all other editors have no matches indicator functionality |
3273 { |
3074 { |
3274 iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout ); |
3075 iEdwinExtension->CreateNoMatchesIndicatorFormatterL( *iLayout ); |
3275 } |
3076 } |
3276 |
3077 |
3277 // Rich text editors that have been configured for phone number grouping |
3078 // Rich text editors that have been configured for phone number grouping |
3278 if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping && |
3079 if (iEdwinInternalFlags&ERichText && iEdwinInternalFlags&EPhoneNumberGrouping && |
3279 phoneNumberGroupingSupported && iEdwinExtension ) |
3080 phoneNumberGroupingSupported ) |
3280 { |
3081 { |
3281 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3082 CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*, iEdwinFepSupport->State(KNullUid) ); |
3282 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3083 edwinState->SetFlags( edwinState->Flags() | EAknEditorFlagNumberGrouping ); |
3283 iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) ); |
3084 iEdwinExtension->CreateRichTextPhoneNumberFormatterL( *iLayout, *(static_cast<CRichText*>(iText)) ); |
3284 } |
3085 } |
3285 |
3086 |
3286 // Install the custom formatter system if needed |
3087 // Install the custom formatter system if needed |
3287 if ( iEdwinExtension && iEdwinExtension->FormExtendedInferfaceProvider() ) |
3088 if ( iEdwinExtension->FormExtendedInferfaceProvider() ) |
3288 TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() ); |
3089 TextLayout()->SetInterfaceProvider( iEdwinExtension->FormExtendedInferfaceProvider() ); |
3289 |
3090 |
3290 UpdateScrollBarsL(); |
3091 UpdateScrollBarsL(); |
3291 ForceScrollBarUpdateL(); |
3092 ForceScrollBarUpdateL(); |
3292 |
3093 |
3579 { |
3377 { |
3580 const TInt count=iObserverArray->Count(); |
3378 const TInt count=iObserverArray->Count(); |
3581 for (TInt ii=0;ii<count;ii++) |
3379 for (TInt ii=0;ii<count;ii++) |
3582 (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType); |
3380 (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType); |
3583 } |
3381 } |
3584 if ( aEventType == MEikEdwinObserver::EEventTextUpdate && iEdwinExtension ) |
3382 if ( aEventType == MEikEdwinObserver::EEventScroll || |
|
3383 aEventType == MEikEdwinObserver::EEventNavigation |
|
3384 ) |
|
3385 { |
|
3386 HandleScrollForSmileyL(); |
|
3387 } |
|
3388 if ( aEventType == MEikEdwinObserver::EEventTextUpdate ) |
3585 { |
3389 { |
3586 iEdwinExtension->iExtendedInputCapabilities->ReportEventL( |
3390 iEdwinExtension->iExtendedInputCapabilities->ReportEventL( |
3587 CAknExtendedInputCapabilities:: |
3391 CAknExtendedInputCapabilities:: |
3588 MAknEventObserver::EControlContentUpdatedInternally, |
3392 MAknEventObserver::EControlContentUpdatedInternally, |
3589 NULL ); |
3393 NULL ); |
3672 ScrollIfAtTopOrBottomL(); |
3476 ScrollIfAtTopOrBottomL(); |
3673 |
3477 |
3674 if ( iEdwinFepSupport && |
3478 if ( iEdwinFepSupport && |
3675 ( aDocPos != oldPos || ( select.Length() > 0 && !aSelect ) ) ) |
3479 ( aDocPos != oldPos || ( select.Length() > 0 && !aSelect ) ) ) |
3676 { |
3480 { |
3677 // Update text window position for cursor change. |
|
3678 iEdwinFepSupport->UpdateDocPosOffsetL( docPos ); |
|
3679 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3481 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3680 if ( edwinState ) |
3482 if ( edwinState ) |
3681 { |
3483 { |
3682 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3484 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3683 } |
3485 } |
3684 } |
3486 } |
3685 // scrollbar:thumb is displayed on the top when editor set cursor position. |
3487 |
3686 iEdwinExtension->iThumbPos = KErrNotFound; |
|
3687 UpdateVertScrollBarThumbL(); |
3488 UpdateVertScrollBarThumbL(); |
3688 UpdateHorizScrollBarThumb(); |
3489 UpdateHorizScrollBarThumb(); |
3689 } |
3490 } |
3690 |
3491 |
3691 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner) |
3492 EXPORT_C void CEikEdwin::SetDocumentOwnership(TOwnershipType aOwner) |
3716 iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos ); |
3517 iEdwinExtension->iSmiley->HandleSetCursor( aCursorPos, aAnchorPos ); |
3717 } |
3518 } |
3718 TCursorSelection select( aCursorPos, aAnchorPos ); |
3519 TCursorSelection select( aCursorPos, aAnchorPos ); |
3719 HandleSelectionForSmiley( select ); |
3520 HandleSelectionForSmiley( select ); |
3720 iTextView->SetSelectionL( select ); |
3521 iTextView->SetSelectionL( select ); |
3721 if ( iEdwinExtension ) |
3522 iEdwinExtension->iThumbPos = KErrNotFound; |
3722 { |
|
3723 iEdwinExtension->iThumbPos = KErrNotFound; |
|
3724 } |
|
3725 |
3523 |
3726 if ( iEdwinFepSupport ) |
3524 if ( iEdwinFepSupport ) |
3727 { |
3525 { |
3728 // Update text window position for cursor change. |
|
3729 iEdwinFepSupport->UpdateDocPosOffsetL( aCursorPos ); |
|
3730 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3526 CAknEdwinState* edwinState = static_cast<CAknEdwinState*>( iEdwinFepSupport->State(KNullUid) ); |
3731 if ( edwinState ) |
3527 if ( edwinState ) |
3732 { |
3528 { |
3733 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3529 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged ) ); |
3734 } |
3530 } |
4311 |
4099 |
4312 EXPORT_C TInt CEikEdwin::SelectionLength() const |
4100 EXPORT_C TInt CEikEdwin::SelectionLength() const |
4313 { |
4101 { |
4314 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4102 __ASSERT_DEBUG(iTextView,Panic(EEikPanicEdwinNoView)); |
4315 TCursorSelection selection( 0, 0 ); |
4103 TCursorSelection selection( 0, 0 ); |
4316 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4104 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4317 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4105 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4318 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4106 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4319 { |
4107 { |
4320 selection.iCursorPos = iEdwinExtension->iTempCursorPos; |
4108 selection.iCursorPos = iEdwinExtension->iTempCursorPos; |
4321 selection.iAnchorPos = iEdwinExtension->iTempAnchorPos; |
4109 selection.iAnchorPos = iEdwinExtension->iTempAnchorPos; |
4710 } |
4498 } |
4711 segmBufPtr = aDes->Mid( segmStart, insertLength); |
4499 segmBufPtr = aDes->Mid( segmStart, insertLength); |
4712 AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter, |
4500 AknTextUtils::ReplaceCharacters(segmBufPtr, KLineBreakCharacter, |
4713 TChar(CEditableText::EParagraphDelimiter)); |
4501 TChar(CEditableText::EParagraphDelimiter)); |
4714 iText->InsertL(oldLength+segmStart,*segmBuf); |
4502 iText->InsertL(oldLength+segmStart,*segmBuf); |
4715 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4503 if ( iEdwinExtension->iSmiley ) |
4716 { |
4504 { |
4717 iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, |
4505 iEdwinExtension->iSmiley->HandleInsertL( oldLength+segmStart, |
4718 insertLength ); |
4506 insertLength ); |
4719 } |
4507 } |
4720 segmStart = segmEnd; |
4508 segmStart = segmEnd; |
4724 } |
4512 } |
4725 } |
4513 } |
4726 |
4514 |
4727 CleanupStack::PopAndDestroy(segmBuf); |
4515 CleanupStack::PopAndDestroy(segmBuf); |
4728 TRAP(err,iText->DeleteL(0,oldLength)); |
4516 TRAP(err,iText->DeleteL(0,oldLength)); |
4729 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4517 if ( iEdwinExtension->iSmiley ) |
4730 { |
4518 { |
4731 iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength ); |
4519 iEdwinExtension->iSmiley->HandleDeleteL( 0, oldLength ); |
4732 ConvertTextForSmileyL( TCursorSelection( 0, |
4520 ConvertTextForSmileyL( TCursorSelection( 0, |
4733 iText->DocumentLength() ), ETrue ); |
4521 iText->DocumentLength() ), ETrue ); |
4734 } |
4522 } |
4735 } |
4523 } |
4736 else |
4524 else |
4737 { |
4525 { |
4738 iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object |
4526 iText->Reset(); // Duplicates previous behaviour where null pointer argument reset text object |
4739 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4527 if ( iEdwinExtension->iSmiley ) |
4740 { |
4528 { |
4741 iEdwinExtension->iSmiley->HandleDeleteL( 0, |
4529 iEdwinExtension->iSmiley->HandleDeleteL( 0, |
4742 iText->DocumentLength() ); |
4530 iText->DocumentLength() ); |
4743 } |
4531 } |
4744 } |
4532 } |
4745 |
4533 |
4746 CheckRemovePictures(0,iText->DocumentLength()); |
4534 CheckRemovePictures(0,iText->DocumentLength()); |
4747 CheckValidityOfChars(0,iText->DocumentLength()); |
4535 CheckValidityOfChars(0,iText->DocumentLength()); |
4748 if ( iEdwinExtension ) |
4536 iEdwinExtension->iDisableConvertInFormat = ETrue; |
4749 { |
4537 SetAmountToFormatL(ETrue); // performs formatting |
4750 iEdwinExtension->iDisableConvertInFormat = ETrue; |
4538 iEdwinExtension->iDisableConvertInFormat = EFalse; |
4751 } |
|
4752 SetAmountToFormatL(ETrue); // performs formatting |
|
4753 if ( iEdwinExtension ) |
|
4754 { |
|
4755 iEdwinExtension->iDisableConvertInFormat = EFalse; |
|
4756 } |
|
4757 // Update cursor position as CursorWidth() needs that. |
4539 // Update cursor position as CursorWidth() needs that. |
4758 if (IsReadyToDraw()) |
4540 if (IsReadyToDraw()) |
4759 { |
4541 { |
4760 ApplyAutoSelectionL(); |
4542 ApplyAutoSelectionL(); |
4761 } |
4543 } |
4781 if ( iCcpuSupport ) |
4563 if ( iCcpuSupport ) |
4782 { |
4564 { |
4783 iCcpuSupport->HandleSelectionChangeL(); |
4565 iCcpuSupport->HandleSelectionChangeL(); |
4784 } |
4566 } |
4785 } |
4567 } |
4786 if ( iEdwinExtension ) |
|
4787 { |
|
4788 iEdwinExtension->iThumbPos = KErrNotFound; |
|
4789 } |
|
4790 if (IsReadyToDraw()) |
4568 if (IsReadyToDraw()) |
4791 { |
4569 { |
4792 UpdateScrollBarsL(); |
4570 UpdateScrollBarsL(); |
4793 } |
4571 } |
4794 |
4572 |
4795 User::LeaveIfError(err); |
4573 User::LeaveIfError(err); |
4796 } |
4574 } |
4797 |
4575 |
4798 EXPORT_C TCursorSelection CEikEdwin::Selection() const |
4576 EXPORT_C TCursorSelection CEikEdwin::Selection() const |
4799 { |
4577 { |
4800 if ( iEdwinExtension && iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4578 if ( iEdwinExtension->iDrawInvoked == CEikEdwinExtension::ENotDraw && |
4801 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4579 iEdwinExtension->iTempCursorPos != KErrNotFound && |
4802 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4580 iEdwinExtension->iTempAnchorPos != KErrNotFound ) |
4803 { |
4581 { |
4804 return TCursorSelection( iEdwinExtension->iTempCursorPos, |
4582 return TCursorSelection( iEdwinExtension->iTempCursorPos, |
4805 iEdwinExtension->iTempAnchorPos ); |
4583 iEdwinExtension->iTempAnchorPos ); |
4850 const TInt lower=newText.LowerPos(); |
4628 const TInt lower=newText.LowerPos(); |
4851 TInt undoneLength=0; |
4629 TInt undoneLength=0; |
4852 TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower)) |
4630 TRAPD(err,undoneLength=iText->PasteFromStoreL(iUndoStore->Store(),iUndoStore->Dictionary(),lower)) |
4853 const TInt cursorPos=iUndoStore->OldCursorPos(); |
4631 const TInt cursorPos=iUndoStore->OldCursorPos(); |
4854 iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos)); |
4632 iTextView->SetPendingSelection(TCursorSelection(cursorPos,cursorPos)); |
4855 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4633 if ( iEdwinExtension->iSmiley ) |
4856 { |
4634 { |
4857 iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength ); |
4635 iEdwinExtension->iSmiley->HandleInsertL( lower, undoneLength ); |
4858 ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue ); |
4636 ConvertTextForSmileyL( TCursorSelection( lower, undoneLength ), ETrue ); |
4859 } |
4637 } |
4860 TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed)); |
4638 TRAPD(err2,iTextView->HandleInsertDeleteL(TCursorSelection(lower,lower+undoneLength),newText.Length(),changed)); |
4928 const TInt cursorPos=CursorPos(); |
4706 const TInt cursorPos=CursorPos(); |
4929 iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds |
4707 iEikonEnv->BusyMsgL(R_EIK_TBUF_IMPORTING,500000); // after 0.5 seconds |
4930 iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation); |
4708 iText->ImportTextFileL(cursorPos,aFileName,aTextOrganisation); |
4931 TInt insertLength( iText->DocumentLength() - oldLength ); |
4709 TInt insertLength( iText->DocumentLength() - oldLength ); |
4932 CheckValidityOfChars( oldLength, insertLength ); |
4710 CheckValidityOfChars( oldLength, insertLength ); |
4933 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4711 if ( iEdwinExtension->iSmiley ) |
4934 { |
4712 { |
4935 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength ); |
4713 iEdwinExtension->iSmiley->HandleInsertL( cursorPos, insertLength ); |
4936 ConvertTextForSmileyL( TCursorSelection( cursorPos, |
4714 ConvertTextForSmileyL( TCursorSelection( cursorPos, |
4937 cursorPos + insertLength ), ETrue ); |
4715 cursorPos + insertLength ), ETrue ); |
4938 } |
4716 } |
5046 if ( KineticScrollingEnabled() ) |
4824 if ( KineticScrollingEnabled() ) |
5047 { |
4825 { |
5048 // If we have deleted some text and previous position (before delete) is |
4826 // If we have deleted some text and previous position (before delete) is |
5049 // out of current editor content, we must move back to inside content. |
4827 // out of current editor content, we must move back to inside content. |
5050 TInt formattedHeight( iLayout->FormattedHeightInPixels() ); |
4828 TInt formattedHeight( iLayout->FormattedHeightInPixels() ); |
5051 if ( prevEndPosition > formattedHeight && iEdwinExtension ) |
4829 if ( prevEndPosition > formattedHeight ) |
5052 { |
4830 { |
5053 TInt movement( prevEndPosition - formattedHeight ); |
4831 TInt movement( prevEndPosition - formattedHeight ); |
5054 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement ); |
4832 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( movement ); |
5055 } |
4833 } |
5056 } |
4834 } |
5057 |
4835 |
5058 if ( reportChange && iEdwinExtension ) |
4836 if (reportChange) |
5059 { |
4837 { |
5060 iEdwinExtension->iThumbPos = KErrNotFound; |
|
5061 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
4838 ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate ); |
5062 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
4839 DoReportEventL( MCoeControlObserver::EEventStateChanged ); |
5063 NotifyEditorStateObserverOfStateChangeL(); |
4840 NotifyEditorStateObserverOfStateChangeL(); |
5064 UpdateScrollBarsL(); |
4841 UpdateScrollBarsL(); |
5065 } |
4842 } |
5155 } |
4932 } |
5156 const TInt higher=selection.HigherPos()+newLength-oldTextLength; |
4933 const TInt higher=selection.HigherPos()+newLength-oldTextLength; |
5157 iTextView->SetPendingSelection(TCursorSelection(higher,higher)); |
4934 iTextView->SetPendingSelection(TCursorSelection(higher,higher)); |
5158 selection.iAnchorPos=selection.LowerPos(); |
4935 selection.iAnchorPos=selection.LowerPos(); |
5159 selection.iCursorPos=selection.iAnchorPos+pastedLength; |
4936 selection.iCursorPos=selection.iAnchorPos+pastedLength; |
5160 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
4937 if ( iEdwinExtension->iSmiley ) |
5161 { |
4938 { |
5162 iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), |
4939 iEdwinExtension->iSmiley->HandleInsertL( selection.LowerPos(), |
5163 selection.Length() ); |
4940 selection.Length() ); |
5164 ConvertTextForSmileyL( selection, ETrue ); |
4941 ConvertTextForSmileyL( selection, ETrue ); |
5165 } |
4942 } |
5849 return; |
5626 return; |
5850 } |
5627 } |
5851 |
5628 |
5852 TRect viewRect( AdjustedViewRect() ); |
5629 TRect viewRect( AdjustedViewRect() ); |
5853 const TInt formattedLines = Max(1, iLayout->NumFormattedLines()); |
5630 const TInt formattedLines = Max(1, iLayout->NumFormattedLines()); |
5854 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5631 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5855 const TBool formattedHeightchanged( iEdwinExtension && |
|
5856 ( formattedHeight != iEdwinExtension->iRecordFormattedHeight ) ); |
|
5857 if ( iEdwinExtension ) |
|
5858 { |
|
5859 iEdwinExtension->iRecordFormattedHeight = formattedHeight; |
|
5860 } |
|
5861 const TInt viewRectHeight = viewRect.Height(); |
5632 const TInt viewRectHeight = viewRect.Height(); |
5862 const TInt totalChars = iText->DocumentLength(); |
5633 const TInt totalChars = iText->DocumentLength(); |
5863 const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() ); |
5634 const TInt formattedLength = Min( totalChars, iLayout->FormattedLength() ); |
5864 const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand(); |
5635 const TInt topLeftDocPos=iLayout->FirstDocPosFullyInBand(); |
5865 const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : |
5636 const TInt avgCharsPerLine = iAvgCharsPerLine ? iAvgCharsPerLine : |
5871 if( AknLayoutUtils::PenEnabled() ) |
5642 if( AknLayoutUtils::PenEnabled() ) |
5872 { |
5643 { |
5873 if ( !iLayout->IsFormattingBand() ) |
5644 if ( !iLayout->IsFormattingBand() ) |
5874 { |
5645 { |
5875 aVertModel.iThumbSpan = viewRectHeight; |
5646 aVertModel.iThumbSpan = viewRectHeight; |
5876 aVertModel.iScrollSpan = formattedHeight; |
5647 aVertModel.iScrollSpan = formattedHeight; |
5877 if ( iEdwinExtension ) |
5648 aVertModel.iThumbPosition = iEdwinExtension->iThumbPos; |
5878 { |
5649 if ( aVertModel.iThumbPosition == KErrNotFound ) |
5879 aVertModel.iThumbPosition = iEdwinExtension->iThumbPos; |
|
5880 } |
|
5881 if ( aVertModel.iThumbPosition == KErrNotFound || formattedHeightchanged ) |
|
5882 { |
5650 { |
5883 if ( bottomPos == totalChars ) |
5651 if ( bottomPos == totalChars ) |
5884 { |
5652 { |
5885 aVertModel.iThumbPosition = aVertModel.iScrollSpan - |
5653 aVertModel.iThumbPosition = aVertModel.iScrollSpan - |
5886 aVertModel.iThumbSpan; |
5654 aVertModel.iThumbSpan; |
6069 |
5833 |
6070 const TAknDoubleSpanScrollBarModel* doubleModel = |
5834 const TAknDoubleSpanScrollBarModel* doubleModel = |
6071 static_cast< const TAknDoubleSpanScrollBarModel* > |
5835 static_cast< const TAknDoubleSpanScrollBarModel* > |
6072 ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() ); |
5836 ( iSBFrame->CEikScrollBarFrame::VerticalScrollBar()->Model() ); |
6073 |
5837 |
6074 if ( iEdwinExtension && ( !iEdwinExtension->iUseRateScroll ) ) |
5838 if ( !iEdwinExtension->iUseRateScroll ) |
6075 { |
5839 { |
6076 aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight |
5840 aVertModel.iScrollSpan = heightBeforeFormat + formattedHeight |
6077 + heightAfterFormat; |
5841 + heightAfterFormat; |
6078 aVertModel.iThumbSpan = viewRectHeight; |
5842 aVertModel.iThumbSpan = viewRectHeight; |
6079 } |
5843 } |
6080 |
5844 |
6081 // Rate scrolling |
5845 // Rate scrolling |
6082 |
5846 |
6083 if ( iEdwinExtension && iEdwinExtension->iUseRateScroll ) |
5847 if ( iEdwinExtension->iUseRateScroll ) |
6084 { |
5848 { |
6085 TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat; |
5849 TInt heightAboveView = formattedHeightAboveView + heightBeforeFormat; |
6086 TInt heightBelowView = formattedHeightBelowView + heightAfterFormat; |
5850 TInt heightBelowView = formattedHeightBelowView + heightAfterFormat; |
6087 |
5851 |
6088 TInt curScrollSpan = aVertModel.iScrollSpan |
5852 TInt curScrollSpan = aVertModel.iScrollSpan |
6162 TInt curScrollSpan = doubleModel->ScrollSpan(); |
5923 TInt curScrollSpan = doubleModel->ScrollSpan(); |
6163 TInt curThumbSpan = doubleModel->WindowSize(); |
5924 TInt curThumbSpan = doubleModel->WindowSize(); |
6164 TInt thumbSpaceAbove = aScrollBar->ThumbPosition(); |
5925 TInt thumbSpaceAbove = aScrollBar->ThumbPosition(); |
6165 TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove; |
5926 TInt thumbSpaceBelow = curScrollSpan - curThumbSpan - thumbSpaceAbove; |
6166 |
5927 |
6167 TInt moveOffset = 0; |
5928 TInt moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition; |
6168 if ( iEdwinExtension ) |
|
6169 { |
|
6170 moveOffset = thumbSpaceAbove - iEdwinExtension->iScrollbarPosition; |
|
6171 } |
|
6172 |
5929 |
6173 const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() ); |
5930 const TInt formattedLines = Max( 1, iLayout->NumFormattedLines() ); |
6174 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
5931 const TInt formattedHeight = iLayout->FormattedHeightInPixels(); |
6175 const TInt viewRectHeight = AdjustedViewRect().Height(); |
5932 const TInt viewRectHeight = AdjustedViewRect().Height(); |
6176 const TInt totalChars = iText->DocumentLength(); |
5933 const TInt totalChars = iText->DocumentLength(); |
6219 else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan ) |
5977 else if ( thumbSpaceAbove >= curScrollSpan - curThumbSpan ) |
6220 { |
5978 { |
6221 textMovePixels -= KAdditionalPixels; |
5979 textMovePixels -= KAdditionalPixels; |
6222 } |
5980 } |
6223 |
5981 |
6224 if ( iEdwinExtension ) |
5982 iEdwinExtension->iScrolledByScrollBar = ETrue; |
6225 { |
5983 |
6226 iEdwinExtension->iScrollbarPosition = thumbSpaceAbove; |
5984 // Actual scrolling is done by calling MoveScrollIndex |
6227 iEdwinExtension->iScrolledByScrollBar = ETrue; |
5985 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels ); |
6228 |
5986 |
6229 // Actual scrolling is done by calling MoveScrollIndex |
5987 iEdwinExtension->iScrolledByScrollBar = EFalse; |
6230 iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels ); |
|
6231 iEdwinExtension->iEndBorderExceeded = EFalse; |
|
6232 iEdwinExtension->iStartBorderExceeded = EFalse; |
|
6233 |
|
6234 iEdwinExtension->iScrolledByScrollBar = EFalse; |
|
6235 } |
|
6236 } |
5988 } |
6237 |
5989 |
6238 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType) |
5990 EXPORT_C void CEikEdwin::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType) |
6239 { |
5991 { |
6240 __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText)); |
5992 __ASSERT_DEBUG(iText,Panic(EEikPanicEdwinNoText)); |
6315 iTextView->SetViewL(docPos, yPos, yPosQ); |
6067 iTextView->SetViewL(docPos, yPos, yPosQ); |
6316 UpdateVertScrollBarThumbL(); |
6068 UpdateVertScrollBarThumbL(); |
6317 UpdateHorizScrollBarThumb();// can also change horizontally |
6069 UpdateHorizScrollBarThumb();// can also change horizontally |
6318 } |
6070 } |
6319 break; |
6071 break; |
6320 case EEikScrollThumbReleaseVert: |
|
6321 { |
|
6322 if ( KineticScrollingEnabled() ) |
|
6323 { |
|
6324 RestoreCursorState(); |
|
6325 } |
|
6326 } |
|
6327 break; |
|
6328 case EEikScrollUp: |
6072 case EEikScrollUp: |
6329 case EEikScrollDown: |
6073 case EEikScrollDown: |
6330 case EEikScrollPageUp: |
6074 case EEikScrollPageUp: |
6331 case EEikScrollPageDown: |
6075 case EEikScrollPageDown: |
6332 case EEikScrollThumbDragVert: |
6076 case EEikScrollThumbDragVert: |
6333 { |
6077 { |
6334 if ( KineticScrollingEnabled() ) |
6078 if ( KineticScrollingEnabled() ) |
6335 { |
6079 { |
6336 StoreCursorState(); |
|
6337 HandleScrollEventWithPhysics( aScrollBar ); |
6080 HandleScrollEventWithPhysics( aScrollBar ); |
6338 break; |
6081 break; |
6339 } |
6082 } |
6340 |
6083 |
6341 TRect viewRect( AdjustedViewRect() ); |
6084 TRect viewRect( AdjustedViewRect() ); |
6378 if ( thumbPosition == thumbSpan ) |
6121 if ( thumbPosition == thumbSpan ) |
6379 { |
6122 { |
6380 docPos = totalChars; |
6123 docPos = totalChars; |
6381 yPos = viewRect.iBr.iY; |
6124 yPos = viewRect.iBr.iY; |
6382 } |
6125 } |
6383 if ( iEdwinExtension ) |
6126 iEdwinExtension->iThumbPos = thumbPosition; |
6384 { |
|
6385 iEdwinExtension->iThumbPos = thumbPosition; |
|
6386 } |
|
6387 TViewYPosQualifier yPosQ; |
6127 TViewYPosQualifier yPosQ; |
6388 yPosQ.SetMakeLineFullyVisible(); |
6128 yPosQ.SetMakeLineFullyVisible(); |
6389 iTextView->SetViewL( docPos, yPos, yPosQ, |
6129 iTextView->SetViewL( docPos, yPos, yPosQ, |
6390 CTextView::EFViewDontDiscardFormat, |
6130 CTextView::EFViewDontDiscardFormat, |
6391 CTextView::EFNoHorizontalScroll); |
6131 CTextView::EFNoHorizontalScroll); |
6903 |
6643 |
6904 switch (aType) |
6644 switch (aType) |
6905 { |
6645 { |
6906 case KEikDynamicLayoutVariantSwitch: |
6646 case KEikDynamicLayoutVariantSwitch: |
6907 { |
6647 { |
6908 if ( KineticScrollingEnabled() && iEdwinExtension ) |
6648 iEdwinExtension->iThumbPos = KErrNotFound; |
6909 { |
|
6910 iEdwinExtension->iPhysicsHandler->DisableDragging(); |
|
6911 } |
|
6912 if ( iEdwinExtension ) |
|
6913 { |
|
6914 iEdwinExtension->iThumbPos = KErrNotFound; |
|
6915 iEdwinExtension->iEndBorderExceeded = EFalse; |
|
6916 iEdwinExtension->iStartBorderExceeded = EFalse; |
|
6917 } |
|
6918 SizeChanged(); |
6649 SizeChanged(); |
6919 if ( !IsReadOnly() && !IsNonFocusing() |
6650 if ( !IsReadOnly() && !IsNonFocusing() |
6920 && !( iEdwinUserFlags & EDisplayOnly ) |
6651 && !( iEdwinUserFlags & EDisplayOnly ) ) |
6921 && !KineticScrollingEnabled() ) |
|
6922 { |
6652 { |
6923 TInt docPos = CursorPos(); |
6653 TInt docPos = CursorPos(); |
6924 TRect viewRect( AdjustedViewRect() ); |
6654 TRect viewRect( AdjustedViewRect() ); |
6925 TViewYPosQualifier yPosQ; |
6655 TViewYPosQualifier yPosQ; |
6926 TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2; |
6656 TInt yPos = ( viewRect.iBr.iY + viewRect.iTl.iY )/2; |
7167 formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length); |
6885 formatChanged=STATIC_CAST(CRichText*,iText)->DelSetInsertCharFormatL(lowerPos,length); |
7168 } |
6886 } |
7169 else |
6887 else |
7170 { |
6888 { |
7171 formatChanged=iText->DeleteL(lowerPos,length); |
6889 formatChanged=iText->DeleteL(lowerPos,length); |
7172 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
6890 if ( iEdwinExtension->iSmiley ) |
7173 { |
6891 { |
7174 iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length ); |
6892 iEdwinExtension->iSmiley->HandleDeleteL( lowerPos, length ); |
7175 } |
6893 } |
7176 } |
6894 } |
7177 iText->InsertL(aInsertPos,aText); |
6895 iText->InsertL(aInsertPos,aText); |
7178 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
6896 if ( iEdwinExtension->iSmiley ) |
7179 { |
6897 { |
7180 iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() ); |
6898 iEdwinExtension->iSmiley->HandleInsertL( aInsertPos, aText.Length() ); |
7181 ConvertTextForSmileyL( TCursorSelection( aInsertPos, |
6899 ConvertTextForSmileyL( TCursorSelection( aInsertPos, |
7182 aInsertPos + aText.Length() ), ETrue ); |
6900 aInsertPos + aText.Length() ), ETrue ); |
7183 } |
6901 } |
7636 default: |
7354 default: |
7637 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP; |
7355 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP; |
7638 break; |
7356 break; |
7639 } |
7357 } |
7640 |
7358 |
7641 // get special character table resource ID |
7359 return iEikonEnv->AllocReadResourceLC(resId); |
7642 TInt sctResourceId = state->SpecialCharacterTableResourceId(); |
|
7643 if ( sctResourceId && ( state->Flags() & EAknEditorFlagUseSCTNumericCharmap ) ) |
|
7644 { |
|
7645 // numericSCTBuf containing number and special characters |
|
7646 HBufC* numericSCTBuf = HBufC::NewLC( KNmericSCTLimit ); |
|
7647 TPtr numericSCTPtr( numericSCTBuf->Des() ); |
|
7648 |
|
7649 // read number characters and add them to numericSCTBuf |
|
7650 HBufC* numberResource = iEikonEnv->AllocReadResourceLC( resId ); |
|
7651 TPtr numberResPtr( numberResource->Des() ); |
|
7652 numericSCTPtr.Append( numberResPtr ); |
|
7653 CleanupStack::PopAndDestroy( numberResource ); // numberResource |
|
7654 |
|
7655 // read special characters from SCT by dialog ID |
|
7656 ReadSpecialCharFromSCTL( numericSCTPtr, sctResourceId ); |
|
7657 |
|
7658 return numericSCTBuf; |
|
7659 } |
|
7660 else |
|
7661 { |
|
7662 return iEikonEnv->AllocReadResourceLC( resId ); |
|
7663 } |
|
7664 } |
7360 } |
7665 else |
7361 else |
7666 { |
7362 { |
7667 User::Leave(KErrNoMemory); |
7363 User::Leave(KErrNoMemory); |
7668 return NULL; |
7364 return NULL; |
8516 // for chinese popup flag |
8188 // for chinese popup flag |
8517 TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup ); |
8189 TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup ); |
8518 if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) ) |
8190 if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) ) |
8519 { |
8191 { |
8520 TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) ); |
8192 TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) ); |
8521 } |
8193 } |
8522 |
|
8523 // To reduce power consumption, text view should be hidden when full screen Touch |
|
8524 // Input is open and editor is covered by it, for user can not see editor in this |
|
8525 // case. When full screen Touch Input is open, FEP will set flag EAknEditorFlagHideTextView |
|
8526 // to notify editor the text view should be hidden. But we have to check if the feature |
|
8527 // of partial screen input is enabled at the same time, for full screen Touch Input window |
|
8528 // will only occupy part of the screen if the feature is eanbled and editor is still visible |
|
8529 // to user. So editor can only be hidden in such situation: full screen Touch Input is open |
|
8530 // and partial screen feature is disabled. |
|
8531 // In the contrary situations (full screen touch input is closed or partial screen |
|
8532 // feature is enabled), text view has to be shown so editor can work as normal. |
|
8533 if ( iTextView && iEdwinExtension ) |
|
8534 { |
|
8535 TBool textViewHideEnabled( ( aNewFlags & EAknEditorFlagHideTextView ) && |
|
8536 !( aOldFlags & EAknEditorFlagHideTextView ) ); |
|
8537 |
|
8538 TBool textViewHideDisabled( !( aNewFlags & EAknEditorFlagHideTextView ) && |
|
8539 ( aOldFlags & EAknEditorFlagHideTextView ) ); |
|
8540 |
|
8541 TBool partialScreenEnabled( ( aNewFlags & EAknEditorFlagEnablePartialScreen ) && |
|
8542 !( aOldFlags & EAknEditorFlagEnablePartialScreen ) ); |
|
8543 |
|
8544 TBool partialScreenDisabled( !( aNewFlags & EAknEditorFlagEnablePartialScreen ) && |
|
8545 ( aOldFlags & EAknEditorFlagEnablePartialScreen ) ); |
|
8546 |
|
8547 if ( ( textViewHideEnabled && |
|
8548 !( aNewFlags & EAknEditorFlagEnablePartialScreen ) ) || |
|
8549 ( partialScreenDisabled && ( aNewFlags & EAknEditorFlagHideTextView ) ) ) |
|
8550 { |
|
8551 iTextView->MakeVisible( EFalse ); |
|
8552 iEdwinExtension->iTextViewHidden = ETrue; |
|
8553 } |
|
8554 else if ( iEdwinExtension->iTextViewHidden && ( textViewHideDisabled || partialScreenEnabled ) ) |
|
8555 { |
|
8556 iTextView->MakeVisible( ETrue ); |
|
8557 DrawNow(); |
|
8558 iEdwinExtension->iTextViewHidden = EFalse; |
|
8559 } |
|
8560 } |
|
8561 } |
8194 } |
8562 |
8195 |
8563 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen ) |
8196 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen ) |
8564 { |
8197 { |
8565 if ( aChinesePopupOpen ) |
8198 if ( aChinesePopupOpen ) |
8573 } |
8206 } |
8574 |
8207 |
8575 // for smiley support |
8208 // for smiley support |
8576 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley ) |
8209 void CEikEdwin::EnableSmileySupportL( TBool aEnableSmiley ) |
8577 { |
8210 { |
8578 if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() && iEdwinExtension ) |
8211 if ( aEnableSmiley && !AknLayoutUtils::LayoutMirrored() ) |
8579 { |
8212 { |
8580 TLanguage language = CAknEnv::Static()->SettingCache().InputLanguage(); |
8213 if ( !iEdwinExtension->iSmiley ) |
8581 if ( language != ELangArabic && language != ELangFarsi && |
8214 { |
8582 language != ELangUrdu && language != ELangHebrew ) |
8215 iEdwinExtension->iSmiley = CSmileyManager::NewL( *this ); |
8583 { |
8216 iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes ); |
8584 if ( !iEdwinExtension->iSmiley ) |
8217 if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly ) |
8585 { |
8218 { |
8586 iEdwinExtension->iSmiley = CSmileyManager::NewL( *this ); |
8219 iEdwinExtension->iSmiley->SetAnimationPlayTimes( |
8587 iEdwinExtension->iSmiley->SetAnimationPlayTimes( KNormalAnimPlayTimes ); |
8220 KInfiniteAnimPlayTimes ); |
8588 if ( IsReadOnly() || iEdwinUserFlags & EDisplayOnly ) |
8221 } |
8589 { |
8222 } |
8590 iEdwinExtension->iSmiley->SetAnimationPlayTimes( |
8223 if ( TextLayout() ) |
8591 KInfiniteAnimPlayTimes ); |
8224 { |
8592 } |
8225 TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap ); |
8593 } |
8226 } |
8594 if ( TextLayout() ) |
|
8595 { |
|
8596 TextLayout()->SetCustomWrap( iEdwinExtension->iSmileyWrap ); |
|
8597 } |
|
8598 } |
|
8599 } |
8227 } |
8600 else if ( iEdwinExtension ) |
8228 else |
8601 { |
8229 { |
8602 delete iEdwinExtension->iSmiley; |
8230 delete iEdwinExtension->iSmiley; |
8603 iEdwinExtension->iSmiley = NULL; |
8231 iEdwinExtension->iSmiley = NULL; |
8604 if ( TextLayout() ) |
8232 if ( TextLayout() ) |
8605 { |
8233 { |
8608 } |
8236 } |
8609 } |
8237 } |
8610 |
8238 |
8611 TBool CEikEdwin::IsSmileyEnabled() const |
8239 TBool CEikEdwin::IsSmileyEnabled() const |
8612 { |
8240 { |
8613 TBool ret = EFalse; |
8241 return ( iEdwinExtension->iSmiley != NULL ); |
8614 if ( iEdwinExtension ) |
8242 } |
8615 { |
8243 |
8616 ret = ( iEdwinExtension->iSmiley != NULL ); |
8244 void CEikEdwin::DrawSmileyInTextL( CBitmapContext& aGc, CFont& aFont, |
8617 } |
8245 const TDesC& aText, const TPoint& aPt ) |
8618 return ret; |
|
8619 } |
|
8620 |
|
8621 void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, |
|
8622 CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt ) |
|
8623 { |
8246 { |
8624 TRect viewRect( AdjustedViewRect() ); |
8247 TRect viewRect( AdjustedViewRect() ); |
8625 TInt topY( aPt.iY - aFont.AscentInPixels() ); |
8248 TInt topY( aPt.iY - aFont.AscentInPixels() ); |
8626 TInt bottomY( aPt.iY + aFont.DescentInPixels() ); |
8249 TInt bottomY( aPt.iY + aFont.DescentInPixels() ); |
8627 const TInt KThreshold = 10; |
8250 const TInt KThreshold = 10; |
8644 text.Copy( aText ); |
8267 text.Copy( aText ); |
8645 TrimText( text ); |
8268 TrimText( text ); |
8646 TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) ); |
8269 TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) ); |
8647 for ( TInt i( 0 ); i < text.Length(); i++ ) |
8270 for ( TInt i( 0 ); i < text.Length(); i++ ) |
8648 { |
8271 { |
8649 if ( iEdwinExtension && CSmileyManager::IsSmileyCode( text[i] ) ) |
8272 if ( CSmileyManager::IsSmileyCode( text[i] ) ) |
8650 { |
8273 { |
8651 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) ); |
8274 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) ); |
8652 TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, |
8275 TRect rect( x, topY, x + smileyWidth, bottomY ); |
8653 aDrawRect.iBr.iY ); |
8276 iEdwinExtension->iSmiley->DrawIconL( aGc, rect, i + pos ); |
8654 rgn.SubRect( clipRect, NULL ); |
|
8655 TRect iconRect( x, topY, x + smileyWidth, bottomY ); |
|
8656 iEdwinExtension->iSmiley->DrawIconL( aGc, iconRect, i + pos ); |
|
8657 } |
8277 } |
8658 } |
8278 } |
8659 } |
8279 } |
8660 delete buf; |
8280 delete buf; |
8661 } |
8281 } |
8662 |
8282 |
8663 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode ) |
8283 void CEikEdwin::ConvertVisibleTextForSmileyL( TBool aTextToCode ) |
8664 { |
8284 { |
8665 if ( iEdwinExtension && !iEdwinExtension->iSmiley && !iTextView ) |
8285 if ( !iEdwinExtension->iSmiley && !iTextView ) |
8666 { |
8286 { |
8667 return; |
8287 return; |
8668 } |
8288 } |
8669 TCursorSelection visibleRange( GetVisibleTextRangeL() ); |
8289 TCursorSelection visibleRange( GetVisibleTextRangeL() ); |
8670 ConvertTextForSmileyL( visibleRange, aTextToCode ); |
8290 ConvertTextForSmileyL( visibleRange, aTextToCode ); |
8671 } |
8291 } |
8672 |
8292 |
8673 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, |
8293 void CEikEdwin::ConvertTextForSmileyL( TCursorSelection aSelect, |
8674 TBool aTextToCode, TBool aRedraw ) |
8294 TBool aTextToCode, TBool aRedraw ) |
8675 { |
8295 { |
8676 if ( iEdwinExtension && iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing ) |
8296 if ( iEdwinExtension->iSmiley && !iEdwinExtension->iInlineEditing ) |
8677 { |
8297 { |
8678 if ( aTextToCode ) |
8298 if ( aTextToCode ) |
8679 { |
8299 { |
8680 ExtendedRangeForSmiley( aSelect ); |
8300 ExtendedRangeForSmiley( aSelect ); |
8681 } |
8301 } |
8778 } |
8392 } |
8779 } |
8393 } |
8780 |
8394 |
8781 TBool CEikEdwin::ConvertSmileyForDeleteL( TInt aDocPos, TBool aBackSpace ) |
8395 TBool CEikEdwin::ConvertSmileyForDeleteL( TInt aDocPos, TBool aBackSpace ) |
8782 { |
8396 { |
8783 if ( iEdwinExtension && !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || |
8397 if ( !iEdwinExtension->iSmiley || ( aDocPos == 0 && aBackSpace ) || |
8784 ( aDocPos == TextLength() && !aBackSpace ) ) |
8398 ( aDocPos == TextLength() && !aBackSpace ) ) |
8785 { |
8399 { |
8786 return EFalse; |
8400 return EFalse; |
8787 } |
8401 } |
8788 TInt checkPos( aDocPos ); |
8402 TInt checkPos( aDocPos ); |
8789 if ( aBackSpace ) |
8403 if ( aBackSpace ) |
8790 { |
8404 { |
8791 checkPos--; |
8405 checkPos--; |
8792 checkPos = checkPos >= 0 ? checkPos : 0; |
8406 checkPos = checkPos >= 0 ? checkPos : 0; |
8793 } |
8407 } |
8794 if ( iEdwinExtension->iSmiley->SmileyCodeByPos( checkPos ) > 0 ) |
8408 if ( CSmileyManager::IsSmileyCode( iEdwinExtension->iSmiley-> |
|
8409 SmileyCodeByPos( checkPos ) ) && |
|
8410 !iEdwinExtension->iSmiley->IsDisabledSmileyIcon( checkPos ) ) |
8795 { |
8411 { |
8796 TInt codeLength( iEdwinExtension->iSmiley->SmileyLength( checkPos ) ); |
8412 TInt codeLength( iEdwinExtension->iSmiley->SmileyLength( checkPos ) ); |
8797 iEdwinExtension->iSmiley->DisableSmileyIcon( checkPos ); |
8413 iEdwinExtension->iSmiley->DisableSmileyIcon( checkPos ); |
8798 TCursorSelection select( aDocPos, aDocPos ); |
8414 TCursorSelection select( aDocPos, aDocPos ); |
8799 if ( aBackSpace ) |
8415 if ( aBackSpace ) |
8840 iText->InsertL( lowerPos, ptr ); |
8456 iText->InsertL( lowerPos, ptr ); |
8841 } |
8457 } |
8842 CleanupStack::PopAndDestroy( buf ); |
8458 CleanupStack::PopAndDestroy( buf ); |
8843 } |
8459 } |
8844 |
8460 |
|
8461 void CEikEdwin::HandleScrollForSmileyL() |
|
8462 { |
|
8463 if ( !iEdwinExtension->iSmiley ) |
|
8464 { |
|
8465 return; |
|
8466 } |
|
8467 TCursorSelection select( GetVisibleTextRangeL() ); |
|
8468 if ( select.LowerPos() != iEdwinExtension->iVisibleRange.LowerPos() || |
|
8469 select.HigherPos() != iEdwinExtension->iVisibleRange.HigherPos() ) |
|
8470 { |
|
8471 iEdwinExtension->iVisibleRange.iCursorPos = select.iCursorPos; |
|
8472 iEdwinExtension->iVisibleRange.iAnchorPos = select.iAnchorPos; |
|
8473 } |
|
8474 iEdwinExtension->iSmiley->SetVisibleRange( select.LowerPos(), |
|
8475 select.Length() ); |
|
8476 } |
|
8477 |
8845 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect ) |
8478 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect ) |
8846 { |
8479 { |
8847 TBool ret( EFalse ); |
8480 TBool ret( EFalse ); |
8848 TCursorSelection select( Selection() ); |
8481 TCursorSelection select( Selection() ); |
8849 TInt cursor( select.iCursorPos ); |
8482 TInt cursor( select.iCursorPos ); |
8850 if ( iEdwinExtension ) |
8483 iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor ); |
8851 { |
|
8852 iEdwinExtension->iSmiley->HandleSetCursor( aOldCursor, cursor ); |
|
8853 } |
|
8854 if ( cursor != select.iCursorPos ) |
8484 if ( cursor != select.iCursorPos ) |
8855 { |
8485 { |
8856 if ( select.iAnchorPos == select.iCursorPos ) |
8486 if ( select.iAnchorPos == select.iCursorPos ) |
8857 { |
8487 { |
8858 select.iAnchorPos = cursor; |
8488 select.iAnchorPos = cursor; |
8868 { |
8498 { |
8869 TRect viewRect( AdjustedViewRect() ); |
8499 TRect viewRect( AdjustedViewRect() ); |
8870 return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY ); |
8500 return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY ); |
8871 } |
8501 } |
8872 |
8502 |
|
8503 void CEikEdwin::GetClipRegionForSmiley( RRegion& rgn, CFont& aFont, |
|
8504 const TDesC& aText, const TPoint& aPt, const TRect& aDrawRect ) const |
|
8505 { |
|
8506 TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) ); |
|
8507 TInt topY( aDrawRect.iTl.iY ); |
|
8508 TInt bottomY( aDrawRect.iBr.iY ); |
|
8509 for ( TInt i( 0 ); i < aText.Length(); i++ ) |
|
8510 { |
|
8511 if ( CSmileyManager::IsSmileyCode( aText[i] ) ) |
|
8512 { |
|
8513 TInt x( aPt.iX + aFont.TextWidthInPixels( aText.Left( i ) ) ); |
|
8514 TRect rect( x, topY, x + smileyWidth, bottomY ); |
|
8515 rgn.SubRect( rect, NULL ); |
|
8516 } |
|
8517 } |
|
8518 } |
|
8519 |
8873 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, |
8520 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, |
8874 TBool aSelect ) |
8521 TBool aSelect ) |
8875 { |
8522 { |
8876 TBool ret( EFalse ); |
8523 TBool ret( EFalse ); |
8877 if ( iEdwinExtension && iEdwinExtension->iSmiley ) |
8524 if ( iEdwinExtension->iSmiley ) |
8878 { |
8525 { |
8879 TInt oldPos( CursorPos() ); |
8526 TInt oldPos( CursorPos() ); |
8880 TInt curPos( oldPos ); |
8527 TInt curPos( oldPos ); |
8881 if ( aMovement == TCursorPosition::EFLeft ) |
8528 if ( aMovement == TCursorPosition::EFLeft ) |
8882 { |
8529 { |
9021 // ends (scrolling over the border toward content). In this case we |
8654 // ends (scrolling over the border toward content). In this case we |
9022 // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border. |
8655 // can use ScrollDisplayPixelsNoLimitBorderL to scroll only to border. |
9023 // After that we have to move to mode where we use ScrollDisplayPixelsL |
8656 // After that we have to move to mode where we use ScrollDisplayPixelsL |
9024 // to detect if we exceed border again. |
8657 // to detect if we exceed border again. |
9025 TBool adjustScrolling( EFalse ); |
8658 TBool adjustScrolling( EFalse ); |
9026 if ( iEdwinExtension ) |
8659 if ( aPixelsToScroll > 0 && iEdwinExtension->iEndBorderExceeded ) |
9027 { |
8660 { |
9028 if ( aPixelsToScroll > 0 && iEdwinExtension->iEndBorderExceeded ) |
8661 if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder ) |
9029 { |
8662 { |
9030 if ( aPixelsToScroll > - iEdwinExtension->iPixelsOutOfBorder ) |
8663 adjustScrolling = ETrue; |
9031 { |
8664 } |
9032 adjustScrolling = ETrue; |
8665 } |
9033 } |
8666 else if ( aPixelsToScroll < 0 && iEdwinExtension->iStartBorderExceeded ) |
9034 } |
8667 { |
9035 else if ( aPixelsToScroll < 0 && iEdwinExtension->iStartBorderExceeded ) |
8668 if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder ) |
9036 { |
8669 { |
9037 if ( aPixelsToScroll < - iEdwinExtension->iPixelsOutOfBorder ) |
8670 adjustScrolling = ETrue; |
9038 { |
8671 } |
9039 adjustScrolling = ETrue; |
8672 } |
9040 } |
8673 |
9041 } |
|
9042 } |
|
9043 |
|
9044 if ( adjustScrolling ) |
8674 if ( adjustScrolling ) |
9045 { |
8675 { |
9046 // we are scrolling over the border, calculate how many |
8676 // we are scrolling over the border, calculate how many |
9047 // pixels we can scroll and how many pixels there is rest |
8677 // pixels we can scroll and how many pixels there is rest |
9048 // after movement |
8678 // after movement |
9051 } |
8681 } |
9052 |
8682 |
9053 // We are out of borders. Call scrolling function that supports bounce-effect |
8683 // We are out of borders. Call scrolling function that supports bounce-effect |
9054 TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) ); |
8684 TRAP_IGNORE( iTextView->ScrollDisplayPixelsNoLimitBorderL( aPixelsToScroll ) ); |
9055 |
8685 |
9056 if ( iEdwinExtension ) |
8686 // Update variable that tells how near the border we are. |
9057 { |
8687 iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll; |
9058 // Update variable that tells how near the border we are. |
8688 |
9059 iEdwinExtension->iPixelsOutOfBorder += aPixelsToScroll; |
8689 if ( iEdwinExtension->iStartBorderExceeded |
9060 |
8690 && iEdwinExtension->iPixelsOutOfBorder <= 0 ) |
9061 if ( iEdwinExtension->iStartBorderExceeded |
8691 { |
9062 && iEdwinExtension->iPixelsOutOfBorder <= 0 ) |
8692 // We are inside borders, reset flag and tell to caller |
9063 { |
8693 iEdwinExtension->iStartBorderExceeded = EFalse; |
9064 // We are inside borders, reset flag and tell to caller |
8694 aEndOfBounce = ETrue; |
9065 iEdwinExtension->iStartBorderExceeded = EFalse; |
8695 } |
9066 aEndOfBounce = ETrue; |
8696 else if ( iEdwinExtension->iEndBorderExceeded |
9067 } |
8697 && iEdwinExtension->iPixelsOutOfBorder >= 0 ) |
9068 else if ( iEdwinExtension->iEndBorderExceeded |
8698 { |
9069 && iEdwinExtension->iPixelsOutOfBorder >= 0 ) |
8699 // we are inside borders, reset flag and tell to caller |
9070 { |
8700 iEdwinExtension->iEndBorderExceeded = EFalse; |
9071 // we are inside borders, reset flag and tell to caller |
8701 aEndOfBounce = ETrue; |
9072 iEdwinExtension->iEndBorderExceeded = EFalse; |
8702 } |
9073 aEndOfBounce = ETrue; |
|
9074 } |
|
9075 } |
|
9076 |
8703 |
9077 if ( aPixelsToScroll != 0 ) |
8704 if ( aPixelsToScroll != 0 ) |
9078 { |
8705 { |
9079 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
8706 TRAP_IGNORE( UpdateVertScrollBarThumbL() ); |
9080 } |
8707 } |
9110 |
8732 |
9111 // Use this function to change scrolling mode. |
8733 // Use this function to change scrolling mode. |
9112 // If aEnable is EFalse, Position scrolling mode is in use. |
8734 // If aEnable is EFalse, Position scrolling mode is in use. |
9113 // If aEnable is ETrue, Rate scrolling mode is in use. |
8735 // If aEnable is ETrue, Rate scrolling mode is in use. |
9114 |
8736 |
9115 if ( iEdwinExtension ) |
8737 iEdwinExtension->iUseRateScroll = aEnable; |
9116 { |
|
9117 iEdwinExtension->iUseRateScroll = aEnable; |
|
9118 } |
|
9119 } |
8738 } |
9120 |
8739 |
9121 // --------------------------------------------------------------------------- |
8740 // --------------------------------------------------------------------------- |
9122 // CEikEdwin::StoreCursorState |
8741 // CEikEdwin::StoreCursorState |
9123 // --------------------------------------------------------------------------- |
8742 // --------------------------------------------------------------------------- |
9124 // |
8743 // |
9125 void CEikEdwin::StoreCursorState() |
8744 void CEikEdwin::StoreCursorState() |
9126 { |
8745 { |
9127 CAknEdwinState* state( EditorState() ); |
8746 CAknEdwinState* state( EditorState() ); |
9128 if ( iEdwinExtension && state && state->Flags() & EAknEditorFlagTextCursorVisible ) |
8747 if ( state && state->Flags() & EAknEditorFlagTextCursorVisible ) |
9129 { |
8748 { |
9130 TRAP_IGNORE( SetCursorVisibilityL( EFalse ) ); |
8749 TRAP_IGNORE( SetCursorVisibilityL( EFalse ) ); |
9131 iEdwinExtension->iCursorWasVisible = ETrue; |
8750 iEdwinExtension->iCursorWasVisible = ETrue; |
9132 } |
8751 } |
9133 } |
8752 } |
9153 { |
8772 { |
9154 return iEdwinExtension && iEdwinExtension->iPhysicsHandler; |
8773 return iEdwinExtension && iEdwinExtension->iPhysicsHandler; |
9155 } |
8774 } |
9156 |
8775 |
9157 |
8776 |
9158 // --------------------------------------------------------------------------- |
|
9159 // CEikEdwin::DrawViewBackground |
|
9160 // --------------------------------------------------------------------------- |
|
9161 // |
|
9162 void CEikEdwin::DrawViewBackground( TBool aStart ) const |
|
9163 { |
|
9164 CWindowGc& gc = SystemGc(); |
|
9165 RWindow& window = Window(); |
|
9166 |
|
9167 if ( aStart ) |
|
9168 { |
|
9169 TRect viewRect( iTextView->ViewRect() ); |
|
9170 window.Invalidate( viewRect ); |
|
9171 window.BeginRedraw( viewRect ); |
|
9172 gc.Activate( window ); |
|
9173 |
|
9174 if ( iEdwinExtension && |
|
9175 !AknsDrawUtils::DrawBackground( |
|
9176 iEdwinExtension->iSkinInstance, |
|
9177 SkinBackgroundControlContext(), |
|
9178 this, |
|
9179 gc, |
|
9180 viewRect.iTl, |
|
9181 viewRect, |
|
9182 KAknsDrawParamNoClearUnderImage ) ) |
|
9183 { |
|
9184 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
9185 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
9186 |
|
9187 TRgb dummyColor; |
|
9188 TRgb backgroundColor = EditorBackgroundColor( dummyColor ); |
|
9189 |
|
9190 gc.SetBrushColor( backgroundColor ); |
|
9191 gc.SetPenColor( backgroundColor ); |
|
9192 gc.DrawRect( iTextView->ViewRect() ); |
|
9193 } |
|
9194 } |
|
9195 else |
|
9196 { |
|
9197 gc.Deactivate(); |
|
9198 window.EndRedraw(); |
|
9199 } |
|
9200 } |
|
9201 |
|
9202 |
|
9203 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect ) |
8777 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect ) |
9204 { |
8778 { |
9205 if ( iEdwinExtension ) |
8779 if ( !iEdwinExtension->iSmiley ) |
9206 { |
8780 { |
9207 if ( !iEdwinExtension->iSmiley ) |
8781 return; |
9208 { |
8782 } |
9209 return; |
8783 if ( iCustomDrawer ) |
9210 } |
8784 { |
9211 if ( iCustomDrawer ) |
8785 iEdwinExtension->iSmiley->SetHighlightColor( |
9212 { |
8786 iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, |
9213 iEdwinExtension->iSmiley->SetHighlightColor( |
8787 KRgbWhite ) ); |
9214 iCustomDrawer->SystemColor( TLogicalRgb::ESystemSelectionBackgroundIndex, |
8788 } |
9215 KRgbWhite ) ); |
8789 iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), |
9216 } |
8790 aSelect.Length() ); |
9217 iEdwinExtension->iSmiley->HandleSelection( aSelect.LowerPos(), |
|
9218 aSelect.Length() ); |
|
9219 } |
|
9220 } |
8791 } |
9221 |
8792 |
9222 // --------------------------------------------------------------------------- |
8793 // --------------------------------------------------------------------------- |
9223 // CEikEdwin::SkipBackgroundDrawer |
8794 // CEikEdwin::SkipBackgroundDrawer |
9224 // --------------------------------------------------------------------------- |
8795 // --------------------------------------------------------------------------- |
9226 TBool CEikEdwin::SkipBackgroundDrawer() const |
8797 TBool CEikEdwin::SkipBackgroundDrawer() const |
9227 { |
8798 { |
9228 return iEdwinInternalFlags & ESkipBackgroundDrawer; |
8799 return iEdwinInternalFlags & ESkipBackgroundDrawer; |
9229 } |
8800 } |
9230 |
8801 |
9231 |
8802 TBool CEikEdwin::IsValidNumericCharL( TChar aChar ) |
9232 // --------------------------------------------------------------------------- |
8803 { |
9233 // CEikEdwin::ContentFitsToViewRect |
8804 TBool ret(ETrue); |
9234 // --------------------------------------------------------------------------- |
8805 CAknEdwinState* state = static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) ); |
9235 // |
8806 if (state && state->CurrentInputMode() == EAknEditorNumericInputMode ) |
9236 TBool CEikEdwin::ContentFitsToViewRect() const |
8807 { |
9237 { |
8808 HBufC* allowedChars = GetAllowedCharsLC(); |
9238 if ( iLayout && !iLayout->IsFormattingBand() ) |
8809 if ( (*allowedChars).Length() > 0 && (*allowedChars).Locate( aChar ) == KErrNotFound ) |
9239 { |
8810 { |
9240 if ( iLayout->FormattedHeightInPixels() |
8811 ret = EFalse; |
9241 <= AdjustedViewRect().Height() + KContentThreshold ) |
8812 } |
9242 { |
8813 CleanupStack::PopAndDestroy(1);//allowedChars |
9243 return ETrue; |
8814 } |
9244 } |
8815 return ret; |
9245 } |
8816 } |
9246 |
|
9247 return EFalse; |
|
9248 } |
|
9249 |
|
9250 |
|
9251 // --------------------------------------------------------------------------- |
|
9252 // ReadSpecialCharFromSCTL |
|
9253 // --------------------------------------------------------------------------- |
|
9254 // |
|
9255 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId ) |
|
9256 { |
|
9257 TResourceReader aReader; |
|
9258 CCoeEnv::Static()->CreateResourceReaderLC( aReader, sctResourceId ); |
|
9259 aReader.Advance( KTInt32Length ); // Diaog Flag |
|
9260 HBufC* titleBar = aReader.ReadHBufCL(); // title bar |
|
9261 // for titleBar useless, release it. |
|
9262 delete titleBar; |
|
9263 titleBar = NULL; |
|
9264 // Page Selector Resource Id, Button Group Container Resource Id |
|
9265 aReader.Advance( KTInt32Length + KTInt32Length ); |
|
9266 TInt lineCount = aReader.ReadInt16(); // line Count |
|
9267 for ( TInt ii = 0; ii < lineCount; ii++ ) |
|
9268 { |
|
9269 TInt controlType = aReader.ReadInt16(); // control Type |
|
9270 if ( controlType == EAknCtPopupHeadingPane ) |
|
9271 { |
|
9272 // read HeadPane |
|
9273 ReadSCTHeadPane( aReader ); |
|
9274 } |
|
9275 else if ( controlType == EAknCtSpecialCharacterMap ) |
|
9276 { |
|
9277 aReader.ReadTPtrC(); // caption text |
|
9278 aReader.Advance( KTInt16Length + KTInt32Length ); // captioned control ID, item flags |
|
9279 |
|
9280 TInt component_count = aReader.ReadInt16(); |
|
9281 for ( TInt jj = 0; jj < component_count; jj++ ) |
|
9282 { |
|
9283 TInt component_id = aReader.ReadInt16(); |
|
9284 if ( component_id == EAknSCTLowerCase || component_id == EAknSCTUpperCase || |
|
9285 component_id == EAknSCTNumeric ) |
|
9286 { |
|
9287 HBufC* specialChar = aReader.ReadHBufCL(); |
|
9288 ptr.Append( specialChar->Des() ); |
|
9289 delete specialChar; |
|
9290 } |
|
9291 } |
|
9292 } |
|
9293 else |
|
9294 { |
|
9295 break; |
|
9296 } |
|
9297 } |
|
9298 CleanupStack::PopAndDestroy(); // aReader |
|
9299 } |
|
9300 |
|
9301 // --------------------------------------------------------------------------- |
|
9302 // ReadSCTHeadPane |
|
9303 // --------------------------------------------------------------------------- |
|
9304 // |
|
9305 void ReadSCTHeadPane( TResourceReader& aReader ) |
|
9306 { |
|
9307 aReader.ReadTPtrC(); // caption text |
|
9308 // captioned control ID, item flags |
|
9309 aReader.Advance( KTInt16Length + KTInt32Length ); |
|
9310 aReader.ReadTPtrC(); // text of head pane |
|
9311 aReader.ReadTPtrC(); // bitmap File Name of head pane |
|
9312 // bitmap Id, bitmap Mask Id,animation Id, layout of head pane |
|
9313 aReader.Advance( KTInt16Length + KTInt16Length + KTUint32Length + KTUint32Length ); |
|
9314 aReader.ReadTPtrC(); // trailer |
|
9315 aReader.ReadTPtrC(); // bitmap File Name of captioned control |
|
9316 // bitmap Id, bitmap Mask Id of captioned control |
|
9317 aReader.Advance( KTInt16Length + KTInt16Length ); |
|
9318 aReader.ReadTPtrC(); // Process ToolTip |
|
9319 } |
|
9320 |
8817 |
9321 // End of File |
8818 // End of File |
9322 |
8819 |