A class representing a text. More...
#include <qwt_text.h>
Classes | |
| class | LayoutCache |
| class | PrivateData |
Public Types | |
| enum | LayoutAttribute { MinimumLayout = 0x01 } |
| Layout Attributes The layout attributes affects some aspects of the layout of the text. More... | |
| typedef QFlags< LayoutAttribute > | LayoutAttributes |
| Layout attributes. More... | |
| enum | PaintAttribute { PaintUsingTextFont = 0x01, PaintUsingTextColor = 0x02, PaintBackground = 0x04 } |
| Paint Attributes. More... | |
| typedef QFlags< PaintAttribute > | PaintAttributes |
| Paint attributes. More... | |
| enum | TextFormat { AutoText = 0, PlainText, RichText, MathMLText, TeXText, OtherFormat = 100 } |
| Text format. More... | |
Public Member Functions | |
| QBrush | backgroundBrush () const |
| QPen | borderPen () const |
| double | borderRadius () const |
| QColor | color () const |
| Return the pen color, used for painting the text. More... | |
| void | draw (QPainter *painter, const QRectF &rect) const |
| QFont | font () const |
| Return the font. More... | |
| double | heightForWidth (double width) const |
| double | heightForWidth (double width, const QFont &) const |
| bool | isEmpty () const |
| bool | isNull () const |
| bool | operator!= (const QwtText &) const |
| Relational operator. More... | |
| QwtText & | operator= (const QwtText &) |
| Assignment operator. More... | |
| bool | operator== (const QwtText &) const |
| Relational operator. More... | |
| QwtText () | |
| QwtText (const QString &, TextFormat textFormat=AutoText) | |
| QwtText (const QwtText &) | |
| Copy constructor. More... | |
| int | renderFlags () const |
| void | setBackgroundBrush (const QBrush &) |
| void | setBorderPen (const QPen &) |
| void | setBorderRadius (double) |
| void | setColor (const QColor &) |
| void | setFont (const QFont &) |
| void | setLayoutAttribute (LayoutAttribute, bool on=true) |
| void | setPaintAttribute (PaintAttribute, bool on=true) |
| void | setRenderFlags (int) |
| Change the render flags. More... | |
| void | setText (const QString &, QwtText::TextFormat textFormat=AutoText) |
| bool | testLayoutAttribute (LayoutAttribute) const |
| bool | testPaintAttribute (PaintAttribute) const |
| QString | text () const |
| QSizeF | textSize () const |
| QSizeF | textSize (const QFont &) const |
| QColor | usedColor (const QColor &) const |
| QFont | usedFont (const QFont &) const |
| ~QwtText () | |
| Destructor. More... | |
Static Public Member Functions | |
| static void | setTextEngine (QwtText::TextFormat, QwtTextEngine *) |
| static const QwtTextEngine * | textEngine (const QString &text, QwtText::TextFormat=AutoText) |
| static const QwtTextEngine * | textEngine (QwtText::TextFormat) |
| Find the text engine for a text format. More... | |
Private Attributes | |
| PrivateData * | d_data |
| LayoutCache * | d_layoutCache |
A class representing a text.
A QwtText is a text including a set of attributes how to render it.
Definition at line 51 of file qwt_text.h.
| typedef QFlags<LayoutAttribute> QwtText::LayoutAttributes |
Layout attributes.
Definition at line 145 of file qwt_text.h.
| typedef QFlags<PaintAttribute> QwtText::PaintAttributes |
Paint attributes.
Definition at line 127 of file qwt_text.h.
Layout Attributes The layout attributes affects some aspects of the layout of the text.
| Enumerator | |
|---|---|
| MinimumLayout |
Layout the text without its margins. This mode is useful if a text needs to be aligned accurately, like the tick labels of a scale. If QwtTextEngine::textMargins is not implemented for the format of the text, MinimumLayout has no effect. |
Definition at line 133 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.
| Enumerator | |
|---|---|
| PaintUsingTextFont |
The text has an individual font. |
| PaintUsingTextColor |
The text has an individual color. |
| PaintBackground |
The text has an individual background. |
Definition at line 114 of file qwt_text.h.
| enum QwtText::TextFormat |
Text format.
The text format defines the QwtTextEngine, that is used to render the text.
| Enumerator | |
|---|---|
| AutoText |
The text format is determined using QwtTextEngine::mightRender() for all available text engines in increasing order > PlainText. If none of the text engines can render the text is rendered like QwtText::PlainText. |
| PlainText |
Draw the text as it is, using a QwtPlainTextEngine. |
| RichText |
Use the Scribe framework (Qt Rich Text) to render the text. |
| MathMLText |
Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine to display the text. In earlier versions of Qwt such an engine was included - since Qwt 6.2 it can be found here: https://github.com/uwerat/qwt-mml-dev To enable MathML support the following code needs to be added to the application: |
| TeXText |
Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine to display the text ( not implemented yet ). |
| OtherFormat |
The number of text formats can be extended using setTextEngine. Formats >= QwtText::OtherFormat are not used by Qwt. |
Definition at line 64 of file qwt_text.h.
| QwtText::QwtText | ( | ) |
Constructor
Definition at line 178 of file qwt_text.cpp.
| QwtText::QwtText | ( | const QString & | text, |
| QwtText::TextFormat | textFormat = AutoText |
||
| ) |
Constructor
| text | Text content |
| textFormat | Text format |
Definition at line 192 of file qwt_text.cpp.
| QwtText::QwtText | ( | const QwtText & | other | ) |
Copy constructor.
Definition at line 202 of file qwt_text.cpp.
| QwtText::~QwtText | ( | ) |
Destructor.
Definition at line 212 of file qwt_text.cpp.
| QBrush QwtText::backgroundBrush | ( | ) | const |
Definition at line 428 of file qwt_text.cpp.
| QPen QwtText::borderPen | ( | ) | const |
Definition at line 407 of file qwt_text.cpp.
| double QwtText::borderRadius | ( | ) | const |
Definition at line 386 of file qwt_text.cpp.
| QColor QwtText::color | ( | ) | const |
Return the pen color, used for painting the text.
Definition at line 349 of file qwt_text.cpp.
| void QwtText::draw | ( | QPainter * | painter, |
| const QRectF & | rect | ||
| ) | const |
Draw a text into a rectangle
| painter | Painter |
| rect | Rectangle |
Definition at line 592 of file qwt_text.cpp.
| QFont QwtText::font | ( | ) | const |
Return the font.
Definition at line 313 of file qwt_text.cpp.
| double QwtText::heightForWidth | ( | double | width | ) | const |
Find the height for a given width
| width | Width |
Definition at line 499 of file qwt_text.cpp.
| double QwtText::heightForWidth | ( | double | width, |
| const QFont & | defaultFont | ||
| ) | 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 512 of file qwt_text.cpp.
| bool QwtText::isEmpty | ( | ) | const |
Definition at line 716 of file qwt_text.cpp.
| bool QwtText::isNull | ( | ) | const |
Definition at line 710 of file qwt_text.cpp.
Relational operator.
Definition at line 241 of file qwt_text.cpp.
Assignment operator.
Definition at line 219 of file qwt_text.cpp.
Relational operator.
Definition at line 227 of file qwt_text.cpp.
| int QwtText::renderFlags | ( | ) | const |
| void QwtText::setBackgroundBrush | ( | const QBrush & | brush | ) |
Set the background brush
| brush | Background brush |
Definition at line 418 of file qwt_text.cpp.
| void QwtText::setBorderPen | ( | const QPen & | pen | ) |
Set the background pen
| pen | Background pen |
Definition at line 397 of file qwt_text.cpp.
| void QwtText::setBorderRadius | ( | double | radius | ) |
Set the radius for the corners of the border frame
| radius | Radius of a rounded corner |
Definition at line 377 of file qwt_text.cpp.
| void QwtText::setColor | ( | const QColor & | color | ) |
Set the pen color used for drawing the text.
| color | Color |
Definition at line 342 of file qwt_text.cpp.
| void QwtText::setFont | ( | const QFont & | font | ) |
Set the font.
| font | Font |
Definition at line 306 of file qwt_text.cpp.
| void QwtText::setLayoutAttribute | ( | LayoutAttribute | attribute, |
| bool | on = true |
||
| ) |
Change a layout attribute
| attribute | Layout attribute |
| on | On/Off |
Definition at line 471 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 443 of file qwt_text.cpp.
| 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 281 of file qwt_text.cpp.
| void QwtText::setText | ( | const QString & | text, |
| QwtText::TextFormat | textFormat = AutoText |
||
| ) |
Assign a new text content
| text | Text content |
| textFormat | Text format |
Definition at line 254 of file qwt_text.cpp.
|
static |
Assign/Replace a text engine for a text format
With setTextEngine it is possible to extend Qwt with other types of text formats.
For QwtText::PlainText it is not allowed to assign a engine == NULL.
| format | Text format |
| engine | Text engine |
Definition at line 690 of file qwt_text.cpp.
| bool QwtText::testLayoutAttribute | ( | LayoutAttribute | attribute | ) | const |
Test a layout attribute
| attribute | Layout attribute |
Definition at line 487 of file qwt_text.cpp.
| bool QwtText::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Test a paint attribute
| attribute | Paint attribute |
Definition at line 459 of file qwt_text.cpp.
| QString QwtText::text | ( | ) | const |
|
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 returned.
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 671 of file qwt_text.cpp.
|
static |
Find the text engine for a text format.
textEngine can be used to find out if a text format is supported.
| format | Text format |
Definition at line 704 of file qwt_text.cpp.
| QSizeF QwtText::textSize | ( | ) | const |
Returns the size, that is needed to render text
Definition at line 547 of file qwt_text.cpp.
| QSizeF QwtText::textSize | ( | const QFont & | defaultFont | ) | const |
Returns the size, that is needed to render text
| defaultFont | Font of the text |
Definition at line 558 of file qwt_text.cpp.
| 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 363 of file qwt_text.cpp.
| 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 327 of file qwt_text.cpp.
|
private |
Definition at line 208 of file qwt_text.h.
|
private |
Definition at line 211 of file qwt_text.h.