xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
cursor.h
Go to the documentation of this file.
1 #pragma once
5 #include <any>
6 #include <cstdint>
7 #include <memory>
8 #include <xtd/object.h>
9 #include <xtd/drawing/bitmap.h>
10 #include <xtd/drawing/point.h>
11 #include <xtd/drawing/size.h>
12 #include "../forms_export.h"
13 
15 namespace xtd {
17  namespace forms {
19  class cursors;
21 
35  class forms_export_ cursor : public object {
36  public:
38  cursor();
42  explicit cursor(intptr_t handle) : cursor(handle, false, "") {}
43 
45  cursor(const cursor& value) = default;
46  ~cursor();
48 
52  static xtd::forms::cursor current();
56  static void current(const xtd::forms::cursor& cursor);
57 
61  intptr_t handle() const {return data_->handle_;}
62 
66  drawing::point hot_spot() const {return data_->hot_spot_;}
67 
71  static drawing::point position();
75  static void position(const drawing::point& position);
76 
79  drawing::size size() const {return data_->size_;}
80 
84  std::any tag() const {return data_->tag_;}
85 
89  void tag(std::any tag) {data_->tag_ = tag;}
90 
94  intptr_t copy_handle() const;
95 
100  static cursor from_bitmap(const xtd::drawing::bitmap& bitmap, const xtd::drawing::point& hot_spot) {return cursor(bitmap, hot_spot);}
105  static cursor from_bitmap(const xtd::drawing::bitmap& bitmap) {return from_bitmap(bitmap, {});}
106 
109  static void hide();
110 
113  static void show();
114 
117  xtd::ustring to_string() const noexcept override;
118 
120  friend std::ostream& operator<<(std::ostream& os, const cursor& value) noexcept {return os << value.to_string();}
121  bool operator==(const cursor& value) const {return data_ == value.data_;}
122  bool operator!=(const cursor& value) const {return !operator==(value);}
124 
126  static cursor none;
127 
128  private:
129  friend class xtd::forms::cursors;
130  cursor(const xtd::drawing::bitmap& bitmap, const xtd::drawing::point& hot_spot);
131  cursor(intptr_t handle, bool destroyable, const xtd::ustring& name);
132 
133  struct data {
134  intptr_t handle_ = 0;
135  bool destroyable_ = true;
136  xtd::drawing::point hot_spot_;
137  xtd::ustring name_;
138  xtd::drawing::size size_;
139  std::any tag_;
140  };
141  std::shared_ptr<data> data_ = std::make_shared<data>();
142  };
143  }
144 }
drawing::point hot_spot() const
Gets the cursor hot spot.
Definition: cursor.h:66
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
Contains xtd::drawing::point class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
drawing::size size() const
Gets the size of the cursor object.
Definition: cursor.h:79
xtd::ustring to_string() const noexcept override
Returns a string containing the name of the cursor.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Represents the image used to paint the mouse pointer.
Definition: cursor.h:35
Provides a collection of xtd::forms::cursor objects for use by a Windows Forms application.
Definition: cursors.h:21
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes...
Definition: bitmap.h:19
static cursor from_bitmap(const xtd::drawing::bitmap &bitmap, const xtd::drawing::point &hot_spot)
Create a cursor form a specified bitmap with specified hot spot.
Definition: cursor.h:100
Hides minimized windows by moving them off the visible area of the screen.
Contains xtd::drawing::size class.
void tag(std::any tag)
Sets the object that contains data about the control.
Definition: cursor.h:89
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
static cursor from_bitmap(const xtd::drawing::bitmap &bitmap)
Create a cursor form a specified bitmap.
Definition: cursor.h:105
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
Contains xtd::drawing::bitmap class.
std::any tag() const
Gets the object that contains data about the control.
Definition: cursor.h:84
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static cursor none
Represent none cursor.
Definition: cursor.h:126
cursor(intptr_t handle)
Initializes a new instance of the Cursor class from the specified Windows handle. ...
Definition: cursor.h:42
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37
intptr_t handle() const
Gets the handle of the cursor.
Definition: cursor.h:61