Qwt User's Guide: qwt_text.h Source File

Qwt User's Guide 6.0.1

- Main Page
- Related Pages
- Classes
- Files

- File List

# 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 #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
    00062     enum TextFormat
    00063     {
    00070         AutoText = 0,
    00071
    00073         PlainText,
    00074
    00076         RichText,
    00077
    00086         MathMLText,
    00087
    00092         TeXText,
    00093
    00098         OtherFormat = 100
    00099     };
    00100
    00107     enum PaintAttribute
    00108     {
    00110         PaintUsingTextFont = 0x01,
    00111
    00113         PaintUsingTextColor = 0x02,
    00114
    00116         PaintBackground = 0x04
    00117     };
    00118
    00120     typedef QFlags<PaintAttribute> PaintAttributes;
    00121
    00126     enum LayoutAttribute
    00127     {
    00134         MinimumLayout = 0x01
    00135     };
    00136
    00138     typedef QFlags<LayoutAttribute> LayoutAttributes;
    00139
    00140     QwtText( const QString & = QString::null,
    00141              TextFormat textFormat = AutoText );
    00142     QwtText( const QwtText & );
    00143     ~QwtText();
    00144
    00145     QwtText &operator=( const QwtText & );
    00146
    00147     bool operator==( const QwtText & ) const;
    00148     bool operator!=( const QwtText & ) const;
    00149
    00150     void setText( const QString &,
    00151         QwtText::TextFormat textFormat = AutoText );
    00152     QString text() const;
    00153
    00154     bool isNull() const;
    00155     bool isEmpty() const;
    00156
    00157     void setFont( const QFont & );
    00158     QFont font() const;
    00159
    00160     QFont usedFont( const QFont & ) const;
    00161
    00162     void setRenderFlags( int flags );
    00163     int renderFlags() const;
    00164
    00165     void setColor( const QColor & );
    00166     QColor color() const;
    00167
    00168     QColor usedColor( const QColor & ) const;
    00169
    00170     void setBackgroundPen( const QPen & );
    00171     QPen backgroundPen() const;
    00172
    00173     void setBackgroundBrush( const QBrush & );
    00174     QBrush backgroundBrush() const;
    00175
    00176     void setPaintAttribute( PaintAttribute, bool on = true );
    00177     bool testPaintAttribute( PaintAttribute ) const;
    00178
    00179     void setLayoutAttribute( LayoutAttribute, bool on = true );
    00180     bool testLayoutAttribute( LayoutAttribute ) const;
    00181
    00182     double heightForWidth( double width, const QFont & = QFont() ) const;
    00183     QSizeF textSize( const QFont & = QFont() ) const;
    00184
    00185     void draw( QPainter *painter, const QRectF &rect ) const;
    00186
    00187     static const QwtTextEngine *textEngine(
    00188         const QString &text, QwtText::TextFormat = AutoText );
    00189
    00190     static const QwtTextEngine *textEngine( QwtText::TextFormat );
    00191     static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
    00192
    00193 private:
    00194     class PrivateData;
    00195     PrivateData *d_data;
    00196
    00197     class LayoutCache;
    00198     LayoutCache *d_layoutCache;
    00199 };
    00200
    00202 inline bool QwtText::isNull() const
    00203 {
    00204     return text().isNull();
    00205 }
    00206
    00208 inline bool QwtText::isEmpty() const
    00209 {
    00210     return text().isEmpty();
    00211 }
    00212
    00213 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
    00214 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
    00215
    00216 #endif