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
00090 enum TextFormat
00091 {
00092 AutoText = 0,
00093
00094 PlainText,
00095 RichText,
00096
00097 MathMLText,
00098 TeXText,
00099
00100 OtherFormat = 100
00101 };
00102
00116 enum PaintAttribute
00117 {
00118 PaintUsingTextFont = 1,
00119 PaintUsingTextColor = 2,
00120 PaintBackground = 4
00121 };
00122
00134 enum LayoutAttribute
00135 {
00136 MinimumLayout = 1
00137 };
00138
00139 QwtText( const QString & = QString::null,
00140 TextFormat textFormat = AutoText );
00141 QwtText( const QwtText & );
00142 ~QwtText();
00143
00144 QwtText &operator=( const QwtText & );
00145
00146 bool operator==( const QwtText & ) const;
00147 bool operator!=( const QwtText & ) const;
00148
00149 void setText( const QString &,
00150 QwtText::TextFormat textFormat = AutoText );
00151 QString text() const;
00152
00153 bool isNull() const;
00154 bool isEmpty() const;
00155
00156 void setFont( const QFont & );
00157 QFont font() const;
00158
00159 QFont usedFont( const QFont & ) const;
00160
00161 void setRenderFlags( int flags );
00162 int renderFlags() const;
00163
00164 void setColor( const QColor & );
00165 QColor color() const;
00166
00167 QColor usedColor( const QColor & ) const;
00168
00169 void setBackgroundPen( const QPen & );
00170 QPen backgroundPen() const;
00171
00172 void setBackgroundBrush( const QBrush & );
00173 QBrush backgroundBrush() const;
00174
00175 void setPaintAttribute( PaintAttribute, bool on = true );
00176 bool testPaintAttribute( PaintAttribute ) const;
00177
00178 void setLayoutAttribute( LayoutAttribute, bool on = true );
00179 bool testLayoutAttribute( LayoutAttribute ) const;
00180
00181 double heightForWidth( double width, const QFont & = QFont() ) const;
00182 QSizeF textSize( const QFont & = QFont() ) const;
00183
00184 void draw( QPainter *painter, const QRectF &rect ) const;
00185
00186 static const QwtTextEngine *textEngine(
00187 const QString &text, QwtText::TextFormat = AutoText );
00188
00189 static const QwtTextEngine *textEngine( QwtText::TextFormat );
00190 static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
00191
00192 private:
00193 class PrivateData;
00194 PrivateData *d_data;
00195
00196 class LayoutCache;
00197 LayoutCache *d_layoutCache;
00198 };
00199
00201 inline bool QwtText::isNull() const
00202 {
00203 return text().isNull();
00204 }
00205
00207 inline bool QwtText::isEmpty() const
00208 {
00209 return text().isEmpty();
00210 }
00211
00212 #endif