Qwt User's Guide: qwt_text_engine.h Source File

Qwt User's Guide 6.0.1

- Main Page
- Related Pages
- Classes
- Files

- File List

# qwt_text_engine.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_ENGINE_H
    00011 #define QWT_TEXT_ENGINE_H 1
    00012
    00013 #include "qwt_global.h"
    00014 #include <qsize.h>
    00015
    00016 class QFont;
    00017 class QRectF;
    00018 class QString;
    00019 class QPainter;
    00020
    00035 class QWT_EXPORT QwtTextEngine
    00036 {
    00037 public:
    00038     virtual ~QwtTextEngine();
    00039
    00050     virtual double heightForWidth( const QFont &font, int flags,
    00051         const QString &text, double width ) const = 0;
    00052
    00062     virtual QSizeF textSize( const QFont &font, int flags,
    00063         const QString &text ) const = 0;
    00064
    00071     virtual bool mightRender( const QString &text ) const = 0;
    00072
    00088     virtual void textMargins( const QFont &font, const QString &text,
    00089         double &left, double &right, double &top, double &bottom ) const = 0;
    00090
    00099     virtual void draw( QPainter *painter, const QRectF &rect,
    00100         int flags, const QString &text ) const = 0;
    00101
    00102 protected:
    00103     QwtTextEngine();
    00104 };
    00105
    00106
    00113 class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
    00114 {
    00115 public:
    00116     QwtPlainTextEngine();
    00117     virtual ~QwtPlainTextEngine();
    00118
    00119     virtual double heightForWidth( const QFont &font, int flags,
    00120         const QString &text, double width ) const;
    00121
    00122     virtual QSizeF textSize( const QFont &font, int flags,
    00123         const QString &text ) const;
    00124
    00125     virtual void draw( QPainter *painter, const QRectF &rect,
    00126         int flags, const QString &text ) const;
    00127
    00128     virtual bool mightRender( const QString & ) const;
    00129
    00130     virtual void textMargins( const QFont &, const QString &,
    00131         double &left, double &right, double &top, double &bottom ) const;
    00132
    00133 private:
    00134     class PrivateData;
    00135     PrivateData *d_data;
    00136 };
    00137
    00138
    00139 #ifndef QT_NO_RICHTEXT
    00140
    00147 class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
    00148 {
    00149 public:
    00150     QwtRichTextEngine();
    00151
    00152     virtual double heightForWidth( const QFont &font, int flags,
    00153         const QString &text, double width ) const;
    00154
    00155     virtual QSizeF textSize( const QFont &font, int flags,
    00156         const QString &text ) const;
    00157
    00158     virtual void draw( QPainter *painter, const QRectF &rect,
    00159         int flags, const QString &text ) const;
    00160
    00161     virtual bool mightRender( const QString & ) const;
    00162
    00163     virtual void textMargins( const QFont &, const QString &,
    00164         double &left, double &right, double &top, double &bottom ) const;
    00165
    00166 private:
    00167     QString taggedText( const QString &, int flags ) const;
    00168 };
    00169
    00170 #endif // !QT_NO_RICHTEXT
    00171
    00172 #endif