xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 
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 
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 }
Contains xtd::drawing::bitmap class.
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition: bitmap.h:19
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Represents the image used to paint the mouse pointer.
Definition: cursor.h:35
static drawing::point position()
Gets the cursor's position.
static xtd::forms::cursor current()
Gets a cursor object that represents the mouse cursor.
cursor()
Initializes a new instance of the cursor class.
intptr_t copy_handle() const
Copies the handle of this cursor.
static void show()
Displays the cursor.
xtd::ustring to_string() const noexcept override
Returns a string containing the name of the cursor.
std::any tag() const
Gets the object that contains data about the control.
Definition: cursor.h:84
static void hide()
Hides the cursor.
cursor(intptr_t handle)
Initializes a new instance of the Cursor class from the specified Windows handle.
Definition: cursor.h:42
static cursor from_bitmap(const xtd::drawing::bitmap &bitmap)
Create a cursor form a specified bitmap.
Definition: cursor.h:105
static cursor none
Represent none cursor.
Definition: cursor.h:126
static void current(const xtd::forms::cursor &cursor)
Sets a cursor object that represents the mouse cursor.
static void position(const drawing::point &position)
Sets the cursor's position.
drawing::size size() const
Gets the size of the cursor object.
Definition: cursor.h:79
drawing::point hot_spot() const
Gets the cursor hot spot.
Definition: cursor.h:66
intptr_t handle() const
Gets the handle of the cursor.
Definition: cursor.h:61
void tag(std::any tag)
Sets the object that contains data about the control.
Definition: cursor.h:89
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
Provides a collection of xtd::forms::cursor objects for use by a Windows Forms application.
Definition: cursors.h:21
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
ustring to_string() const noexcept override
Returns a std::string that represents the current object.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::drawing::point class.
Contains xtd::drawing::size class.