Cursor.h 3.98 KB
Newer Older
1
/*
darin's avatar
darin committed
2
 * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

26 27
#ifndef Cursor_h
#define Cursor_h
28

weinig's avatar
weinig committed
29 30 31
#include <wtf/Platform.h>

#if PLATFORM(WIN)
ggaren's avatar
ggaren committed
32 33
typedef struct HICON__* HICON;
typedef HICON HCURSOR;
34
#include <Shared.h>
35
#include <wtf/RefPtr.h>
zecke's avatar
/:  
zecke committed
36
#elif PLATFORM(GTK)
ggaren's avatar
ggaren committed
37
#include <gdk/gdk.h>
38 39
#elif PLATFORM(QT)
#include <QCursor>
darin's avatar
darin committed
40
#endif
41

42
#if PLATFORM(MAC)
mjs's avatar
mjs committed
43
#ifdef __OBJC__
44 45 46
@class NSCursor;
#else
class NSCursor;
mjs's avatar
mjs committed
47
#endif
darin's avatar
darin committed
48
#endif
mjs's avatar
mjs committed
49

50 51
namespace WebCore {

darin's avatar
darin committed
52
    class Image;
rwlbuis's avatar
rwlbuis committed
53
    class IntPoint;
54

weinig's avatar
weinig committed
55
#if PLATFORM(WIN)
56 57 58 59 60 61
    class SharedCursor : public Shared<SharedCursor> {
    public:
        SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) {}
        ~SharedCursor() {
            DestroyIcon(m_nativeCursor);
        }
62
        HCURSOR nativeCursor() const { return m_nativeCursor; }
63 64 65 66
    private:
        HCURSOR m_nativeCursor;
    };
    typedef RefPtr<SharedCursor> PlatformCursor;
67
#elif PLATFORM(MAC)
darin's avatar
darin committed
68
    typedef NSCursor* PlatformCursor;
zecke's avatar
/:  
zecke committed
69
#elif PLATFORM(GTK)
ggaren's avatar
ggaren committed
70
    typedef GdkCursor* PlatformCursor;
71
#elif PLATFORM(QT) && !defined(QT_NO_CURSOR)
72
    typedef QCursor PlatformCursor;
darin's avatar
darin committed
73 74
#else
    typedef void* PlatformCursor;
darin's avatar
darin committed
75
#endif
76

darin's avatar
darin committed
77 78
    class Cursor {
    public:
79 80 81 82 83 84
        Cursor()
#if !PLATFORM(QT)
        : m_impl(0)
#endif
        { }

rwlbuis's avatar
rwlbuis committed
85
        Cursor(Image*, const IntPoint& hotspot);
darin's avatar
darin committed
86 87 88
        Cursor(const Cursor&);
        ~Cursor();
        Cursor& operator=(const Cursor&);
89

darin's avatar
darin committed
90 91
        Cursor(PlatformCursor);
        PlatformCursor impl() const { return m_impl; }
92

darin's avatar
darin committed
93 94 95 96
     private:
        PlatformCursor m_impl;
    };

97
    const Cursor& pointerCursor();
darin's avatar
darin committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111
    const Cursor& crossCursor();
    const Cursor& handCursor();
    const Cursor& moveCursor();
    const Cursor& iBeamCursor();
    const Cursor& waitCursor();
    const Cursor& helpCursor();
    const Cursor& eastResizeCursor();
    const Cursor& northResizeCursor();
    const Cursor& northEastResizeCursor();
    const Cursor& northWestResizeCursor();
    const Cursor& southResizeCursor();
    const Cursor& southEastResizeCursor();
    const Cursor& southWestResizeCursor();
    const Cursor& westResizeCursor();
thatcher's avatar
thatcher committed
112 113 114 115 116 117
    const Cursor& northSouthResizeCursor();
    const Cursor& eastWestResizeCursor();
    const Cursor& northEastSouthWestResizeCursor();
    const Cursor& northWestSouthEastResizeCursor();
    const Cursor& columnResizeCursor();
    const Cursor& rowResizeCursor();
118 119 120
    const Cursor& verticalTextCursor();
    const Cursor& cellCursor();
    const Cursor& contextMenuCursor();
121
    const Cursor& noDropCursor();
adele's avatar
adele committed
122
    const Cursor& notAllowedCursor();
123 124
    const Cursor& progressCursor();
    const Cursor& aliasCursor();
andersca's avatar
andersca committed
125 126
    const Cursor& zoomInCursor();
    const Cursor& zoomOutCursor();
127
    const Cursor& copyCursor();
128
    const Cursor& noneCursor();
129

weinig's avatar
weinig committed
130
} // namespace WebCore
131

132
#endif // Cursor_h