Qwt User's Guide 6.1.3

- Main Page
- Classes

qwt_text.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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
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 #include <qmetatype.h>
18
19 class QColor;
20 class QPen;
21 class QBrush;
22 class QRectF;
23 class QPainter;
24 class QwtTextEngine;
25
51 class QWT_EXPORT QwtText
52 {
53 public:
54
64 enum TextFormat
65 {
72 AutoText = 0,
73
75 PlainText,
76
78 RichText,
79
88 MathMLText,
89
94 TeXText,
95
100 OtherFormat = 100
101 };
102
109 enum PaintAttribute
110 {
112 PaintUsingTextFont = 0x01,
113
115 PaintUsingTextColor = 0x02,
116
118 PaintBackground = 0x04
119 };
120
122 typedef QFlags<PaintAttribute> PaintAttributes;
123
128 enum LayoutAttribute
129 {
136 MinimumLayout = 0x01
137 };
138
140 typedef QFlags<LayoutAttribute> LayoutAttributes;
141
142 QwtText( const QString & = QString::null,
143 TextFormat textFormat = AutoText );
144 QwtText( const QwtText & );
145 ~QwtText();
146
147 QwtText &operator=( const QwtText & );
148
149 bool operator==( const QwtText & ) const;
150 bool operator!=( const QwtText & ) const;
151
152 void setText( const QString &,
153 QwtText::TextFormat textFormat = AutoText );
154 QString text() const;
155
156 bool isNull() const;
157 bool isEmpty() const;
158
159 void setFont( const QFont & );
160 QFont font() const;
161
162 QFont usedFont( const QFont & ) const;
163
164 void setRenderFlags( int flags );
165 int renderFlags() const;
166
167 void setColor( const QColor & );
168 QColor color() const;
169
170 QColor usedColor( const QColor & ) const;
171
172 void setBorderRadius( double );
173 double borderRadius() const;
174
175 void setBorderPen( const QPen & );
176 QPen borderPen() const;
177
178 void setBackgroundBrush( const QBrush & );
179 QBrush backgroundBrush() const;
180
181 void setPaintAttribute( PaintAttribute, bool on = true );
182 bool testPaintAttribute( PaintAttribute ) const;
183
184 void setLayoutAttribute( LayoutAttribute, bool on = true );
185 bool testLayoutAttribute( LayoutAttribute ) const;
186
187 double heightForWidth( double width, const QFont & = QFont() ) const;
188 QSizeF textSize( const QFont & = QFont() ) const;
189
190 void draw( QPainter *painter, const QRectF &rect ) const;
191
192 static const QwtTextEngine *textEngine(
193 const QString &text, QwtText::TextFormat = AutoText );
194
195 static const QwtTextEngine *textEngine( QwtText::TextFormat );
196 static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
197
198 private:
199 class PrivateData;
200 PrivateData *d_data;
201
202 class LayoutCache;
203 LayoutCache *d_layoutCache;
204 };
205
207 inline bool QwtText::isNull() const
208 {
209 return text().isNull();
210 }
211
213 inline bool QwtText::isEmpty() const
214 {
215 return text().isEmpty();
216 }
217
218 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
219 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
220
221 Q_DECLARE_METATYPE( QwtText )
222
223 #endif
QwtText::TextFormat
TextFormat
Text format.
Definition: qwt_text.h:64
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtText::MathMLText
Definition: qwt_text.h:88
QwtText::PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition: qwt_text.h:75
QwtText::isNull
bool isNull() const
Definition: qwt_text.h:207
QwtText::isEmpty
bool isEmpty() const
Definition: qwt_text.h:213
QwtText::LayoutAttributes
QFlags< LayoutAttribute > LayoutAttributes
Layout attributes.
Definition: qwt_text.h:140
QwtText::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
Definition: qwt_text.h:122
QwtText::TeXText
Definition: qwt_text.h:94
QwtText::LayoutAttribute
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text...
Definition: qwt_text.h:128
QwtTextEngine
Abstract base class for rendering text strings.
Definition: qwt_text_engine.h:35
QwtText::RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition: qwt_text.h:78
QwtText::PaintAttribute
PaintAttribute
Paint Attributes.
Definition: qwt_text.h:109