• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <wtf/Platform.h>
30 
31 #if PLATFORM(WIN)
32 typedef struct HICON__* HICON;
33 typedef HICON HCURSOR;
34 #include <wtf/PassRefPtr.h>
35 #include <wtf/RefCounted.h>
36 #include <wtf/RefPtr.h>
37 #elif PLATFORM(GTK)
38 typedef struct _GdkCursor GdkCursor;
39 #elif PLATFORM(QT)
40 #include <QCursor>
41 #elif PLATFORM(CHROMIUM)
42 #include "PlatformCursor.h"
43 #elif PLATFORM(HAIKU)
44 #include <app/Cursor.h>
45 #endif
46 
47 #if PLATFORM(MAC)
48 #ifdef __OBJC__
49 @class NSCursor;
50 #else
51 class NSCursor;
52 #endif
53 #endif
54 
55 #if PLATFORM(WX)
56 class wxCursor;
57 #endif
58 
59 #if PLATFORM(WIN)
60 typedef struct HICON__ *HICON;
61 typedef HICON HCURSOR;
62 #endif
63 
64 namespace WebCore {
65 
66     class Image;
67     class IntPoint;
68 
69 #if PLATFORM(WIN)
70     class SharedCursor : public RefCounted<SharedCursor> {
71     public:
create(HCURSOR nativeCursor)72         static PassRefPtr<SharedCursor> create(HCURSOR nativeCursor) { return adoptRef(new SharedCursor(nativeCursor)); }
73         ~SharedCursor();
nativeCursor()74         HCURSOR nativeCursor() const { return m_nativeCursor; }
75     private:
SharedCursor(HCURSOR nativeCursor)76         SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) { }
77         HCURSOR m_nativeCursor;
78     };
79     typedef RefPtr<SharedCursor> PlatformCursor;
80     typedef HCURSOR PlatformCursorHandle;
81 #elif PLATFORM(MAC)
82     typedef NSCursor* PlatformCursor;
83     typedef NSCursor* PlatformCursorHandle;
84 #elif PLATFORM(GTK)
85     typedef GdkCursor* PlatformCursor;
86     typedef GdkCursor* PlatformCursorHandle;
87 #elif PLATFORM(QT) && !defined(QT_NO_CURSOR)
88     typedef QCursor PlatformCursor;
89     typedef QCursor* PlatformCursorHandle;
90 #elif PLATFORM(WX)
91     typedef wxCursor* PlatformCursor;
92     typedef wxCursor* PlatformCursorHandle;
93 #elif PLATFORM(CHROMIUM)
94     // See PlatformCursor.h
95     typedef void* PlatformCursorHandle;
96 #elif PLATFORM(HAIKU)
97     typedef BCursor* PlatformCursor;
98     typedef BCursor* PlatformCursorHandle;
99 #else
100     typedef void* PlatformCursor;
101     typedef void* PlatformCursorHandle;
102 #endif
103 
104     class Cursor {
105     public:
Cursor()106         Cursor()
107 #if !PLATFORM(QT)
108         : m_impl(0)
109 #endif
110         { }
111 
112         Cursor(Image*, const IntPoint& hotspot);
113         Cursor(const Cursor&);
114         ~Cursor();
115         Cursor& operator=(const Cursor&);
116 
117         Cursor(PlatformCursor);
impl()118         PlatformCursor impl() const { return m_impl; }
119 
120      private:
121         PlatformCursor m_impl;
122     };
123 
124     const Cursor& pointerCursor();
125     const Cursor& crossCursor();
126     const Cursor& handCursor();
127     const Cursor& moveCursor();
128     const Cursor& iBeamCursor();
129     const Cursor& waitCursor();
130     const Cursor& helpCursor();
131     const Cursor& eastResizeCursor();
132     const Cursor& northResizeCursor();
133     const Cursor& northEastResizeCursor();
134     const Cursor& northWestResizeCursor();
135     const Cursor& southResizeCursor();
136     const Cursor& southEastResizeCursor();
137     const Cursor& southWestResizeCursor();
138     const Cursor& westResizeCursor();
139     const Cursor& northSouthResizeCursor();
140     const Cursor& eastWestResizeCursor();
141     const Cursor& northEastSouthWestResizeCursor();
142     const Cursor& northWestSouthEastResizeCursor();
143     const Cursor& columnResizeCursor();
144     const Cursor& rowResizeCursor();
145     const Cursor& middlePanningCursor();
146     const Cursor& eastPanningCursor();
147     const Cursor& northPanningCursor();
148     const Cursor& northEastPanningCursor();
149     const Cursor& northWestPanningCursor();
150     const Cursor& southPanningCursor();
151     const Cursor& southEastPanningCursor();
152     const Cursor& southWestPanningCursor();
153     const Cursor& westPanningCursor();
154     const Cursor& verticalTextCursor();
155     const Cursor& cellCursor();
156     const Cursor& contextMenuCursor();
157     const Cursor& noDropCursor();
158     const Cursor& notAllowedCursor();
159     const Cursor& progressCursor();
160     const Cursor& aliasCursor();
161     const Cursor& zoomInCursor();
162     const Cursor& zoomOutCursor();
163     const Cursor& copyCursor();
164     const Cursor& noneCursor();
165     const Cursor& grabCursor();
166     const Cursor& grabbingCursor();
167 
168 } // namespace WebCore
169 
170 #endif // Cursor_h
171