KWordWrap Class Reference
Word-wrap algorithm that takes into account beautifulness ;) That means:- not letting a letter alone on the last line,
- breaking at punctuation signs (not only at spaces)
- improved handling of (), [] and {}
- improved handling of '/' (e.g.
#include <kwordwrap.h>
Public Types | |
enum | { FadeOut = 0x10000000 } |
Public Member Functions | |
QRect | boundingRect () const |
QString | wrappedString () const |
QString | truncatedString (bool dots=true) const |
void | drawText (QPainter *painter, int x, int y, int flags=Qt::AlignAuto) const |
~KWordWrap () | |
Static Public Member Functions | |
KWordWrap * | formatText (QFontMetrics &fm, const QRect &r, int flags, const QString &str, int len=-1) |
void | drawFadeoutText (QPainter *p, int x, int y, int maxW, const QString &t) |
Detailed Description
Word-wrap algorithm that takes into account beautifulness ;) That means:- not letting a letter alone on the last line,
- breaking at punctuation signs (not only at spaces)
- improved handling of (), [] and {}
- improved handling of '/' (e.g.
for paths)
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.
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.
- Author:
- David Faure <faure@kde.org>
Definition at line 44 of file kwordwrap.h.
Member Enumeration Documentation
|
Use this flag in drawText() if you want to fade out the text if it does not fit into the constraining rectangle.
Definition at line 52 of file kwordwrap.h. |
Constructor & Destructor Documentation
|
Destructor.
Definition at line 123 of file kwordwrap.cpp. |
Member Function Documentation
|
Main method for wrapping text.
Definition at line 33 of file kwordwrap.cpp. References QValueList< int >::append(), QFontMetrics::charWidth(), QFontMetrics::height(), QString::left(), QString::length(), m_boundingRect, m_breakPositions, m_lineWidths, m_text, QRect::setRect(), and QRect::width(). |
|
Definition at line 73 of file kwordwrap.h. |
|
Definition at line 127 of file kwordwrap.cpp. References QValueList< int >::begin(), QValueList< int >::end(), and QString::mid(). |
|
Definition at line 143 of file kwordwrap.cpp. References QValueList< int >::begin(), QValueList< int >::end(), and QString::left(). |
|
Draw the text that has been previously wrapped, at position x,y. Flags are for alignment, e.g. Qt::AlignHCenter. Default is Qt::AlignAuto.
Definition at line 196 of file kwordwrap.cpp. References QFontMetrics::ascent(), QValueList< int >::begin(), drawFadeoutText(), QPainter::drawText(), QValueList< int >::end(), QPainter::fontMetrics(), QFontMetrics::height(), QString::mid(), and QRect::width(). |
|
Draws the string
Definition at line 164 of file kwordwrap.cpp. References QString::at(), QPainter::backgroundColor(), QFontMetrics::boundingRect(), QFontMetrics::charWidth(), QPainter::drawText(), QPainter::fontMetrics(), QString::left(), QString::length(), QPainter::pen(), QPainter::setPen(), and QFontMetrics::width(). Referenced by drawText(). |
The documentation for this class was generated from the following files: