Qwt User's Guide: qwt_text.h Source File

- Main Page
- Classes
- Files
- Related Pages

# 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
    00149     inline bool isNull() const { return text().isNull(); }
    00150
    00152     inline bool isEmpty() const { return text().isEmpty(); }
    00153
    00154     void setFont(const QFont &);
    00155     QFont font() const;
    00156
    00157     QFont usedFont(const QFont &) const;
    00158
    00159     void setRenderFlags(int flags);
    00160     int renderFlags() const;
    00161
    00162     void setColor(const QColor &);
    00163     QColor color() const;
    00164
    00165     QColor usedColor(const QColor &) const;
    00166
    00167     void setBackgroundPen(const QPen &);
    00168     QPen backgroundPen() const;
    00169
    00170     void setBackgroundBrush(const QBrush &);
    00171     QBrush backgroundBrush() const;
    00172
    00173     void setPaintAttribute(PaintAttribute, bool on = true);
    00174     bool testPaintAttribute(PaintAttribute) const;
    00175
    00176     void setLayoutAttribute(LayoutAttribute, bool on = true);
    00177     bool testLayoutAttribute(LayoutAttribute) const;
    00178
    00179     int heightForWidth(int width, const QFont & = QFont()) const;
    00180     QSize textSize(const QFont & = QFont()) const;
    00181
    00182     void draw(QPainter *painter, const QRect &rect) const;
    00183
    00184     static const QwtTextEngine *textEngine(const QString &text,
    00185         QwtText::TextFormat = AutoText);
    00186
    00187     static const QwtTextEngine *textEngine(QwtText::TextFormat);
    00188     static void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
    00189
    00190 private:
    00191     class PrivateData;
    00192     PrivateData *d_data;
    00193
    00194     class LayoutCache;
    00195     LayoutCache *d_layoutCache;
    00196 };
    00197
    00198 #endif