19ecf9d1cSIngo Weinhold/*
289208c77SStephan Aßmus * Copyright 2006, Haiku, Inc. All rights reserved.
39ecf9d1cSIngo Weinhold * Distributed under the terms of the MIT License.
49ecf9d1cSIngo Weinhold */
59ecf9d1cSIngo Weinhold#ifndef	_SIZE_H
69ecf9d1cSIngo Weinhold#define	_SIZE_H
79ecf9d1cSIngo Weinhold
89ecf9d1cSIngo Weinhold#include <limits.h>
99ecf9d1cSIngo Weinhold
109ecf9d1cSIngo Weinhold#include <SupportDefs.h>
119ecf9d1cSIngo Weinhold
127f4c0ffeSIngo Weinhold
139ecf9d1cSIngo Weinholdenum {
14cb968676SIngo Weinhold	B_SIZE_UNSET		= -2,
159ecf9d1cSIngo Weinhold	B_SIZE_UNLIMITED	= 1024 * 1024 * 1024,
169ecf9d1cSIngo Weinhold};
179ecf9d1cSIngo Weinhold
187f4c0ffeSIngo Weinhold
199ecf9d1cSIngo Weinholdclass BSize {
209ecf9d1cSIngo Weinholdpublic:
219ecf9d1cSIngo Weinhold			float				width;
229ecf9d1cSIngo Weinhold			float				height;
239ecf9d1cSIngo Weinhold
249ecf9d1cSIngo Weinhold	inline						BSize();
259ecf9d1cSIngo Weinhold	inline						BSize(const BSize& other);
269ecf9d1cSIngo Weinhold	inline						BSize(float width, float height);
279ecf9d1cSIngo Weinhold
289ecf9d1cSIngo Weinhold	inline	float				Width() const;
299ecf9d1cSIngo Weinhold	inline	float				Height() const;
309ecf9d1cSIngo Weinhold
31ea2dcf71SIngo Weinhold	inline	void				Set(float width, float height);
329ecf9d1cSIngo Weinhold	inline	void				SetWidth(float width);
339ecf9d1cSIngo Weinhold	inline	void				SetHeight(float height);
349ecf9d1cSIngo Weinhold
359ecf9d1cSIngo Weinhold	inline	int32				IntegerWidth() const;
369ecf9d1cSIngo Weinhold	inline	int32				IntegerHeight() const;
379ecf9d1cSIngo Weinhold
389ecf9d1cSIngo Weinhold	inline	bool				IsWidthSet() const;
399ecf9d1cSIngo Weinhold	inline	bool				IsHeightSet() const;
409ecf9d1cSIngo Weinhold
419ecf9d1cSIngo Weinhold	inline	bool				operator==(const BSize& other) const;
429ecf9d1cSIngo Weinhold	inline	bool				operator!=(const BSize& other) const;
439ecf9d1cSIngo Weinhold
449ecf9d1cSIngo Weinhold	inline	BSize&				operator=(const BSize& other);
459ecf9d1cSIngo Weinhold};
469ecf9d1cSIngo Weinhold
479ecf9d1cSIngo Weinhold
489ecf9d1cSIngo Weinholdinline
499ecf9d1cSIngo WeinholdBSize::BSize()
509ecf9d1cSIngo Weinhold	: width(B_SIZE_UNSET),
519ecf9d1cSIngo Weinhold	  height(B_SIZE_UNSET)
529ecf9d1cSIngo Weinhold{
539ecf9d1cSIngo Weinhold}
549ecf9d1cSIngo Weinhold
557f4c0ffeSIngo Weinhold
569ecf9d1cSIngo Weinholdinline
579ecf9d1cSIngo WeinholdBSize::BSize(const BSize& other)
589ecf9d1cSIngo Weinhold	: width(other.width),
599ecf9d1cSIngo Weinhold	  height(other.height)
609ecf9d1cSIngo Weinhold{
619ecf9d1cSIngo Weinhold}
629ecf9d1cSIngo Weinhold
637f4c0ffeSIngo Weinhold
649ecf9d1cSIngo Weinholdinline
659ecf9d1cSIngo WeinholdBSize::BSize(float width, float height)
669ecf9d1cSIngo Weinhold	: width(width),
679ecf9d1cSIngo Weinhold	  height(height)
689ecf9d1cSIngo Weinhold{
699ecf9d1cSIngo Weinhold}
709ecf9d1cSIngo Weinhold
717f4c0ffeSIngo Weinhold
729ecf9d1cSIngo Weinholdinline float
739ecf9d1cSIngo WeinholdBSize::Width() const
749ecf9d1cSIngo Weinhold{
759ecf9d1cSIngo Weinhold	return width;
769ecf9d1cSIngo Weinhold}
779ecf9d1cSIngo Weinhold
787f4c0ffeSIngo Weinhold
799ecf9d1cSIngo Weinholdinline float
809ecf9d1cSIngo WeinholdBSize::Height() const
819ecf9d1cSIngo Weinhold{
829ecf9d1cSIngo Weinhold	return height;
839ecf9d1cSIngo Weinhold}
849ecf9d1cSIngo Weinhold
857f4c0ffeSIngo Weinhold
86ea2dcf71SIngo Weinholdinline void
87ea2dcf71SIngo WeinholdBSize::Set(float width, float height)
88ea2dcf71SIngo Weinhold{
89ea2dcf71SIngo Weinhold	this->width = width;
90ea2dcf71SIngo Weinhold	this->height = height;
91ea2dcf71SIngo Weinhold}
92ea2dcf71SIngo Weinhold
93ea2dcf71SIngo Weinhold
949ecf9d1cSIngo Weinholdinline void
959ecf9d1cSIngo WeinholdBSize::SetWidth(float width)
969ecf9d1cSIngo Weinhold{
979ecf9d1cSIngo Weinhold	this->width = width;
989ecf9d1cSIngo Weinhold}
999ecf9d1cSIngo Weinhold
1007f4c0ffeSIngo Weinhold
1019ecf9d1cSIngo Weinholdinline void
1029ecf9d1cSIngo WeinholdBSize::SetHeight(float height)
1039ecf9d1cSIngo Weinhold{
1049ecf9d1cSIngo Weinhold	this->height = height;
1059ecf9d1cSIngo Weinhold}
1069ecf9d1cSIngo Weinhold
1077f4c0ffeSIngo Weinhold
1089ecf9d1cSIngo Weinholdinline int32
1099ecf9d1cSIngo WeinholdBSize::IntegerWidth() const
1109ecf9d1cSIngo Weinhold{
1119ecf9d1cSIngo Weinhold	return (int32)width;
1129ecf9d1cSIngo Weinhold}
1139ecf9d1cSIngo Weinhold
1147f4c0ffeSIngo Weinhold
1159ecf9d1cSIngo Weinholdinline int32
1169ecf9d1cSIngo WeinholdBSize::IntegerHeight() const
1179ecf9d1cSIngo Weinhold{
1189ecf9d1cSIngo Weinhold	return (int32)height;
1199ecf9d1cSIngo Weinhold}
1209ecf9d1cSIngo Weinhold
1217f4c0ffeSIngo Weinhold
1229ecf9d1cSIngo Weinholdinline bool
1239ecf9d1cSIngo WeinholdBSize::IsWidthSet() const
1249ecf9d1cSIngo Weinhold{
1259ecf9d1cSIngo Weinhold	return width != B_SIZE_UNSET;
1269ecf9d1cSIngo Weinhold}
1279ecf9d1cSIngo Weinhold
1287f4c0ffeSIngo Weinhold
1299ecf9d1cSIngo Weinholdinline bool
1309ecf9d1cSIngo WeinholdBSize::IsHeightSet() const
1319ecf9d1cSIngo Weinhold{
1329ecf9d1cSIngo Weinhold	return height != B_SIZE_UNSET;
1339ecf9d1cSIngo Weinhold}
1349ecf9d1cSIngo Weinhold
1357f4c0ffeSIngo Weinhold
1369ecf9d1cSIngo Weinholdinline bool
1379ecf9d1cSIngo WeinholdBSize::operator==(const BSize& other) const
1389ecf9d1cSIngo Weinhold{
1399ecf9d1cSIngo Weinhold	return (width == other.width && height == other.height);
1409ecf9d1cSIngo Weinhold}
1419ecf9d1cSIngo Weinhold
1427f4c0ffeSIngo Weinhold
1439ecf9d1cSIngo Weinholdinline bool
1449ecf9d1cSIngo WeinholdBSize::operator!=(const BSize& other) const
1459ecf9d1cSIngo Weinhold{
1469ecf9d1cSIngo Weinhold	return !(*this == other);
1479ecf9d1cSIngo Weinhold}
1489ecf9d1cSIngo Weinhold
1497f4c0ffeSIngo Weinhold
1509ecf9d1cSIngo Weinholdinline BSize&
1519ecf9d1cSIngo WeinholdBSize::operator=(const BSize& other)
1529ecf9d1cSIngo Weinhold{
1539ecf9d1cSIngo Weinhold	width = other.width;
1549ecf9d1cSIngo Weinhold	height = other.height;
1559ecf9d1cSIngo Weinhold	return *this;
1569ecf9d1cSIngo Weinhold}
1579ecf9d1cSIngo Weinhold
15889208c77SStephan Aßmus#endif // _SIZE_H
159