Qwt User's Guide 6.2.0

qwt_text_engine.h
1 /******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
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 *****************************************************************************/
9
10 #ifndef QWT_TEXT_ENGINE_H
11 #define QWT_TEXT_ENGINE_H
12
13 #include "qwt_global.h"
14 #include <qsize.h>
15
16 class QFont;
17 class QRectF;
18 class QString;
19 class QPainter;
20
30 class QWT_EXPORT QwtTextEngine
31 {
32 public:
33 virtual ~QwtTextEngine();
34
45 virtual double heightForWidth( const QFont& font, int flags,
46 const QString& text, double width ) const = 0;
47
57 virtual QSizeF textSize( const QFont& font, int flags,
58 const QString& text ) const = 0;
59
66 virtual bool mightRender( const QString& text ) const = 0;
67
83 virtual void textMargins( const QFont& font, const QString& text,
84 double& left, double& right, double& top, double& bottom ) const = 0;
85
94 virtual void draw( QPainter* painter, const QRectF& rect,
95 int flags, const QString& text ) const = 0;
96
97 protected:
98 QwtTextEngine();
99
100 private:
101 Q_DISABLE_COPY(QwtTextEngine)
102 };
103
104
111 class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine
112 {
113 public:
114 QwtPlainTextEngine();
115 virtual ~QwtPlainTextEngine();
116
117 virtual double heightForWidth( const QFont& font, int flags,
118 const QString& text, double width ) const QWT_OVERRIDE;
119
120 virtual QSizeF textSize( const QFont& font, int flags,
121 const QString& text ) const QWT_OVERRIDE;
122
123 virtual void draw( QPainter*, const QRectF& rect,
124 int flags, const QString& text ) const QWT_OVERRIDE;
125
126 virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
127
128 virtual void textMargins(
129 const QFont&, const QString&,
130 double& left, double& right,
131 double& top, double& bottom ) const QWT_OVERRIDE;
132
133 private:
134 class PrivateData;
135 PrivateData* m_data;
136 };
137
138
139 #ifndef QT_NO_RICHTEXT
140
147 class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine
148 {
149 public:
150 QwtRichTextEngine();
151
152 virtual double heightForWidth( const QFont& font, int flags,
153 const QString& text, double width ) const QWT_OVERRIDE;
154
155 virtual QSizeF textSize( const QFont& font, int flags,
156 const QString& text ) const QWT_OVERRIDE;
157
158 virtual void draw( QPainter*, const QRectF& rect,
159 int flags, const QString& text ) const QWT_OVERRIDE;
160
161 virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
162
163 virtual void textMargins(
164 const QFont&, const QString&,
165 double& left, double& right,
166 double& top, double& bottom ) const QWT_OVERRIDE;
167
168 private:
169 QString taggedText( const QString&, int flags ) const;
170 };
171
172 #endif // !QT_NO_RICHTEXT
173
174 #endif
QwtPlainTextEngine
A text engine for plain texts.
Definition: qwt_text_engine.h:112
QwtRichTextEngine
A text engine for Qt rich texts.
Definition: qwt_text_engine.h:148
QwtTextEngine
Abstract base class for rendering text strings.
Definition: qwt_text_engine.h:31
QwtTextEngine::textMargins
virtual void textMargins(const QFont &font, const QString &text, double &left, double &right, double &top, double &bottom) const =0
QwtTextEngine::mightRender
virtual bool mightRender(const QString &text) const =0
QwtTextEngine::draw
virtual void draw(QPainter *painter, const QRectF &rect, int flags, const QString &text) const =0
QwtTextEngine::textSize
virtual QSizeF textSize(const QFont &font, int flags, const QString &text) const =0
QwtTextEngine::heightForWidth
virtual double heightForWidth(const QFont &font, int flags, const QString &text, double width) const =0