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/string>
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 using object::equals;
90 bool equals(const xtd::drawing::size& value) const noexcept override;
91
94 xtd::string to_string() const noexcept override;
96
98
104 static size add(const size& size1, const size& size2) noexcept;
105
109 static size ceiling(const size_f& value) noexcept;
110
114 static size round(const size_f& value) noexcept;
115
120 static xtd::drawing::size subtract(const xtd::drawing::size& sz1, const xtd::drawing::size& sz2) noexcept;
121
125 static size truncate(const size_f& value) noexcept;
127
129
134 size operator +(const xtd::drawing::size& size) const noexcept;
135
139 size& operator +=(const xtd::drawing::size& size) noexcept;
140
144 size operator -(const xtd::drawing::size& size) const noexcept;
145
149 size& operator -=(const xtd::drawing::size& size) noexcept;
151
152 private:
153 int32 width_ = 0;
154 int32 height_ = 0;
155 };
156 }
157
159 template<>
160 inline drawing::size parse<drawing::size>(const std::string& str) {
161 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
162 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
163 }
165}
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
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:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.h:43
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
@ 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.