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