QWT 7.0.1
Loading...
Searching...
No Matches
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
68class QWT_EXPORT QwtText
69{
70public:
81 {
88 AutoText = 0,
89
92
95
110
116
121 OtherFormat = 100
122 };
123
131 {
133 PaintUsingTextFont = 0x01,
134
136 PaintUsingTextColor = 0x02,
137
139 PaintBackground = 0x04
140 };
141
142 Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute)
143
144
149 {
156 MinimumLayout = 0x01
157 };
158
159 Q_DECLARE_FLAGS(LayoutAttributes, LayoutAttribute)
160
161 QwtText();
162 QwtText(const QString&, TextFormat textFormat = AutoText);
163 QwtText(const QwtText&);
164
165 ~QwtText();
166
167 QwtText& operator=(const QwtText&);
168
169 bool operator==(const QwtText&) const;
170 bool operator!=(const QwtText&) const;
171
172 void setText(const QString&, QwtText::TextFormat textFormat = AutoText);
173 QString text() const;
174
175 bool isNull() const;
176 bool isEmpty() const;
177
178 void setFont(const QFont&);
179 QFont font() const;
180
181 QFont usedFont(const QFont&) const;
182
183 // get the current format
184 TextFormat format() const;
185
186 void setRenderFlags(int);
187 int renderFlags() const;
188
189 void setColor(const QColor&);
190 QColor color() const;
191
192 QColor usedColor(const QColor&) const;
193
194 void setBorderRadius(double);
195 double borderRadius() const;
196
197 void setBorderPen(const QPen&);
198 QPen borderPen() const;
199
200 void setBackgroundBrush(const QBrush&);
201 QBrush backgroundBrush() const;
202
203 void setPaintAttribute(PaintAttribute, bool on = true);
204 bool testPaintAttribute(PaintAttribute) const;
205
206 void setLayoutAttribute(LayoutAttribute, bool on = true);
207 bool testLayoutAttribute(LayoutAttribute) const;
208
209 double heightForWidth(double width) const;
210 double heightForWidth(double width, const QFont&) const;
211
212 QSizeF textSize() const;
213 QSizeF textSize(const QFont&) const;
214
215 void draw(QPainter* painter, const QRectF& rect) const;
216
217 static const QwtTextEngine* textEngine(const QString& text, QwtText::TextFormat = AutoText);
218
219 static const QwtTextEngine* textEngine(QwtText::TextFormat);
220 static void setTextEngine(QwtText::TextFormat, QwtTextEngine*);
221
222private:
223 class PrivateData;
224 PrivateData* m_data;
225
226 class LayoutCache;
227 LayoutCache* m_layoutCache;
228};
229
230Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::PaintAttributes)
231Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::LayoutAttributes)
232
233Q_DECLARE_METATYPE(QwtText)
234
235#endif
Abstract base class for rendering text strings.
Definition qwt_text_engine.h:48
A class representing a text.
Definition qwt_text.h:69
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text.
Definition qwt_text.h:149
TextFormat
Text format.
Definition qwt_text.h:81
@ RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition qwt_text.h:94
@ PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition qwt_text.h:91
@ MathMLText
Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine to display the text.
Definition qwt_text.h:109
@ TeXText
Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine to display the text ( not implemented yet ...
Definition qwt_text.h:115
PaintAttribute
Paint Attributes.
Definition qwt_text.h:131