Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

qwt_text.h
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 #ifndef QWT_TEXT_H
11 #define QWT_TEXT_H
12
13 #include "qwt_global.h"
14 #include <qstring.h>
15 #include <qsize.h>
16 #include <qfont.h>
17
18 class QColor;
19 class QPen;
20 class QBrush;
21 class QRectF;
22 class QPainter;
23 class QwtTextEngine;
24
49 class QWT_EXPORT QwtText
50 {
51 public:
52
62 enum TextFormat
63 {
70 AutoText = 0,
71
73 PlainText,
74
76 RichText,
77
86 MathMLText,
87
92 TeXText,
93
98 OtherFormat = 100
99 };
100
107 enum PaintAttribute
108 {
110 PaintUsingTextFont = 0x01,
111
113 PaintUsingTextColor = 0x02,
114
116 PaintBackground = 0x04
117 };
118
120 typedef QFlags<PaintAttribute> PaintAttributes;
121
126 enum LayoutAttribute
127 {
134 MinimumLayout = 0x01
135 };
136
138 typedef QFlags<LayoutAttribute> LayoutAttributes;
139
140 QwtText( const QString & = QString::null,
141 TextFormat textFormat = AutoText );
142 QwtText( const QwtText & );
143 ~QwtText();
144
145 QwtText &operator=( const QwtText & );
146
147 bool operator==( const QwtText & ) const;
148 bool operator!=( const QwtText & ) const;
149
150 void setText( const QString &,
151 QwtText::TextFormat textFormat = AutoText );
152 QString text() const;
153
154 bool isNull() const;
155 bool isEmpty() const;
156
157 void setFont( const QFont & );
158 QFont font() const;
159
160 QFont usedFont( const QFont & ) const;
161
162 void setRenderFlags( int flags );
163 int renderFlags() const;
164
165 void setColor( const QColor & );
166 QColor color() const;
167
168 QColor usedColor( const QColor & ) const;
169
170 void setBackgroundPen( const QPen & );
171 QPen backgroundPen() const;
172
173 void setBackgroundBrush( const QBrush & );
174 QBrush backgroundBrush() const;
175
176 void setPaintAttribute( PaintAttribute, bool on = true );
177 bool testPaintAttribute( PaintAttribute ) const;
178
179 void setLayoutAttribute( LayoutAttribute, bool on = true );
180 bool testLayoutAttribute( LayoutAttribute ) const;
181
182 double heightForWidth( double width, const QFont & = QFont() ) const;
183 QSizeF textSize( const QFont & = QFont() ) const;
184
185 void draw( QPainter *painter, const QRectF &rect ) const;
186
187 static const QwtTextEngine *textEngine(
188 const QString &text, QwtText::TextFormat = AutoText );
189
190 static const QwtTextEngine *textEngine( QwtText::TextFormat );
191 static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
192
193 private:
194 class PrivateData;
195 PrivateData *d_data;
196
197 class LayoutCache;
198 LayoutCache *d_layoutCache;
199 };
200
202 inline bool QwtText::isNull() const
203 {
204 return text().isNull();
205 }
206
208 inline bool QwtText::isEmpty() const
209 {
210 return text().isEmpty();
211 }
212
213 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
214 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
215
216 #endif