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.
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"
15 namespace xtd {
17  namespace forms {
19  class cursors;
35  class forms_export_ cursor : public object {
36  public:
38  cursor();
42  explicit cursor(intptr_t handle) : cursor(handle, false, "") {}
45  cursor(const cursor& value) = default;
46  ~cursor();
52  static xtd::forms::cursor current();
56  static void current(const xtd::forms::cursor& cursor);
61  intptr_t handle() const {return data_->handle_;}
66  drawing::point hot_spot() const {return data_->hot_spot_;}
71  static drawing::point position();
75  static void position(const drawing::point& position);
79  drawing::size size() const {return data_->size_;}
84  std::any tag() const {return data_->tag_;}
89  void tag(std::any tag) {data_->tag_ = tag;}
94  intptr_t copy_handle() const;
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, {});}
109  static void hide();
113  static void show();
117  xtd::ustring to_string() const noexcept override;
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);}
126  static cursor none;
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);
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