xtd - Reference Guide 0.2.0
icon.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <memory>
7 #include <xtd/object.h>
8 #include <xtd/ustring.h>
9 #include "../drawing_export.h"
10 #include "bitmap.h"
11 
13 namespace xtd {
15  namespace drawing {
27  class drawing_export_ icon : public xtd::object {
28  public:
30 
32  static icon empty;
34 
36 
45  explicit icon(const xtd::ustring& filename);
51  icon(const xtd::ustring& filename, const xtd::drawing::size& size);
58  icon(const xtd::ustring& filename, int32_t width, int32_t height);
66  explicit icon(std::istream& stream);
70  icon(std::istream& stream, const xtd::drawing::size& size);
75  icon(std::istream& stream, int32_t width, int32_t height);
84  explicit icon(const char* const* bits);
89  icon(const char* const* bits, const xtd::drawing::size& size);
95  icon(const char* const* bits, int32_t width, int32_t height);
100  icon(const icon& original, const xtd::drawing::size& size);
106  icon(const icon& original, int32_t width, int32_t height);
108 
110  icon() = default;
111  icon(const icon& icon) = default;
112  icon& operator =(const icon& icon) = default;
113  bool operator ==(const icon& icon) const;
114  bool operator !=(const icon& icon) const;
115  ~icon();
117 
119 
123  intptr_t handle() const;
124 
127  int32_t height() const;
128 
131  const xtd::drawing::size& size() const;
132 
135  int32_t width() const;
137 
139 
143  void save(const xtd::ustring& filename) const;
146  void save(std::ostream& stream) const;
147 
152  static icon from_handle(intptr_t handle);
153 
157  static icon from_bitmap(const xtd::drawing::bitmap& bitmap);
158 
162  xtd::drawing::bitmap to_bitmap() const;
163 
166  xtd::ustring to_string() const noexcept override {return ustring::full_class_name(*this);}
168 
169  private:
170  explicit icon(const bitmap& bitmap);
171  struct data {
172  intptr_t handle = 0;
173  xtd::drawing::size size;
174  };
175 
176  std::shared_ptr<data> data_ = std::make_shared<data>();
177  };
178  }
179 }
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:51
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes...
Definition: bitmap.h:24
Contains xtd::ustring class.
xtd::ustring to_string() const noexcept override
Gets a human-readable string that describes the xtd::drawing::icon.
Definition: icon.h:166
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
Contains xtd::drawing::bitmap class.
static ustring full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t...
Definition: ustring.h:781
Represents a Windows icon, which is a small bitmap image that is used to represent an object...
Definition: icon.h:27