A text engine for plain texts. More...
#include <qwt_text_engine.h>


Classes | |
| class | PrivateData |
Public Member Functions | |
| QwtPlainTextEngine () | |
| Constructor. | |
| virtual | ~QwtPlainTextEngine () |
| Destructor. | |
| virtual int | heightForWidth (const QFont &font, int flags, const QString &text, int width) const |
| virtual QSize | textSize (const QFont &font, int flags, const QString &text) const |
| virtual void | draw (QPainter *painter, const QRect &rect, int flags, const QString &text) const |
| Draw the text in a clipping rectangle. | |
| virtual bool | mightRender (const QString &) const |
| virtual void | textMargins (const QFont &, const QString &, int &left, int &right, int &top, int &bottom) const |
A text engine for plain texts.
QwtPlainTextEngine renders texts using the basic Qt classes QPainter and QFontMetrics.
Definition at line 116 of file qwt_text_engine.h.
| QwtPlainTextEngine::QwtPlainTextEngine | ( | ) |
| QwtPlainTextEngine::~QwtPlainTextEngine | ( | ) | [virtual] |
| void QwtPlainTextEngine::draw | ( | QPainter * | painter, |
| const QRect & | rect, | ||
| int | flags, | ||
| const QString & | text | ||
| ) | const [virtual] |
Draw the text in a clipping rectangle.
A wrapper for QPainter::drawText.
| painter | Painter |
| rect | Clipping rectangle |
| flags | Bitwise OR of the flags used like in QPainter::drawText |
| text | Text to be rendered |
Implements QwtTextEngine.
Definition at line 259 of file qwt_text_engine.cpp.
References QwtPainter::drawText().
{
QwtPainter::drawText(painter, rect, flags, text);
}
| int QwtPlainTextEngine::heightForWidth | ( | const QFont & | font, |
| int | flags, | ||
| const QString & | text, | ||
| int | width | ||
| ) | const [virtual] |
Find the height for a given width
| font | Font of the text |
| flags | Bitwise OR of the flags used like in QPainter::drawText |
| text | Text to be rendered |
| width | Width |
Implements QwtTextEngine.
Definition at line 201 of file qwt_text_engine.cpp.
{
const QFontMetrics fm(font);
const QRect rect = fm.boundingRect(
0, 0, width, QWIDGETSIZE_MAX, flags, text);
return rect.height();
}
| bool QwtPlainTextEngine::mightRender | ( | const QString & | ) | const [virtual] |
Test if a string can be rendered by this text engine.
Implements QwtTextEngine.
Definition at line 269 of file qwt_text_engine.cpp.
{
return true;
}
| void QwtPlainTextEngine::textMargins | ( | const QFont & | font, |
| const QString & | , | ||
| int & | left, | ||
| int & | right, | ||
| int & | top, | ||
| int & | bottom | ||
| ) | const [virtual] |
Return margins around the texts
| font | Font of the text |
| left | Return 0 |
| right | Return 0 |
| top | Return value for the top margin |
| bottom | Return value for the bottom margin |
Implements QwtTextEngine.
Definition at line 239 of file qwt_text_engine.cpp.
References QwtPlainTextEngine::PrivateData::effectiveAscent().
{
left = right = top = 0;
const QFontMetrics fm(font);
top = fm.ascent() - d_data->effectiveAscent(font);
bottom = fm.descent() + 1;
}
| QSize QwtPlainTextEngine::textSize | ( | const QFont & | font, |
| int | flags, | ||
| const QString & | text | ||
| ) | const [virtual] |
Returns the size, that is needed to render text
| font | Font of the text |
| flags | Bitwise OR of the flags used like in QPainter::drawText |
| text | Text to be rendered |
Implements QwtTextEngine.
Definition at line 220 of file qwt_text_engine.cpp.
{
const QFontMetrics fm(font);
const QRect rect = fm.boundingRect(
0, 0, QWIDGETSIZE_MAX, QWIDGETSIZE_MAX, flags, text);
return rect.size();
}
1.7.2