2006-08-26 20:21:15 +04:00
|
|
|
/*
|
2009-08-27 15:12:41 +04:00
|
|
|
* Copyright 2006, Haiku, Inc. All rights reserved.
|
2006-08-26 20:21:15 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SIZE_H
|
|
|
|
#define _SIZE_H
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
enum {
|
2007-06-17 05:10:12 +04:00
|
|
|
B_SIZE_UNSET = -2,
|
2006-08-26 20:21:15 +04:00
|
|
|
B_SIZE_UNLIMITED = 1024 * 1024 * 1024,
|
|
|
|
};
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
class BSize {
|
|
|
|
public:
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
|
|
|
|
inline BSize();
|
|
|
|
inline BSize(const BSize& other);
|
|
|
|
inline BSize(float width, float height);
|
|
|
|
|
|
|
|
inline float Width() const;
|
|
|
|
inline float Height() const;
|
|
|
|
|
2007-06-09 03:16:20 +04:00
|
|
|
inline void Set(float width, float height);
|
2006-08-26 20:21:15 +04:00
|
|
|
inline void SetWidth(float width);
|
|
|
|
inline void SetHeight(float height);
|
|
|
|
|
|
|
|
inline int32 IntegerWidth() const;
|
|
|
|
inline int32 IntegerHeight() const;
|
|
|
|
|
|
|
|
inline bool IsWidthSet() const;
|
|
|
|
inline bool IsHeightSet() const;
|
|
|
|
|
|
|
|
inline bool operator==(const BSize& other) const;
|
|
|
|
inline bool operator!=(const BSize& other) const;
|
|
|
|
|
|
|
|
inline BSize& operator=(const BSize& other);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
BSize::BSize()
|
|
|
|
: width(B_SIZE_UNSET),
|
|
|
|
height(B_SIZE_UNSET)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline
|
|
|
|
BSize::BSize(const BSize& other)
|
|
|
|
: width(other.width),
|
|
|
|
height(other.height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline
|
|
|
|
BSize::BSize(float width, float height)
|
|
|
|
: width(width),
|
|
|
|
height(height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline float
|
|
|
|
BSize::Width() const
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline float
|
|
|
|
BSize::Height() const
|
|
|
|
{
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2007-06-09 03:16:20 +04:00
|
|
|
inline void
|
|
|
|
BSize::Set(float width, float height)
|
|
|
|
{
|
|
|
|
this->width = width;
|
|
|
|
this->height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline void
|
|
|
|
BSize::SetWidth(float width)
|
|
|
|
{
|
|
|
|
this->width = width;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline void
|
|
|
|
BSize::SetHeight(float height)
|
|
|
|
{
|
|
|
|
this->height = height;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline int32
|
|
|
|
BSize::IntegerWidth() const
|
|
|
|
{
|
|
|
|
return (int32)width;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline int32
|
|
|
|
BSize::IntegerHeight() const
|
|
|
|
{
|
|
|
|
return (int32)height;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline bool
|
|
|
|
BSize::IsWidthSet() const
|
|
|
|
{
|
|
|
|
return width != B_SIZE_UNSET;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline bool
|
|
|
|
BSize::IsHeightSet() const
|
|
|
|
{
|
|
|
|
return height != B_SIZE_UNSET;
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline bool
|
|
|
|
BSize::operator==(const BSize& other) const
|
|
|
|
{
|
|
|
|
return (width == other.width && height == other.height);
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline bool
|
|
|
|
BSize::operator!=(const BSize& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2007-05-12 20:24:18 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
inline BSize&
|
|
|
|
BSize::operator=(const BSize& other)
|
|
|
|
{
|
|
|
|
width = other.width;
|
|
|
|
height = other.height;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
#endif // _SIZE_H
|