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