# 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 // vim: expandtab
    00011
    00012 #ifndef QWT_TEXT_ENGINE_H
    00013 #define QWT_TEXT_ENGINE_H 1
    00014
    00015 #include <qsize.h>
    00016 #include "qwt_global.h"
    00017
    00018 class QFont;
    00019 class QRect;
    00020 class QString;
    00021 class QPainter;
    00022
    00038 class QWT_EXPORT QwtTextEngine
    00039 {
    00040 public:
    00041     virtual ~QwtTextEngine();
    00042
    00053     virtual int heightForWidth(const QFont &font, int flags,
    00054         const QString &text, int width) const = 0;
    00055
    00065     virtual QSize textSize(const QFont &font, int flags,
    00066         const QString &text) const = 0;
    00067
    00074     virtual bool mightRender(const QString &text) const = 0;
    00075
    00091     virtual void textMargins(const QFont &font, const QString &text,
    00092         int &left, int &right, int &top, int &bottom) const = 0;
    00093
    00102     virtual void draw(QPainter *painter, const QRect &rect,
    00103         int flags, const QString &text) const = 0;
    00104
    00105 protected:
    00106     QwtTextEngine();
    00107 };
    00108
    00109
    00116 class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
    00117 {
    00118 public:
    00119     QwtPlainTextEngine();
    00120     virtual ~QwtPlainTextEngine();
    00121
    00122     virtual int heightForWidth(const QFont &font, int flags,
    00123         const QString &text, int width) const;
    00124
    00125     virtual QSize textSize(const QFont &font, int flags,
    00126         const QString &text) const;
    00127
    00128     virtual void draw(QPainter *painter, const QRect &rect,
    00129         int flags, const QString &text) const;
    00130
    00131     virtual bool mightRender(const QString &) const;
    00132
    00133     virtual void textMargins(const QFont &, const QString &,
    00134         int &left, int &right, int &top, int &bottom) const;
    00135
    00136 private:
    00137     class PrivateData;
    00138     PrivateData *d_data;
    00139 };
    00140
    00141
    00142 #ifndef QT_NO_RICHTEXT
    00143
    00150 class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
    00151 {
    00152 public:
    00153     QwtRichTextEngine();
    00154
    00155     virtual int heightForWidth(const QFont &font, int flags,
    00156         const QString &text, int width) const;
    00157
    00158     virtual QSize textSize(const QFont &font, int flags,
    00159         const QString &text) const;
    00160
    00161     virtual void draw(QPainter *painter, const QRect &rect,
    00162         int flags, const QString &text) const;
    00163
    00164     virtual bool mightRender(const QString &) const;
    00165
    00166     virtual void textMargins(const QFont &, const QString &,
    00167         int &left, int &right, int &top, int &bottom) const;
    00168 private:
    00169     QString taggedText(const QString &, int flags) const;
    00170 };
    00171
    00172 #endif // !QT_NO_RICHTEXT
    00173
    00174 #endif