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 <cstdint>
6 #include <memory>
7 #include <ostream>
8 #include <xtd/object.h>
9 #include <xtd/ustring.h>
10 #include "../drawing_export.h"
12 #include "drawing2d/pen_type.h"
13 #include "brush.h"
14 #include "color.h"
15 #include "dash_style.h"
18 namespace xtd {
20  namespace drawing {
22  class graphics;
29  class drawing_export_ pen final : public object {
30  public:
42  pen(const xtd::drawing::brush& brush, float width);
53  pen(const xtd::drawing::color& color, float width);
56  pen(const xtd::drawing::pen& value);
57  pen& operator=(const xtd::drawing::pen& value);
58  ~pen();
59  bool operator==(const xtd::drawing::pen& value) const {return data_->alignment_ == value.data_->alignment_ && data_->type_ == value.data_->type_;}
60  bool operator!=(const xtd::drawing::pen& value) const {return !operator==(value);}
66  xtd::drawing::drawing2d::pen_alignment alignment() const {return data_->alignment_;}
73  std::unique_ptr<xtd::drawing::brush> brush() const;
74  xtd::drawing::pen& brush(const xtd::drawing::brush& brush);
76  const xtd::drawing::color& color() const {return data_->color_;}
77  xtd::drawing::pen& color(const xtd::drawing::color& color);
79  std::vector<float> dash_pattern() const {return data_->dash_pattern_;}
80  xtd::drawing::pen& dash_pattern(const std::initializer_list<float>& il) {return dash_pattern(std::vector<float>(il));}
81  xtd::drawing::pen& dash_pattern(const std::vector<float>& dash_pattern);
83  xtd::drawing::dash_style dash_style() const {return data_->dash_style_;}
86  xtd::drawing::drawing2d::pen_type type() const {return data_->type_;}
89  float width() const {return data_->width_;}
90  xtd::drawing::pen& width(float width);
92  xtd::ustring to_string() const noexcept override {return ustring::full_class_name(*this);}
95  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::pen& pen) noexcept {
96  return os << pen.to_string();
97  }
100  private:
101  pen();
102  friend class graphics;
103  struct data {
104  intptr_t handle_ = 0;
106  xtd::drawing::color color_;
109  float width_ = 1.0f;
110  std::vector<float> dash_pattern_;
111  };
112  std::shared_ptr<data> data_ = std::make_shared<data>();
113  };
114  }
115 }
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
xtd::drawing::drawing2d::pen_alignment alignment() const
Gets the alignment for this xtd::drawing::pen.
Definition: pen.h:66
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
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
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
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:39
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: pen.h:29
Contains xtd::drawing::dash_style enum class.
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition: pen.h:92
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:26
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:427
Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.
Definition: brush.h:27
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
SSpecifies the alignment of a xtd::drawing::pen object in relation to the theoretical, zero-width line.
Definition: pen_alignment.h:21