1 /* 2 * Copyright 2006, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SIZE_H 6 #define _SIZE_H 7 8 #include <limits.h> 9 10 #include <SupportDefs.h> 11 12 13 const float B_SIZE_UNSET = -2; 14 const float B_SIZE_UNLIMITED = 1024 * 1024 * 1024; 15 16 17 class BSize { 18 public: 19 float width; 20 float height; 21 22 inline BSize(); 23 inline BSize(const BSize& other); 24 inline BSize(float width, float height); 25 26 inline float Width() const; 27 inline float Height() const; 28 29 inline void Set(float width, float height); 30 inline void SetWidth(float width); 31 inline void SetHeight(float height); 32 33 inline int32 IntegerWidth() const; 34 inline int32 IntegerHeight() const; 35 36 inline bool IsWidthSet() const; 37 inline bool IsHeightSet() const; 38 39 inline bool operator==(const BSize& other) const; 40 inline bool operator!=(const BSize& other) const; 41 42 inline BSize& operator=(const BSize& other); 43 }; 44 45 46 inline 47 BSize::BSize() 48 : width(B_SIZE_UNSET), 49 height(B_SIZE_UNSET) 50 { 51 } 52 53 54 inline 55 BSize::BSize(const BSize& other) 56 : width(other.width), 57 height(other.height) 58 { 59 } 60 61 62 inline 63 BSize::BSize(float width, float height) 64 : width(width), 65 height(height) 66 { 67 } 68 69 70 inline float 71 BSize::Width() const 72 { 73 return width; 74 } 75 76 77 inline float 78 BSize::Height() const 79 { 80 return height; 81 } 82 83 84 inline void 85 BSize::Set(float width, float height) 86 { 87 this->width = width; 88 this->height = height; 89 } 90 91 92 inline void 93 BSize::SetWidth(float width) 94 { 95 this->width = width; 96 } 97 98 99 inline void 100 BSize::SetHeight(float height) 101 { 102 this->height = height; 103 } 104 105 106 inline int32 107 BSize::IntegerWidth() const 108 { 109 return (int32)width; 110 } 111 112 113 inline int32 114 BSize::IntegerHeight() const 115 { 116 return (int32)height; 117 } 118 119 120 inline bool 121 BSize::IsWidthSet() const 122 { 123 return width != B_SIZE_UNSET; 124 } 125 126 127 inline bool 128 BSize::IsHeightSet() const 129 { 130 return height != B_SIZE_UNSET; 131 } 132 133 134 inline bool 135 BSize::operator==(const BSize& other) const 136 { 137 return (width == other.width && height == other.height); 138 } 139 140 141 inline bool 142 BSize::operator!=(const BSize& other) const 143 { 144 return !(*this == other); 145 } 146 147 148 inline BSize& 149 BSize::operator=(const BSize& other) 150 { 151 width = other.width; 152 height = other.height; 153 return *this; 154 } 155 156 #endif // _SIZE_H 157