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