QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_text.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_H
28#define QWT_TEXT_H
29
30#include "qwt_global.h"
31#include <qmetatype.h>
32
33class QFont;
34class QString;
35class QColor;
36class QPen;
37class QBrush;
38class QSizeF;
39class QRectF;
40class QPainter;
41class QwtTextEngine;
42
92class QWT_EXPORT QwtText
93{
94public:
114 {
127 AutoText = 0,
128
131
134
162
173
184 OtherFormat = 100
185 };
186
203 {
205 PaintUsingTextFont = 0x01,
206
208 PaintUsingTextColor = 0x02,
209
211 PaintBackground = 0x04
212 };
213
214 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
215
216
228 {
241 MinimumLayout = 0x01
242 };
243
244 Q_DECLARE_FLAGS(LayoutAttributes, LayoutAttribute)
245
246 // Default constructor
247 QwtText();
248 // Constructor with text and format
249 QwtText(const QString&, TextFormat textFormat = AutoText);
250 // Copy constructor
251 QwtText(const QwtText&);
252
253 // Destructor
254 ~QwtText();
255
256 // Assignment operator
257 QwtText& operator=(const QwtText&);
258
259 // Equality operator
260 bool operator==(const QwtText&) const;
261 // Inequality operator
262 bool operator!=(const QwtText&) const;
263
264 // Set text content and format
265 void setText(const QString&, QwtText::TextFormat textFormat = AutoText);
266 // Get text content
267 QString text() const;
268
269 // Check if text is null
270 bool isNull() const;
271 // Check if text is empty
272 bool isEmpty() const;
273
274 // Set font
275 void setFont(const QFont&);
276 // Get font
277 QFont font() const;
278
279 // Get used font (with fallback)
280 QFont usedFont(const QFont&) const;
281
282 // Get the current format
283 TextFormat format() const;
284
285 // Set render flags
286 void setRenderFlags(int);
287 // Get render flags
288 int renderFlags() const;
289
290 // Set text color
291 void setColor(const QColor&);
292 // Get text color
293 QColor color() const;
294
295 // Get used color (with fallback)
296 QColor usedColor(const QColor&) const;
297
298 // Set border radius
299 void setBorderRadius(double);
300 // Get border radius
301 double borderRadius() const;
302
303 // Set border pen
304 void setBorderPen(const QPen&);
305 // Get border pen
306 QPen borderPen() const;
307
308 // Set background brush
309 void setBackgroundBrush(const QBrush&);
310 // Get background brush
311 QBrush backgroundBrush() const;
312
313 // Set paint attribute
314 void setPaintAttribute(PaintAttribute, bool on = true);
315 // Test paint attribute
316 bool testPaintAttribute(PaintAttribute) const;
317
318 // Set layout attribute
319 void setLayoutAttribute(LayoutAttribute, bool on = true);
320 // Test layout attribute
321 bool testLayoutAttribute(LayoutAttribute) const;
322
323 // Get height for width
324 double heightForWidth(double width) const;
325 // Get height for width with font
326 double heightForWidth(double width, const QFont&) const;
327
328 // Get text size
329 QSizeF textSize() const;
330 // Get text size with font
331 QSizeF textSize(const QFont&) const;
332
333 // Draw text into rectangle
334 void draw(QPainter* painter, const QRectF& rect) const;
335
336 // Get text engine for text and format
337 static const QwtTextEngine* textEngine(const QString& text, QwtText::TextFormat = AutoText);
338
339 // Get text engine for format
340 static const QwtTextEngine* textEngine(QwtText::TextFormat);
341 // Set text engine for format
342 static void setTextEngine(QwtText::TextFormat, QwtTextEngine*);
343
344private:
345 class PrivateData;
346 PrivateData* m_data;
347
348 class LayoutCache;
349 LayoutCache* m_layoutCache;
350};
351
352Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::PaintAttributes)
353Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::LayoutAttributes)
354
355Q_DECLARE_METATYPE(QwtText)
356
357#endif
用于渲染文本字符串的抽象基类
Definition qwt_text_engine.h:53
表示文本的类
Definition qwt_text.h:93
LayoutAttribute
布局属性 布局属性影响文本布局的某些方面。
Definition qwt_text.h:228
TextFormat
文本格式
Definition qwt_text.h:114
@ RichText
使用 Scribe 框架(Qt 富文本)渲染文本。
Definition qwt_text.h:133
@ PlainText
使用 QwtPlainTextEngine 按原样绘制文本。
Definition qwt_text.h:130
@ MathMLText
Definition qwt_text.h:161
@ TeXText
Definition qwt_text.h:172
PaintAttribute
绘制属性
Definition qwt_text.h:203