Chromium Code Reviews| Index: ui/aura/cursor.h |
| diff --git a/ui/aura/cursor.h b/ui/aura/cursor.h |
| index 33664e89ef05d6e3de60342c320e97f0baafe701..32314e5ebefded006c49cb24f6dc3783c433dfb9 100644 |
| --- a/ui/aura/cursor.h |
| +++ b/ui/aura/cursor.h |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -6,8 +6,30 @@ |
| #define UI_AURA_CURSOR_H_ |
| #pragma once |
| +#include "build/build_config.h" |
| +#include "ui/aura/aura_export.h" |
| + |
| +namespace gfx { |
| +class Point; |
| +class Size; |
| +} |
| + |
| +#if defined(OS_WIN) |
| +typedef struct HINSTANCE__* HINSTANCE; |
| +typedef struct HICON__* HICON; |
| +typedef HICON HCURSOR; |
| +#endif |
| + |
| namespace aura { |
| +#if defined(OS_WIN) |
| +typedef ::HCURSOR PlatformCursor; |
| +#elif defined(USE_X11) |
| +typedef unsigned long PlatformCursor; |
| +#else |
| +typedef void* PlatformCursor; |
| +#endif |
| + |
| // TODO(jamescook): Once we're on C++0x we could change these constants |
| // to an enum and forward declare it in native_widget_types.h. |
| @@ -61,6 +83,65 @@ const int kCursorGrab = 42; |
| const int kCursorGrabbing = 43; |
| const int kCursorCustom = 44; |
| +// Ref-counted cursor that supports both default and custom cursors. |
| +class AURA_EXPORT Cursor { |
| + public: |
| + Cursor() |
| + : native_type_(0), |
| + platform_(0) { |
| + } |
| + |
| + // Implicit constructor. |
| + Cursor(int type) |
| + : native_type_(type), |
| + platform_(0) { |
| + } |
| + |
| + // Allow copy. |
| + Cursor(const Cursor& cursor) |
| + : native_type_(cursor.native_type_), |
| + platform_(cursor.platform_) { |
| + if (native_type_ == kCursorCustom) |
| + RefCustomCursor(); |
| + } |
| + |
| + ~Cursor() { |
| + if (native_type_ == kCursorCustom) |
| + UnrefCustomCursor(); |
| + } |
| + |
| + void SetPlatformCursor(const PlatformCursor& platform) { |
| + if (platform_) |
| + UnrefCustomCursor(); |
| + native_type_ = kCursorCustom; |
| + platform_ = platform; |
| + RefCustomCursor(); |
| + } |
| + |
| + void RefCustomCursor(); |
| + void UnrefCustomCursor(); |
| + |
| + int native_type() const { return native_type_; } |
| + PlatformCursor platform() const { return platform_; } |
| + |
| + bool operator==(int type) const { return native_type_ == type; } |
|
Daniel Erat
2012/02/27 17:53:55
This feels a bit weird to me. I think that it'd b
|
| + bool operator==(const Cursor& cursor) const { |
| + return native_type_ == cursor.native_type_ && |
| + platform_ == cursor.platform_; |
| + } |
| + bool operator!=(int type) const { return native_type_ != type; } |
| + bool operator!=(const Cursor& cursor) const { |
| + return native_type_ != cursor.native_type_ || |
| + platform_ != cursor.platform_; |
| + } |
| + |
| + private: |
| + // See definitions above. |
| + int native_type_; |
| + |
| + PlatformCursor platform_; |
|
Daniel Erat
2012/02/27 17:53:55
nit: rename to platform_cursor_
|
| +}; |
| + |
| } // namespace aura |
| #endif // UI_AURA_CURSOR_H_ |