How to use wrapping

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().

    // 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
// New wrap width = new view rect width minus total margin width
iLayout->DisableWrapOverride(EFalse); // Ensure wrapping on