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