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
*****************************************************************************/
12
#ifndef QWT_TEXT_ENGINE_H
13
#define QWT_TEXT_ENGINE_H 1
16
#include "qwt_global.h"
24
\brief Abstract base class for rendering text strings
26
A text engine is responsible for rendering texts for a
27
specific text format. They are used by QwtText to render a text.
29
QwtPlainTextEngine and QwtRichTextEngine are part of the Qwt library.
31
QwtMathMLTextEngine can be found in Qwt MathML extension, that
32
needs the MathML renderer of the Qt solutions package. Unfortunately
33
it is only available with a commercial Qt license.
35
\sa QwtText::setTextEngine
38
class QWT_EXPORT QwtTextEngine
41
virtual ~QwtTextEngine();
44
Find the height for a given width
46
\param font Font of the text
47
\param flags Bitwise OR of the flags used like in QPainter::drawText
48
\param text Text to be rendered
51
\return Calculated height
53
virtual int heightForWidth(const QFont &font, int flags,
54
const QString &text, int width) const = 0;
57
Returns the size, that is needed to render text
59
\param font Font of the text
60
\param flags Bitwise OR of the flags like in for QPainter::drawText
61
\param text Text to be rendered
63
\return Caluclated size
65
virtual QSize textSize(const QFont &font, int flags,
66
const QString &text) const = 0;
69
Test if a string can be rendered by this text engine
71
\param text Text to be tested
72
\return true, if it can be rendered
74
virtual bool mightRender(const QString &text) const = 0;
77
Return margins around the texts
79
The textSize might include margins around the
80
text, like QFontMetrics::descent. In situations
81
where texts need to be aligend in detail, knowing
82
these margins might improve the layout calculations.
84
\param font Font of the text
85
\param text Text to be rendered
86
\param left Return value for the left margin
87
\param right Return value for the right margin
88
\param top Return value for the top margin
89
\param bottom Return value for the bottom margin
91
virtual void textMargins(const QFont &font, const QString &text,
92
int &left, int &right, int &top, int &bottom) const = 0;
95
Draw the text in a clipping rectangle
97
\param painter Painter
98
\param rect Clipping rectangle
99
\param flags Bitwise OR of the flags like in for QPainter::drawText
100
\param text Text to be rendered
102
virtual void draw(QPainter *painter, const QRect &rect,
103
int flags, const QString &text) const = 0;
111
\brief A text engine for plain texts
113
QwtPlainTextEngine renders texts using the basic Qt classes
114
QPainter and QFontMetrics.
116
class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
119
QwtPlainTextEngine();
120
virtual ~QwtPlainTextEngine();
122
virtual int heightForWidth(const QFont &font, int flags,
123
const QString &text, int width) const;
125
virtual QSize textSize(const QFont &font, int flags,
126
const QString &text) const;
128
virtual void draw(QPainter *painter, const QRect &rect,
129
int flags, const QString &text) const;
131
virtual bool mightRender(const QString &) const;
133
virtual void textMargins(const QFont &, const QString &,
134
int &left, int &right, int &top, int &bottom) const;
142
#ifndef QT_NO_RICHTEXT
145
\brief A text engine for Qt rich texts
147
QwtRichTextEngine renders Qt rich texts using the classes
148
of the Scribe framework of Qt.
150
class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
155
virtual int heightForWidth(const QFont &font, int flags,
156
const QString &text, int width) const;
158
virtual QSize textSize(const QFont &font, int flags,
159
const QString &text) const;
161
virtual void draw(QPainter *painter, const QRect &rect,
162
int flags, const QString &text) const;
164
virtual bool mightRender(const QString &) const;
166
virtual void textMargins(const QFont &, const QString &,
167
int &left, int &right, int &top, int &bottom) const;
169
QString taggedText(const QString &, int flags) const;
172
#endif // !QT_NO_RICHTEXT