xtd 0.2.0
pen.h
Go to the documentation of this file.
1 #pragma once
5 #include "../drawing_export.h"
6 #include "drawing_2d/line_cap.h"
7 #include "drawing_2d/line_join.h"
9 #include "drawing_2d/pen_type.h"
10 #include "brush.h"
11 #include "color.h"
12 #include "dash_style.h"
13 #include <xtd/iequatable>
14 #include <xtd/object>
15 #include <xtd/ustring>
16 #include <cstdint>
17 #include <memory>
18 #include <ostream>
19 
21 namespace xtd {
23  namespace drawing {
35  class drawing_export_ pen final : public xtd::object, public xtd::iequatable<pen> {
36  struct data;
37 
38  public:
40 
46  template <typename brush_t>
47  explicit pen(const brush_t& brush) {
48  create_data();
49  this->brush(brush);
50  }
51 
57  template<typename brush_t>
58  pen(const brush_t& brush, float width) {
59  create_data();
60  this->width(width);
61  this->brush(brush);
62  }
63 
67  explicit pen(const xtd::drawing::color& color);
68 
73  pen(const xtd::drawing::color& color, float width);
75 
77  pen(const xtd::drawing::pen& value);
78  pen& operator =(const xtd::drawing::pen& value);
79  ~pen();
81 
83 
88  xtd::drawing::drawing_2d::pen_alignment alignment() const noexcept;
89 
94 
98  const std::unique_ptr<xtd::drawing::brush>& brush() const noexcept;
102  template<typename brush_t>
103  xtd::drawing::pen& brush(const brush_t& value) {
104  brush_(value.template memberwise_clone<brush_t>());
106  recreate_handle();
107  return *this;
108  }
109 
112  const xtd::drawing::color& color() const noexcept;
116  xtd::drawing::pen& color(const xtd::drawing::color& value);
117 
123  std::vector<float> dash_pattern() const noexcept;
129  xtd::drawing::pen& dash_pattern(const std::vector<float>& value);
130 
134  xtd::drawing::dash_style dash_style() const noexcept;
140 
143  xtd::drawing::drawing_2d::line_cap end_cap() const noexcept;
148 
151  intptr handle() const noexcept;
152 
164 
169  float miter_limit() const noexcept;
175  xtd::drawing::pen& miter_limit(float value);
176 
179  xtd::drawing::drawing_2d::line_cap start_cap() const noexcept;
184 
188  xtd::drawing::drawing_2d::pen_type type() const noexcept;
189 
193  float width() const noexcept;
198  xtd::drawing::pen& width(float value);
200 
202  xtd::drawing::pen& dash_pattern(const std::initializer_list<float>& value);
204 
206 
208  bool equals(const xtd::drawing::pen& value) const noexcept override;
209 
210  xtd::ustring to_string() const noexcept override;
212 
213  private:
214  pen();
215  void brush_(std::unique_ptr<xtd::drawing::brush>&& brush);
216  void color_(const xtd::drawing::color& color);
217  void create_data();
218  void recreate_handle();
219 
220  std::shared_ptr<data> data_;
221  };
222  }
223 }
dash_style
Specifies the style of dashed lines drawn with a xtd::drawing::pen object.
Definition: dash_style.h:18
Contains xtd::drawing::drawing_2d/::pen_type enum class.
std::type_info type
Stores information about a type.
Definition: types.h:217
intmax_t intptr
Represent a pointer or a handle.
Definition: types.h:151
line_cap
Specifies the available cap styles with which a xtd::drawing::pen object can end a line...
Definition: line_cap.h:20
pen(const brush_t &brush, float width)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
Definition: pen.h:58
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static const xtd::drawing::color empty
Represents a color that is null.
Definition: color.h:51
Contains xtd::drawing::brush class.
Contains xtd::drawing::drawing_2d/::line_join enum class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1063
pen_alignment
SSpecifies the alignment of a xtd::drawing::pen object in relation to the theoretical, zero-width line.
Definition: pen_alignment.h:22
pen_type
Specifies the type of fill a xtd::drawing::pen object uses to fill lines.
Definition: pen_type.h:21
line_join
Specifies how to join consecutive line or curve segments in a figure (subpath) contained in a xtd::dr...
Definition: line_join.h:21
Contains xtd::drawing::drawing_2d/::pen_alignment enum class.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:45
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: pen.h:35
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Contains xtd::drawing::dash_style enum class.
Contains xtd::drawing::color class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
xtd::drawing::pen & brush(const brush_t &value)
Sets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
Definition: pen.h:103
Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.
Definition: brush.h:33
Contains xtd::drawing::drawing_2d/::line_cap enum class.
pen(const brush_t &brush)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
Definition: pen.h:47