xtd - Reference Guide 0.2.0
rectangle.h
Go to the documentation of this file.
1 #pragma once
5 #include <cmath>
6 #include <cstdint>
7 #include <ostream>
8 #include <xtd/object.h>
9 #include <xtd/ustring.h>
10 #include "../drawing_export.h"
11 #include "point.h"
12 #include "size.h"
13 #include "rectangle_f.h"
14 
16 namespace xtd {
18  namespace drawing {
44  class drawing_export_ rectangle : public xtd::object {
45  public:
47 
50  static const rectangle empty;
52 
54 
58  rectangle() noexcept = default;
64  rectangle(int32_t x, int32_t y, int32_t width, int32_t height) noexcept;
68  rectangle(const xtd::drawing::point& location, const xtd::drawing::size& size) noexcept;
70 
72  rectangle(const rectangle&) noexcept = default;
73  rectangle& operator =(const rectangle&) noexcept = default;
74  operator rectangle_f() const noexcept;
76 
78 
83  int32_t bottom() const noexcept;
84 
88  int32_t height() const noexcept;
92  void height(int32_t value) noexcept;
93 
96  bool is_empty() const noexcept;
97 
100  int32_t left() const noexcept;
101 
104  xtd::drawing::point location() const noexcept;
107  void location(const xtd::drawing::point& value) noexcept;
108 
111  int32_t right() const noexcept;
112 
115  xtd::drawing::size size() const noexcept;
118  void size(const xtd::drawing::size& value) noexcept;
119 
122  int32_t top() const noexcept;
123 
127  int32_t width() const noexcept;
131  void width(int32_t value) noexcept;
132 
136  int32_t x() const noexcept;
140  void x(int32_t value) noexcept;
141 
145  int32_t y() const noexcept;
149  void y(int32_t value) noexcept;
151 
153 
158  void add(const drawing::size& sz) noexcept;
163  void add(int width, int height) noexcept;
170  static rectangle add(const rectangle& rect, int x, int y) noexcept;
176  static rectangle add(const rectangle& rect, const drawing::size& sz) noexcept;
177 
181  static rectangle ceiling(const xtd::drawing::rectangle_f& rect) noexcept;
182 
187  bool contains(const xtd::drawing::point& pt) const noexcept;
192  bool contains(const xtd::drawing::rectangle& rect) const noexcept;
198  bool contains(int32_t x, int32_t y) const noexcept;
199 
207  static rectangle from_ltrb(int32_t left, int32_t top, int32_t right, int32_t bottom) noexcept;
208 
212  void inflate(const drawing::size& sz) noexcept;
218  void inflate(int width, int height) noexcept;
225  static rectangle inflate(const rectangle& rect, int x, int y) noexcept;
231  static rectangle inflate(const rectangle& rect, const drawing::size& sz) noexcept;
232 
236  bool intersects_with(const rectangle& rect) const noexcept;
237 
242  static rectangle make_intersect(const rectangle& a, const rectangle& b) noexcept;
245  void make_intersect(const rectangle& rect) noexcept;
246 
251  static rectangle make_union(const rectangle& a, const rectangle& b) noexcept;
254  void make_union(const rectangle& rect) noexcept;
255 
259  void offset(const point& pos) noexcept;
263  void offset(int32_t x, int32_t y) noexcept;
269  static rectangle offset(const rectangle& rect, const point& pos) noexcept;
276  static rectangle offset(const rectangle& rect, int x, int y) noexcept;
277 
281  static rectangle round(const rectangle_f& rect) noexcept;
282 
285  xtd::ustring to_string() const noexcept override;
286 
290  static rectangle truncate(const rectangle_f& rect) noexcept;
292 
294 
299  bool operator ==(const rectangle& value) const noexcept;
303  bool operator !=(const rectangle& value) const noexcept;
305 
306  private:
307  int32_t x_ = 0;
308  int32_t y_ = 0;
309  int32_t width_ = 0;
310  int32_t height_ = 0;
311  };
312  }
313 }
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:53
Contains xtd::drawing::point class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Stores a set of four floating-point numbers that represent the location and size of a rectangle...
Definition: rectangle_f.h:34
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:51
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1100
Contains xtd::drawing::rectangle_f class.
Contains xtd::drawing::size class.
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:44
Contains xtd::ustring class.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
static const rectangle empty
Represents a xtd::drawing::rectangle that has xtd::drawing::rectagle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width and xtd::drawing::rectangle::height values set to zero.
Definition: rectangle.h:50