QWT API (中文) 7.3.0
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
69class QWT_EXPORT QwtText
70{
71public:
82 {
89 AutoText = 0,
90
93
96
111
117
122 OtherFormat = 100
123 };
124
133 {
135 PaintUsingTextFont = 0x01,
136
138 PaintUsingTextColor = 0x02,
139
141 PaintBackground = 0x04
142 };
143
144 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
145
146
152 {
159 MinimumLayout = 0x01
160 };
161
162 Q_DECLARE_FLAGS(LayoutAttributes, LayoutAttribute)
163
164 // Default constructor
165 QwtText();
166 // Constructor with text and format
167 QwtText(const QString&, TextFormat textFormat = AutoText);
168 // Copy constructor
169 QwtText(const QwtText&);
170 // Move constructor
171 QwtText(QwtText&&) noexcept;
172
173 // Destructor
174 ~QwtText();
175
176 // Assignment operator
177 QwtText& operator=(const QwtText&);
178 // Move assignment
179 QwtText& operator=(QwtText&&) noexcept;
180
181 // Equality operator
182 bool operator==(const QwtText&) const;
183 // Inequality operator
184 bool operator!=(const QwtText&) const;
185
186 // Set text content and format
187 void setText(const QString&, QwtText::TextFormat textFormat = AutoText);
188 // Get text content
189 QString text() const;
190
191 // Check if text is null
192 bool isNull() const;
193 // Check if text is empty
194 bool isEmpty() const;
195
196 // Set font
197 void setFont(const QFont&);
198 // Get font
199 QFont font() const;
200
201 // Get used font (with fallback)
202 QFont usedFont(const QFont&) const;
203
204 // Get the current format
205 TextFormat format() const;
206
207 // Set render flags
208 void setRenderFlags(int);
209 // Get render flags
210 int renderFlags() const;
211
212 // Set text color
213 void setColor(const QColor&);
214 // Get text color
215 QColor color() const;
216
217 // Get used color (with fallback)
218 QColor usedColor(const QColor&) const;
219
220 // Set border radius
221 void setBorderRadius(double);
222 // Get border radius
223 double borderRadius() const;
224
225 // Set border pen
226 void setBorderPen(const QPen&);
227 // Get border pen
228 QPen borderPen() const;
229
230 // Set background brush
231 void setBackgroundBrush(const QBrush&);
232 // Get background brush
233 QBrush backgroundBrush() const;
234
235 // Set paint attribute
236 void setPaintAttribute(PaintAttribute, bool on = true);
237 // Test paint attribute
238 bool testPaintAttribute(PaintAttribute) const;
239
240 // Set layout attribute
241 void setLayoutAttribute(LayoutAttribute, bool on = true);
242 // Test layout attribute
243 bool testLayoutAttribute(LayoutAttribute) const;
244
245 // Get height for width
246 double heightForWidth(double width) const;
247 // Get height for width with font
248 double heightForWidth(double width, const QFont&) const;
249
250 // Get text size
251 QSizeF textSize() const;
252 // Get text size with font
253 QSizeF textSize(const QFont&) const;
254
255 // Draw text into rectangle
256 void draw(QPainter* painter, const QRectF& rect) const;
257
258 // Get text engine for text and format
259 static const QwtTextEngine* textEngine(const QString& text, QwtText::TextFormat = AutoText);
260
261 // Get text engine for format
262 static const QwtTextEngine* textEngine(QwtText::TextFormat);
263 // Set text engine for format
264 static void setTextEngine(QwtText::TextFormat, QwtTextEngine*);
265
266private:
267 QWT_DECLARE_PRIVATE(QwtText)
268
269 class LayoutCache;
270 LayoutCache* m_layoutCache;
271};
272
273Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::PaintAttributes)
274Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::LayoutAttributes)
275
276Q_DECLARE_METATYPE(QwtText)
277
278#endif
Abstract base class for rendering text strings
Definition qwt_text_engine.h:46
A class representing a text
Definition qwt_text.h:70
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text.
Definition qwt_text.h:152
TextFormat
Text format
Definition qwt_text.h:82
@ RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition qwt_text.h:95
@ PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition qwt_text.h:92
@ MathMLText
Definition qwt_text.h:110
@ TeXText
Definition qwt_text.h:116
PaintAttribute
Paint Attributes
Definition qwt_text.h:133