~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/Cursor.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/Assertions.h>
 
32
#include <wtf/RefPtr.h>
 
33
 
 
34
#if PLATFORM(WIN)
 
35
typedef struct HICON__* HICON;
 
36
typedef HICON HCURSOR;
 
37
#include <wtf/PassRefPtr.h>
 
38
#include <wtf/RefCounted.h>
 
39
#elif PLATFORM(MAC)
 
40
#include <wtf/RetainPtr.h>
 
41
#elif PLATFORM(GTK)
 
42
#include "GRefPtrGtk.h"
 
43
#elif PLATFORM(QT)
 
44
#include <QCursor>
 
45
#elif PLATFORM(BLACKBERRY)
 
46
#include <BlackBerryPlatformCursor.h>
 
47
#endif
 
48
 
 
49
#if PLATFORM(MAC) && !PLATFORM(IOS)
 
50
OBJC_CLASS NSCursor;
 
51
#endif
 
52
 
 
53
#if PLATFORM(WX)
 
54
class wxCursor;
 
55
#endif
 
56
 
 
57
#if PLATFORM(WIN)
 
58
typedef struct HICON__ *HICON;
 
59
typedef HICON HCURSOR;
 
60
#endif
 
61
 
 
62
// Looks like it's just PLATFORM(WX) and PLATFORM(BLACKBERRY) still not using this?
 
63
#if PLATFORM(WIN) || PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(CHROMIUM)
 
64
#define WTF_USE_LAZY_NATIVE_CURSOR 1
 
65
#endif
 
66
 
 
67
namespace WebCore {
 
68
 
 
69
    class Image;
 
70
 
 
71
#if PLATFORM(WIN)
 
72
    class SharedCursor : public RefCounted<SharedCursor> {
 
73
    public:
 
74
        static PassRefPtr<SharedCursor> create(HCURSOR nativeCursor) { return adoptRef(new SharedCursor(nativeCursor)); }
 
75
        ~SharedCursor();
 
76
        HCURSOR nativeCursor() const { return m_nativeCursor; }
 
77
    private:
 
78
        SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) { }
 
79
        HCURSOR m_nativeCursor;
 
80
    };
 
81
    typedef RefPtr<SharedCursor> PlatformCursor;
 
82
#elif PLATFORM(MAC) && !PLATFORM(IOS)
 
83
    typedef NSCursor *PlatformCursor;
 
84
#elif PLATFORM(GTK)
 
85
    typedef GRefPtr<GdkCursor> PlatformCursor;
 
86
#elif PLATFORM(EFL)
 
87
    typedef const char* PlatformCursor;
 
88
#elif PLATFORM(QT) && !defined(QT_NO_CURSOR)
 
89
    // Do not need to be shared but need to be created dynamically via ensurePlatformCursor.
 
90
    typedef QCursor* PlatformCursor;
 
91
#elif PLATFORM(WX)
 
92
    typedef wxCursor* PlatformCursor;
 
93
#elif PLATFORM(BLACKBERRY)
 
94
    typedef BlackBerry::Platform::BlackBerryCursor PlatformCursor;
 
95
#else
 
96
    typedef void* PlatformCursor;
 
97
#endif
 
98
 
 
99
    class Cursor {
 
100
        WTF_MAKE_FAST_ALLOCATED;
 
101
    public:
 
102
        enum Type {
 
103
            Pointer = 0,
 
104
            Cross,
 
105
            Hand,
 
106
            IBeam,
 
107
            Wait,
 
108
            Help,
 
109
            EastResize,
 
110
            NorthResize,
 
111
            NorthEastResize,
 
112
            NorthWestResize,
 
113
            SouthResize,
 
114
            SouthEastResize,
 
115
            SouthWestResize,
 
116
            WestResize,
 
117
            NorthSouthResize,
 
118
            EastWestResize,
 
119
            NorthEastSouthWestResize,
 
120
            NorthWestSouthEastResize,
 
121
            ColumnResize,
 
122
            RowResize,
 
123
            MiddlePanning,
 
124
            EastPanning,
 
125
            NorthPanning,
 
126
            NorthEastPanning,
 
127
            NorthWestPanning,
 
128
            SouthPanning,
 
129
            SouthEastPanning,
 
130
            SouthWestPanning,
 
131
            WestPanning,
 
132
            Move,
 
133
            VerticalText,
 
134
            Cell,
 
135
            ContextMenu,
 
136
            Alias,
 
137
            Progress,
 
138
            NoDrop,
 
139
            Copy,
 
140
            None,
 
141
            NotAllowed,
 
142
            ZoomIn,
 
143
            ZoomOut,
 
144
            Grab,
 
145
            Grabbing,
 
146
            Custom
 
147
        };
 
148
 
 
149
        static const Cursor& fromType(Cursor::Type);
 
150
 
 
151
        Cursor()
 
152
#if !PLATFORM(IOS) && !PLATFORM(BLACKBERRY)
 
153
#if USE(LAZY_NATIVE_CURSOR)
 
154
            // This is an invalid Cursor and should never actually get used.
 
155
            : m_type(static_cast<Type>(-1))
 
156
            , m_platformCursor(0)
 
157
#else
 
158
            : m_platformCursor(0)
 
159
#endif // USE(LAZY_NATIVE_CURSOR)
 
160
#endif // !PLATFORM(IOS) && !PLATFORM(BLACKBERRY)
 
161
        {
 
162
        }
 
163
 
 
164
#if !PLATFORM(IOS)
 
165
        Cursor(Image*, const IntPoint& hotSpot);
 
166
        Cursor(const Cursor&);
 
167
        ~Cursor();
 
168
        Cursor& operator=(const Cursor&);
 
169
 
 
170
#if USE(LAZY_NATIVE_CURSOR)
 
171
        explicit Cursor(Type);
 
172
        Type type() const
 
173
        {
 
174
            ASSERT(m_type >= 0 && m_type <= Custom);
 
175
            return m_type;
 
176
        }
 
177
        Image* image() const { return m_image.get(); }
 
178
        const IntPoint& hotSpot() const { return m_hotSpot; }
 
179
        PlatformCursor platformCursor() const;
 
180
#else
 
181
        explicit Cursor(PlatformCursor);
 
182
        PlatformCursor impl() const { return m_platformCursor; }
 
183
#endif
 
184
 
 
185
     private:
 
186
#if USE(LAZY_NATIVE_CURSOR)
 
187
        void ensurePlatformCursor() const;
 
188
 
 
189
        Type m_type;
 
190
        RefPtr<Image> m_image;
 
191
        IntPoint m_hotSpot;
 
192
#endif
 
193
 
 
194
#if !PLATFORM(MAC)
 
195
        mutable PlatformCursor m_platformCursor;
 
196
#else
 
197
        mutable RetainPtr<NSCursor> m_platformCursor;
 
198
#endif
 
199
#endif // !PLATFORM(IOS)
 
200
    };
 
201
 
 
202
    IntPoint determineHotSpot(Image*, const IntPoint& specifiedHotSpot);
 
203
    
 
204
    const Cursor& pointerCursor();
 
205
    const Cursor& crossCursor();
 
206
    const Cursor& handCursor();
 
207
    const Cursor& moveCursor();
 
208
    const Cursor& iBeamCursor();
 
209
    const Cursor& waitCursor();
 
210
    const Cursor& helpCursor();
 
211
    const Cursor& eastResizeCursor();
 
212
    const Cursor& northResizeCursor();
 
213
    const Cursor& northEastResizeCursor();
 
214
    const Cursor& northWestResizeCursor();
 
215
    const Cursor& southResizeCursor();
 
216
    const Cursor& southEastResizeCursor();
 
217
    const Cursor& southWestResizeCursor();
 
218
    const Cursor& westResizeCursor();
 
219
    const Cursor& northSouthResizeCursor();
 
220
    const Cursor& eastWestResizeCursor();
 
221
    const Cursor& northEastSouthWestResizeCursor();
 
222
    const Cursor& northWestSouthEastResizeCursor();
 
223
    const Cursor& columnResizeCursor();
 
224
    const Cursor& rowResizeCursor();
 
225
    const Cursor& middlePanningCursor();
 
226
    const Cursor& eastPanningCursor();
 
227
    const Cursor& northPanningCursor();
 
228
    const Cursor& northEastPanningCursor();
 
229
    const Cursor& northWestPanningCursor();
 
230
    const Cursor& southPanningCursor();
 
231
    const Cursor& southEastPanningCursor();
 
232
    const Cursor& southWestPanningCursor();
 
233
    const Cursor& westPanningCursor();
 
234
    const Cursor& verticalTextCursor();
 
235
    const Cursor& cellCursor();
 
236
    const Cursor& contextMenuCursor();
 
237
    const Cursor& noDropCursor();
 
238
    const Cursor& notAllowedCursor();
 
239
    const Cursor& progressCursor();
 
240
    const Cursor& aliasCursor();
 
241
    const Cursor& zoomInCursor();
 
242
    const Cursor& zoomOutCursor();
 
243
    const Cursor& copyCursor();
 
244
    const Cursor& noneCursor();
 
245
    const Cursor& grabCursor();
 
246
    const Cursor& grabbingCursor();
 
247
 
 
248
} // namespace WebCore
 
249
 
 
250
#endif // Cursor_h