1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* 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.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Cursor.h"
#include "Image.h"
#include "IntPoint.h"
#include "NotImplemented.h"
#include <stdio.h>
#include <stdlib.h>
#undef CopyCursor
namespace WebCore {
Cursor::Cursor(const Cursor& other)
: 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()
{
#ifndef QT_NO_CURSOR
delete m_platformCursor;
#endif
}
Cursor& Cursor::operator=(const Cursor& other)
{
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
return *this;
}
static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
{
#ifndef QT_NO_CURSOR
IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
#else
return 0;
#endif
}
void Cursor::ensurePlatformCursor() const
{
#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
}
}
// vim: ts=4 sw=4 et
|