xtd - Reference Guide 0.2.0
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <memory>
7 #include <ostream>
8 #include <xtd/object.h>
9 #include <xtd/ustring.h>
10 #include "../drawing_export.h"
11 #include "drawing2d/line_cap.h"
12 #include "drawing2d/line_join.h"
14 #include "drawing2d/pen_type.h"
15 #include "brush.h"
16 #include "color.h"
17 #include "dash_style.h"
20 namespace xtd {
22  namespace drawing {
34  class drawing_export_ pen final : public xtd::object {
35  public:
43  template <typename brush_t>
44  explicit pen(const brush_t& brush) {
45  this->brush(brush);
46  }
53  template<typename brush_t>
54  pen(const brush_t& brush, float width) {
55  this->width(width);
56  this->brush(brush);
57  }
62  explicit pen(const xtd::drawing::color& color);
68  pen(const xtd::drawing::color& color, float width);
72  pen(const xtd::drawing::pen& value);
73  pen& operator =(const xtd::drawing::pen& value);
74  ~pen();
75  bool operator ==(const xtd::drawing::pen& value) const;
76  bool operator !=(const xtd::drawing::pen& value) const;
95  const std::unique_ptr<xtd::drawing::brush>& brush() const;
99  template<typename brush_t>
100  xtd::drawing::pen& brush(const brush_t& value) {
101  data_->brush = value.template memberwise_clone<brush_t>();
102  data_->color = xtd::drawing::color::empty;
103  recreate_handle();
104  return *this;
105  }
109  const xtd::drawing::color& color() const;
113  xtd::drawing::pen& color(const xtd::drawing::color& value);
120  std::vector<float> dash_pattern() const;
126  xtd::drawing::pen& dash_pattern(const std::vector<float>& value);
140  xtd::drawing::drawing2d::line_cap end_cap() const noexcept;
148  intptr_t handle() const;
166  float miter_limit() const noexcept;
172  xtd::drawing::pen& miter_limit(float value);
176  xtd::drawing::drawing2d::line_cap start_cap() const noexcept;
190  float width() const {return data_->width;}
195  xtd::drawing::pen& width(float value);
199  xtd::drawing::pen& dash_pattern(const std::initializer_list<float>& value);
205  xtd::ustring to_string() const noexcept override;
208  private:
209  pen();
210  void recreate_handle();
211  struct data {
212  intptr_t handle_ = 0;
214  xtd::drawing::color color;
215  std::unique_ptr<xtd::drawing::brush> brush;
216  float dash_offset = 0.0f;
217  std::vector<float> dash_pattern;
221  float miter_limit = 10.0f;
224  float width = 1.0f;
225  };
226  std::shared_ptr<data> data_ = std::make_shared<data>();
227  };
228  }
229 }
Specifies the style of dashed lines drawn with a xtd::drawing::pen object.
Definition: dash_style.h:18
Contains xtd::drawing::drawing2d::pen_type enum class.
std::type_info type
Stores information about a type.
Definition: types.h:179
Specifies the available cap styles with which a xtd::drawing::pen object can end a line...
Definition: line_cap.h:19
Specifies a mitered join. This produces a sharp corner or a clipped corner, depending on whether the ...
Specifies how to join consecutive line or curve segments in a figure (subpath) contained in a xtd::dr...
Definition: line_join.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:54
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:50
Specifies a solid line.
Contains xtd::drawing::brush class.
Specifies the type of fill a xtd::drawing::pen object uses to fill lines.
Definition: pen_type.h:20
Contains xtd::drawing::drawing2d::line_join enum class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:51
float width() const
Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for draw...
Definition: pen.h:190
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:1100
const std::unique_ptr< xtd::drawing::brush > & brush() const
Gets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
Specifies that the xtd::drawing::pen object is centered over the theoretical line.
Contains xtd::drawing::drawing2d::pen_alignment enum class.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:44
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: pen.h:34
Contains xtd::drawing::dash_style enum class.
Contains xtd::ustring class.
Contains xtd::drawing::color class.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
Specifies a flat line cap.
xtd::drawing::pen & brush(const brush_t &value)
Sets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
Definition: pen.h:100
Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.
Definition: brush.h:50
Contains xtd::drawing::drawing2d::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:44
SSpecifies the alignment of a xtd::drawing::pen object in relation to the theoretical, zero-width line.
Definition: pen_alignment.h:21