A QwtText is a text including a set of attributes how to render it.
Definition at line 51 of file qwt_text.h.
Public Types | |
enum | TextFormat { AutoText = 0, PlainText, RichText, MathMLText, TeXText, OtherFormat = 100 } |
enum | PaintAttribute { PaintUsingTextFont = 1, PaintUsingTextColor = 2, PaintBackground = 4 } |
enum | LayoutAttribute { MinimumLayout = 1 } |
Public Member Functions | |
QwtText (const QString &=QString::null, TextFormat textFormat=AutoText) | |
QwtText (const QwtText &) | |
~QwtText () | |
QwtText & | operator= (const QwtText &) |
int | operator== (const QwtText &) const |
int | operator!= (const QwtText &) const |
void | setText (const QString &, QwtText::TextFormat textFormat=AutoText) |
QString | text () const |
bool | isNull () const |
bool | isEmpty () const |
void | setFont (const QFont &) |
QFont | font () const |
QFont | usedFont (const QFont &) const |
void | setRenderFlags (int flags) |
int | renderFlags () const |
void | setColor (const QColor &) |
QColor | color () const |
QColor | usedColor (const QColor &) const |
void | setBackgroundPen (const QPen &) |
QPen | backgroundPen () const |
void | setBackgroundBrush (const QBrush &) |
QBrush | backgroundBrush () const |
void | setPaintAttribute (PaintAttribute, bool on=true) |
bool | testPaintAttribute (PaintAttribute) const |
void | setLayoutAttribute (LayoutAttribute, bool on=true) |
bool | testLayoutAttribute (LayoutAttribute) const |
int | heightForWidth (int width, const QFont &=QFont()) const |
QSize | textSize (const QFont &=QFont()) const |
void | draw (QPainter *painter, const QRect &rect) const |
Static Public Member Functions | |
static const QwtTextEngine * | textEngine (const QString &text, QwtText::TextFormat=AutoText) |
static const QwtTextEngine * | textEngine (QwtText::TextFormat) |
static void | setTextEngine (QwtText::TextFormat, QwtTextEngine *) |
enum QwtText::TextFormat |
Text format.
The text format defines the QwtTextEngine, that is used to render the text.
Definition at line 85 of file qwt_text.h.
Paint Attributes.
Font and color and background are optional attributes of a QwtText. The paint attributes hold the information, if they are set.
Definition at line 111 of file qwt_text.h.
Layout Attributes.
The layout attributes affects some aspects of the layout of the text.
Definition at line 129 of file qwt_text.h.
QwtText::QwtText | ( | const QString & | text = QString::null , |
|
QwtText::TextFormat | textFormat = AutoText | |||
) |
Constructor
text | Text content | |
textFormat | Text format |
Definition at line 180 of file qwt_text.cpp.
References textEngine().
QwtText::QwtText | ( | const QwtText & | ) |
Copy constructor.
Definition at line 190 of file qwt_text.cpp.
References d_data, and d_layoutCache.
QwtText::~QwtText | ( | ) |
Assignement operator.
Definition at line 207 of file qwt_text.cpp.
References d_data, and d_layoutCache.
void QwtText::setText | ( | const QString & | text, | |
QwtText::TextFormat | textFormat = AutoText | |||
) |
Assign a new text content
text | Text content | |
textFormat | Text format |
Definition at line 237 of file qwt_text.cpp.
References textEngine().
QString QwtText::text | ( | ) | const |
Return the text.
Definition at line 249 of file qwt_text.cpp.
Referenced by QwtPlot::grabProperties().
bool QwtText::isNull | ( | ) | const [inline] |
bool QwtText::isEmpty | ( | ) | const [inline] |
Definition at line 152 of file qwt_text.h.
Referenced by QwtScaleDraw::drawLabel(), QwtRoundScaleDraw::drawLabel(), QwtRoundScaleDraw::extent(), QwtScaleDraw::labelRect(), and QwtPicker::trackerRect().
void QwtText::setFont | ( | const QFont & | font | ) |
Set the font.
font | Font |
Definition at line 289 of file qwt_text.cpp.
References PaintUsingTextFont, and setPaintAttribute().
Referenced by QwtPlotPrintFilter::apply().
QFont QwtText::font | ( | ) | const |
Return the font.
Definition at line 296 of file qwt_text.cpp.
Referenced by QwtPlotPrintFilter::apply(), draw(), heightForWidth(), and textSize().
QFont QwtText::usedFont | ( | const QFont & | defaultFont | ) | const |
Return the font of the text, if it has one. Otherwise return defaultFont.
defaultFont | Default font |
Definition at line 308 of file qwt_text.cpp.
References PaintUsingTextFont.
Referenced by heightForWidth(), and textSize().
void QwtText::setRenderFlags | ( | int | renderFlags | ) |
Change the render flags.
The default setting is Qt::AlignCenter
renderFlags | Bitwise OR of the flags used like in QPainter::drawText |
Definition at line 264 of file qwt_text.cpp.
Referenced by QwtScaleWidget::drawTitle(), QwtLegendItem::setText(), QwtScaleWidget::setTitle(), and QwtAbstractScaleDraw::tickLabel().
int QwtText::renderFlags | ( | ) | const |
Definition at line 277 of file qwt_text.cpp.
Referenced by QwtScaleWidget::setTitle().
void QwtText::setColor | ( | const QColor & | color | ) |
Set the pen color used for painting the text.
color | Color |
Definition at line 323 of file qwt_text.cpp.
References PaintUsingTextColor, and setPaintAttribute().
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
QColor QwtText::color | ( | ) | const |
Return the pen color, used for painting the text.
Definition at line 330 of file qwt_text.cpp.
Referenced by QwtPlotPrintFilter::apply().
QColor QwtText::usedColor | ( | const QColor & | defaultColor | ) | const |
Return the color of the text, if it has one. Otherwise return defaultColor.
defaultColor | Default color |
Definition at line 342 of file qwt_text.cpp.
References PaintUsingTextColor.
void QwtText::setBackgroundPen | ( | const QPen & | pen | ) |
Set the background pen
pen | Background pen |
Definition at line 356 of file qwt_text.cpp.
References PaintBackground, and setPaintAttribute().
QPen QwtText::backgroundPen | ( | ) | const |
Definition at line 366 of file qwt_text.cpp.
void QwtText::setBackgroundBrush | ( | const QBrush & | brush | ) |
Set the background brush
brush | Background brush |
Definition at line 377 of file qwt_text.cpp.
References PaintBackground, and setPaintAttribute().
QBrush QwtText::backgroundBrush | ( | ) | const |
Definition at line 387 of file qwt_text.cpp.
void QwtText::setPaintAttribute | ( | PaintAttribute | attribute, | |
bool | on = true | |||
) |
Change a paint attribute
attribute | Paint attribute | |
on | On/Off |
Definition at line 401 of file qwt_text.cpp.
Referenced by setBackgroundBrush(), setBackgroundPen(), setColor(), and setFont().
bool QwtText::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Test a paint attribute
attribute | Paint attribute |
Definition at line 417 of file qwt_text.cpp.
Referenced by QwtPlotPrintFilter::apply().
void QwtText::setLayoutAttribute | ( | LayoutAttribute | attribute, | |
bool | on = true | |||
) |
Change a layout attribute
attribute | Layout attribute | |
on | On/Off |
Definition at line 429 of file qwt_text.cpp.
bool QwtText::testLayoutAttribute | ( | LayoutAttribute | attribute | ) | const |
Test a layout attribute
attribute | Layout attribute |
Definition at line 445 of file qwt_text.cpp.
int QwtText::heightForWidth | ( | int | width, | |
const QFont & | defaultFont = QFont() | |||
) | const |
Find the height for a given width
defaultFont | Font, used for the calculation if the text has no font | |
width | Width |
Definition at line 458 of file qwt_text.cpp.
References font(), QwtMetricsMap::layoutToScreenX(), QwtPainter::metricsMap(), MinimumLayout, QwtMetricsMap::screenToLayoutY(), and usedFont().
QSize QwtText::textSize | ( | const QFont & | defaultFont = QFont() |
) | const |
Returns the size, that is needed to render text
defaultFont | Font of the text |
Definition at line 510 of file qwt_text.cpp.
References font(), QwtMetricsMap::isIdentity(), QwtPainter::metricsMap(), MinimumLayout, QwtMetricsMap::screenToLayout(), and usedFont().
Referenced by QwtScaleDraw::drawLabel(), QwtRoundScaleDraw::drawLabel(), QwtRoundScaleDraw::extent(), QwtScaleDraw::labelRect(), and QwtPicker::trackerRect().
void QwtText::draw | ( | QPainter * | painter, | |
const QRect & | rect | |||
) | const |
Draw a text into a rectangle
painter | Painter | |
rect | Rectangle |
Definition at line 565 of file qwt_text.cpp.
References QwtPainter::drawRect(), font(), QwtPainter::metricsMap(), MinimumLayout, PaintBackground, PaintUsingTextColor, PaintUsingTextFont, QwtMetricsMap::screenToLayoutX(), and QwtMetricsMap::screenToLayoutY().
Referenced by QwtLegendItem::drawItem(), QwtScaleDraw::drawLabel(), QwtRoundScaleDraw::drawLabel(), QwtScaleWidget::drawTitle(), and QwtPlot::printTitle().
const QwtTextEngine * QwtText::textEngine | ( | const QString & | text, | |
QwtText::TextFormat | format = AutoText | |||
) | [static] |
Find the text engine for a text format
In case of QwtText::AutoText the first text engine (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender returns true. If there is none QwtPlainTextEngine is returnd.
If no text engine is registered for the format QwtPlainTextEngine is returnd.
text | Text, needed in case of AutoText | |
format | Text format |
Definition at line 641 of file qwt_text.cpp.
const QwtTextEngine * QwtText::textEngine | ( | QwtText::TextFormat | format | ) | [static] |
Find the text engine for a text format.
textEngine can be used to find out if a text format is supported. F.e, if one wants to use MathML labels, the MathML renderer from the commercial Qt solutions package might be required, that is not available in Qt Open Source Edition environments.
format | Text format |
Definition at line 688 of file qwt_text.cpp.
void QwtText::setTextEngine | ( | QwtText::TextFormat | format, | |
QwtTextEngine * | engine | |||
) | [static] |
Assign/Replace a text engine for a text format
With setTextEngine it is possible to extend Qwt with other types of text formats.
Owner of a commercial Qt license can build the qwtmathml library, that is based on the MathML renderer, that is included in MML Widget component of the Qt solutions package.
For QwtText::PlainText it is not allowed to assign a engine == NULL.
format | Text format | |
engine | Text engine |
Definition at line 668 of file qwt_text.cpp.