QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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
纯文本的文本引擎
Definition qwt_text_engine.h:183
Qt 富文本的文本引擎
Definition qwt_text_engine.h:233
用于渲染文本字符串的抽象基类
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
返回文本周围的边距
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
计算给定宽度的高度