.TH "KWordWrap" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdeui Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KWordWrap \- Word-wrap algorithm that takes into account beautifulness ;).  

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

.in +1c
.ti -1c
.RI "enum { \fBFadeOut\fP =  0x10000000, \fBTruncate\fP =  0x20000000 }"
.br
.in -1c
.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
.ti -1c
.RI "\fB~KWordWrap\fP ()"
.br
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "static \fBKWordWrap\fP * \fBformatText\fP (\fBQFontMetrics\fP &fm, const \fBQRect\fP &r, int flags, const \fBQString\fP &str, int len=-1)"
.br
.ti -1c
.RI "static void \fBdrawFadeoutText\fP (\fBQPainter\fP *p, int x, int y, int maxW, const \fBQString\fP &t)"
.br
.ti -1c
.RI "static void \fBdrawTruncateText\fP (\fBQPainter\fP *p, int x, int y, int maxW, const \fBQString\fP &t)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Word-wrap algorithm that takes into account beautifulness ;). 

That means: 
.PD 0

.IP "\(bu" 2
not letting a letter alone on the last line, 
.IP "\(bu" 2
breaking at punctuation signs (not only at spaces) 
.IP "\(bu" 2
improved handling of (), [] and {} 
.IP "\(bu" 2
improved handling of '/' (e.g. for paths)
.PP
Usage: call the static method, formatText, 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
\fBAuthor:\fP
.RS 4
David Faure <faure@kde.org> 
.RE
.PP

.PP
Definition at line 48 of file kwordwrap.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "anonymous enum"
.PP
Use this flag in \fBdrawText()\fP if you want to fade out the text if it does not fit into the constraining rectangle. 
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP

.PP
Definition at line 56 of file kwordwrap.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KWordWrap::~\fBKWordWrap\fP ()"
.PP
Destructor. 
.PP
Definition at line 144 of file kwordwrap.cpp.
.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 = \fC-1\fP)\fC [static]\fP"
.PP
Main method for wrapping text. 
.PP
\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. With negative height the complete text will be rendered 
.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

.PP
Definition at line 34 of file kwordwrap.cpp.
.PP
References QValueList::append(), QChar::isPunct(), QChar::isSpace(), QChar::isSymbol(), QString::left(), QString::length(), m_boundingRect, m_breakPositions, m_lineWidths, m_text, QString::remove(), and QRect::setRect().
.SS "\fBQRect\fP KWordWrap::boundingRect () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
the bounding rect, calculated by formatText. The width is the width of the widest text line, and never wider than the rectangle given to formatText. The height is the text block. X and Y are always 0. 
.RE
.PP

.PP
Definition at line 77 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

.PP
Definition at line 148 of file kwordwrap.cpp.
.PP
References QValueList::begin(), QValueList::end(), and QString::mid().
.SS "\fBQString\fP KWordWrap::truncatedString (bool dots = \fCtrue\fP) 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

.PP
Definition at line 164 of file kwordwrap.cpp.
.PP
References QValueList::first(), QValueList::isEmpty(), and QString::left().
.SS "void KWordWrap::drawText (\fBQPainter\fP * painter, int x, int y, int flags = \fCQt::AlignAuto\fP) const"
.PP
Draw the text that has been previously wrapped, at position x,y. 
.PP
Flags are for alignment, e.g. Qt::AlignHCenter. Default is Qt::AlignAuto. 
.PP
\fBParameters:\fP
.RS 4
\fIpainter\fP the \fBQPainter\fP to use. 
.br
\fIx\fP the horizontal position of the text 
.br
\fIy\fP the vertical position of the text 
.br
\fIflags\fP the ORed text alignment flags from the \fBQt\fP namespace, ORed with FadeOut if you want the text to fade out if it does not fit (the \fCpainter's\fP background must be set accordingly) 
.RE
.PP

.PP
Definition at line 219 of file kwordwrap.cpp.
.PP
References QFontMetrics::ascent(), QValueList::begin(), drawFadeoutText(), drawTruncateText(), QValueList::end(), QFontMetrics::height(), QString::mid(), and QRect::width().
.SS "void KWordWrap::drawFadeoutText (\fBQPainter\fP * p, int x, int y, int maxW, const \fBQString\fP & t)\fC [static]\fP"
.PP
Draws the string \fCt\fP at the given coordinates, if it does not \fCfit\fP into \fCmaxW\fP the text will be faded out. 
.PP
\fBParameters:\fP
.RS 4
\fIp\fP the painter to use. Must have set the pen for the text color and the background for the color to fade out 
.br
\fIx\fP the horizontal position of the text 
.br
\fIy\fP the vertical position of the text 
.br
\fImaxW\fP the maximum width of the text (including the fade-out effect) 
.br
\fIt\fP the text to draw 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP

.PP
Definition at line 181 of file kwordwrap.cpp.
.PP
References QFontMetrics::boundingRect(), QFontMetrics::charWidth(), and QFontMetrics::width().
.PP
Referenced by drawText().
.SS "void KWordWrap::drawTruncateText (\fBQPainter\fP * p, int x, int y, int maxW, const \fBQString\fP & t)\fC [static]\fP"
.PP
Draws the string \fCt\fP at the given coordinates, if it does not \fCfit\fP into \fCmaxW\fP the text will be truncated. 
.PP
\fBParameters:\fP
.RS 4
\fIp\fP the painter to use 
.br
\fIx\fP the horizontal position of the text 
.br
\fIy\fP the vertical position of the text 
.br
\fImaxW\fP the maximum width of the text (including the '...') 
.br
\fIt\fP the text to draw 
.RE
.PP
\fBSince:\fP
.RS 4
3.3 
.RE
.PP

.PP
Definition at line 213 of file kwordwrap.cpp.
.PP
References KStringHandler::rPixelSqueeze().
.PP
Referenced by drawText().

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