1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2003 Uwe Rathmann
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the Qwt License, Version 1.0
8
*****************************************************************************/
18
#include "qwt_global.h"
28
\brief A class representing a text
30
A QwtText is a text including a set of attributes how to render it.
33
A text might include control sequences (f.e tags) describing
34
how to render it. Each format (f.e MathML, TeX, Qt Rich Text)
35
has its own set of control sequences, that can be handles by
36
a QwtTextEngine for this format.
38
A text might have a background, defined by a QPen and QBrush
39
to improve its visibility.
41
A text might have an individual font.
43
A text might have an individual color.
45
Flags from Qt::AlignmentFlag and Qt::TextFlag used like in
48
\sa QwtTextEngine, QwtTextLabel
51
class QWT_EXPORT QwtText
58
The text format defines the QwtTextEngine, that is used to render
62
The text format is determined using QwtTextEngine::mightRender for
63
all available text engines in increasing order > PlainText.
64
If none of the text engines can render the text is rendered
67
Draw the text as it is, using a QwtPlainTextEngine.
69
Use the Scribe framework (Qt Rich Text) to render the text.
71
Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine
72
to display the text. The Qwt MathML extension offers such an engine
73
based on the MathML renderer of the Qt solutions package. Unfortunately
74
it is only available for owners of a commercial Qt license.
76
Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine
79
The number of text formats can be extended using setTextEngine.
80
Formats >= OtherFormat are not used by Qwt.
82
\sa QwtTextEngine, setTextEngine
99
\brief Paint Attributes
101
Font and color and background are optional attributes of a QwtText.
102
The paint attributes hold the information, if they are set.
104
- PaintUsingTextFont\n
105
The text has an individual font.
106
- PaintUsingTextColor\n
107
The text has an individual color.
109
The text has an individual background.
113
PaintUsingTextFont = 1,
114
PaintUsingTextColor = 2,
119
\brief Layout Attributes
121
The layout attributes affects some aspects of the layout of the text.
124
Layout the text without its margins. This mode is useful if a
125
text needs to be aligned accurately, like the tick labels of a scale.
126
If QwtTextEngine::textMargins is not implemented for the format
127
of the text, MinimumLayout has no effect.
134
QwtText(const QString & = QString::null,
135
TextFormat textFormat = AutoText);
136
QwtText(const QwtText &);
139
QwtText &operator=(const QwtText &);
141
int operator==(const QwtText &) const;
142
int operator!=(const QwtText &) const;
144
void setText(const QString &,
145
QwtText::TextFormat textFormat = AutoText);
146
QString text() const;
148
//! \return text().isNull()
149
inline bool isNull() const { return text().isNull(); }
151
//! \return text().isEmpty()
152
inline bool isEmpty() const { return text().isEmpty(); }
154
void setFont(const QFont &);
157
QFont usedFont(const QFont &) const;
159
void setRenderFlags(int flags);
160
int renderFlags() const;
162
void setColor(const QColor &);
163
QColor color() const;
165
QColor usedColor(const QColor &) const;
167
void setBackgroundPen(const QPen &);
168
QPen backgroundPen() const;
170
void setBackgroundBrush(const QBrush &);
171
QBrush backgroundBrush() const;
173
void setPaintAttribute(PaintAttribute, bool on = true);
174
bool testPaintAttribute(PaintAttribute) const;
176
void setLayoutAttribute(LayoutAttribute, bool on = true);
177
bool testLayoutAttribute(LayoutAttribute) const;
179
int heightForWidth(int width, const QFont & = QFont()) const;
180
QSize textSize(const QFont & = QFont()) const;
182
void draw(QPainter *painter, const QRect &rect) const;
184
static const QwtTextEngine *textEngine(const QString &text,
185
QwtText::TextFormat = AutoText);
187
static const QwtTextEngine *textEngine(QwtText::TextFormat);
188
static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
195
LayoutCache *d_layoutCache;