#ifndef LURCHTEXTOBJECT_H
#define LURCHTEXTOBJECT_H
#include <QTextObjectInterface>
#include <QCache>
#include <QSvgRenderer>
#include "Interface.h"
#include "lob.h"
#include "texengine.h"
const int LTO_FORMAT_KEY = QTextFormat::UserProperty+0x010000;
class QtMmlWidget;
class QTextDocument;
class QTextFormat;
class QPainter;
class QRectF;
class QSizeF;
class LurchEnvironment;
class LurchTextObject : public QObject, public QTextObjectInterface
{
Q_OBJECT
Q_INTERFACES( QTextObjectInterface )
public:
enum { FormatCode = QTextFormat::UserObject+0x0100 };
LurchTextObject ( QFont defaultFont );
~LurchTextObject ();
void setEnvironment ( LurchEnvironment* environment );
QSizeF intrinsicSize ( QTextDocument *doc, int posInDocument,
const QTextFormat &format );
void drawObject ( QPainter *painter, const QRectF &rect, QTextDocument *doc,
int posInDocument, const QTextFormat &format );
int descent ( const QTextFormat &format, int fullImageHeight = -1,
bool includeMagnificationFactor = true ); // in pixels
bool updateLobRepresentation ( const Lob& L, QTextDocument* document,
bool force = false );
void setMagnification ( qreal factor );
QString formatToHTML ( const QTextFormat& format );
signals:
// emitted when computation of a typeset math expression was queued for
// background processing, and thus not actually done yet. in such cases, an
// empty image is returned for use in the document, but this signal is
// emitted so that the application knows to check back soon for when the
// asynchronous typesetting is complete, to get the real typeset image.
void deferredTypesetting ();
private:
QString formatToString ( const QTextFormat& format, bool forceRecompute = false );
QPicture formatToPicture ( const QTextFormat& format );
blahtex::Interface blahi;
QtMmlWidget* mathRenderer;
LurchEnvironment* env;
qreal magFactor;
static QCache<QString,QPicture> cache;
static QMap<QString,float> percentBelowBaseline;
TeXEngine te;
QSvgRenderer* svgRenderer;
QFont documentFont;
int lastScaleFactor;
};
#endif // LURCHTEXTOBJECT_H