#ifndef Cursor_h
#define Cursor_h
#include "Image.h"
#include "IntPoint.h"
#include <wtf/Assertions.h>
#include <wtf/RefPtr.h>
#if PLATFORM(WIN)
typedef struct HICON__* HICON;
typedef HICON HCURSOR;
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#elif PLATFORM(COCOA)
#include <wtf/RetainPtr.h>
#elif PLATFORM(GTK)
#include "GRefPtrGtk.h"
#endif
#if USE(APPKIT)
OBJC_CLASS NSCursor;
#endif
#if PLATFORM(WIN)
typedef struct HICON__ *HICON;
typedef HICON HCURSOR;
#endif
namespace WebCore {
class Image;
#if PLATFORM(WIN)
class SharedCursor : public RefCounted<SharedCursor> {
public:
static Ref<SharedCursor> create(HCURSOR nativeCursor) { return adoptRef(*new SharedCursor(nativeCursor)); }
~SharedCursor();
HCURSOR nativeCursor() const { return m_nativeCursor; }
private:
SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) { }
HCURSOR m_nativeCursor;
};
typedef RefPtr<SharedCursor> PlatformCursor;
#elif USE(APPKIT)
typedef NSCursor *PlatformCursor;
#elif PLATFORM(GTK)
typedef GRefPtr<GdkCursor> PlatformCursor;
#elif PLATFORM(EFL)
typedef const char* PlatformCursor;
#else
typedef void* PlatformCursor;
#endif
class Cursor {
WTF_MAKE_FAST_ALLOCATED;
public:
enum Type {
Pointer = 0,
Cross,
Hand,
IBeam,
Wait,
Help,
EastResize,
NorthResize,
NorthEastResize,
NorthWestResize,
SouthResize,
SouthEastResize,
SouthWestResize,
WestResize,
NorthSouthResize,
EastWestResize,
NorthEastSouthWestResize,
NorthWestSouthEastResize,
ColumnResize,
RowResize,
MiddlePanning,
EastPanning,
NorthPanning,
NorthEastPanning,
NorthWestPanning,
SouthPanning,
SouthEastPanning,
SouthWestPanning,
WestPanning,
Move,
VerticalText,
Cell,
ContextMenu,
Alias,
Progress,
NoDrop,
Copy,
None,
NotAllowed,
ZoomIn,
ZoomOut,
Grab,
Grabbing,
Custom
};
WEBCORE_EXPORT static const Cursor& fromType(Cursor::Type);
Cursor()
#if !PLATFORM(IOS)
: m_type(static_cast<Type>(-1))
#if ENABLE(MOUSE_CURSOR_SCALE)
, m_imageScaleFactor(1)
#endif
, m_platformCursor(0)
#endif // !PLATFORM(IOS)
{
}
#if !PLATFORM(IOS)
WEBCORE_EXPORT Cursor(Image*, const IntPoint& hotSpot);
WEBCORE_EXPORT Cursor(const Cursor&);
#if ENABLE(MOUSE_CURSOR_SCALE)
WEBCORE_EXPORT Cursor(Image*, const IntPoint& hotSpot, float imageScaleFactor);
#endif
WEBCORE_EXPORT ~Cursor();
WEBCORE_EXPORT Cursor& operator=(const Cursor&);
explicit Cursor(Type);
Type type() const
{
ASSERT(m_type >= 0 && m_type <= Custom);
return m_type;
}
Image* image() const { return m_image.get(); }
const IntPoint& hotSpot() const { return m_hotSpot; }
#if ENABLE(MOUSE_CURSOR_SCALE)
float imageScaleFactor() const { return m_imageScaleFactor; }
#endif
WEBCORE_EXPORT PlatformCursor platformCursor() const;
private:
void ensurePlatformCursor() const;
Type m_type;
RefPtr<Image> m_image;
IntPoint m_hotSpot;
#if ENABLE(MOUSE_CURSOR_SCALE)
float m_imageScaleFactor;
#endif
#if !USE(APPKIT)
mutable PlatformCursor m_platformCursor;
#else
mutable RetainPtr<NSCursor> m_platformCursor;
#endif
#endif // !PLATFORM(IOS)
};
IntPoint determineHotSpot(Image*, const IntPoint& specifiedHotSpot);
WEBCORE_EXPORT const Cursor& pointerCursor();
const Cursor& crossCursor();
WEBCORE_EXPORT const Cursor& handCursor();
const Cursor& moveCursor();
WEBCORE_EXPORT 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();
const Cursor& northSouthResizeCursor();
const Cursor& eastWestResizeCursor();
const Cursor& northEastSouthWestResizeCursor();
const Cursor& northWestSouthEastResizeCursor();
const Cursor& columnResizeCursor();
const Cursor& rowResizeCursor();
const Cursor& middlePanningCursor();
const Cursor& eastPanningCursor();
const Cursor& northPanningCursor();
const Cursor& northEastPanningCursor();
const Cursor& northWestPanningCursor();
const Cursor& southPanningCursor();
const Cursor& southEastPanningCursor();
const Cursor& southWestPanningCursor();
const Cursor& westPanningCursor();
const Cursor& verticalTextCursor();
const Cursor& cellCursor();
const Cursor& contextMenuCursor();
const Cursor& noDropCursor();
const Cursor& notAllowedCursor();
const Cursor& progressCursor();
const Cursor& aliasCursor();
const Cursor& zoomInCursor();
const Cursor& zoomOutCursor();
const Cursor& copyCursor();
const Cursor& noneCursor();
const Cursor& grabCursor();
const Cursor& grabbingCursor();
}
#endif // Cursor_h