00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_TEXT_H
00011 #define QWT_TEXT_H
00012
00013 #include "qwt_global.h"
00014 #include <qstring.h>
00015 #include <qsize.h>
00016 #include <qfont.h>
00017
00018 class QColor;
00019 class QPen;
00020 class QBrush;
00021 class QRectF;
00022 class QPainter;
00023 class QwtTextEngine;
00024
00049 class QWT_EXPORT QwtText
00050 {
00051 public:
00052
00083 enum TextFormat
00084 {
00085 AutoText = 0,
00086
00087 PlainText,
00088 RichText,
00089
00090 MathMLText,
00091 TeXText,
00092
00093 OtherFormat = 100
00094 };
00095
00109 enum PaintAttribute
00110 {
00111 PaintUsingTextFont = 1,
00112 PaintUsingTextColor = 2,
00113 PaintBackground = 4
00114 };
00115
00127 enum LayoutAttribute
00128 {
00129 MinimumLayout = 1
00130 };
00131
00132 QwtText(const QString & = QString::null,
00133 TextFormat textFormat = AutoText);
00134 QwtText(const QwtText &);
00135 ~QwtText();
00136
00137 QwtText &operator=(const QwtText &);
00138
00139 int operator==(const QwtText &) const;
00140 int operator!=(const QwtText &) const;
00141
00142 void setText(const QString &,
00143 QwtText::TextFormat textFormat = AutoText);
00144 QString text() const;
00145
00146 bool isNull() const;
00147 bool isEmpty() const;
00148
00149 void setFont(const QFont &);
00150 QFont font() const;
00151
00152 QFont usedFont(const QFont &) const;
00153
00154 void setRenderFlags(int flags);
00155 int renderFlags() const;
00156
00157 void setColor(const QColor &);
00158 QColor color() const;
00159
00160 QColor usedColor(const QColor &) const;
00161
00162 void setBackgroundPen(const QPen &);
00163 QPen backgroundPen() const;
00164
00165 void setBackgroundBrush(const QBrush &);
00166 QBrush backgroundBrush() const;
00167
00168 void setPaintAttribute(PaintAttribute, bool on = true);
00169 bool testPaintAttribute(PaintAttribute) const;
00170
00171 void setLayoutAttribute(LayoutAttribute, bool on = true);
00172 bool testLayoutAttribute(LayoutAttribute) const;
00173
00174 int heightForWidth(int width, const QFont & = QFont()) const;
00175 QSize textSize(const QFont & = QFont()) const;
00176
00177 void draw(QPainter *painter, const QRectF &rect) const;
00178
00179 static const QwtTextEngine *textEngine(const QString &text,
00180 QwtText::TextFormat = AutoText);
00181
00182 static const QwtTextEngine *textEngine(QwtText::TextFormat);
00183 static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
00184
00185 private:
00186 class PrivateData;
00187 PrivateData *d_data;
00188
00189 class LayoutCache;
00190 LayoutCache *d_layoutCache;
00191 };
00192
00194 inline bool QwtText::isNull() const
00195 {
00196 return text().isNull();
00197 }
00198
00200 inline bool QwtText::isEmpty() const
00201 {
00202 return text().isEmpty();
00203 }
00204
00205 #endif