source: pacpusframework/branches/2.0-beta1/include/extlib/qwt-5.2.1/qwt_text.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: 5.6 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_H
13#define QWT_TEXT_H
14
15#include <qstring.h>
16#include <qsize.h>
17#include <qfont.h>
18#include "qwt_global.h"
19
20class QColor;
21class QPen;
22class QBrush;
23class QRect;
24class QPainter;
25class QwtTextEngine;
26
27/*!
28 \brief A class representing a text
29
30 A QwtText is a text including a set of attributes how to render it.
31
32 - Format\n
33 A text might include control sequences (f.e tags) describing
34 how to render it. Each format (f.e MathML, TeX, Qt Rich Text)
35 has its own set of control sequences, that can be handles by
36 a QwtTextEngine for this format.
37 - Background\n
38 A text might have a background, defined by a QPen and QBrush
39 to improve its visibility.
40 - Font\n
41 A text might have an individual font.
42 - Color\n
43 A text might have an individual color.
44 - Render Flags\n
45 Flags from Qt::AlignmentFlag and Qt::TextFlag used like in
46 QPainter::drawText.
47
48 \sa QwtTextEngine, QwtTextLabel
49*/
50
51class QWT_EXPORT QwtText
52{
53public:
54
55 /*!
56 \brief Text format
57
58 The text format defines the QwtTextEngine, that is used to render
59 the text.
60
61 - AutoText\n
62 The text format is determined using QwtTextEngine::mightRender for
63 all available text engines in increasing order > PlainText.
64 If none of the text engines can render the text is rendered
65 like PlainText.
66 - PlainText\n
67 Draw the text as it is, using a QwtPlainTextEngine.
68 - RichText\n
69 Use the Scribe framework (Qt Rich Text) to render the text.
70 - MathMLText\n
71 Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine
72 to display the text. The Qwt MathML extension offers such an engine
73 based on the MathML renderer of the Qt solutions package. Unfortunately
74 it is only available for owners of a commercial Qt license.
75 - TeXText\n
76 Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine
77 to display the text.
78 - OtherFormat\n
79 The number of text formats can be extended using setTextEngine.
80 Formats >= OtherFormat are not used by Qwt.
81
82 \sa QwtTextEngine, setTextEngine()
83 */
84
85 enum TextFormat
86 {
87 AutoText = 0,
88
89 PlainText,
90 RichText,
91
92 MathMLText,
93 TeXText,
94
95 OtherFormat = 100
96 };
97
98 /*!
99 \brief Paint Attributes
100
101 Font and color and background are optional attributes of a QwtText.
102 The paint attributes hold the information, if they are set.
103
104 - PaintUsingTextFont\n
105 The text has an individual font.
106 - PaintUsingTextColor\n
107 The text has an individual color.
108 - PaintBackground\n
109 The text has an individual background.
110 */
111 enum PaintAttribute
112 {
113 PaintUsingTextFont = 1,
114 PaintUsingTextColor = 2,
115 PaintBackground = 4
116 };
117
118 /*!
119 \brief Layout Attributes
120
121 The layout attributes affects some aspects of the layout of the text.
122
123 - MinimumLayout\n
124 Layout the text without its margins. This mode is useful if a
125 text needs to be aligned accurately, like the tick labels of a scale.
126 If QwtTextEngine::textMargins is not implemented for the format
127 of the text, MinimumLayout has no effect.
128 */
129 enum LayoutAttribute
130 {
131 MinimumLayout = 1
132 };
133
134 QwtText(const QString & = QString::null,
135 TextFormat textFormat = AutoText);
136 QwtText(const QwtText &);
137 ~QwtText();
138
139 QwtText &operator=(const QwtText &);
140
141 int operator==(const QwtText &) const;
142 int operator!=(const QwtText &) const;
143
144 void setText(const QString &,
145 QwtText::TextFormat textFormat = AutoText);
146 QString text() const;
147
148 bool isNull() const;
149 bool isEmpty() const;
150
151 void setFont(const QFont &);
152 QFont font() const;
153
154 QFont usedFont(const QFont &) const;
155
156 void setRenderFlags(int flags);
157 int renderFlags() const;
158
159 void setColor(const QColor &);
160 QColor color() const;
161
162 QColor usedColor(const QColor &) const;
163
164 void setBackgroundPen(const QPen &);
165 QPen backgroundPen() const;
166
167 void setBackgroundBrush(const QBrush &);
168 QBrush backgroundBrush() const;
169
170 void setPaintAttribute(PaintAttribute, bool on = true);
171 bool testPaintAttribute(PaintAttribute) const;
172
173 void setLayoutAttribute(LayoutAttribute, bool on = true);
174 bool testLayoutAttribute(LayoutAttribute) const;
175
176 int heightForWidth(int width, const QFont & = QFont()) const;
177 QSize textSize(const QFont & = QFont()) const;
178
179 void draw(QPainter *painter, const QRect &rect) const;
180
181 static const QwtTextEngine *textEngine(const QString &text,
182 QwtText::TextFormat = AutoText);
183
184 static const QwtTextEngine *textEngine(QwtText::TextFormat);
185 static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
186
187private:
188 class PrivateData;
189 PrivateData *d_data;
190
191 class LayoutCache;
192 LayoutCache *d_layoutCache;
193};
194
195//! \return text().isNull()
196inline bool QwtText::isNull() const
197{
198 return text().isNull();
199}
200
201//! \return text().isEmpty()
202inline bool QwtText::isEmpty() const
203{
204 return text().isEmpty();
205}
206
207#endif
Note: See TracBrowser for help on using the repository browser.