QWT API (English) 7.0.1
Qt Widget Library for Technical Applications - English API Documentation
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
52class QWT_EXPORT QwtTextEngine
53{
54 public:
55 // Virtual destructor
56 virtual ~QwtTextEngine();
57
76 virtual double heightForWidth( const QFont& font, int flags,
77 const QString& text, double width ) const = 0;
78
95 virtual QSizeF textSize( const QFont& font, int flags,
96 const QString& text ) const = 0;
97
110 virtual bool mightRender( const QString& text ) const = 0;
111
138 virtual void textMargins( const QFont& font, const QString& text,
139 double& left, double& right, double& top, double& bottom ) const = 0;
140
157 virtual void draw( QPainter* painter, const QRectF& rect,
158 int flags, const QString& text ) const = 0;
159
160 protected:
163
164 private:
165 Q_DISABLE_COPY(QwtTextEngine)
166};
167
168
182class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine
183{
184 public:
185 // Constructor
187 // Destructor
188 virtual ~QwtPlainTextEngine();
189
190 // Calculate height for a given width
191 virtual double heightForWidth( const QFont& font, int flags,
192 const QString& text, double width ) const override;
193
194 // Return the size needed to render text
195 virtual QSizeF textSize( const QFont& font, int flags,
196 const QString& text ) const override;
197
198 // Draw the text
199 virtual void draw( QPainter*, const QRectF& rect,
200 int flags, const QString& text ) const override;
201
202 // Test if a string can be rendered
203 virtual bool mightRender( const QString& ) const override;
204
205 // Return text margins
206 virtual void textMargins(
207 const QFont&, const QString&,
208 double& left, double& right,
209 double& top, double& bottom ) const override;
210
211 private:
212 class PrivateData;
213 PrivateData* m_data;
214};
215
216
217#ifndef QT_NO_RICHTEXT
218
232class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine
233{
234 public:
235 // Constructor
237
238 // Calculate height for a given width
239 virtual double heightForWidth( const QFont& font, int flags,
240 const QString& text, double width ) const override;
241
242 // Return the size needed to render text
243 virtual QSizeF textSize( const QFont& font, int flags,
244 const QString& text ) const override;
245
246 // Draw the text
247 virtual void draw( QPainter*, const QRectF& rect,
248 int flags, const QString& text ) const override;
249
250 // Test if a string can be rendered
251 virtual bool mightRender( const QString& ) const override;
252
253 // Return text margins
254 virtual void textMargins(
255 const QFont&, const QString&,
256 double& left, double& right,
257 double& top, double& bottom ) const override;
258
259 private:
260 QString taggedText( const QString&, int flags ) const;
261};
262
263#endif // !QT_NO_RICHTEXT
264
265#endif
A text engine for plain texts.
Definition qwt_text_engine.h:183
A text engine for Qt rich texts.
Definition qwt_text_engine.h:233
Abstract base class for rendering text strings.
Definition qwt_text_engine.h:53
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
Return the size 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.