xtd 0.2.0
Loading...
Searching...
No Matches
size_f.h
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.h"
6#include <xtd/iequatable>
7#include <xtd/object>
8#include <xtd/ustring>
9#include <ostream>
10
12namespace xtd {
14 namespace drawing {
16 class point_f;
17 class size;
19
31 class drawing_export_ size_f : public xtd::object, public xtd::iequatable<size_f> {
32 public:
34
39
41
44 size_f() noexcept = default;
45
48 explicit size_f(const xtd::drawing::point_f& point) noexcept;
49
53 size_f(float width, float height) noexcept;
55
57 size_f(const xtd::drawing::size_f&) noexcept = default;
58 size_f& operator =(const xtd::drawing::size_f& size) noexcept = default;
60
62
67 float height() const noexcept;
68
72 void height(float value) noexcept;
73
76 bool is_empty() const noexcept;
77
81 float width() const noexcept;
82
86 void width(float value) noexcept;
88
90
92 bool equals(const xtd::drawing::size_f& value) const noexcept override;
93
96 xtd::ustring to_string() const noexcept override;
98
100
106 static xtd::drawing::size_f add(const xtd::drawing::size_f& size1, const xtd::drawing::size_f& size2) noexcept;
107
112 static xtd::drawing::size_f subtract(const xtd::drawing::size_f& sz1, const xtd::drawing::size_f& sz2) noexcept;
114
116
121 size_f operator +(const xtd::drawing::size_f& size) const noexcept;
125 size_f operator +(const xtd::drawing::size& size) const noexcept;
126
130 size_f& operator +=(const xtd::drawing::size_f& size) noexcept;
134 size_f& operator +=(const xtd::drawing::size& size) noexcept;
135
139 size_f operator -(const xtd::drawing::size_f& size) const noexcept;
143 size_f operator -(const xtd::drawing::size& size) const noexcept;
144
148 size_f& operator -=(const xtd::drawing::size_f& size) noexcept;
152 size_f& operator -=(const xtd::drawing::size& size) noexcept;
154
155 private:
156 float width_ = 0;
157 float height_ = 0;
158 };
159 }
160
162 template<>
163 inline drawing::size_f parse<drawing::size_f>(const std::string& str) {
164 auto values = xtd::ustring(str).replace("}", "").replace(" height=", "").replace("{width=", "").split({','});
165 return {xtd::parse<float>(values[0]), xtd::parse<float>(values[1])};
166 }
168}
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.h:35
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.h:54
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.h:31
static const xtd::drawing::size_f empty
Gets a Size class that has a Height and Width value of 0. This field is constant.
Definition size_f.h:37
size_f() noexcept=default
Initializes a new instance of the Size class that has a Height and Width value of 0.
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:31
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
std::vector< ustring > split(const std::vector< value_type > &separators, size_t count, string_split_options options) const noexcept
Splits this string into a maximum number of substrings based on the characters in an array.
ustring replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this string with another specified char_t.
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
size_t size
Represents a size of any object in bytes.
Definition types.h:197
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.h:191
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10