18 |
18 |
19 #include "FRMTLAY.H" |
19 #include "FRMTLAY.H" |
20 #include "FRMLAYDT.H" |
20 #include "FRMLAYDT.H" |
21 #include "FRMCONST.H" |
21 #include "FRMCONST.H" |
22 |
22 |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "CARETTraces.h" |
|
26 #endif |
|
27 |
23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
24 #include "FRMCONST_INTERNAL.H" |
29 #include "FRMCONST_INTERNAL.H" |
25 #include "FRMCONST_PARTNER.H" |
30 #include "FRMCONST_PARTNER.H" |
26 #include "TAGMA_INTERNAL.H" |
31 #include "TAGMA_INTERNAL.H" |
27 #endif |
32 #endif |
35 return iLayout->SetViewL(aDocPos,aYPos,yPosQualifier); |
40 return iLayout->SetViewL(aDocPos,aYPos,yPosQualifier); |
36 } |
41 } |
37 |
42 |
38 void TCursorPosition::CheckSelection(TBool aSelect) |
43 void TCursorPosition::CheckSelection(TBool aSelect) |
39 { |
44 { |
|
45 if (IsSelection() && iDocPos.iPos == iAnchor) |
|
46 { |
|
47 OstTrace0( TRACE_DUMP, TCURSORPOSITION_CHECKSELECTION, "EFSelectedRangeZeroLen" ); |
|
48 } |
|
49 |
40 __ASSERT_DEBUG(!IsSelection() || iDocPos.iPos != iAnchor,FormPanic(EFSelectedRangeZeroLen)); |
50 __ASSERT_DEBUG(!IsSelection() || iDocPos.iPos != iAnchor,FormPanic(EFSelectedRangeZeroLen)); |
41 CheckNullSelection(); |
51 CheckNullSelection(); |
42 TUint drawSelectionFlags = 0; |
52 TUint drawSelectionFlags = 0; |
43 iOldDocPos=iDocPos.iPos; |
53 iOldDocPos=iDocPos.iPos; |
44 iOldAnchor=iAnchor; |
54 iOldAnchor=iAnchor; |
105 TInt higherPos = iLayout->PosInBand(higher_doc_pos,&higher_line_info) ? EFInside : EFAbove; |
115 TInt higherPos = iLayout->PosInBand(higher_doc_pos,&higher_line_info) ? EFInside : EFAbove; |
106 TInt selectionPos = EFInside; |
116 TInt selectionPos = EFInside; |
107 TInt extraScroll; |
117 TInt extraScroll; |
108 TBool cursorVisible = EFalse; |
118 TBool cursorVisible = EFalse; |
109 |
119 |
|
120 if (aSelection.iCursorPos<0 || aSelection.iCursorPos>iLayout->DocumentLength()) |
|
121 { |
|
122 OstTrace0( TRACE_DUMP, TCURSORPOSITION_SETSELECTIONL, "EFInvalidDocPos" ); |
|
123 } |
110 __ASSERT_DEBUG(aSelection.iCursorPos>=0 && aSelection.iCursorPos<=iLayout->DocumentLength() |
124 __ASSERT_DEBUG(aSelection.iCursorPos>=0 && aSelection.iCursorPos<=iLayout->DocumentLength() |
111 ,FormPanic(EFInvalidDocPos)); |
125 ,FormPanic(EFInvalidDocPos)); |
112 iLayout->PosRangeInBand(firstVisChar); |
126 iLayout->PosRangeInBand(firstVisChar); |
113 if (lowerPos == EFInside) |
127 if (lowerPos == EFInside) |
114 { |
128 { |
285 TInt pixels=0; |
299 TInt pixels=0; |
286 |
300 |
287 CheckSelection(aDragSelectOn); |
301 CheckSelection(aDragSelectOn); |
288 DoSetXyPos(aPos); |
302 DoSetXyPos(aPos); |
289 TRAPD(ret,pixels=CheckCursorOnScreenL(aPos.iY)); |
303 TRAPD(ret,pixels=CheckCursorOnScreenL(aPos.iY)); |
|
304 if (ret) |
|
305 { |
|
306 OstTrace0( TRACE_FATAL, TCURSORPOSITION_SETXYPOSL, "EFShouldNotLeave" ); |
|
307 } |
290 __ASSERT_ALWAYS(!ret,FormPanic(EFShouldNotLeave)); |
308 __ASSERT_ALWAYS(!ret,FormPanic(EFShouldNotLeave)); |
291 UpdateLatentX(aPos.iX); |
309 UpdateLatentX(aPos.iX); |
292 UpdateLatentY(aPos.iY); |
310 UpdateLatentY(aPos.iY); |
293 if (!aDragSelectOn && aAllowPictureFrame) |
311 if (!aDragSelectOn && aAllowPictureFrame) |
294 { |
312 { |
546 @param aLine returns details of the line containing aPos. |
564 @param aLine returns details of the line containing aPos. |
547 @return ETrue if the cursor moved one position within the line. */ |
565 @return ETrue if the cursor moved one position within the line. */ |
548 TBool TCursorPosition::LeftRightL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
566 TBool TCursorPosition::LeftRightL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
549 { |
567 { |
550 TTmPosInfo2 posInfo; |
568 TTmPosInfo2 posInfo; |
|
569 if (!(aMove == EFLeft || aMove == EFRight)) |
|
570 { |
|
571 OstTrace0( TRACE_DUMP, TCURSORPOSITION_LEFTRIGHTL, "EFIncorrectCursorMovement" ); |
|
572 } |
551 __ASSERT_DEBUG(aMove == EFLeft || aMove == EFRight, |
573 __ASSERT_DEBUG(aMove == EFLeft || aMove == EFRight, |
552 FormPanic(EFIncorrectCursorMovement)); |
574 FormPanic(EFIncorrectCursorMovement)); |
553 TBool found = EFalse; |
575 TBool found = EFalse; |
554 TTmPosInfo2 otherPosInfo; |
576 TTmPosInfo2 otherPosInfo; |
555 CTextLayout::TTagmaForwarder forwarder(*iLayout); |
577 CTextLayout::TTagmaForwarder forwarder(*iLayout); |
611 @param aToStart ETrue if finding the visual start of the line, EFalse if finding the end. |
633 @param aToStart ETrue if finding the visual start of the line, EFalse if finding the end. |
612 @param aPos Returns the position found. |
634 @param aPos Returns the position found. |
613 @param aLine Returns details of the line containing aPos.*/ |
635 @param aLine Returns details of the line containing aPos.*/ |
614 void TCursorPosition::StartEnd(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
636 void TCursorPosition::StartEnd(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
615 { |
637 { |
|
638 if (aMove != EFLineBeg && aMove != EFLineEnd) |
|
639 { |
|
640 OstTrace0( TRACE_DUMP, TCURSORPOSITION_STARTEND, "EFIncorrectCursorMovement" ); |
|
641 } |
616 __ASSERT_DEBUG(aMove == EFLineBeg || aMove == EFLineEnd, |
642 __ASSERT_DEBUG(aMove == EFLineBeg || aMove == EFLineEnd, |
617 FormPanic(EFIncorrectCursorMovement)); |
643 FormPanic(EFIncorrectCursorMovement)); |
618 iLayout->FindDocPos(iDocPos, aPos, &aLine); |
644 iLayout->FindDocPos(iDocPos, aPos, &aLine); |
619 TBool toBeginning = aMove == EFLineBeg? ETrue : EFalse; |
645 TBool toBeginning = aMove == EFLineBeg? ETrue : EFalse; |
620 TBool toRight = aLine.iFlags & TTmLineInfo::EParRightToLeft? |
646 TBool toRight = aLine.iFlags & TTmLineInfo::EParRightToLeft? |
630 @param aUp ETrue if moving up, EFalse if moving down. |
656 @param aUp ETrue if moving up, EFalse if moving down. |
631 @param aPos returns the position found. |
657 @param aPos returns the position found. |
632 @param aLine returns details of the line containing aPos. */ |
658 @param aLine returns details of the line containing aPos. */ |
633 void TCursorPosition::UpDownL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
659 void TCursorPosition::UpDownL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove) |
634 { |
660 { |
|
661 if (aMove != EFLineUp && aMove != EFLineDown) |
|
662 { |
|
663 OstTrace0( TRACE_DUMP, TCURSORPOSITION_UPDOWNL, "EFIncorrectCursorMovement" ); |
|
664 } |
635 __ASSERT_DEBUG(aMove == EFLineUp || aMove == EFLineDown, |
665 __ASSERT_DEBUG(aMove == EFLineUp || aMove == EFLineDown, |
636 FormPanic(EFIncorrectCursorMovement)); |
666 FormPanic(EFIncorrectCursorMovement)); |
637 iLayout->FindDocPos(iDocPos, aPos, &aLine); |
667 iLayout->FindDocPos(iDocPos, aPos, &aLine); |
638 TPoint c(iLatentX, aMove == EFLineUp? |
668 TPoint c(iLatentX, aMove == EFLineUp? |
639 aLine.iOuterRect.iTl.iY - 1 |
669 aLine.iOuterRect.iTl.iY - 1 |
675 } |
705 } |
676 |
706 |
677 // Move the display one page and put the cursor back in the same place (as far as possible). |
707 // Move the display one page and put the cursor back in the same place (as far as possible). |
678 TInt TCursorPosition::PageScrollL(TMovementType& aMove) |
708 TInt TCursorPosition::PageScrollL(TMovementType& aMove) |
679 { |
709 { |
|
710 if (aMove!=EFPageUp && aMove!=EFPageDown) |
|
711 { |
|
712 OstTrace0( TRACE_DUMP, TCURSORPOSITION_PAGESCROLLL, "EFIncorrectCursorMovement" ); |
|
713 } |
680 __ASSERT_DEBUG(aMove==EFPageUp || aMove==EFPageDown,FormPanic(EFIncorrectCursorMovement)); |
714 __ASSERT_DEBUG(aMove==EFPageUp || aMove==EFPageDown,FormPanic(EFIncorrectCursorMovement)); |
681 TPoint scrPos; |
715 TPoint scrPos; |
682 TInt pixelsScrolled; |
716 TInt pixelsScrolled; |
683 TTmDocPos docPos=iDocPos; |
717 TTmDocPos docPos=iDocPos; |
684 |
718 |
723 const TInt botRow=iLayout->BandHeight(); |
757 const TInt botRow=iLayout->BandHeight(); |
724 TInt linesToScroll=0; |
758 TInt linesToScroll=0; |
725 TInt pixels=0; |
759 TInt pixels=0; |
726 |
760 |
727 iLayout->GetLineRect(aY,cursorLine); |
761 iLayout->GetLineRect(aY,cursorLine); |
|
762 if (cursorLine.iTl.iY>aY || cursorLine.iBr.iY<aY) |
|
763 { |
|
764 OstTrace0( TRACE_DUMP, TCURSORPOSITION_CHECKCURSORONSCREENL, "EFPixelNotInFormattedLine" ); |
|
765 } |
728 __ASSERT_DEBUG(cursorLine.iTl.iY<=aY && cursorLine.iBr.iY>=aY,FormPanic(EFPixelNotInFormattedLine)); |
766 __ASSERT_DEBUG(cursorLine.iTl.iY<=aY && cursorLine.iBr.iY>=aY,FormPanic(EFPixelNotInFormattedLine)); |
729 if (cursorLine.iTl.iY<0 && cursorLine.iBr.iY<botRow) |
767 if (cursorLine.iTl.iY<0 && cursorLine.iBr.iY<botRow) |
730 linesToScroll=1; |
768 linesToScroll=1; |
731 else if (cursorLine.iBr.iY>botRow && cursorLine.iTl.iY>0) |
769 else if (cursorLine.iBr.iY>botRow && cursorLine.iTl.iY>0) |
732 linesToScroll=-1; |
770 linesToScroll=-1; |
734 { |
772 { |
735 pixels=iLayout->ScrollLinesL(linesToScroll); |
773 pixels=iLayout->ScrollLinesL(linesToScroll); |
736 |
774 |
737 aY+=pixels; |
775 aY+=pixels; |
738 } |
776 } |
|
777 if (aY<0 && aY>=botRow) |
|
778 { |
|
779 OstTrace0( TRACE_DUMP, DUP1_TCURSORPOSITION_CHECKCURSORONSCREENL, "EFCursorOffDisplay" ); |
|
780 } |
739 __ASSERT_DEBUG(aY>=0 || aY<botRow,FormPanic(EFCursorOffDisplay)); |
781 __ASSERT_DEBUG(aY>=0 || aY<botRow,FormPanic(EFCursorOffDisplay)); |
|
782 if (!(cursorLine.Height()>=botRow || cursorLine.iBr.iY>=botRow |
|
783 || (cursorLine.iTl.iY+pixels>=0 && cursorLine.iBr.iY+pixels<=botRow)) ) |
|
784 { |
|
785 OstTrace0( TRACE_DUMP, DUP2_TCURSORPOSITION_CHECKCURSORONSCREENL, "EFCursorOffDisplay" ); |
|
786 } |
740 __ASSERT_DEBUG(cursorLine.Height()>=botRow || cursorLine.iBr.iY>=botRow |
787 __ASSERT_DEBUG(cursorLine.Height()>=botRow || cursorLine.iBr.iY>=botRow |
741 || (cursorLine.iTl.iY+pixels>=0 && cursorLine.iBr.iY+pixels<=botRow),FormPanic(EFCursorOffDisplay)); |
788 || (cursorLine.iTl.iY+pixels>=0 && cursorLine.iBr.iY+pixels<=botRow),FormPanic(EFCursorOffDisplay)); |
742 return pixels; |
789 return pixels; |
743 } |
790 } |
744 |
791 |