xtd - Reference Guide 0.2.0
point.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <ostream>
7 #include <xtd/object.h>
8 #include <xtd/ustring.h>
9 #include "../drawing_export.h"
10 #include "point_f.h"
11 
13 namespace xtd {
15  namespace drawing {
17  class size;
19 
53  class drawing_export_ point : public xtd::object {
54  public:
56 
59  static const point empty;
61 
63 
67  point() noexcept = default;
68 
91  explicit point(int32_t dw) noexcept;
92 
115  point(int32_t x, int32_t y) noexcept;
116 
138  explicit point(const size& sz) noexcept;
140 
142  point(const point&) noexcept = default;
143  point& operator=(const point&) noexcept = default;
144  operator point_f() const noexcept;
146 
148 
152  bool is_empty() const noexcept;
153 
175  int32_t x() const noexcept;
176 
198  void x(int32_t x) noexcept;
199 
221  int32_t y() const noexcept;
222 
244  void y(int32_t y) noexcept;
246 
248 
264  static point add(const point& pt, const size& sz) noexcept;
269  static point add(const point& pt1, const point& pt2) noexcept;
270 
274  static point ceiling(const point_f& value) noexcept;
275 
279  void offset(int32_t dx, int32_t dy) noexcept;
280 
294  void offset(const point& p) noexcept;
295 
299  static point round(const point_f& value) noexcept;
300 
306  static point subtract(const point& pt, const size& sz) noexcept;
311  static point subtract(const point& pt1, const point& pt2) noexcept;
312 
315  xtd::ustring to_string() const noexcept override;
316 
320  static point truncate(const point_f& value) noexcept;
322 
324  bool operator==(const point& value) const noexcept;
325  bool operator!=(const point& value) const noexcept;
326 
327  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::point& point) noexcept {return os << point.to_string();}
329 
331 
336  point operator+(const size& sz) const noexcept;
340  point operator+(const point& pt) const noexcept;
344  point& operator+=(const size& sz) noexcept;
348  point& operator+=(const point& pt) noexcept;
352  point operator-(const size& sz) const noexcept;
356  point operator-(const point& pt) const noexcept;
360  point& operator-=(const size& sz) noexcept;
364  point& operator-=(const point& pt) noexcept;
366 
367  private:
368  int32_t x_ = 0;
369  int32_t y_ = 0;
370  };
371  }
372 
373  template<>
374  inline drawing::point parse<drawing::point>(const std::string& str) {
375  auto values = xtd::ustring(str).replace("}", "").replace(" y=", "").replace("{x=", "").split({','});
376  return {xtd::parse<int32_t>(values[0]), xtd::parse<int32_t>(values[1])};
377  }
378 }
static const point empty
Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values se...
Definition: point.h:59
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:53
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
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...
Contains xtd::drawing::point_f class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
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:1110
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:34
Specifies that both the width and height property values of the control are defined.
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...
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
xtd::ustring to_string() const noexcept override
Converts this point to a human-readable string.
Specifies a printer&#39;s point (1/72 inch) as the unit of measure.