.TH "KWordWrap" 3 "28 Jan 2004" "kdeui Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KWordWrap \- Word-wrap algorithm that takes into account beautifulness ;) That means: not letting a letter alone on the last line, breaking at punctuation signs, etc.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kwordwrap.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBQRect\fP \fBboundingRect\fP () const "
.br
.ti -1c
.RI "\fBQString\fP \fBwrappedString\fP () const "
.br
.ti -1c
.RI "\fBQString\fP \fBtruncatedString\fP (bool dots=true) const "
.br
.ti -1c
.RI "void \fBdrawText\fP (\fBQPainter\fP *painter, int x, int y, int flags=Qt::AlignAuto) const "
.br
.RI "\fIDraw the text that has been previously wrapped, at position x,y. \fP"
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKWordWrap\fP * \fBformatText\fP (\fBQFontMetrics\fP &fm, const  \fBQRect\fP &r, int flags, const  \fBQString\fP &str, int len=-1)"
.br
.RI "\fIMain method for wrapping text. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Word-wrap algorithm that takes into account beautifulness ;) That means: not letting a letter alone on the last line, breaking at punctuation signs, etc. 

Usage: call the static method, \fBformatText\fP, with the text to wrap and the constraining rectangle etc., it will return an instance of KWordWrap containing internal data, result of the word-wrapping. From that instance you can retrieve the boundingRect, and invoke drawing.
.PP
This design allows to call the word-wrap algorithm only when the text changes and not every time we want to know the bounding rect or draw the text. 
.PP
Definition at line 40 of file kwordwrap.h.
.SH "Member Function Documentation"
.PP 
.SS "\fBKWordWrap\fP * KWordWrap::formatText (\fBQFontMetrics\fP & fm, const \fBQRect\fP & r, int flags, const \fBQString\fP & str, int len = -1)\fC [static]\fP"
.PP
Main method for wrapping text. \fBParameters:\fP
.RS 4
\fIfm\fP Font metrics, for the chosen font. Better cache it, creating a \fBQFontMetrics\fP is expensive. 
.br
\fIr\fP Constraining rectangle. Only the width and height matter. 
.br
\fIflags\fP - currently unused. 
.br
\fIstr\fP The text to be wrapped. 
.br
\fIlen\fP Length of text to wrap (default is -1 for all). 
.RE
.PP
\fBReturns:\fP
.RS 4
a KWordWrap instance. The caller is responsible for storing and deleting the result. 
.RE
.PP
Definition at line 22 of file kwordwrap.cpp.
.PP
References QValueList< int >::append(), QFontMetrics::charWidth(), QFontMetrics::height(), QChar::isPunct(), QChar::isSpace(), QChar::isSymbol(), QString::left(), QString::length(), m_boundingRect, m_breakPositions, m_lineWidths, m_text, QRect::setRect(), and QRect::width().
.SS "\fBQRect\fP KWordWrap::boundingRect () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
the bounding rect, calculated by formatText. 
.RE
.PP
Definition at line 58 of file kwordwrap.h.
.SS "\fBQString\fP KWordWrap::wrappedString () const"
.PP
\fBReturns:\fP
.RS 4
the original string, with '
.br
' inserted where the text is broken by the wordwrap algorithm. 
.RE
.PP
Definition at line 94 of file kwordwrap.cpp.
.PP
References QValueList< int >::begin(), KStdAccel::end(), QValueList< int >::end(), and QString::mid().
.SS "\fBQString\fP KWordWrap::truncatedString (bool dots = true) const"
.PP
\fBReturns:\fP
.RS 4
the original string, truncated to the first line. If \fCdots\fP was set, '...' is appended in case the string was truncated. Bug: Note that the '...' come out of the bounding rect. 
.RE
.PP
Definition at line 110 of file kwordwrap.cpp.
.PP
References QValueList< int >::begin(), QValueList< int >::end(), and QString::left().
.SS "void KWordWrap::drawText (\fBQPainter\fP * painter, int x, int y, int flags = Qt::AlignAuto) const"
.PP
Draw the text that has been previously wrapped, at position x,y. Flags are for alignment, e.g. AlignHCenter. Default is AlignAuto. Definition at line 125 of file kwordwrap.cpp.
.PP
References QFontMetrics::ascent(), QValueList< int >::begin(), QPainter::drawText(), KStdAccel::end(), QValueList< int >::end(), QPainter::fontMetrics(), QFontMetrics::height(), QString::mid(), and QRect::width().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdeui Library from the source code.
