xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
pen.h
Go to the documentation of this file.
1
4#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"
16
18namespace xtd {
20 namespace drawing {
22 class graphics;
24
29 class drawing_export_ pen final : public object {
30 public:
32 pen();
33
39
45 pen(const xtd::drawing::brush& brush, float width);
46
51
56 pen(const xtd::drawing::color& color, float width);
57
59 pen(const xtd::drawing::pen& value);
60 pen& operator=(const xtd::drawing::pen& value);
61 ~pen();
62 bool operator==(const xtd::drawing::pen& value) const {return data_->alignment_ == value.data_->alignment_ && data_->type_ == value.data_->type_;}
63 bool operator!=(const xtd::drawing::pen& value) const {return !operator==(value);}
65
69 xtd::drawing::drawing2d::pen_alignment alignment() const {return data_->alignment_;}
70
75
76 std::unique_ptr<xtd::drawing::brush> brush() const;
78
79 const xtd::drawing::color& color() const {return data_->color_;}
81
82 std::vector<float> dash_pattern() const {return data_->dash_pattern_;}
83 xtd::drawing::pen& dash_pattern(const std::initializer_list<float>& il) {return dash_pattern(std::vector<float>(il));}
84 xtd::drawing::pen& dash_pattern(const std::vector<float>& dash_pattern);
85
86 xtd::drawing::dash_style dash_style() const {return data_->dash_style_;}
87 xtd::drawing::pen& dash_style(drawing::dash_style dash_style);
88
89 xtd::drawing::drawing2d::pen_type type() const {return data_->type_;}
91
92 float width() const {return data_->width_;}
93 xtd::drawing::pen& width(float width);
94
95 xtd::ustring to_string() const noexcept override {return ustring::full_class_name(*this);}
96
98 friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::pen& pen) noexcept {
99 return os << pen.to_string();
100 }
102
103 private:
104 friend class graphics;
105 struct data {
106 intptr_t handle_ = 0;
108 xtd::drawing::color color_;
111 float width_ = 1.0f;
112 std::vector<float> dash_pattern_;
113 };
114 std::shared_ptr<data> data_ = std::make_shared<data>();
115 };
116 }
117}
Contains xtd::drawing::brush class.
Defines objects used to fill the interiors of graphical shapes such as rectangles,...
Definition brush.h:27
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
xtd::drawing::pen & alignment(xtd::drawing::drawing2d::pen_alignment alignment)
Sets the alignment for this xtd::drawing::pen.
pen(const xtd::drawing::brush &brush)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
pen()
Initializes a new instance of the xtd::drawing::pen class.
pen(const xtd::drawing::brush &brush, float width)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
pen(const xtd::drawing::color &color, float width)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition pen.h:95
xtd::drawing::drawing2d::pen_alignment alignment() const
Gets the alignment for this xtd::drawing::pen.
Definition pen.h:69
pen(const xtd::drawing::color &color)
Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
Contains xtd::drawing::color class.
Contains xtd::drawing::dash_style enum class.
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
std::type_info type
Stores information about a type.
Definition types.h:179
dash_style
Specifies the style of dashed lines drawn with a xtd::drawing::pen object.
Definition dash_style.h:18
pen_type
Specifies the type of fill a xtd::drawing::pen object uses to fill lines.
Definition pen_type.h:20
pen_alignment
SSpecifies the alignment of a xtd::drawing::pen object in relation to the theoretical,...
Definition pen_alignment.h:21
@ solid
Specifies a solid line.
@ solid_color
Specifies a solid fill.
@ center
Specifies that the xtd::drawing::pen object is centered over the theoretical line.
@ width
Specifies that the width of the control is defined.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.
Contains xtd::drawing::drawing2d::pen_alignment enum class.
Contains xtd::drawing::drawing2d::pen_type enum class.
Contains xtd::ustring class.