QWT API (中文)
7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
src
plot
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
33
class
QFont;
34
class
QRectF;
35
class
QString;
36
class
QPainter;
37
45
class
QWT_EXPORT
QwtTextEngine
46
{
47
public
:
48
// Virtual destructor
49
virtual
~QwtTextEngine
();
50
51
// Find the height for a given width
52
virtual
double
heightForWidth(
const
QFont& font,
int
flags,
const
QString& text,
double
width)
const
= 0;
53
54
// Return the size needed to render text
55
virtual
QSizeF textSize(
const
QFont& font,
int
flags,
const
QString& text)
const
= 0;
56
57
// Test if a string can be rendered by this text engine
58
virtual
bool
mightRender(
const
QString& text)
const
= 0;
59
60
// Return margins around the texts
61
virtual
void
62
textMargins(
const
QFont& font,
const
QString& text,
double
& left,
double
& right,
double
& top,
double
& bottom)
const
= 0;
63
64
// Draw the text in a clipping rectangle
65
virtual
void
draw(QPainter* painter,
const
QRectF& rect,
int
flags,
const
QString& text)
const
= 0;
66
67
protected
:
69
QwtTextEngine
();
70
71
private
:
72
QwtTextEngine
(
const
QwtTextEngine
&) =
delete
;
73
QwtTextEngine
& operator=(
const
QwtTextEngine
&) =
delete
;
74
};
75
82
class
QWT_EXPORT
QwtPlainTextEngine
:
public
QwtTextEngine
83
{
84
public
:
85
// Constructor
86
QwtPlainTextEngine
();
87
// Destructor
88
~QwtPlainTextEngine
()
override
;
89
90
// Calculate height for a given width
91
virtual
double
heightForWidth(
const
QFont& font,
int
flags,
const
QString& text,
double
width)
const override
;
92
93
// Return the size needed to render text
94
virtual
QSizeF textSize(
const
QFont& font,
int
flags,
const
QString& text)
const override
;
95
96
// Draw the text
97
virtual
void
draw(QPainter*,
const
QRectF& rect,
int
flags,
const
QString& text)
const override
;
98
99
// Test if a string can be rendered
100
virtual
bool
mightRender(
const
QString&)
const override
;
101
102
// Return text margins
103
virtual
void
104
textMargins(
const
QFont&,
const
QString&,
double
& left,
double
& right,
double
& top,
double
& bottom)
const override
;
105
106
private
:
107
QWT_DECLARE_PRIVATE(
QwtPlainTextEngine
)
108
};
109
110
#ifndef QT_NO_RICHTEXT
111
118
class
QWT_EXPORT
QwtRichTextEngine
:
public
QwtTextEngine
119
{
120
public
:
121
// Constructor
122
QwtRichTextEngine
();
123
124
// Calculate height for a given width
125
virtual
double
heightForWidth(
const
QFont& font,
int
flags,
const
QString& text,
double
width)
const override
;
126
127
// Return the size needed to render text
128
virtual
QSizeF textSize(
const
QFont& font,
int
flags,
const
QString& text)
const override
;
129
130
// Draw the text
131
virtual
void
draw(QPainter*,
const
QRectF& rect,
int
flags,
const
QString& text)
const override
;
132
133
// Test if a string can be rendered
134
virtual
bool
mightRender(
const
QString&)
const override
;
135
136
// Return text margins
137
virtual
void
138
textMargins(
const
QFont&,
const
QString&,
double
& left,
double
& right,
double
& top,
double
& bottom)
const override
;
139
140
private
:
141
QString taggedText(
const
QString&,
int
flags)
const
;
142
};
143
144
#endif
// !QT_NO_RICHTEXT
145
146
#endif
QwtPlainTextEngine
A text engine for plain texts
Definition
qwt_text_engine.h:83
QwtRichTextEngine
A text engine for Qt rich texts
Definition
qwt_text_engine.h:119
QwtTextEngine
Abstract base class for rendering text strings
Definition
qwt_text_engine.h:46
制作者
1.9.8