/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the 
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGRAPHICSSYSTEMCURSOR_H
#define QGRAPHICSSYSTEMCURSOR_H

#include <QtCore/QList>
#include <QtGui/QImage>
#include <QtGui/QMouseEvent>
#include <QtCore/QWeakPointer>
#include <QtCore/QObject>
#include <QtGui/QPlatformScreen>
#include <QtGui/QCursor>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Gui)

// Cursor graphics management
class Q_GUI_EXPORT QPlatformCursorImage {
public:
    QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
    { set(data, mask, width, height, hotX, hotY); }
    QImage * image() { return &cursorImage; }
    QPoint hotspot() { return hot; }
    void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
    void set(const QImage &image, int hx, int hy);
    void set(Qt::CursorShape);
private:
    static void createSystemCursor(int id);
    QImage cursorImage;
    QPoint hot;
};

class QPlatformCursor;

class QPlatformCursorPrivate {
public:
    static QList<QWeakPointer<QPlatformCursor> > getInstances() { return instances; }
    static QList<QWeakPointer<QPlatformCursor> > instances;
};

class Q_GUI_EXPORT QPlatformCursor : public QObject {
public:
    QPlatformCursor(QPlatformScreen *);

    // input methods
    virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
    virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0;
    virtual QPoint pos() const;
    virtual void setPos(const QPoint &pos);

protected:
    QPlatformScreen* screen;  // Where to request an update

private:
    Q_DECLARE_PRIVATE(QPlatformCursor);
    friend void qt_qpa_set_cursor(QWidget * w, bool force);
    friend class QApplicationPrivate;
};

QT_END_NAMESPACE

QT_END_HEADER

#endif // QGRAPHICSSYSTEMCURSOR_H
