QWT 7.0.1
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_TEXT_ENGINE_H
28#define QWT_TEXT_ENGINE_H
29
30#include "qwt_global.h"
31#include <qsize.h>
32
33class QFont;
34class QRectF;
35class QString;
36class QPainter;
37
47class QWT_EXPORT QwtTextEngine
48{
49 public:
50 virtual ~QwtTextEngine();
51
62 virtual double heightForWidth( const QFont& font, int flags,
63 const QString& text, double width ) const = 0;
64
74 virtual QSizeF textSize( const QFont& font, int flags,
75 const QString& text ) const = 0;
76
83 virtual bool mightRender( const QString& text ) const = 0;
84
100 virtual void textMargins( const QFont& font, const QString& text,
101 double& left, double& right, double& top, double& bottom ) const = 0;
102
111 virtual void draw( QPainter* painter, const QRectF& rect,
112 int flags, const QString& text ) const = 0;
113
114 protected:
116
117 private:
118 Q_DISABLE_COPY(QwtTextEngine)
119};
120
121
128class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine
129{
130 public:
132 virtual ~QwtPlainTextEngine();
133
134 virtual double heightForWidth( const QFont& font, int flags,
135 const QString& text, double width ) const QWT_OVERRIDE;
136
137 virtual QSizeF textSize( const QFont& font, int flags,
138 const QString& text ) const QWT_OVERRIDE;
139
140 virtual void draw( QPainter*, const QRectF& rect,
141 int flags, const QString& text ) const QWT_OVERRIDE;
142
143 virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
144
145 virtual void textMargins(
146 const QFont&, const QString&,
147 double& left, double& right,
148 double& top, double& bottom ) const QWT_OVERRIDE;
149
150 private:
151 class PrivateData;
152 PrivateData* m_data;
153};
154
155
156#ifndef QT_NO_RICHTEXT
157
164class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine
165{
166 public:
168
169 virtual double heightForWidth( const QFont& font, int flags,
170 const QString& text, double width ) const QWT_OVERRIDE;
171
172 virtual QSizeF textSize( const QFont& font, int flags,
173 const QString& text ) const QWT_OVERRIDE;
174
175 virtual void draw( QPainter*, const QRectF& rect,
176 int flags, const QString& text ) const QWT_OVERRIDE;
177
178 virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
179
180 virtual void textMargins(
181 const QFont&, const QString&,
182 double& left, double& right,
183 double& top, double& bottom ) const QWT_OVERRIDE;
184
185 private:
186 QString taggedText( const QString&, int flags ) const;
187};
188
189#endif // !QT_NO_RICHTEXT
190
191#endif
A text engine for plain texts.
Definition qwt_text_engine.h:129
A text engine for Qt rich texts.
Definition qwt_text_engine.h:165
Abstract base class for rendering text strings.
Definition qwt_text_engine.h:48
virtual void textMargins(const QFont &font, const QString &text, double &left, double &right, double &top, double &bottom) const =0
Return margins around the texts.
virtual bool mightRender(const QString &text) const =0
Test if a string can be rendered by this text engine.
virtual void draw(QPainter *painter, const QRectF &rect, int flags, const QString &text) const =0
Draw the text in a clipping rectangle.
virtual QSizeF textSize(const QFont &font, int flags, const QString &text) const =0
Returns the size, that is needed to render text.
virtual double heightForWidth(const QFont &font, int flags, const QString &text, double width) const =0
Find the height for a given width.