Qwt User's Guide 5.2.2

qwt_text.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2003   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 // vim: expandtab
00011 
00012 #ifndef QWT_TEXT_H
00013 #define QWT_TEXT_H
00014 
00015 #include <qstring.h>
00016 #include <qsize.h>
00017 #include <qfont.h>
00018 #include "qwt_global.h"
00019 
00020 class QColor;
00021 class QPen;
00022 class QBrush;
00023 class QRect;
00024 class QPainter;
00025 class QwtTextEngine;
00026 
00051 class QWT_EXPORT QwtText
00052 {
00053 public:
00054 
00085     enum TextFormat
00086     {
00087         AutoText = 0,
00088         
00089         PlainText,
00090         RichText,
00091 
00092         MathMLText,
00093         TeXText,
00094 
00095         OtherFormat = 100
00096     };
00097 
00111     enum PaintAttribute
00112     {
00113         PaintUsingTextFont = 1,
00114         PaintUsingTextColor = 2,
00115         PaintBackground = 4
00116     };
00117 
00129     enum LayoutAttribute
00130     {
00131         MinimumLayout = 1
00132     };
00133 
00134     QwtText(const QString & = QString::null, 
00135         TextFormat textFormat = AutoText);
00136     QwtText(const QwtText &);
00137     ~QwtText();
00138 
00139     QwtText &operator=(const QwtText &);
00140 
00141     int operator==(const QwtText &) const;
00142     int operator!=(const QwtText &) const;
00143 
00144     void setText(const QString &, 
00145         QwtText::TextFormat textFormat = AutoText);
00146     QString text() const;
00147 
00148     bool isNull() const;
00149     bool isEmpty() const;
00150 
00151     void setFont(const QFont &);
00152     QFont font() const;
00153 
00154     QFont usedFont(const QFont &) const;
00155 
00156     void setRenderFlags(int flags);
00157     int renderFlags() const;
00158 
00159     void setColor(const QColor &);
00160     QColor color() const;
00161 
00162     QColor usedColor(const QColor &) const;
00163 
00164     void setBackgroundPen(const QPen &);
00165     QPen backgroundPen() const;
00166 
00167     void setBackgroundBrush(const QBrush &);
00168     QBrush backgroundBrush() const;
00169 
00170     void setPaintAttribute(PaintAttribute, bool on = true);
00171     bool testPaintAttribute(PaintAttribute) const;
00172 
00173     void setLayoutAttribute(LayoutAttribute, bool on = true);
00174     bool testLayoutAttribute(LayoutAttribute) const;
00175 
00176     int heightForWidth(int width, const QFont & = QFont()) const;
00177     QSize textSize(const QFont & = QFont()) const;
00178 
00179     void draw(QPainter *painter, const QRect &rect) const;
00180 
00181     static const QwtTextEngine *textEngine(const QString &text,
00182         QwtText::TextFormat = AutoText);
00183 
00184     static const QwtTextEngine *textEngine(QwtText::TextFormat);
00185     static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
00186 
00187 private:
00188     class PrivateData;
00189     PrivateData *d_data;
00190 
00191     class LayoutCache;
00192     LayoutCache *d_layoutCache;
00193 };
00194 
00196 inline bool QwtText::isNull() const 
00197 { 
00198     return text().isNull(); 
00199 }
00200 
00202 inline bool QwtText::isEmpty() const 
00203 { 
00204     return text().isEmpty(); 
00205 }
00206 
00207 #endif