Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "OstTraceDefinitions.h"
24 #ifdef OST_TRACE_COMPILER_IN_USE
25 #include "CARETTraces.h"
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
29 #include "FRMCONST_INTERNAL.H"
30 #include "FRMCONST_PARTNER.H"
31 #include "TAGMA_INTERNAL.H"
34 // Set the top of the line containing aDocPos to the y coordinate aYPos.
35 TInt TCursorPosition::ViewTopOfLineL(const TTmDocPos& aDocPos,TInt& aYPos)
37 TViewYPosQualifier yPosQualifier;
38 yPosQualifier.SetHotSpot(TViewYPosQualifier::EFViewTopOfLine);
39 yPosQualifier.SetFillScreen(ETrue);
40 return iLayout->SetViewL(aDocPos,aYPos,yPosQualifier);
43 void TCursorPosition::CheckSelection(TBool aSelect)
45 if (IsSelection() && iDocPos.iPos == iAnchor)
47 OstTrace0( TRACE_DUMP, TCURSORPOSITION_CHECKSELECTION, "EFSelectedRangeZeroLen" );
50 __ASSERT_DEBUG(!IsSelection() || iDocPos.iPos != iAnchor,FormPanic(EFSelectedRangeZeroLen));
52 TUint drawSelectionFlags = 0;
53 iOldDocPos=iDocPos.iPos;
57 drawSelectionFlags |= EDrawOldPictureFrame;
59 if (iFlags & ESelected)
63 if (aSelect || !IsPictureFrame())
64 drawSelectionFlags |= EDrawHighlight;
65 if (aSelect && IsPictureFrame())
72 iAnchor=iDocPos.iPos; //Change the value of iOldDocPos so that the old highlight appears to be empty
74 drawSelectionFlags |= EDrawHighlight;
76 iOldDocPos=iOldAnchor=iAnchor;
78 iFlags &= ~(EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame);
79 iFlags |= drawSelectionFlags;
82 // The cursor pos has changed so the selection might be zero length
83 void TCursorPosition::CheckNullSelection()
85 if ((iFlags & ESelected) && iDocPos.iPos == iAnchor)
89 TBool TCursorPosition::IsPictureFrame() const
91 if (iFlags & EReturnPreviousHighlight)
92 return (iFlags & EDrawOldPictureFrame) != 0;
94 return (iFlags & EDrawNewPictureFrame) != 0;
97 TBool TCursorPosition::IsNewPictureFrame() const
99 return (iFlags & EDrawNewPictureFrame) != 0;
102 TInt TCursorPosition::SetSelectionL(const TCursorSelection& aSelection)
104 //Change the highlighted region to be that specified
108 TInt botOfWin=iLayout->BandHeight();
110 TTmLineInfo lower_line_info;
111 TTmLineInfo higher_line_info;
112 TTmDocPos lower_doc_pos = TTmDocPos(aSelection.LowerPos(), ETrue);
113 TTmDocPos higher_doc_pos = TTmDocPos(aSelection.HigherPos(), EFalse);
114 TInt lowerPos = iLayout->PosInBand(lower_doc_pos,&lower_line_info) ? EFInside : EFAbove;
115 TInt higherPos = iLayout->PosInBand(higher_doc_pos,&higher_line_info) ? EFInside : EFAbove;
116 TInt selectionPos = EFInside;
118 TBool cursorVisible = EFalse;
120 if (aSelection.iCursorPos<0 || aSelection.iCursorPos>iLayout->DocumentLength())
122 OstTrace0( TRACE_DUMP, TCURSORPOSITION_SETSELECTIONL, "EFInvalidDocPos" );
124 __ASSERT_DEBUG(aSelection.iCursorPos>=0 && aSelection.iCursorPos<=iLayout->DocumentLength()
125 ,FormPanic(EFInvalidDocPos));
126 iLayout->PosRangeInBand(firstVisChar);
127 if (lowerPos == EFInside)
129 if (lower_line_info.iOuterRect.iTl.iY < 0)
132 else if (firstVisChar < aSelection.LowerPos())
135 if (higherPos==EFInside)
137 if (higher_line_info.iOuterRect.iBr.iY > botOfWin + 1)
140 else if (firstVisChar < aSelection.HigherPos())
142 CheckSelection(ETrue);
144 iAnchor = aSelection.iAnchorPos;
145 if (lower_doc_pos.iPos == aSelection.iCursorPos)
146 iDocPos = lower_doc_pos;
148 iDocPos = higher_doc_pos;
150 if (lowerPos==EFAbove)
152 selectionPos=EFBelow;
153 if (aSelection.iCursorPos==aSelection.HigherPos() && higherPos==EFBelow)
154 selectionPos=EFAbove;
156 else if (higherPos==EFBelow)
157 selectionPos=EFAbove;
159 if (selectionPos == EFBelow || selectionPos == EFAbove)
161 TViewYPosQualifier yPosQualifier;
162 yPosQualifier.SetMakeLineFullyVisible();
163 TInt docPos = aSelection.LowerPos();
164 TInt desiredY = scroll;
165 if (selectionPos == EFBelow)
167 yPosQualifier.SetHotSpot(TViewYPosQualifier::EFViewTopOfLine);
168 yPosQualifier.SetFillScreen(TRUE);
173 docPos = aSelection.iCursorPos < aSelection.iAnchorPos?
174 aSelection.iAnchorPos - 1 : aSelection.iCursorPos;
175 yPosQualifier.SetHotSpot(TViewYPosQualifier::EFViewBottomOfLine);
177 if (aSelection.iCursorPos == docPos)
178 cursorVisible = ETrue;
179 scroll = iLayout->SetViewL(docPos, desiredY, yPosQualifier);
183 extraScroll=DoSetVisibleDocPosL(TTmDocPos(aSelection.iCursorPos, ETrue));
185 extraScroll=DoSetDocPosL(TTmDocPos(aSelection.iCursorPos, ETrue));
186 if (scroll!=CTextLayout::EFScrollRedrawWholeScreen)
191 void TCursorPosition::SetPendingSelection(const TCursorSelection& aSelection)
193 iFlags &= ~(ESelected | EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame);
194 iDocPos.iPos = aSelection.iCursorPos;
195 iDocPos.iLeadingEdge = aSelection.iCursorPos < aSelection.iAnchorPos ? ETrue : EFalse;
196 iAnchor = aSelection.iAnchorPos;
197 if (iDocPos.iPos != iAnchor)
199 iLayout->SetTextViewCursorPos(this); // Put in for INC092568
202 void TCursorPosition::GetOldSelection(TCursorSelection& aSelection) const
204 aSelection.iAnchorPos = iOldAnchor;
205 aSelection.iCursorPos = iOldDocPos;
208 // Return the highlighted range
209 void TCursorPosition::GetSelection(TCursorSelection& aSelection) const
211 if (iFlags & EReturnPreviousHighlight)
212 GetOldSelection(aSelection);
215 aSelection.iCursorPos = iDocPos.iPos;
216 aSelection.iAnchorPos = iFlags & ESelected? iAnchor : iDocPos.iPos;
221 Selection of the left end or right end of a run of text. If both ends are in
222 one line, the logical end that is visually in the direction specified will be
223 chosen. If aStart and aEnd are in different lines, then we look at whether
224 aEnd is choosing the end that is furthest forwards or furthest back by comparing
225 it against the directionality of the paragraph containing aStart.
226 @return Reference to aStart or aEnd.
229 const TTmDocPos& TCursorPosition::VisualEndOfRunL(
230 const TTmDocPos& aStart, const TTmDocPos& aEnd,
231 TVisualEnd aDirection)
233 iLayout->ExtendFormattingToCoverPosL(aStart.iPos);
234 iLayout->ExtendFormattingToCoverPosL(aEnd.iPos);
236 TTmPosInfo2 startInfo;
237 TTmLineInfo startLine;
238 iLayout->FindDocPos(aStart, startInfo, &startLine);
240 iLayout->FindDocPos(aEnd, endInfo);
242 TVisualEnd startEnd = startInfo.iEdge.iX < endInfo.iEdge.iX?
243 EVisualLeft : EVisualRight;
245 if (startInfo.iEdge.iY != endInfo.iEdge.iY)
248 TVisualEnd backwards = startLine.iFlags & TTmLineInfo::EParRightToLeft?
249 EVisualRight : EVisualLeft;
250 TVisualEnd forwards = backwards? EVisualLeft : EVisualRight;
251 startEnd = aStart < aEnd? backwards : forwards;
253 return startEnd == aDirection? aStart : aEnd;
256 // Set the cursor position to aDocPos and update the stored selection according to the value of aDragSelectOn.
257 TInt TCursorPosition::SetDocPosL(TBool aDragSelectOn,const TTmDocPos& aDocPos)
259 CheckSelection(aDragSelectOn);
260 return DoSetDocPosL(aDocPos);
263 // Set the cursor position to aDocPos.
264 TInt TCursorPosition::DoSetDocPosL(const TTmDocPos& aDocPos)
267 if (iLayout->PosInBand(aDocPos))
268 scroll = DoSetVisibleDocPosL(aDocPos);
271 iDocPos = aDocPos; // in case the next line leaves
272 scroll = ViewTopOfLineL(aDocPos,scroll);
273 DoSetVisibleDocPosL(aDocPos);
278 // Set the cursor position to the specified document position.
279 TInt TCursorPosition::DoSetVisibleDocPosL(const TTmDocPos& aDocPos)
282 CheckNullSelection();
283 TTmPosInfo2 pos_info;
284 iLayout->FindDocPos(aDocPos,pos_info);
285 TInt pixels = CheckCursorOnScreenL(pos_info.iEdge.iY);
286 UpdateLatentX(pos_info.iEdge.iX);
287 UpdateLatentY(pos_info.iEdge.iY);
291 TInt TCursorPosition::SetXyPosL(TBool aDragSelectOn,TPoint aPos,TBool aAllowPictureFrame)
293 //Move the cursor back to the point on the screen nearest to the position specified
294 //and return the document position and screen position
295 //and update the saved X and Y positions
298 TPoint originalPoint = aPos;
301 CheckSelection(aDragSelectOn);
303 TRAPD(ret,pixels=CheckCursorOnScreenL(aPos.iY));
306 OstTrace0( TRACE_FATAL, TCURSORPOSITION_SETXYPOSL, "EFShouldNotLeave" );
308 __ASSERT_ALWAYS(!ret,FormPanic(EFShouldNotLeave));
309 UpdateLatentX(aPos.iX);
310 UpdateLatentY(aPos.iY);
311 if (!aDragSelectOn && aAllowPictureFrame)
314 TInt pos = iLayout->XyPosToDocPosL(originalPoint);
315 if (iLayout->PictureRectangleL(pos, pict))
317 TTmDocPos docPos(pos + 1, EFalse);
318 SetPictureFrame(docPos, pos, pict);
325 Returns a reference to the more suitable of the positions, taking
326 the cursor positioning hint into account.
328 The candidate returned if the positioning hint does not decide it.
330 The alternative candidate; only returned if the positioning hint
331 makes it more desirable than aPreferred.
332 @return either aPreferred or aBackup.
335 TTmPosInfo2& TCursorPosition::ChoosePosition(TTmPosInfo2& aPreferred,
336 TTmPosInfo2& aBackup)
339 // The following part is to find out whether the aPreferred or aBackup is
340 // overlapped. For overlapped position, because it could visually exist at two
341 // different places/XY-coordinates, the iLayout->FindDocPos may return an aPos
342 // with a different iEdge against the original, so that we can know which doc position
344 iLayout->FindDocPos(aPreferred.iDocPos, posInfo, NULL);
345 TBool preferredOverlapped = (aPreferred.iEdge != posInfo.iEdge);
347 iLayout->FindDocPos(aBackup.iDocPos, posInfo, NULL);
348 TBool backupOverlapped = ( aBackup.iEdge != posInfo.iEdge);
350 if(preferredOverlapped && !backupOverlapped)
352 if(!preferredOverlapped && backupOverlapped)
355 if (iPositioningHint == EInsertStrongL2R)
357 if (!aBackup.iRightToLeft && aPreferred.iRightToLeft)
360 else if (iPositioningHint == EInsertStrongR2L)
362 if (aBackup.iRightToLeft && !aPreferred.iRightToLeft)
369 Move the cursor to the point on the screen nearest to the position specified
370 and return the document position and screen position.
372 void TCursorPosition::DoSetXyPos(TPoint& aXyPos)
374 TTmPosInfo2 leftPosInfo;
375 TTmPosInfo2 rightPosInfo;
376 TTmLineInfo lineInfo;
377 CTextLayout::TTagmaForwarder forwarder(*iLayout);
378 if (forwarder.FindXyPosWithDisambiguation(aXyPos,
379 leftPosInfo, rightPosInfo, lineInfo))
381 TTmPosInfo2& chosen = ChoosePosition(leftPosInfo, rightPosInfo);
382 iDocPos = chosen.iDocPos;
383 aXyPos = chosen.iEdge;
384 CheckNullSelection();
388 // Set up a picture frame.
389 void TCursorPosition::SetPictureFrame(const TTmDocPos& aDocPos,TInt aAnchor,const TRect& aPictureRect)
391 iFlags |= (ESelected | EDrawNewPictureFrame);
394 iLatentX = (aPictureRect.iTl.iX + aPictureRect.iBr.iX) / 2;
397 TInt TCursorPosition::MoveL(TBool aDragSelectOn, TMovementType& aMove,
398 TBool aAllowPictureFrame)
400 // Get the anchor point, either old or new.
401 TBool oldSelection = iFlags & ESelected;
402 TInt anchor = oldSelection? iAnchor : iDocPos.iPos;
404 iLayout->ExtendFormattingToCoverPosL(iDocPos.iPos);
406 TMovementType move = aMove;
408 TBool pagingMove = EFalse;
409 TTmPosInfo2 suggestedCursorPos;
410 TInt picturePos = KErrNotFound;
414 // Get a value for suggestedCursorPos.
415 // Also scroll if aMove is EFPageUp or EFPageDown.
419 iLayout->FindDocPos(iDocPos, suggestedCursorPos);
423 // MoveL is not called if a picture frame is moved away from,
424 // so we will not deal with that situation.
425 if (IsPictureFrame())
427 suggestedCursorPos.iDocPos.iPos = iDocPos.iPos;
428 suggestedCursorPos.iDocPos.iLeadingEdge = ETrue;
429 suggestedCursorPos.iEdge.iX = iLatentX;
430 suggestedCursorPos.iEdge.iY = iLatentY;
434 anchorPos.iPos = anchor;
435 anchorPos.iLeadingEdge = anchor < iDocPos.iPos? ETrue : EFalse;
436 suggestedCursorPos.iDocPos = VisualEndOfRunL(
438 move == EFLeft ? EVisualLeft : EVisualRight);
439 anchor = iDocPos.iPos;
442 else if (LeftRightL(suggestedCursorPos, line, move)
443 && aAllowPictureFrame && !aDragSelectOn)
445 // Have we just moved over a picture?
446 TPoint c = suggestedCursorPos.iEdge;
447 c.iX += aMove == EFLeft? 1 : -1;
448 picturePos = iLayout->PictureRectangleAndPosL(c, pictureRect);
453 UpDownL(suggestedCursorPos, line, move);
454 if (aAllowPictureFrame && !aDragSelectOn && move == aMove)
456 TPoint c(iLatentX, line.iBaseline);
457 picturePos = iLayout->PictureRectangleAndPosL(c, pictureRect);
462 pixels = PageScrollL(move);
467 StartEnd(suggestedCursorPos, line, move);
471 // Do the scrolling, if not already done.
473 pixels = iLayout->ScrollDocPosIntoViewL(suggestedCursorPos.iDocPos);
475 // Work out if the cursor has not moved.
476 if (iDocPos == suggestedCursorPos.iDocPos
477 && !IsPictureFrame() && picturePos < 0)
481 iOldDocPos = iDocPos.iPos;
482 iOldAnchor = oldSelection? iAnchor : iOldDocPos;
483 if (iFlags & EDrawNewPictureFrame)
484 iFlags |= EDrawOldPictureFrame;
486 iFlags &= ~EDrawOldPictureFrame;
488 // Finally, set everything worked out.
490 iDocPos = suggestedCursorPos.iDocPos;
492 if (!aDragSelectOn || anchor == suggestedCursorPos.iDocPos.iPos)
494 iFlags &= ~ESelected;
495 iAnchor = suggestedCursorPos.iDocPos.iPos;
508 iLatentX = suggestedCursorPos.iEdge.iX;
510 iLatentX = (pictureRect.iTl.iX + pictureRect.iBr.iX) >> 1;
514 iLatentY = suggestedCursorPos.iEdge.iY;
520 iFlags |= (ESelected | EDrawNewPictureFrame);
521 iDocPos.iPos = picturePos;
522 iDocPos.iLeadingEdge = ETrue;
523 iAnchor = picturePos + 1;
526 iFlags &= ~EDrawNewPictureFrame;
528 ((iFlags & ESelected) && !(iFlags & EDrawNewPictureFrame)))
529 iFlags |= EDrawHighlight;
531 iFlags &= ~EDrawHighlight;
536 void TCursorPosition::UpdateLatentPosition()
539 CalculateCursorPos(pos);
540 UpdateLatentY(pos.iY);
541 UpdateLatentX(pos.iX);
544 void TCursorPosition::TextMoveVertically()
546 //Reset the Vertical Latent position
551 CalculateCursorPos(scrPos);
552 UpdateLatentY(scrPos.iY);
555 /** Find the position one position to the left or right of the current cursor.
556 If the cursor is already at that extreme of the line, the cursor will move
557 to the opposite of the previous (if moving backwards) or next (if moving
558 forwards) line. The cursor is considered to be moving forwards if it is
559 moving in the same direction as the paragraph directionality. This may, of
560 course, be different to the local direction of the text.
562 @param aToLeft ETrue if moving left, EFalse if moving right.
563 @param aPos returns the position found.
564 @param aLine returns details of the line containing aPos.
565 @return ETrue if the cursor moved one position within the line. */
566 TBool TCursorPosition::LeftRightL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove)
569 if (!(aMove == EFLeft || aMove == EFRight))
571 OstTrace0( TRACE_DUMP, TCURSORPOSITION_LEFTRIGHTL, "EFIncorrectCursorMovement" );
573 __ASSERT_DEBUG(aMove == EFLeft || aMove == EFRight,
574 FormPanic(EFIncorrectCursorMovement));
575 TBool found = EFalse;
576 TTmPosInfo2 otherPosInfo;
577 CTextLayout::TTagmaForwarder forwarder(*iLayout);
580 found = forwarder.GetNextPosLeftWithDisambiguation(
581 iDocPos, otherPosInfo, posInfo);
585 found = forwarder.GetNextPosRightWithDisambiguation(
586 iDocPos, posInfo, otherPosInfo);
590 iLayout->FindDocPos(ChoosePosition(posInfo, otherPosInfo).iDocPos,
595 // We have reached the extreme of the line.
596 // But the beginning or the end?
597 TTmLineInfo currentLineInfo;
598 iLayout->FindDocPos(iDocPos, posInfo, ¤tLineInfo);
599 TBool toLeft = aMove == EFLeft? ETrue : EFalse;
600 TBool movingBackwards = currentLineInfo.iFlags & TTmLineInfo::EParRightToLeft?
602 TInt lineToGoToY = movingBackwards?
603 currentLineInfo.iOuterRect.iTl.iY - 1
604 : currentLineInfo.iOuterRect.iBr.iY;
606 iLayout->ExtendFormattingToCoverYL(lineToGoToY);
607 const CTmTextLayout& tm = iLayout->TagmaTextLayout();
609 TPoint c(0, lineToGoToY);
610 if (iLayout->FindXyPos(c, posInfo, &aLine))
612 // moving to next/previous line
613 TBool toRightEnd = aLine.iFlags & TTmLineInfo::EParRightToLeft?
614 !movingBackwards : movingBackwards;
615 tm.LineExtreme(posInfo.iDocPos, toRightEnd, newPos);
619 // We appear to have reached the end of the document.
620 if (movingBackwards || currentLineInfo.iStart == currentLineInfo.iEnd)
621 // before start of line
622 newPos = TTmDocPos(currentLineInfo.iStart, EFalse);
624 // after end of line (last character is paragraph delimiter)
625 newPos = TTmDocPos(currentLineInfo.iEnd - 1, ETrue);
627 tm.FindDocPos(newPos, aPos, aLine);
628 // Cursor either changed line, or did not move.
632 /** Find the visual start or end of the line containing the cursor.
633 @param aToStart ETrue if finding the visual start of the line, EFalse if finding the end.
634 @param aPos Returns the position found.
635 @param aLine Returns details of the line containing aPos.*/
636 void TCursorPosition::StartEnd(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove)
638 if (aMove != EFLineBeg && aMove != EFLineEnd)
640 OstTrace0( TRACE_DUMP, TCURSORPOSITION_STARTEND, "EFIncorrectCursorMovement" );
642 __ASSERT_DEBUG(aMove == EFLineBeg || aMove == EFLineEnd,
643 FormPanic(EFIncorrectCursorMovement));
644 iLayout->FindDocPos(iDocPos, aPos, &aLine);
645 TBool toBeginning = aMove == EFLineBeg? ETrue : EFalse;
646 TBool toRight = aLine.iFlags & TTmLineInfo::EParRightToLeft?
647 toBeginning : !toBeginning;
649 iLayout->TagmaTextLayout().LineExtreme(iDocPos, toRight, newPos);
650 iLayout->FindDocPos(newPos, aPos, &aLine);
653 /** Find a position in the previous or next line close to the current cursor
656 @param aUp ETrue if moving up, EFalse if moving down.
657 @param aPos returns the position found.
658 @param aLine returns details of the line containing aPos. */
659 void TCursorPosition::UpDownL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove)
661 if (aMove != EFLineUp && aMove != EFLineDown)
663 OstTrace0( TRACE_DUMP, TCURSORPOSITION_UPDOWNL, "EFIncorrectCursorMovement" );
665 __ASSERT_DEBUG(aMove == EFLineUp || aMove == EFLineDown,
666 FormPanic(EFIncorrectCursorMovement));
667 iLayout->FindDocPos(iDocPos, aPos, &aLine);
668 TPoint c(iLatentX, aMove == EFLineUp?
669 aLine.iOuterRect.iTl.iY - 1
670 : aLine.iOuterRect.iBr.iY);
672 // Ensure formatting extends to the new cursor position above or
673 // below the current line. Solves the problem where scrolling down
674 // at the bottom of a view to the next paragraph needed two
675 // down cursor key presses.
676 iLayout->ExtendFormattingToCoverYL(c.iY);
678 TTmPosInfo2 otherPosInfo;
679 CTextLayout::TTagmaForwarder forwarder(*iLayout);
680 if (!forwarder.FindXyPosWithDisambiguation(c,
681 otherPosInfo, aPos, aLine))
684 if (aMove == EFLineUp)
694 TBool toRight = aLine.iFlags & TTmLineInfo::EParRightToLeft?
697 iLayout->TagmaTextLayout().LineExtreme(aPos.iDocPos, toRight, newPos);
698 iLayout->FindDocPos(newPos, aPos, &aLine);
700 // as FindXyPosWithDisambiguation returned EFalse, there is no
701 // "otherPosInfo" so no need to ChoosePosition() just return
704 aPos = ChoosePosition(aPos, otherPosInfo);
707 // Move the display one page and put the cursor back in the same place (as far as possible).
708 TInt TCursorPosition::PageScrollL(TMovementType& aMove)
710 if (aMove!=EFPageUp && aMove!=EFPageDown)
712 OstTrace0( TRACE_DUMP, TCURSORPOSITION_PAGESCROLLL, "EFIncorrectCursorMovement" );
714 __ASSERT_DEBUG(aMove==EFPageUp || aMove==EFPageDown,FormPanic(EFIncorrectCursorMovement));
717 TTmDocPos docPos=iDocPos;
719 if (!iLayout->PosInBand(iDocPos,scrPos))
724 iLatentY=(iLayout->BandHeight()-1);
727 iLayout->PageUpL(iLatentY,pixelsScrolled);
729 iLayout->PageDownL(iLatentY,pixelsScrolled);
730 scrPos.SetXY(iLatentX,iLatentY);
732 if (docPos.iPos == iDocPos.iPos && pixelsScrolled == 0) // Cursor in first or last line
735 CalculateCursorPos(pos);
737 if (aMove == EFPageUp)
738 DoSetDocPosL(TTmDocPos(0, ETrue));
740 DoSetDocPosL(TTmDocPos(iLayout->DocumentLength(), EFalse));
741 CalculateCursorPos(pos);
742 // If the line didn't change change the movement type to reflect this.
744 aMove = aMove == EFPageUp? EFLineBeg : EFLineEnd;
747 return pixelsScrolled;
751 Find the position of the line on the screen
752 Scroll it completely on if it is partly off.
754 TInt TCursorPosition::CheckCursorOnScreenL(TInt& aY)
757 const TInt botRow=iLayout->BandHeight();
758 TInt linesToScroll=0;
761 iLayout->GetLineRect(aY,cursorLine);
762 if (cursorLine.iTl.iY>aY || cursorLine.iBr.iY<aY)
764 OstTrace0( TRACE_DUMP, TCURSORPOSITION_CHECKCURSORONSCREENL, "EFPixelNotInFormattedLine" );
766 __ASSERT_DEBUG(cursorLine.iTl.iY<=aY && cursorLine.iBr.iY>=aY,FormPanic(EFPixelNotInFormattedLine));
767 if (cursorLine.iTl.iY<0 && cursorLine.iBr.iY<botRow)
769 else if (cursorLine.iBr.iY>botRow && cursorLine.iTl.iY>0)
771 if (linesToScroll!=0)
773 pixels=iLayout->ScrollLinesL(linesToScroll);
777 if (aY<0 && aY>=botRow)
779 OstTrace0( TRACE_DUMP, DUP1_TCURSORPOSITION_CHECKCURSORONSCREENL, "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)) )
785 OstTrace0( TRACE_DUMP, DUP2_TCURSORPOSITION_CHECKCURSORONSCREENL, "EFCursorOffDisplay" );
787 __ASSERT_DEBUG(cursorLine.Height()>=botRow || cursorLine.iBr.iY>=botRow
788 || (cursorLine.iTl.iY+pixels>=0 && cursorLine.iBr.iY+pixels<=botRow),FormPanic(EFCursorOffDisplay));
792 TBool TCursorPosition::GetCursor(TTmCursorPlacement aPlacement,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const
795 TBool result = iLayout->GetCursor(iDocPos,aPlacement,line_rect,aOrigin,aWidth,aAscent,aDescent);