diff options
Diffstat (limited to 'shared/native_view_qt.h')
-rw-r--r-- | shared/native_view_qt.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/shared/native_view_qt.h b/shared/native_view_qt.h new file mode 100644 index 000000000..80bb24e87 --- /dev/null +++ b/shared/native_view_qt.h @@ -0,0 +1,97 @@ +#ifndef NATIVE_VIEW_QT_H +#define NATIVE_VIEW_QT_H + + +#include <QWidget> +#include <QQuickPaintedItem> + +class BackingStoreQt; +class QWindow; +class QQuickItem; +class QFocusEvent; +class QMouseEvent; +class QKeyEvent; +class QWheelEvent; + +namespace content { + class RenderWidgetHostViewQt; +} + +class NativeViewQt { +public: + virtual ~NativeViewQt() {} + virtual void setBackingStore(BackingStoreQt* backingStore) = 0; + virtual QRectF screenRect() const = 0; + virtual void show() = 0; + virtual void hide() = 0; + virtual bool isVisible() const = 0; + virtual QWindow* window() const = 0; + virtual void update() = 0; +}; + +class QWidgetNativeView : public QWidget, public NativeViewQt +{ +public: + QWidgetNativeView(content::RenderWidgetHostViewQt* view, QWidget *parent = 0); + + virtual void setBackingStore(BackingStoreQt* backingStore); + virtual QRectF screenRect() const; + virtual void show(); + virtual void hide(); + virtual bool isVisible() const; + virtual QWindow* window() const; + virtual void update(); + + QPainter* painter(); + +protected: + void paintEvent(QPaintEvent * event); + bool event(QEvent *event); + void resizeEvent(QResizeEvent *resizeEvent); + +private: + BackingStoreQt* m_backingStore; + QPainter* m_painter; + content::RenderWidgetHostViewQt *m_view; +}; + +class QQuickNativeView : public QQuickPaintedItem, public NativeViewQt +{ + Q_OBJECT +public: + QQuickNativeView(content::RenderWidgetHostViewQt* view, QQuickItem *parent = 0); + + virtual void setBackingStore(BackingStoreQt* backingStore); + virtual QRectF screenRect() const; + virtual void show(); + virtual void hide(); + virtual bool isVisible() const; + virtual QWindow* window() const; + virtual void update(); + + void paint(QPainter *painter); + void resize(int width, int height); + + void focusInEvent(QFocusEvent*); + void focusOutEvent(QFocusEvent*); + void mousePressEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + void keyPressEvent(QKeyEvent*); + void keyReleaseEvent(QKeyEvent*); + void wheelEvent(QWheelEvent*); + +protected Q_SLOTS: + void resizeBackingStore(); + +protected: + QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * data); + +private: + BackingStoreQt* m_backingStore; + content::RenderWidgetHostViewQt *m_view; + +}; + +#endif |