source: pacpusframework/branches/2.0-beta1/include/extlib/qwt-5.2.1/qwt_text_engine.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

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