diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2009-11-26 13:39:06 +0100 |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2009-11-26 14:27:45 +0100 |
commit | c290785d0f8e1ef7af4bdff683aab40b8ff33681 (patch) | |
tree | ed3ff2635d237ef9853cd940b39650fd41718661 /src/gui | |
parent | 19039afd151f2c2401659904b89968d302149493 (diff) |
move software cursor from QGraphicsSystemCursor into QGraphicsSystemSoftwareCursor
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qgraphicssystemcursor.cpp | 72 | ||||
-rw-r--r-- | src/gui/painting/qgraphicssystemcursor.h | 24 |
2 files changed, 5 insertions, 91 deletions
diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 3afaf4bfbc..022dc64c70 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -53,79 +53,9 @@ QT_BEGIN_NAMESPACE QPointer<QGraphicsSystemCursor> QGraphicsSystemCursor::instance = 0; QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) - :currentRect(QRect()), prevRect(QRect()), screen(scr) + : screen(scr) { - graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); instance = this; - setCursor(Qt::ArrowCursor); -} - -QGraphicsSystemCursor::~QGraphicsSystemCursor() -{ -} - -void QGraphicsSystemCursor::setCursor(Qt::CursorShape shape) -{ - graphic->set(shape); -} - -void QGraphicsSystemCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) -{ - graphic->set(data, mask, width, height, hotX, hotY); -} - -QRect QGraphicsSystemCursor::dirtyRect() -{ - if (!prevRect.isNull()) { - QRect rect = prevRect; - prevRect = QRect(); - return rect; - } - return QRect(); -} - -QRect QGraphicsSystemCursor::drawCursor(QPainter & painter) -{ - if (currentRect.isNull()) - return QRect(); - - prevRect = currentRect; - painter.drawImage(prevRect, *graphic->image()); - return prevRect; -} - -QRect QGraphicsSystemCursor::getCurrentRect() -{ - QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), - -graphic->hotspot().y()); - rect.translate(QCursor::pos()); - return rect; -} - -void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e) -{ - Q_UNUSED(e); - currentRect = getCurrentRect(); - screen->setDirty(currentRect); -} - -void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) -{ - Q_UNUSED(widget); - Qt::CursorShape shape = widgetCursor->shape(); - - if (shape == Qt::BitmapCursor) { - // application supplied cursor - const QBitmap * map = widgetCursor->bitmap(); - const QBitmap * mask = widgetCursor->mask(); - QPoint spot = widgetCursor->hotSpot(); - setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); - } else { - // system cursor - setCursor(shape); - } - currentRect = getCurrentRect(); - screen->setDirty(currentRect); } // End of display and pointer event handling code diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index d385ac0f64..42727a828a 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE // Cursor graphics management -class QGraphicsSystemCursorImage { +class Q_GUI_EXPORT QGraphicsSystemCursorImage { public: QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) { set(data, mask, width, height, hotX, hotY); } @@ -68,33 +68,17 @@ private: class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { public: QGraphicsSystemCursor(QGraphicsSystemScreen *); - virtual ~QGraphicsSystemCursor(); // input methods - virtual void pointerEvent(const QMouseEvent & event); - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); - - // output methods - virtual QRect drawCursor(QPainter &); - virtual QRect dirtyRect(); + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; static QPointer<QGraphicsSystemCursor> getInstance() { return instance; } protected: - static QPointer<QGraphicsSystemCursor> instance; - - QRect currentRect; // next place to draw the cursor - QRect prevRect; // last place the cursor was drawn + static QPointer<QGraphicsSystemCursor> instance; // limit 1 cursor at a time QGraphicsSystemScreen * screen; // Where to request an update - - QGraphicsSystemCursorImage * graphic; - -private: - - void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void setCursor(Qt::CursorShape shape); - QRect getCurrentRect(); }; QT_END_NAMESPACE |