Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


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.

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.

// 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();