summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/qt/CursorQt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/qt/CursorQt.cpp')
-rw-r--r--WebCore/platform/qt/CursorQt.cpp444
1 files changed, 141 insertions, 303 deletions
diff --git a/WebCore/platform/qt/CursorQt.cpp b/WebCore/platform/qt/CursorQt.cpp
index 6017daa..227b80c 100644
--- a/WebCore/platform/qt/CursorQt.cpp
+++ b/WebCore/platform/qt/CursorQt.cpp
@@ -3,6 +3,7 @@
* Copyright (C) 2006 George Staikos <staikos@kde.org>
* Copyright (C) 2006 Charles Samuels <charles@kde.org>
* Copyright (C) 2008, 2009 Holger Hans Peter Freyther
+ * Copyright (C) 2010 University of Szeged
*
* All rights reserved.
*
@@ -43,329 +44,166 @@
namespace WebCore {
-Cursor::Cursor(PlatformCursor p)
- : m_platformCursor(p)
-{
-}
-
Cursor::Cursor(const Cursor& other)
- : m_platformCursor(other.m_platformCursor)
+ : m_type(other.m_type)
+ , m_image(other.m_image)
+ , m_hotSpot(other.m_hotSpot)
+#ifndef QT_NO_CURSOR
+ , m_platformCursor(other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0)
+#endif
{
}
Cursor::~Cursor()
{
-}
-
-Cursor::Cursor(Image* image, const IntPoint& hotSpot)
-{
#ifndef QT_NO_CURSOR
- IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
- m_platformCursor = QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
+ delete m_platformCursor;
#endif
}
Cursor& Cursor::operator=(const Cursor& other)
{
- m_platformCursor = other.m_platformCursor;
- return *this;
-}
-
-namespace {
-
-// FIXME: static deleter
-class Cursors : public Noncopyable {
-protected:
- Cursors()
+ m_type = other.m_type;
+ m_image = other.m_image;
+ m_hotSpot = other.m_hotSpot;
#ifndef QT_NO_CURSOR
- : CrossCursor(Qt::CrossCursor)
- , MoveCursor(Qt::SizeAllCursor)
- , PointerCursor(Qt::ArrowCursor)
- , PointingHandCursor(Qt::PointingHandCursor)
- , IBeamCursor(Qt::IBeamCursor)
- , WaitCursor(Qt::WaitCursor)
- , WhatsThisCursor(Qt::WhatsThisCursor)
- , SizeHorCursor(Qt::SizeHorCursor)
- , SizeVerCursor(Qt::SizeVerCursor)
- , SizeFDiagCursor(Qt::SizeFDiagCursor)
- , SizeBDiagCursor(Qt::SizeBDiagCursor)
- , SplitHCursor(Qt::SplitHCursor)
- , SplitVCursor(Qt::SplitVCursor)
- , NoDropCursor(Qt::ForbiddenCursor)
- , BlankCursor(Qt::BlankCursor)
- , ZoomInCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")), 7, 7))
- , ZoomOutCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")), 7, 7))
- , VerticalTextCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")), 7, 7))
- , CellCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")), 7, 7))
- , ContextMenuCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")), 3, 2))
- , CopyCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")), 3, 2))
- , ProgressCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")), 3, 2))
- , AliasCursor(QCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")), 11, 3))
-
+ m_platformCursor = other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0;
#endif
- {
- }
-
- ~Cursors()
- {
- }
-
-public:
- static Cursors* self();
- static Cursors* s_self;
-
- Cursor CrossCursor;
- Cursor MoveCursor;
- Cursor PointerCursor;
- Cursor PointingHandCursor;
- Cursor IBeamCursor;
- Cursor WaitCursor;
- Cursor WhatsThisCursor;
- Cursor SizeHorCursor;
- Cursor SizeVerCursor;
- Cursor SizeFDiagCursor;
- Cursor SizeBDiagCursor;
- Cursor SplitHCursor;
- Cursor SplitVCursor;
- Cursor NoDropCursor;
- Cursor BlankCursor;
- Cursor ZoomInCursor;
- Cursor ZoomOutCursor;
- Cursor VerticalTextCursor;
- Cursor CellCursor;
- Cursor ContextMenuCursor;
- Cursor CopyCursor;
- Cursor ProgressCursor;
- Cursor AliasCursor;
-};
-
-Cursors* Cursors::s_self = 0;
-
-Cursors* Cursors::self()
-{
- if (!s_self)
- s_self = new Cursors();
-
- return s_self;
-}
-
-}
-
-const Cursor& pointerCursor()
-{
- return Cursors::self()->PointerCursor;
-}
-
-const Cursor& moveCursor()
-{
- return Cursors::self()->MoveCursor;
-}
-
-const Cursor& crossCursor()
-{
- return Cursors::self()->CrossCursor;
-}
-
-const Cursor& handCursor()
-{
- return Cursors::self()->PointingHandCursor;
-}
-
-const Cursor& iBeamCursor()
-{
- return Cursors::self()->IBeamCursor;
-}
-
-const Cursor& waitCursor()
-{
- return Cursors::self()->WaitCursor;
-}
-
-const Cursor& helpCursor()
-{
- return Cursors::self()->WhatsThisCursor;
-}
-
-const Cursor& eastResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& northEastResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& northWestResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& southResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& southEastResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& southWestResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& westResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& columnResizeCursor()
-{
- return Cursors::self()->SplitHCursor;
-}
-
-const Cursor& rowResizeCursor()
-{
- return Cursors::self()->SplitVCursor;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-const Cursor& verticalTextCursor()
-{
- return Cursors::self()->VerticalTextCursor;
-}
-
-const Cursor& cellCursor()
-{
- return Cursors::self()->CellCursor;
-}
-
-const Cursor& contextMenuCursor()
-{
- return Cursors::self()->ContextMenuCursor;
-}
-
-const Cursor& noDropCursor()
-{
- return Cursors::self()->NoDropCursor;
-}
-
-const Cursor& copyCursor()
-{
- return Cursors::self()->CopyCursor;
-}
-
-const Cursor& progressCursor()
-{
- return Cursors::self()->ProgressCursor;
-}
-
-const Cursor& aliasCursor()
-{
- return Cursors::self()->AliasCursor;
-}
-
-const Cursor& noneCursor()
-{
- return Cursors::self()->BlankCursor;
-}
-
-const Cursor& notAllowedCursor()
-{
- return Cursors::self()->NoDropCursor;
-}
-
-const Cursor& zoomInCursor()
-{
- return Cursors::self()->ZoomInCursor;
-}
-
-const Cursor& zoomOutCursor()
-{
- return Cursors::self()->ZoomOutCursor;
+ return *this;
}
-const Cursor& grabCursor()
+static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
{
- notImplemented();
- return Cursors::self()->PointerCursor;
+#ifndef QT_NO_CURSOR
+ IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
+ return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
+#else
+ return 0;
+#endif
}
-const Cursor& grabbingCursor()
+void Cursor::ensurePlatformCursor() const
{
- notImplemented();
- return Cursors::self()->PointerCursor;
+#ifndef QT_NO_CURSOR
+ if (m_platformCursor)
+ return;
+
+ switch (m_type) {
+ case Pointer:
+ m_platformCursor = new QCursor(Qt::ArrowCursor);
+ break;
+ case Cross:
+ m_platformCursor = new QCursor(Qt::CrossCursor);
+ break;
+ case Hand:
+ m_platformCursor = new QCursor(Qt::PointingHandCursor);
+ break;
+ case IBeam:
+ m_platformCursor = new QCursor(Qt::IBeamCursor);
+ break;
+ case Wait:
+ m_platformCursor = new QCursor(Qt::WaitCursor);
+ break;
+ case Help:
+ m_platformCursor = new QCursor(Qt::WhatsThisCursor);
+ break;
+ case EastResize:
+ case EastPanning:
+ m_platformCursor = new QCursor(Qt::SizeHorCursor);
+ break;
+ case NorthResize:
+ case NorthPanning:
+ m_platformCursor = new QCursor(Qt::SizeVerCursor);
+ break;
+ case NorthEastResize:
+ case NorthEastPanning:
+ m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
+ break;
+ case NorthWestResize:
+ case NorthWestPanning:
+ m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
+ break;
+ case SouthResize:
+ case SouthPanning:
+ m_platformCursor = new QCursor(Qt::SizeVerCursor);
+ break;
+ case SouthEastResize:
+ case SouthEastPanning:
+ m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
+ break;
+ case SouthWestResize:
+ case SouthWestPanning:
+ m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
+ break;
+ case WestResize:
+ case WestPanning:
+ m_platformCursor = new QCursor(Qt::SizeHorCursor);
+ break;
+ case NorthSouthResize:
+ m_platformCursor = new QCursor(Qt::SizeVerCursor);
+ break;
+ case EastWestResize:
+ m_platformCursor = new QCursor(Qt::SizeHorCursor);
+ break;
+ case NorthEastSouthWestResize:
+ m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
+ break;
+ case NorthWestSouthEastResize:
+ m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
+ break;
+ case ColumnResize:
+ m_platformCursor = new QCursor(Qt::SplitHCursor);
+ break;
+ case RowResize:
+ m_platformCursor = new QCursor(Qt::SplitVCursor);
+ break;
+ case MiddlePanning:
+ case Move:
+ m_platformCursor = new QCursor(Qt::SizeAllCursor);
+ break;
+ case None:
+ m_platformCursor = new QCursor(Qt::BlankCursor);
+ break;
+ case NoDrop:
+ case NotAllowed:
+ m_platformCursor = new QCursor(Qt::ForbiddenCursor);
+ break;
+ case Grab:
+ case Grabbing:
+ notImplemented();
+ m_platformCursor = new QCursor(Qt::ArrowCursor);
+ break;
+ case VerticalText:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")), 7, 7);
+ break;
+ case Cell:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")), 7, 7);
+ break;
+ case ContextMenu:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")), 3, 2);
+ break;
+ case Alias:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")), 11, 3);
+ break;
+ case Progress:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")), 3, 2);
+ break;
+ case Copy:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")), 3, 2);
+ break;
+ case ZoomIn:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")), 7, 7);
+ break;
+ case ZoomOut:
+ m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")), 7, 7);
+ break;
+ case Custom:
+ m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+#endif
}
}