qwt_text_engine.h
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_TEXT_ENGINE_H
#define QWT_TEXT_ENGINE_H
#include "qwt_global.h"
#include <qsize.h>
class QFont;
class QRectF;
class QString;
class QPainter;
class QWT_EXPORT QwtTextEngine
{
public:
virtual ~QwtTextEngine();
virtual double heightForWidth( const QFont& font, int flags,
const QString& text, double width ) const = 0;
virtual QSizeF textSize( const QFont& font, int flags,
const QString& text ) const = 0;
virtual bool mightRender( const QString& text ) const = 0;
virtual void textMargins( const QFont& font, const QString& text,
double& left, double& right, double& top, double& bottom ) const = 0;
virtual void draw( QPainter* painter, const QRectF& rect,
int flags, const QString& text ) const = 0;
protected:
QwtTextEngine();
private:
Q_DISABLE_COPY(QwtTextEngine)
};
class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine
{
public:
QwtPlainTextEngine();
virtual ~QwtPlainTextEngine();
virtual double heightForWidth( const QFont& font, int flags,
const QString& text, double width ) const QWT_OVERRIDE;
virtual QSizeF textSize( const QFont& font, int flags,
const QString& text ) const QWT_OVERRIDE;
virtual void draw( QPainter*, const QRectF& rect,
int flags, const QString& text ) const QWT_OVERRIDE;
virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
virtual void textMargins(
const QFont&, const QString&,
double& left, double& right,
double& top, double& bottom ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
#ifndef QT_NO_RICHTEXT
class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine
{
public:
QwtRichTextEngine();
virtual double heightForWidth( const QFont& font, int flags,
const QString& text, double width ) const QWT_OVERRIDE;
virtual QSizeF textSize( const QFont& font, int flags,
const QString& text ) const QWT_OVERRIDE;
virtual void draw( QPainter*, const QRectF& rect,
int flags, const QString& text ) const QWT_OVERRIDE;
virtual bool mightRender( const QString& ) const QWT_OVERRIDE;
virtual void textMargins(
const QFont&, const QString&,
double& left, double& right,
double& top, double& bottom ) const QWT_OVERRIDE;
private:
QString taggedText( const QString&, int flags ) const;
};
#endif // !QT_NO_RICHTEXT
#endif
QwtPlainTextEngine
A text engine for plain texts.
Definition: qwt_text_engine.h:112
QwtRichTextEngine
A text engine for Qt rich texts.
Definition: qwt_text_engine.h:148
QwtTextEngine
Abstract base class for rendering text strings.
Definition: qwt_text_engine.h:31
QwtTextEngine::textMargins
virtual void textMargins(const QFont &font, const QString &text, double &left, double &right, double &top, double &bottom) const =0
QwtTextEngine::mightRender
virtual bool mightRender(const QString &text) const =0
QwtTextEngine::draw
virtual void draw(QPainter *painter, const QRectF &rect, int flags, const QString &text) const =0
QwtTextEngine::textSize
virtual QSizeF textSize(const QFont &font, int flags, const QString &text) const =0
QwtTextEngine::heightForWidth
virtual double heightForWidth(const QFont &font, int flags, const QString &text, double width) const =0