Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / cursor / cursor.h
blob72999d4c3be41e8cfc65a694a63129f555d60ec6
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_BASE_CURSOR_CURSOR_H_
6 #define UI_BASE_CURSOR_CURSOR_H_
8 #include "build/build_config.h"
9 #include "ui/base/ui_base_export.h"
11 namespace gfx {
12 class Point;
13 class Size;
16 #if defined(OS_WIN)
17 typedef struct HINSTANCE__* HINSTANCE;
18 typedef struct HICON__* HICON;
19 typedef HICON HCURSOR;
20 #endif
22 namespace ui {
24 #if defined(OS_WIN)
25 typedef ::HCURSOR PlatformCursor;
26 #elif defined(USE_X11)
27 typedef unsigned long PlatformCursor;
28 #else
29 typedef void* PlatformCursor;
30 #endif
32 // TODO(jamescook): Once we're on C++0x we could change these constants
33 // to an enum and forward declare it in native_widget_types.h.
35 // Equivalent to a NULL HCURSOR on Windows.
36 const int kCursorNull = 0;
38 // These cursors mirror WebKit cursors from WebCursorInfo, but are replicated
39 // here so we don't introduce a WebKit dependency.
40 const int kCursorPointer = 1;
41 const int kCursorCross = 2;
42 const int kCursorHand = 3;
43 const int kCursorIBeam = 4;
44 const int kCursorWait = 5;
45 const int kCursorHelp = 6;
46 const int kCursorEastResize = 7;
47 const int kCursorNorthResize = 8;
48 const int kCursorNorthEastResize = 9;
49 const int kCursorNorthWestResize = 10;
50 const int kCursorSouthResize = 11;
51 const int kCursorSouthEastResize = 12;
52 const int kCursorSouthWestResize = 13;
53 const int kCursorWestResize = 14;
54 const int kCursorNorthSouthResize = 15;
55 const int kCursorEastWestResize = 16;
56 const int kCursorNorthEastSouthWestResize = 17;
57 const int kCursorNorthWestSouthEastResize = 18;
58 const int kCursorColumnResize = 19;
59 const int kCursorRowResize = 20;
60 const int kCursorMiddlePanning = 21;
61 const int kCursorEastPanning = 22;
62 const int kCursorNorthPanning = 23;
63 const int kCursorNorthEastPanning = 24;
64 const int kCursorNorthWestPanning = 25;
65 const int kCursorSouthPanning = 26;
66 const int kCursorSouthEastPanning = 27;
67 const int kCursorSouthWestPanning = 28;
68 const int kCursorWestPanning = 29;
69 const int kCursorMove = 30;
70 const int kCursorVerticalText = 31;
71 const int kCursorCell = 32;
72 const int kCursorContextMenu = 33;
73 const int kCursorAlias = 34;
74 const int kCursorProgress = 35;
75 const int kCursorNoDrop = 36;
76 const int kCursorCopy = 37;
77 const int kCursorNone = 38;
78 const int kCursorNotAllowed = 39;
79 const int kCursorZoomIn = 40;
80 const int kCursorZoomOut = 41;
81 const int kCursorGrab = 42;
82 const int kCursorGrabbing = 43;
83 const int kCursorCustom = 44;
85 enum CursorSetType {
86 CURSOR_SET_NORMAL,
87 CURSOR_SET_LARGE
90 // Ref-counted cursor that supports both default and custom cursors.
91 class UI_BASE_EXPORT Cursor {
92 public:
93 Cursor();
95 // Implicit constructor.
96 Cursor(int type);
98 // Allow copy.
99 Cursor(const Cursor& cursor);
101 ~Cursor();
103 void SetPlatformCursor(const PlatformCursor& platform);
105 void RefCustomCursor();
106 void UnrefCustomCursor();
108 int native_type() const { return native_type_; }
109 PlatformCursor platform() const { return platform_cursor_; }
110 float device_scale_factor() const {
111 return device_scale_factor_;
113 void set_device_scale_factor(float device_scale_factor) {
114 device_scale_factor_ = device_scale_factor;
117 bool operator==(int type) const { return native_type_ == type; }
118 bool operator==(const Cursor& cursor) const {
119 return native_type_ == cursor.native_type_ &&
120 platform_cursor_ == cursor.platform_cursor_ &&
121 device_scale_factor_ == cursor.device_scale_factor_;
123 bool operator!=(int type) const { return native_type_ != type; }
124 bool operator!=(const Cursor& cursor) const {
125 return native_type_ != cursor.native_type_ ||
126 platform_cursor_ != cursor.platform_cursor_ ||
127 device_scale_factor_ != cursor.device_scale_factor_;
130 void operator=(const Cursor& cursor) {
131 Assign(cursor);
134 private:
135 void Assign(const Cursor& cursor);
137 // See definitions above.
138 int native_type_;
140 PlatformCursor platform_cursor_;
142 // The device scale factor for the cursor.
143 float device_scale_factor_;
146 } // namespace ui
148 #endif // UI_BASE_CURSOR_CURSOR_H_