xtd - Reference Guide  0.1.1
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:
28 
30  size_f() = default;
31 
35 
39  size_f(float width, float height) : width_(width), height_(height) {}
40 
42  size_f(const xtd::drawing::size_f&) = default;
43  bool operator==(const xtd::drawing::size_f& value) const {return width_ == value.width_ && height_ == value.height_;}
44  bool operator!=(const xtd::drawing::size_f& value) const {return !operator==(value);}
45  size_f& operator=(const xtd::drawing::size_f& size) = default;
46  size_f operator+(const xtd::drawing::size_f& size) const;
47  size_f operator-(const xtd::drawing::size_f& size) const;
48  size_f& operator+=(const xtd::drawing::size_f& size);
49  size_f& operator-=(const xtd::drawing::size_f& size);
51 
55  float height() const {return height_;}
56 
60  void height(float height) {height_ = height;}
61 
65  float width() const {return width_;}
66 
70  void width(float width) {width_ = width;}
71 
77 
80  bool is_empty() const {return *this == size_f::empty;}
81 
88 
91  xtd::ustring to_string() const noexcept override {return "{width=" + std::to_string(width_) + ", height=" + std::to_string(height_) + "}";}
92 
94  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::size_f& size) noexcept {
95  return os << size.to_string();
96  }
98 
99  private:
100  float width_ = 0;
101  float height_ = 0;
102  };
103  }
104 }
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:26
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 floating-point, which specify a height and width.
Definition: size_f.h:24
float width() const
Gets the horizontal component of this Size class.
Definition: size_f.h:65
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:27
size_f()=default
Initializes a new instance of the Size class that has a Height and Width value of 0.
xtd::ustring to_string() const noexcept override
Creates a human-readable string that represents this size class.
Definition: size_f.h:91
bool is_empty() const
Tests whether this Size class has width and height of 0.
Definition: size_f.h:80
void width(float width)
Sets the horizontal component of this Size class.
Definition: size_f.h:70
float height() const
Gets he vertical component of this Size Class.
Definition: size_f.h:55
void height(float height)
Sets the vertical component of this Size Class.
Definition: size_f.h:60
size_f(const xtd::drawing::point_f &point)
Initializes a new instance of the Size class from the specified Point class.
static xtd::drawing::size_f subtract(const xtd::drawing::size_f &sz1, const xtd::drawing::size_f &sz2)
Returns the result of subtracting specified size from the specified size.
static xtd::drawing::size_f add(const xtd::drawing::size_f &size1, const xtd::drawing::size_f &size2)
Adds the width and height of one Size class to the width and height of another size class.
size_f(float width, float height)
Initializes a new instance of the Size class from the specified dimensions.
Definition: size_f.h:39
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
xtd::ustring to_string() const noexcept override
Creates a human-readable string that represents this size class.
Definition: size.h:103
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
#define drawing_export_
Define shared library export.
Definition: drawing_export.h:13
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.