xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
size_f.h
Go to the documentation of this file.
1 #pragma once
5 #include <ostream>
6 #include <xtd/object.h>
7 #include <xtd/ustring.h>
8 #include "../drawing_export.h"
9 
11 namespace xtd {
13  namespace drawing {
15  class point_f;
17 
24  class drawing_export_ size_f : public object {
25  public:
27 
32 
34 
37  size_f() = default;
38 
41  explicit size_f(const xtd::drawing::point_f& point);
42 
46  size_f(float width, float height) : width_(width), height_(height) {}
48 
50  size_f(const xtd::drawing::size_f&) = default;
51  bool operator==(const xtd::drawing::size_f& value) const {return width_ == value.width_ && height_ == value.height_;}
52  bool operator!=(const xtd::drawing::size_f& value) const {return !operator==(value);}
53  size_f& operator=(const xtd::drawing::size_f& size) = default;
54  size_f operator+(const xtd::drawing::size_f& size) const;
55  size_f operator-(const xtd::drawing::size_f& size) const;
56  size_f& operator+=(const xtd::drawing::size_f& size);
57  size_f& operator-=(const xtd::drawing::size_f& size);
59 
61 
63 
66  bool is_empty() const {return *this == size_f::empty;}
70  float height() const {return height_;}
71 
75  void height(float height) {height_ = height;}
76 
80  float width() const {return width_;}
81 
85  void width(float width) {width_ = width;}
87 
89 
95  static xtd::drawing::size_f add(const xtd::drawing::size_f& size1, const xtd::drawing::size_f& size2);
96 
103 
106  xtd::ustring to_string() const noexcept override {return "{width=" + std::to_string(width_) + ", height=" + std::to_string(height_) + "}";}
108 
110  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::size_f& size) noexcept {
111  return os << size.to_string();
112  }
114 
115  private:
116  float width_ = 0;
117  float height_ = 0;
118  };
119  }
120 }
size_f(float width, float height)
Initializes a new instance of the Size class from the specified dimensions.
Definition: size_f.h:46
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
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
bool is_empty() const
Tests whether this Size class has width and height of 0.
Definition: size_f.h:66
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:26
Stores an ordered pair of floating-point, which specify a height and width.
Definition: size_f.h:24
xtd::ustring to_string() const noexcept override
Creates a human-readable string that represents this size class.
Definition: size_f.h:106
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
void height(float height)
Sets the vertical component of this Size Class.
Definition: size_f.h:75
float width() const
Gets the horizontal component of this Size class.
Definition: size_f.h:80
float height() const
Gets he vertical component of this Size Class.
Definition: size_f.h:70
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:30
void width(float width)
Sets the horizontal component of this Size class.
Definition: size_f.h:85
The Subtract key.