1/*
2 * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
3 * Copyright (C) 2010 Stephan AÃmus <superstippi@gmx.de>
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "Cursor.h"
31
32#include "NotImplemented.h"
33
34namespace WebCore {
35
36Cursor::Cursor(PlatformCursor cursor)
37    : m_platformCursor(cursor)
38{
39}
40
41Cursor::Cursor(const Cursor& other)
42    : m_platformCursor(0)
43{
44    *this = other;
45}
46
47Cursor::~Cursor()
48{
49    delete m_platformCursor;
50}
51
52Cursor::Cursor(Image*, const IntPoint&)
53    : m_platformCursor(0)
54{
55    notImplemented();
56}
57
58Cursor& Cursor::operator=(const Cursor& other)
59{
60    delete m_platformCursor;
61    m_platformCursor = other.m_platformCursor ? new BCursor(*other.m_platformCursor) : 0;
62    return *this;
63}
64
65static Cursor createCursorByID(BCursorID id)
66{
67    return Cursor(new BCursor(id));
68}
69
70const Cursor& pointerCursor()
71{
72    static Cursor cursorSystemDefault(0);
73    return cursorSystemDefault;
74}
75
76const Cursor& moveCursor()
77{
78    static Cursor cursorMove = createCursorByID(B_CURSOR_ID_MOVE);
79    return cursorMove;
80}
81
82const Cursor& crossCursor()
83{
84    static Cursor cursorCrossHair = createCursorByID(B_CURSOR_ID_CROSS_HAIR);
85    return cursorCrossHair;
86}
87
88const Cursor& handCursor()
89{
90    static Cursor cursorFollowLink = createCursorByID(B_CURSOR_ID_FOLLOW_LINK);
91    return cursorFollowLink;
92}
93
94const Cursor& iBeamCursor()
95{
96    static Cursor cursorIBeam = createCursorByID(B_CURSOR_ID_I_BEAM);
97    return cursorIBeam;
98}
99
100const Cursor& waitCursor()
101{
102    static Cursor cursorProgress = createCursorByID(B_CURSOR_ID_PROGRESS);
103    return cursorProgress;
104}
105
106const Cursor& helpCursor()
107{
108    static Cursor cursorHelp = createCursorByID(B_CURSOR_ID_HELP);
109    return cursorHelp;
110}
111
112const Cursor& eastResizeCursor()
113{
114    static Cursor cursorResizeEast = createCursorByID(B_CURSOR_ID_RESIZE_EAST);
115    return cursorResizeEast;
116}
117
118const Cursor& northResizeCursor()
119{
120    static Cursor cursorResizeNorth = createCursorByID(B_CURSOR_ID_RESIZE_NORTH);
121    return cursorResizeNorth;
122}
123
124const Cursor& northEastResizeCursor()
125{
126    static Cursor cursorResizeNorthEast = createCursorByID(B_CURSOR_ID_RESIZE_NORTH_EAST);
127    return cursorResizeNorthEast;
128}
129
130const Cursor& northWestResizeCursor()
131{
132    static Cursor cursorResizeNorthWest = createCursorByID(B_CURSOR_ID_RESIZE_NORTH_WEST);
133    return cursorResizeNorthWest;
134}
135
136const Cursor& southResizeCursor()
137{
138    static Cursor cursorResizeSouth = createCursorByID(B_CURSOR_ID_RESIZE_SOUTH);
139    return cursorResizeSouth;
140}
141
142const Cursor& southEastResizeCursor()
143{
144    static Cursor cursorResizeSouthEast = createCursorByID(B_CURSOR_ID_RESIZE_SOUTH_EAST);
145    return cursorResizeSouthEast;
146}
147
148const Cursor& southWestResizeCursor()
149{
150    static Cursor cursorResizeSouthWest = createCursorByID(B_CURSOR_ID_RESIZE_SOUTH_WEST);
151    return cursorResizeSouthWest;
152}
153
154const Cursor& westResizeCursor()
155{
156    static Cursor cursorResizeWest = createCursorByID(B_CURSOR_ID_RESIZE_WEST);
157    return cursorResizeWest;
158}
159
160const Cursor& northSouthResizeCursor()
161{
162    static Cursor cursorResizeNorthSouth = createCursorByID(B_CURSOR_ID_RESIZE_NORTH_SOUTH);
163    return cursorResizeNorthSouth;
164}
165
166const Cursor& eastWestResizeCursor()
167{
168    static Cursor cursorResizeEastWest = createCursorByID(B_CURSOR_ID_RESIZE_EAST_WEST);
169    return cursorResizeEastWest;
170}
171
172const Cursor& northEastSouthWestResizeCursor()
173{
174    static Cursor cursorResizeNorthEastSouthWest = createCursorByID(B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST);
175    return cursorResizeNorthEastSouthWest;
176}
177
178const Cursor& northWestSouthEastResizeCursor()
179{
180    static Cursor cursorResizeNorthWestSouthEast = createCursorByID(B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST);
181    return cursorResizeNorthWestSouthEast;
182}
183
184const Cursor& columnResizeCursor()
185{
186    return eastWestResizeCursor();
187}
188
189const Cursor& rowResizeCursor()
190{
191    return northSouthResizeCursor();
192}
193
194const Cursor& verticalTextCursor()
195{
196    static Cursor cursorIBeamHorizontal = createCursorByID(B_CURSOR_ID_I_BEAM_HORIZONTAL);
197    return cursorIBeamHorizontal;
198}
199
200const Cursor& cellCursor()
201{
202    return pointerCursor();
203}
204
205const Cursor& contextMenuCursor()
206{
207    static Cursor cursorContextMenu = createCursorByID(B_CURSOR_ID_CONTEXT_MENU);
208    return cursorContextMenu;
209}
210
211const Cursor& noDropCursor()
212{
213    static Cursor cursorNotAllowed = createCursorByID(B_CURSOR_ID_NOT_ALLOWED);
214    return cursorNotAllowed;
215}
216
217const Cursor& copyCursor()
218{
219    static Cursor cursorCopy = createCursorByID(B_CURSOR_ID_COPY);
220    return cursorCopy;
221}
222
223const Cursor& progressCursor()
224{
225    static Cursor cursorProgress = createCursorByID(B_CURSOR_ID_PROGRESS);
226    return cursorProgress;
227}
228
229const Cursor& aliasCursor()
230{
231    return handCursor();
232}
233
234const Cursor& noneCursor()
235{
236    static Cursor cursorNoCursor = createCursorByID(B_CURSOR_ID_NO_CURSOR);
237    return cursorNoCursor;
238}
239
240const Cursor& notAllowedCursor()
241{
242    static Cursor cursorNotAllowed = createCursorByID(B_CURSOR_ID_NOT_ALLOWED);
243    return cursorNotAllowed;
244}
245
246const Cursor& zoomInCursor()
247{
248    static Cursor cursorZoomIn = createCursorByID(B_CURSOR_ID_ZOOM_IN);
249    return cursorZoomIn;
250}
251
252const Cursor& zoomOutCursor()
253{
254    static Cursor cursorZoomOut = createCursorByID(B_CURSOR_ID_ZOOM_OUT);
255    return cursorZoomOut;
256}
257
258const Cursor& grabCursor()
259{
260    static Cursor cursorGrab = createCursorByID(B_CURSOR_ID_GRAB);
261    return cursorGrab;
262}
263
264const Cursor& grabbingCursor()
265{
266    static Cursor cursorGrabbing = createCursorByID(B_CURSOR_ID_GRABBING);
267    return cursorGrabbing;
268}
269
270} // namespace WebCore
271
272