Qwt User's Guide: qwt_text.h Source File

Qwt User's Guide 5.2.3

- 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 // 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
20 class QColor;
21 class QPen;
22 class QBrush;
23 class QRect;
24 class QPainter;
25 class QwtTextEngine;
26
51 class QWT_EXPORT QwtText
52 {
53 public:
54
85 enum TextFormat
86 {
87 AutoText = 0,
88
89 PlainText,
90 RichText,
91
92 MathMLText,
93 TeXText,
94
95 OtherFormat = 100
96 };
97
111 enum PaintAttribute
112 {
113 PaintUsingTextFont = 1,
114 PaintUsingTextColor = 2,
115 PaintBackground = 4
116 };
117
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
187 private:
188 class PrivateData;
189 PrivateData *d_data;
190
191 class LayoutCache;
192 LayoutCache *d_layoutCache;
193 };
194
196 inline bool QwtText::isNull() const
197 {
198 return text().isNull();
199 }
200
202 inline bool QwtText::isEmpty() const
203 {
204 return text().isEmpty();
205 }
206
207 #endif