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