source: ntrip/trunk/BNC/qwt/qwt_text_engine.h@ 10110

Last change on this file since 10110 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.7 KB
RevLine 
[4271]1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
[8127]4 * Copyright (C) 2002 Uwe Rathmann
[4271]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
10#ifndef QWT_TEXT_ENGINE_H
11#define QWT_TEXT_ENGINE_H 1
12
13#include "qwt_global.h"
14#include <qsize.h>
15
16class QFont;
17class QRectF;
18class QString;
19class QPainter;
20
21/*!
22 \brief Abstract base class for rendering text strings
23
24 A text engine is responsible for rendering texts for a
25 specific text format. They are used by QwtText to render a text.
26
27 QwtPlainTextEngine and QwtRichTextEngine are part of the Qwt library.
[9383]28 The implementation of QwtMathMLTextEngine uses code from the
[4271]29 Qt solution package. Because of license implications it is built into
30 a separate library.
[9383]31
[4271]32 \sa QwtText::setTextEngine()
33*/
34
35class QWT_EXPORT QwtTextEngine
36{
37public:
38 virtual ~QwtTextEngine();
39
40 /*!
41 Find the height for a given width
42
43 \param font Font of the text
44 \param flags Bitwise OR of the flags used like in QPainter::drawText
45 \param text Text to be rendered
46 \param width Width
47
48 \return Calculated height
49 */
50 virtual double heightForWidth( const QFont &font, int flags,
51 const QString &text, double width ) const = 0;
52
53 /*!
54 Returns the size, that is needed to render text
55
56 \param font Font of the text
57 \param flags Bitwise OR of the flags like in for QPainter::drawText
58 \param text Text to be rendered
59
[8127]60 \return Calculated size
[4271]61 */
62 virtual QSizeF textSize( const QFont &font, int flags,
63 const QString &text ) const = 0;
64
65 /*!
66 Test if a string can be rendered by this text engine
67
68 \param text Text to be tested
69 \return true, if it can be rendered
70 */
71 virtual bool mightRender( const QString &text ) const = 0;
72
73 /*!
74 Return margins around the texts
75
76 The textSize might include margins around the
[8127]77 text, like QFontMetrics::descent(). In situations
78 where texts need to be aligned in detail, knowing
[4271]79 these margins might improve the layout calculations.
80
81 \param font Font of the text
82 \param text Text to be rendered
83 \param left Return value for the left margin
84 \param right Return value for the right margin
85 \param top Return value for the top margin
86 \param bottom Return value for the bottom margin
87 */
88 virtual void textMargins( const QFont &font, const QString &text,
89 double &left, double &right, double &top, double &bottom ) const = 0;
90
91 /*!
92 Draw the text in a clipping rectangle
93
94 \param painter Painter
95 \param rect Clipping rectangle
[8127]96 \param flags Bitwise OR of the flags like in for QPainter::drawText()
[4271]97 \param text Text to be rendered
98 */
99 virtual void draw( QPainter *painter, const QRectF &rect,
100 int flags, const QString &text ) const = 0;
101
102protected:
103 QwtTextEngine();
104};
105
106
107/*!
108 \brief A text engine for plain texts
109
110 QwtPlainTextEngine renders texts using the basic Qt classes
111 QPainter and QFontMetrics.
112*/
113class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
114{
115public:
116 QwtPlainTextEngine();
117 virtual ~QwtPlainTextEngine();
118
119 virtual double heightForWidth( const QFont &font, int flags,
120 const QString &text, double width ) const;
121
122 virtual QSizeF textSize( const QFont &font, int flags,
123 const QString &text ) const;
124
125 virtual void draw( QPainter *painter, const QRectF &rect,
126 int flags, const QString &text ) const;
127
128 virtual bool mightRender( const QString & ) const;
129
130 virtual void textMargins( const QFont &, const QString &,
131 double &left, double &right, double &top, double &bottom ) const;
132
133private:
134 class PrivateData;
135 PrivateData *d_data;
136};
137
138
139#ifndef QT_NO_RICHTEXT
140
141/*!
142 \brief A text engine for Qt rich texts
143
144 QwtRichTextEngine renders Qt rich texts using the classes
145 of the Scribe framework of Qt.
146*/
147class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
148{
149public:
150 QwtRichTextEngine();
151
152 virtual double heightForWidth( const QFont &font, int flags,
153 const QString &text, double width ) const;
154
155 virtual QSizeF textSize( const QFont &font, int flags,
156 const QString &text ) const;
157
158 virtual void draw( QPainter *painter, const QRectF &rect,
159 int flags, const QString &text ) const;
160
161 virtual bool mightRender( const QString & ) const;
162
163 virtual void textMargins( const QFont &, const QString &,
164 double &left, double &right, double &top, double &bottom ) const;
165
166private:
167 QString taggedText( const QString &, int flags ) const;
168};
169
170#endif // !QT_NO_RICHTEXT
171
172#endif
Note: See TracBrowser for help on using the repository browser.