xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
cursor.h
1 #pragma once
2 #include <any>
3 #include <cstdint>
4 #include <memory>
5 #include <xtd/drawing/bitmap.h>
6 #include <xtd/drawing/point.h>
7 #include <xtd/drawing/size.h>
8 
10 namespace xtd {
12  namespace forms {
14  class cursors;
16 
21  class cursor {
22  public:
24  cursor();
28  explicit cursor(intptr_t handle) : cursor(handle, false, "") {}
29 
31  cursor(const cursor& value) = default;
32  ~cursor();
34 
38  static xtd::forms::cursor current();
42  static void current(const xtd::forms::cursor& cursor);
43 
47  intptr_t handle() const {return this->data_->handle_;}
48 
52  drawing::point hot_spot() const {return this->data_->hot_spot_;}
53 
57  static drawing::point position();
61  static void position(const drawing::point& position);
62 
65  drawing::size size() const {return this->data_->size_;}
66 
70  std::any tag() const {return this->data_->tag_;}
71 
75  void tag(std::any tag) {this->data_->tag_ = tag;}
76 
80  intptr_t copy_handle() const;
81 
82  static cursor from_bitmap(const xtd::drawing::bitmap& bitmap, const xtd::drawing::point& hot_spot) {return cursor(bitmap, hot_spot);}
83  static cursor from_bitmap(const xtd::drawing::bitmap& bitmap) {return from_bitmap(bitmap, {});}
84 
87  static void hide();
88 
91  static void show();
92 
93  std::string to_string() const;
94 
96  friend std::ostream& operator<<(std::ostream& os, const cursor& value) noexcept {return os << value.to_string();}
97  bool operator==(const cursor& value) const {return this->data_ == value.data_;}
98  bool operator!=(const cursor& value) const {return !this->operator==(value);}
100 
101  static cursor none;
102 
103  private:
104  friend class cursors;
105  cursor(const xtd::drawing::bitmap& bitmap, const xtd::drawing::point& hot_spot);
106  cursor(intptr_t handle, bool destroyable, const std::string& name);
107 
108  struct data {
109  intptr_t handle_ = 0;
110  bool destroyable_ = true;
111  drawing::point hot_spot_;
112  std::string name_;
113  drawing::size size_;
114  std::any tag_;
115  };
116  std::shared_ptr<data> data_ = std::make_shared<data>();
117  };
118  }
119 }
drawing::point hot_spot() const
Gets the cursor hot spot.
Definition: cursor.h:52
static void hide()
Hides the cursor.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
intptr_t copy_handle() const
drawing::size size() const
Gets the size of the cursor object.
Definition: cursor.h:65
cursor()
Initializes a new instance of the Cursor class.
Represents the image used to paint the mouse pointer.
Definition: cursor.h:21
Provides a collection of Cursor objects for use by a Windows Forms application.
Definition: cursors.h:10
void tag(std::any tag)
Sets the object that contains data about the control.
Definition: cursor.h:75
static void show()
Displays the cursor.
std::any tag() const
Gets the object that contains data about the control.
Definition: cursor.h:70
static xtd::forms::cursor current()
Gets a cursor object that represents the mouse cursor.
static drawing::point position()
Gets the cursor&#39;s position.
cursor(intptr_t handle)
Initializes a new instance of the Cursor class from the specified Windows handle. ...
Definition: cursor.h:28
intptr_t handle() const
Gets the handle of the cursor.
Definition: cursor.h:47