|
1 /* |
|
2 * Copyright (C) 2004, 2006, 2008 Apple 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 |
|
6 * are met: |
|
7 * 1. Redistributions of source code must retain the above copyright |
|
8 * notice, this list of conditions and the following disclaimer. |
|
9 * 2. Redistributions in binary form must reproduce the above copyright |
|
10 * notice, this list of conditions and the following disclaimer in the |
|
11 * documentation and/or other materials provided with the distribution. |
|
12 * |
|
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
|
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #ifndef Cursor_h |
|
27 #define Cursor_h |
|
28 |
|
29 #include "Image.h" |
|
30 #include "IntPoint.h" |
|
31 #include <wtf/RefPtr.h> |
|
32 |
|
33 #if PLATFORM(WIN) |
|
34 typedef struct HICON__* HICON; |
|
35 typedef HICON HCURSOR; |
|
36 #include <wtf/PassRefPtr.h> |
|
37 #include <wtf/RefCounted.h> |
|
38 #elif PLATFORM(GTK) |
|
39 typedef struct _GdkCursor GdkCursor; |
|
40 #elif PLATFORM(QT) |
|
41 #include <QCursor> |
|
42 #elif PLATFORM(CHROMIUM) |
|
43 #include "PlatformCursor.h" |
|
44 #elif PLATFORM(HAIKU) |
|
45 #include <app/Cursor.h> |
|
46 #endif |
|
47 |
|
48 #if PLATFORM(MAC) |
|
49 #ifdef __OBJC__ |
|
50 @class NSCursor; |
|
51 #else |
|
52 class NSCursor; |
|
53 #endif |
|
54 #endif |
|
55 |
|
56 #if PLATFORM(WX) |
|
57 class wxCursor; |
|
58 #endif |
|
59 |
|
60 #if PLATFORM(WIN) |
|
61 typedef struct HICON__ *HICON; |
|
62 typedef HICON HCURSOR; |
|
63 #endif |
|
64 |
|
65 #if PLATFORM(WIN) || PLATFORM(MAC) |
|
66 #define WTF_USE_LAZY_NATIVE_CURSOR 1 |
|
67 #endif |
|
68 |
|
69 namespace WebCore { |
|
70 |
|
71 class Image; |
|
72 |
|
73 #if PLATFORM(WIN) |
|
74 class SharedCursor : public RefCounted<SharedCursor> { |
|
75 public: |
|
76 static PassRefPtr<SharedCursor> create(HCURSOR nativeCursor) { return adoptRef(new SharedCursor(nativeCursor)); } |
|
77 ~SharedCursor(); |
|
78 HCURSOR nativeCursor() const { return m_nativeCursor; } |
|
79 private: |
|
80 SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) { } |
|
81 HCURSOR m_nativeCursor; |
|
82 }; |
|
83 typedef RefPtr<SharedCursor> PlatformCursor; |
|
84 #elif PLATFORM(MAC) |
|
85 typedef NSCursor* PlatformCursor; |
|
86 #elif PLATFORM(GTK) |
|
87 typedef GdkCursor* PlatformCursor; |
|
88 #elif PLATFORM(EFL) |
|
89 typedef const char* PlatformCursor; |
|
90 #elif PLATFORM(QT) && !defined(QT_NO_CURSOR) |
|
91 typedef QCursor PlatformCursor; |
|
92 #elif PLATFORM(WX) |
|
93 typedef wxCursor* PlatformCursor; |
|
94 #elif PLATFORM(CHROMIUM) |
|
95 // See PlatformCursor.h |
|
96 #elif PLATFORM(HAIKU) |
|
97 typedef BCursor* PlatformCursor; |
|
98 #else |
|
99 typedef void* PlatformCursor; |
|
100 #endif |
|
101 |
|
102 class Cursor { |
|
103 public: |
|
104 enum Type { |
|
105 Pointer, |
|
106 Cross, |
|
107 Hand, |
|
108 IBeam, |
|
109 Wait, |
|
110 Help, |
|
111 EastResize, |
|
112 NorthResize, |
|
113 NorthEastResize, |
|
114 NorthWestResize, |
|
115 SouthResize, |
|
116 SouthEastResize, |
|
117 SouthWestResize, |
|
118 WestResize, |
|
119 NorthSouthResize, |
|
120 EastWestResize, |
|
121 NorthEastSouthWestResize, |
|
122 NorthWestSouthEastResize, |
|
123 ColumnResize, |
|
124 RowResize, |
|
125 MiddlePanning, |
|
126 EastPanning, |
|
127 NorthPanning, |
|
128 NorthEastPanning, |
|
129 NorthWestPanning, |
|
130 SouthPanning, |
|
131 SouthEastPanning, |
|
132 SouthWestPanning, |
|
133 WestPanning, |
|
134 Move, |
|
135 VerticalText, |
|
136 Cell, |
|
137 ContextMenu, |
|
138 Alias, |
|
139 Progress, |
|
140 NoDrop, |
|
141 Copy, |
|
142 None, |
|
143 NotAllowed, |
|
144 ZoomIn, |
|
145 ZoomOut, |
|
146 Grab, |
|
147 Grabbing, |
|
148 Custom |
|
149 }; |
|
150 |
|
151 static const Cursor& fromType(Cursor::Type); |
|
152 |
|
153 Cursor() |
|
154 #if !PLATFORM(QT) && !PLATFORM(EFL) |
|
155 : m_platformCursor(0) |
|
156 #endif |
|
157 { |
|
158 } |
|
159 |
|
160 Cursor(Image*, const IntPoint& hotSpot); |
|
161 Cursor(const Cursor&); |
|
162 ~Cursor(); |
|
163 Cursor& operator=(const Cursor&); |
|
164 |
|
165 #if USE(LAZY_NATIVE_CURSOR) |
|
166 Cursor(Type); |
|
167 Type type() const { return m_type; } |
|
168 Image* image() const { return m_image.get(); } |
|
169 const IntPoint& hotSpot() const { return m_hotSpot; } |
|
170 PlatformCursor platformCursor() const; |
|
171 #else |
|
172 Cursor(PlatformCursor); |
|
173 PlatformCursor impl() const { return m_platformCursor; } |
|
174 #endif |
|
175 |
|
176 private: |
|
177 #if USE(LAZY_NATIVE_CURSOR) |
|
178 void ensurePlatformCursor() const; |
|
179 |
|
180 Type m_type; |
|
181 RefPtr<Image> m_image; |
|
182 IntPoint m_hotSpot; |
|
183 #endif |
|
184 |
|
185 mutable PlatformCursor m_platformCursor; |
|
186 }; |
|
187 |
|
188 IntPoint determineHotSpot(Image*, const IntPoint& specifiedHotSpot); |
|
189 const char* nameForCursorType(Cursor::Type); |
|
190 |
|
191 const Cursor& pointerCursor(); |
|
192 const Cursor& crossCursor(); |
|
193 const Cursor& handCursor(); |
|
194 const Cursor& moveCursor(); |
|
195 const Cursor& iBeamCursor(); |
|
196 const Cursor& waitCursor(); |
|
197 const Cursor& helpCursor(); |
|
198 const Cursor& eastResizeCursor(); |
|
199 const Cursor& northResizeCursor(); |
|
200 const Cursor& northEastResizeCursor(); |
|
201 const Cursor& northWestResizeCursor(); |
|
202 const Cursor& southResizeCursor(); |
|
203 const Cursor& southEastResizeCursor(); |
|
204 const Cursor& southWestResizeCursor(); |
|
205 const Cursor& westResizeCursor(); |
|
206 const Cursor& northSouthResizeCursor(); |
|
207 const Cursor& eastWestResizeCursor(); |
|
208 const Cursor& northEastSouthWestResizeCursor(); |
|
209 const Cursor& northWestSouthEastResizeCursor(); |
|
210 const Cursor& columnResizeCursor(); |
|
211 const Cursor& rowResizeCursor(); |
|
212 const Cursor& middlePanningCursor(); |
|
213 const Cursor& eastPanningCursor(); |
|
214 const Cursor& northPanningCursor(); |
|
215 const Cursor& northEastPanningCursor(); |
|
216 const Cursor& northWestPanningCursor(); |
|
217 const Cursor& southPanningCursor(); |
|
218 const Cursor& southEastPanningCursor(); |
|
219 const Cursor& southWestPanningCursor(); |
|
220 const Cursor& westPanningCursor(); |
|
221 const Cursor& verticalTextCursor(); |
|
222 const Cursor& cellCursor(); |
|
223 const Cursor& contextMenuCursor(); |
|
224 const Cursor& noDropCursor(); |
|
225 const Cursor& notAllowedCursor(); |
|
226 const Cursor& progressCursor(); |
|
227 const Cursor& aliasCursor(); |
|
228 const Cursor& zoomInCursor(); |
|
229 const Cursor& zoomOutCursor(); |
|
230 const Cursor& copyCursor(); |
|
231 const Cursor& noneCursor(); |
|
232 const Cursor& grabCursor(); |
|
233 const Cursor& grabbingCursor(); |
|
234 |
|
235 } // namespace WebCore |
|
236 |
|
237 #endif // Cursor_h |