| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_AURA_CURSOR_H_ | 5 #ifndef UI_BASE_CURSOR_CURSOR_H_ |
| 6 #define UI_AURA_CURSOR_H_ | 6 #define UI_BASE_CURSOR_CURSOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 namespace aura { | 9 #include "build/build_config.h" |
| 10 #include "ui/base/ui_export.h" |
| 11 |
| 12 namespace gfx { |
| 13 class Point; |
| 14 class Size; |
| 15 } |
| 16 |
| 17 #if defined(OS_WIN) |
| 18 typedef struct HINSTANCE__* HINSTANCE; |
| 19 typedef struct HICON__* HICON; |
| 20 typedef HICON HCURSOR; |
| 21 #endif |
| 22 |
| 23 namespace ui { |
| 24 |
| 25 #if defined(OS_WIN) |
| 26 typedef ::HCURSOR PlatformCursor; |
| 27 #elif defined(USE_X11) |
| 28 typedef unsigned long PlatformCursor; |
| 29 #else |
| 30 typedef void* PlatformCursor; |
| 31 #endif |
| 10 | 32 |
| 11 // TODO(jamescook): Once we're on C++0x we could change these constants | 33 // TODO(jamescook): Once we're on C++0x we could change these constants |
| 12 // to an enum and forward declare it in native_widget_types.h. | 34 // to an enum and forward declare it in native_widget_types.h. |
| 13 | 35 |
| 14 // Equivalent to a NULL HCURSOR on Windows. | 36 // Equivalent to a NULL HCURSOR on Windows. |
| 15 const int kCursorNull = 0; | 37 const int kCursorNull = 0; |
| 16 | 38 |
| 17 // Aura cursors mirror WebKit cursors from WebCursorInfo, but are replicated | 39 // These cursors mirror WebKit cursors from WebCursorInfo, but are replicated |
| 18 // here so we don't introduce a WebKit dependency. | 40 // here so we don't introduce a WebKit dependency. |
| 19 const int kCursorPointer = 1; | 41 const int kCursorPointer = 1; |
| 20 const int kCursorCross = 2; | 42 const int kCursorCross = 2; |
| 21 const int kCursorHand = 3; | 43 const int kCursorHand = 3; |
| 22 const int kCursorIBeam = 4; | 44 const int kCursorIBeam = 4; |
| 23 const int kCursorWait = 5; | 45 const int kCursorWait = 5; |
| 24 const int kCursorHelp = 6; | 46 const int kCursorHelp = 6; |
| 25 const int kCursorEastResize = 7; | 47 const int kCursorEastResize = 7; |
| 26 const int kCursorNorthResize = 8; | 48 const int kCursorNorthResize = 8; |
| 27 const int kCursorNorthEastResize = 9; | 49 const int kCursorNorthEastResize = 9; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 const int kCursorNoDrop = 36; | 76 const int kCursorNoDrop = 36; |
| 55 const int kCursorCopy = 37; | 77 const int kCursorCopy = 37; |
| 56 const int kCursorNone = 38; | 78 const int kCursorNone = 38; |
| 57 const int kCursorNotAllowed = 39; | 79 const int kCursorNotAllowed = 39; |
| 58 const int kCursorZoomIn = 40; | 80 const int kCursorZoomIn = 40; |
| 59 const int kCursorZoomOut = 41; | 81 const int kCursorZoomOut = 41; |
| 60 const int kCursorGrab = 42; | 82 const int kCursorGrab = 42; |
| 61 const int kCursorGrabbing = 43; | 83 const int kCursorGrabbing = 43; |
| 62 const int kCursorCustom = 44; | 84 const int kCursorCustom = 44; |
| 63 | 85 |
| 64 } // namespace aura | 86 // Ref-counted cursor that supports both default and custom cursors. |
| 87 class UI_EXPORT Cursor { |
| 88 public: |
| 89 Cursor(); |
| 65 | 90 |
| 66 #endif // UI_AURA_CURSOR_H_ | 91 // Implicit constructor. |
| 92 Cursor(int type); |
| 93 |
| 94 // Allow copy. |
| 95 Cursor(const Cursor& cursor); |
| 96 |
| 97 ~Cursor(); |
| 98 |
| 99 void SetPlatformCursor(const PlatformCursor& platform); |
| 100 |
| 101 void RefCustomCursor(); |
| 102 void UnrefCustomCursor(); |
| 103 |
| 104 int native_type() const { return native_type_; } |
| 105 PlatformCursor platform() const { return platform_cursor_; } |
| 106 |
| 107 bool operator==(int type) const { return native_type_ == type; } |
| 108 bool operator==(const Cursor& cursor) const { |
| 109 return native_type_ == cursor.native_type_ && |
| 110 platform_cursor_ == cursor.platform_cursor_; |
| 111 } |
| 112 bool operator!=(int type) const { return native_type_ != type; } |
| 113 bool operator!=(const Cursor& cursor) const { |
| 114 return native_type_ != cursor.native_type_ || |
| 115 platform_cursor_ != cursor.platform_cursor_; |
| 116 } |
| 117 |
| 118 private: |
| 119 // See definitions above. |
| 120 int native_type_; |
| 121 |
| 122 PlatformCursor platform_cursor_; |
| 123 }; |
| 124 |
| 125 } // namespace ui |
| 126 |
| 127 #endif // UI_BASE_CURSOR_CURSOR_H_ |
| OLD | NEW |