1/*
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include "config.h"
32#include "Cursor.h"
33
34#include <wtf/Assertions.h>
35
36namespace WebCore {
37
38Cursor::Cursor(const Cursor& other)
39    : m_platformCursor(other.m_platformCursor)
40{
41}
42
43Cursor::Cursor(Image* image, const IntPoint& hotSpot)
44    : m_platformCursor(image, hotSpot)
45{
46}
47
48Cursor::~Cursor()
49{
50}
51
52Cursor& Cursor::operator=(const Cursor& other)
53{
54    m_platformCursor = other.m_platformCursor;
55    return *this;
56}
57
58Cursor::Cursor(PlatformCursor c)
59    : m_platformCursor(c)
60{
61}
62
63const Cursor& pointerCursor()
64{
65    static const Cursor c(PlatformCursor::TypePointer);
66    return c;
67}
68
69const Cursor& crossCursor()
70{
71    static const Cursor c(PlatformCursor::TypeCross);
72    return c;
73}
74
75const Cursor& handCursor()
76{
77    static const Cursor c(PlatformCursor::TypeHand);
78    return c;
79}
80
81const Cursor& iBeamCursor()
82{
83    static const Cursor c(PlatformCursor::TypeIBeam);
84    return c;
85}
86
87const Cursor& waitCursor()
88{
89    static const Cursor c(PlatformCursor::TypeWait);
90    return c;
91}
92
93const Cursor& helpCursor()
94{
95    static const Cursor c(PlatformCursor::TypeHelp);
96    return c;
97}
98
99const Cursor& eastResizeCursor()
100{
101    static const Cursor c(PlatformCursor::TypeEastResize);
102    return c;
103}
104
105const Cursor& northResizeCursor()
106{
107    static const Cursor c(PlatformCursor::TypeNorthResize);
108    return c;
109}
110
111const Cursor& northEastResizeCursor()
112{
113    static const Cursor c(PlatformCursor::TypeNorthEastResize);
114    return c;
115}
116
117const Cursor& northWestResizeCursor()
118{
119    static const Cursor c(PlatformCursor::TypeNorthWestResize);
120    return c;
121}
122
123const Cursor& southResizeCursor()
124{
125    static const Cursor c(PlatformCursor::TypeSouthResize);
126    return c;
127}
128
129const Cursor& southEastResizeCursor()
130{
131    static const Cursor c(PlatformCursor::TypeSouthEastResize);
132    return c;
133}
134
135const Cursor& southWestResizeCursor()
136{
137    static const Cursor c(PlatformCursor::TypeSouthWestResize);
138    return c;
139}
140
141const Cursor& westResizeCursor()
142{
143    static const Cursor c(PlatformCursor::TypeWestResize);
144    return c;
145}
146
147const Cursor& northSouthResizeCursor()
148{
149    static const Cursor c(PlatformCursor::TypeNorthSouthResize);
150    return c;
151}
152
153const Cursor& eastWestResizeCursor()
154{
155    static const Cursor c(PlatformCursor::TypeEastWestResize);
156    return c;
157}
158
159const Cursor& northEastSouthWestResizeCursor()
160{
161    static const Cursor c(PlatformCursor::TypeNorthEastSouthWestResize);
162    return c;
163}
164
165const Cursor& northWestSouthEastResizeCursor()
166{
167    static const Cursor c(PlatformCursor::TypeNorthWestSouthEastResize);
168    return c;
169}
170
171const Cursor& columnResizeCursor()
172{
173    static const Cursor c(PlatformCursor::TypeColumnResize);
174    return c;
175}
176
177const Cursor& rowResizeCursor()
178{
179    static const Cursor c(PlatformCursor::TypeRowResize);
180    return c;
181}
182
183const Cursor& middlePanningCursor()
184{
185    static const Cursor c(PlatformCursor::TypeMiddlePanning);
186    return c;
187}
188
189const Cursor& eastPanningCursor()
190{
191    static const Cursor c(PlatformCursor::TypeEastPanning);
192    return c;
193}
194
195const Cursor& northPanningCursor()
196{
197    static const Cursor c(PlatformCursor::TypeNorthPanning);
198    return c;
199}
200
201const Cursor& northEastPanningCursor()
202{
203    static const Cursor c(PlatformCursor::TypeNorthEastPanning);
204    return c;
205}
206
207const Cursor& northWestPanningCursor()
208{
209    static const Cursor c(PlatformCursor::TypeNorthWestPanning);
210    return c;
211}
212
213const Cursor& southPanningCursor()
214{
215    static const Cursor c(PlatformCursor::TypeSouthPanning);
216    return c;
217}
218
219const Cursor& southEastPanningCursor()
220{
221    static const Cursor c(PlatformCursor::TypeSouthEastPanning);
222    return c;
223}
224
225const Cursor& southWestPanningCursor()
226{
227    static const Cursor c(PlatformCursor::TypeSouthWestPanning);
228    return c;
229}
230
231const Cursor& westPanningCursor()
232{
233    static const Cursor c(PlatformCursor::TypeWestPanning);
234    return c;
235}
236
237const Cursor& moveCursor()
238{
239    static const Cursor c(PlatformCursor::TypeMove);
240    return c;
241}
242
243const Cursor& verticalTextCursor()
244{
245    static const Cursor c(PlatformCursor::TypeVerticalText);
246    return c;
247}
248
249const Cursor& cellCursor()
250{
251    static const Cursor c(PlatformCursor::TypeCell);
252    return c;
253}
254
255const Cursor& contextMenuCursor()
256{
257    static const Cursor c(PlatformCursor::TypeContextMenu);
258    return c;
259}
260
261const Cursor& aliasCursor()
262{
263    static const Cursor c(PlatformCursor::TypeAlias);
264    return c;
265}
266
267const Cursor& progressCursor()
268{
269    static const Cursor c(PlatformCursor::TypeProgress);
270    return c;
271}
272
273const Cursor& noDropCursor()
274{
275    static const Cursor c(PlatformCursor::TypeNoDrop);
276    return c;
277}
278
279const Cursor& copyCursor()
280{
281    static const Cursor c(PlatformCursor::TypeCopy);
282    return c;
283}
284
285const Cursor& noneCursor()
286{
287    static const Cursor c(PlatformCursor::TypeNone);
288    return c;
289}
290
291const Cursor& notAllowedCursor()
292{
293    static const Cursor c(PlatformCursor::TypeNotAllowed);
294    return c;
295}
296
297const Cursor& zoomInCursor()
298{
299    static const Cursor c(PlatformCursor::TypeZoomIn);
300    return c;
301}
302
303const Cursor& zoomOutCursor()
304{
305    static const Cursor c(PlatformCursor::TypeZoomOut);
306    return c;
307}
308
309const Cursor& grabCursor()
310{
311    static const Cursor c(PlatformCursor::TypeGrab);
312    return c;
313}
314
315const Cursor& grabbingCursor()
316{
317    static const Cursor c(PlatformCursor::TypeGrabbing);
318    return c;
319}
320
321} // namespace WebCore
322
323#define COMPILE_ASSERT_MATCHING_ENUM(cursor_name, platform_cursor_name) \
324    COMPILE_ASSERT(int(WebCore::Cursor::cursor_name) == int(WebCore::PlatformCursor::platform_cursor_name), mismatching_enums)
325
326COMPILE_ASSERT_MATCHING_ENUM(Pointer, TypePointer);
327COMPILE_ASSERT_MATCHING_ENUM(Cross, TypeCross);
328COMPILE_ASSERT_MATCHING_ENUM(Hand, TypeHand);
329COMPILE_ASSERT_MATCHING_ENUM(IBeam, TypeIBeam);
330COMPILE_ASSERT_MATCHING_ENUM(Wait, TypeWait);
331COMPILE_ASSERT_MATCHING_ENUM(Help, TypeHelp);
332COMPILE_ASSERT_MATCHING_ENUM(EastResize, TypeEastResize);
333COMPILE_ASSERT_MATCHING_ENUM(NorthResize, TypeNorthResize);
334COMPILE_ASSERT_MATCHING_ENUM(NorthEastResize, TypeNorthEastResize);
335COMPILE_ASSERT_MATCHING_ENUM(NorthWestResize, TypeNorthWestResize);
336COMPILE_ASSERT_MATCHING_ENUM(SouthResize, TypeSouthResize);
337COMPILE_ASSERT_MATCHING_ENUM(SouthEastResize, TypeSouthEastResize);
338COMPILE_ASSERT_MATCHING_ENUM(SouthWestResize, TypeSouthWestResize);
339COMPILE_ASSERT_MATCHING_ENUM(WestResize, TypeWestResize);
340COMPILE_ASSERT_MATCHING_ENUM(NorthSouthResize, TypeNorthSouthResize);
341COMPILE_ASSERT_MATCHING_ENUM(EastWestResize, TypeEastWestResize);
342COMPILE_ASSERT_MATCHING_ENUM(NorthEastSouthWestResize, TypeNorthEastSouthWestResize);
343COMPILE_ASSERT_MATCHING_ENUM(NorthWestSouthEastResize, TypeNorthWestSouthEastResize);
344COMPILE_ASSERT_MATCHING_ENUM(ColumnResize, TypeColumnResize);
345COMPILE_ASSERT_MATCHING_ENUM(RowResize, TypeRowResize);
346COMPILE_ASSERT_MATCHING_ENUM(MiddlePanning, TypeMiddlePanning);
347COMPILE_ASSERT_MATCHING_ENUM(EastPanning, TypeEastPanning);
348COMPILE_ASSERT_MATCHING_ENUM(NorthPanning, TypeNorthPanning);
349COMPILE_ASSERT_MATCHING_ENUM(NorthEastPanning, TypeNorthEastPanning);
350COMPILE_ASSERT_MATCHING_ENUM(NorthWestPanning, TypeNorthWestPanning);
351COMPILE_ASSERT_MATCHING_ENUM(SouthPanning, TypeSouthPanning);
352COMPILE_ASSERT_MATCHING_ENUM(SouthEastPanning, TypeSouthEastPanning);
353COMPILE_ASSERT_MATCHING_ENUM(SouthWestPanning, TypeSouthWestPanning);
354COMPILE_ASSERT_MATCHING_ENUM(WestPanning, TypeWestPanning);
355COMPILE_ASSERT_MATCHING_ENUM(Move, TypeMove);
356COMPILE_ASSERT_MATCHING_ENUM(VerticalText, TypeVerticalText);
357COMPILE_ASSERT_MATCHING_ENUM(Cell, TypeCell);
358COMPILE_ASSERT_MATCHING_ENUM(ContextMenu, TypeContextMenu);
359COMPILE_ASSERT_MATCHING_ENUM(Alias, TypeAlias);
360COMPILE_ASSERT_MATCHING_ENUM(Progress, TypeProgress);
361COMPILE_ASSERT_MATCHING_ENUM(NoDrop, TypeNoDrop);
362COMPILE_ASSERT_MATCHING_ENUM(Copy, TypeCopy);
363COMPILE_ASSERT_MATCHING_ENUM(None, TypeNone);
364COMPILE_ASSERT_MATCHING_ENUM(NotAllowed, TypeNotAllowed);
365COMPILE_ASSERT_MATCHING_ENUM(ZoomIn, TypeZoomIn);
366COMPILE_ASSERT_MATCHING_ENUM(ZoomOut, TypeZoomOut);
367COMPILE_ASSERT_MATCHING_ENUM(Grab, TypeGrab);
368COMPILE_ASSERT_MATCHING_ENUM(Grabbing, TypeGrabbing);
369COMPILE_ASSERT_MATCHING_ENUM(Custom, TypeCustom);
370