Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
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
16class QFont;
17class QRectF;
18class QString;
19class QPainter;
20
30class 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:
99
100 private:
101 Q_DISABLE_COPY(QwtTextEngine)
102};
103
104
111class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine
112{
113 public:
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
147class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine
148{
149 public:
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
A text engine for plain texts.
A text engine for Qt rich texts.
Abstract base class for rendering text strings.
virtual void textMargins(const QFont &font, const QString &text, double &left, double &right, double &top, double &bottom) const =0
virtual bool mightRender(const QString &text) const =0
virtual void draw(QPainter *painter, const QRectF &rect, int flags, const QString &text) const =0
virtual QSizeF textSize(const QFont &font, int flags, const QString &text) const =0
virtual double heightForWidth(const QFont &font, int flags, const QString &text, double width) const =0