qcontext2dcanvas.h Example File
script/context2d/qcontext2dcanvas.h
#ifndef QCONTEXT2DCANVAS_H
#define QCONTEXT2DCANVAS_H
#include <qscriptengine.h>
#include <qscriptcontext.h>
#include <qscriptvalue.h>
#include <QWidget>
class QPaintEvent;
class QResizeEvent;
class QMouseEvent;
class QKeyEvent;
class Environment;
class Context2D;
class QContext2DCanvas : public QWidget
{
Q_OBJECT
public:
QContext2DCanvas(Context2D *context, Environment *env, QWidget *parent = 0);
~QContext2DCanvas();
Context2D *context() const;
void reset();
public slots:
QScriptValue getContext(const QString &str);
void resize(int width, int height);
void addEventListener(const QString &type, const QScriptValue &listener,
bool useCapture);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual void keyReleaseEvent(QKeyEvent *e);
virtual void resizeEvent(QResizeEvent *e);
private slots:
void contentsChanged(const QImage &image);
private:
Context2D *m_context;
Environment *m_env;
QImage m_image;
};
#endif