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, etc. More...
#include <kwordwrap.h>
Public Methods | |
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 |
Draw the text that has been previously wrapped, at position x,y. | |
Static Public Methods | |
KWordWrap * | formatText (QFontMetrics &fm, const QRect &r, int flags, const QString &str, int len=-1) |
Main method for wrapping text. |
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, etc.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.
Definition at line 40 of file kwordwrap.h.
Member Function Documentation
|
Main method for wrapping text.
Definition at line 22 of file kwordwrap.cpp. 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(). |
|
Definition at line 58 of file kwordwrap.h. |
|
Definition at line 94 of file kwordwrap.cpp. References QValueList< int >::begin(), KStdAccel::end(), QValueList< int >::end(), and QString::mid(). |
|
Definition at line 110 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. AlignHCenter. Default is AlignAuto. Definition at line 125 of file kwordwrap.cpp. References QFontMetrics::ascent(), QValueList< int >::begin(), QPainter::drawText(), KStdAccel::end(), QValueList< int >::end(), QPainter::fontMetrics(), QFontMetrics::height(), QString::mid(), and QRect::width(). |
The documentation for this class was generated from the following files: