After any operation which resizes the text area, the wrapping width may need to be changed. The code in this section resets the view rectangle, and then resets the wrapping width accordingly.
Resize the view rectangle (an instance of class TRect
) by shrinking it by forty pixels in both directions.
Reset the view rectangle using CTextView::SetViewRect()
.
iViewRect.Shrink(40,40); iTextView->SetViewRect(iViewRect); iTextView->HandleGlobalChangeL(); // update formatting and draw the completely revamped view
The following code sets the wrapping width to be the width of the new view rectangle minus the total margin width, so that text wraps at the right hand edge of the view rectangle.
To ensure that text wrapping is set, use CTextLayout::DisableWrapOverride(EFalse)
. By default, wrapping is set.
As the wrapping width is a global document characteristic, changes to it may be handled using CTextView::HandleGlobalChangeL()
.
// Wrap text to new view rectangle TInt labelsWidth,lineCursorWidth; // Get both margin widths iTextView->MarginWidths(labelsWidth,lineCursorWidth); // New wrap width = new view rect width minus total margin width iLayout->SetWrapWidth(iViewRect.Width()-(labelsWidth+lineCursorWidth)); iLayout->DisableWrapOverride(EFalse); // Ensure wrapping on iTextView->HandleGlobalChangeL();