2 * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
3 * Copyright (C) 2006 George Staikos <staikos@kde.org>
4 * Copyright (C) 2006 Charles Samuels <charles@kde.org>
5 * Copyright (C) 2008, 2009 Holger Hans Peter Freyther
6 * Copyright (C) 2010 University of Szeged
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include "NotImplemented.h"
47 Cursor::Cursor(const Cursor& other)
48 : m_type(other.m_type)
49 , m_image(other.m_image)
50 , m_hotSpot(other.m_hotSpot)
52 , m_platformCursor(other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0)
60 delete m_platformCursor;
64 Cursor& Cursor::operator=(const Cursor& other)
66 m_type = other.m_type;
67 m_image = other.m_image;
68 m_hotSpot = other.m_hotSpot;
70 m_platformCursor = other.m_platformCursor ? new QCursor(*other.m_platformCursor) : 0;
76 static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
78 IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
79 return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
83 void Cursor::ensurePlatformCursor() const
91 m_platformCursor = new QCursor(Qt::ArrowCursor);
94 m_platformCursor = new QCursor(Qt::CrossCursor);
97 m_platformCursor = new QCursor(Qt::PointingHandCursor);
100 m_platformCursor = new QCursor(Qt::IBeamCursor);
103 m_platformCursor = new QCursor(Qt::WaitCursor);
106 m_platformCursor = new QCursor(Qt::WhatsThisCursor);
110 m_platformCursor = new QCursor(Qt::SizeHorCursor);
114 m_platformCursor = new QCursor(Qt::SizeVerCursor);
116 case NorthEastResize:
117 case NorthEastPanning:
118 m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
120 case NorthWestResize:
121 case NorthWestPanning:
122 m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
126 m_platformCursor = new QCursor(Qt::SizeVerCursor);
128 case SouthEastResize:
129 case SouthEastPanning:
130 m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
132 case SouthWestResize:
133 case SouthWestPanning:
134 m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
138 m_platformCursor = new QCursor(Qt::SizeHorCursor);
140 case NorthSouthResize:
141 m_platformCursor = new QCursor(Qt::SizeVerCursor);
144 m_platformCursor = new QCursor(Qt::SizeHorCursor);
146 case NorthEastSouthWestResize:
147 m_platformCursor = new QCursor(Qt::SizeBDiagCursor);
149 case NorthWestSouthEastResize:
150 m_platformCursor = new QCursor(Qt::SizeFDiagCursor);
153 m_platformCursor = new QCursor(Qt::SplitHCursor);
156 m_platformCursor = new QCursor(Qt::SplitVCursor);
160 m_platformCursor = new QCursor(Qt::SizeAllCursor);
163 m_platformCursor = new QCursor(Qt::BlankCursor);
167 m_platformCursor = new QCursor(Qt::ForbiddenCursor);
172 m_platformCursor = new QCursor(Qt::ArrowCursor);
175 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")), 7, 7);
178 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")), 7, 7);
181 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")), 3, 2);
184 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")), 11, 3);
187 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")), 3, 2);
190 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")), 3, 2);
193 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")), 7, 7);
196 m_platformCursor = new QCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")), 7, 7);
199 m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
202 ASSERT_NOT_REACHED();