Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: gulutil.h
Link against: egul.lib

Class TextUtils

TextUtils

Support

Supported from 6.0

Description

Provides utility functions for truncating and aligning text strings.

Defined in TextUtils:
ClipToFit(), ColumnText(), TruncateToNumChars()


Member functions


ClipToFit()

static void ClipToFit(TDes& aBuffer,const CFont& aFont,TInt aMaxWidthInPixels,TChar aAlternativeEnd=KTextUtilClipEndChar);

Description

Clips the text to fit a maximum width.

If the text is too wide to fit in the width when displayed in aFont, the function truncates the text to fit and then appends the specified character (by default, a horizontal ellipsis).

Parameters

TDes& aBuffer

A buffer containing the text to clip.

const CFont& aFont

The font.

const TInt aMaxWidthInPixels

The maximum width in pixels.

const TChar aAlternativeEnd=KTextUtilClipEndChar

The Unicode character to append to the buffer if truncated. By default, this is the horizontal ellipsis.


ColumnText()

static TInt ColumnText(TPtrC& aColumnText,TInt aColumn,const TDesC* aSourceText,TChar aColumnSeparator=KColumnListSeparator);

Description

Gets a portion of text from a descriptor corresponding to the requested column.

Parameters

TPtrC& aColumnText

On return, set to the portion of aSourceText that corresponds to the column aColumn.

TInt aColumn

The column to extract. The first column is numbered zero.

const TDesC* aSourceText

The source text string that contains one or more column separator characters.

const TChar aColumnSeparator=KColumnListSeparator

The character used in aSourceText to separate the columns. By default, a tab character.

Return value

TInt

KErrNotFound if the column number is invalid, otherwise KErrNone.


TruncateToNumChars()

static void TruncateToNumChars(TDes& aBuffer, TInt numChars);

Description

Truncates text to a number of characters. If truncation is required (aBuffer contains more than numChars characters), an ellipsis is added to a buffer as the last character.

Parameters

TDes& aBuffer

On return, contains the truncated text.

TInt numChars

The number of characters.