xtd 0.2.0
Loading...
Searching...
No Matches
size.h
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.h"
6#include "size_f.h"
7#include <xtd/iequatable>
8#include <xtd/object>
9#include <xtd/ustring>
10#include <ostream>
11
13namespace xtd {
15 namespace drawing {
17 class point;
19
31 class drawing_export_ size : public xtd::object, public xtd::iequatable<size> {
32 public:
34
39
41
44 size() = default;
47 explicit size(const xtd::drawing::point& point) noexcept;
51 size(int32 width, int32 height) noexcept;
53
55 size(const xtd::drawing::size&) noexcept = default;
56 size& operator =(const xtd::drawing::size& size) noexcept = default;
57 operator size_f() const noexcept;
59
61
66 int32 height() const noexcept;
70 void height(int32 value) noexcept;
71
74 bool is_empty() const noexcept;
75
79 int32 width() const noexcept;
83 void width(int32 value) noexcept;
85
87
89 bool equals(const xtd::drawing::size& value) const noexcept override;
90
93 xtd::ustring to_string() const noexcept override;
95
97
103 static size add(const size& size1, const size& size2) noexcept;
104
108 static size ceiling(const size_f& value) noexcept;
109
113 static size round(const size_f& value) noexcept;
114
119 static xtd::drawing::size subtract(const xtd::drawing::size& sz1, const xtd::drawing::size& sz2) noexcept;
120
124 static size truncate(const size_f& value) noexcept;
126
128
133 size operator +(const xtd::drawing::size& size) const noexcept;
134
138 size& operator +=(const xtd::drawing::size& size) noexcept;
139
143 size operator -(const xtd::drawing::size& size) const noexcept;
144
148 size& operator -=(const xtd::drawing::size& size) noexcept;
150
151 private:
152 int32 width_ = 0;
153 int32 height_ = 0;
154 };
155 }
156
158 template<>
159 inline drawing::size parse<drawing::size>(const std::string& str) {
160 auto values = xtd::ustring(str).replace("}", "").replace(" height=", "").replace("{width=", "").split({','});
161 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
162 }
164}
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
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:31
size(const xtd::drawing::point &point) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified xtd::drawing::point cla...
size(int32 width, int32 height) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified dimensions.
size()=default
Initializes a new instance of the xtd::drawing::size class that has a Height and Width value of 0.
static const xtd::drawing::size empty
Gets a xtd::drawing::size class that has a Height and Width value of 0. This field is constant.
Definition size.h:37
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
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
@ point
Specifies a printer's point (1/72 inch) as the unit of measure.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::drawing::size_f class.