haiku/headers/os/interface/Alignment.h
Stephan Aßmus 89208c77f1 Finished unifying the Interface Kit headers:
* Fixed copyrights (puncuation and capitalization, removed authors from
  headers)
* Updated indentation style
* Unified pointer/reference style
* Re-ordered some methods for better grouping where it could be done
  (abd adopted source accordingly)
* Small coding style fixes here and there

No functional change intended.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32745 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-27 11:12:41 +00:00

129 lines
2.4 KiB
C++

/*
* Copyright 2006, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ALIGNMENT_H
#define _ALIGNMENT_H
#include <InterfaceDefs.h>
class BAlignment {
public:
alignment horizontal;
vertical_alignment vertical;
inline BAlignment();
inline BAlignment(const BAlignment& other);
inline BAlignment(alignment horizontal,
vertical_alignment vertical);
inline alignment Horizontal() const;
inline vertical_alignment Vertical() const;
float RelativeHorizontal() const;
float RelativeVertical() const;
inline void SetHorizontal(alignment horizontal);
inline void SetVertical(vertical_alignment vertical);
inline bool IsHorizontalSet() const;
inline bool IsVerticalSet() const;
inline bool operator==(const BAlignment& other) const;
inline bool operator!=(const BAlignment& other) const;
inline BAlignment& operator=(const BAlignment& other);
};
// constructor
inline
BAlignment::BAlignment()
: horizontal(B_ALIGN_HORIZONTAL_UNSET),
vertical(B_ALIGN_VERTICAL_UNSET)
{
}
// copy constructor
inline
BAlignment::BAlignment(const BAlignment& other)
: horizontal(other.horizontal),
vertical(other.vertical)
{
}
// constructor
inline
BAlignment::BAlignment(alignment horizontal, vertical_alignment vertical)
: horizontal(horizontal),
vertical(vertical)
{
}
// Horizontal
inline alignment
BAlignment::Horizontal() const
{
return horizontal;
}
// Vertical
inline vertical_alignment
BAlignment::Vertical() const
{
return vertical;
}
// SetHorizontal
inline void
BAlignment::SetHorizontal(alignment horizontal)
{
this->horizontal = horizontal;
}
// SetVertical
inline void
BAlignment::SetVertical(vertical_alignment vertical)
{
this->vertical = vertical;
}
// IsHorizontalSet
inline bool
BAlignment::IsHorizontalSet() const
{
return (horizontal != B_ALIGN_HORIZONTAL_UNSET);
}
// IsVerticalSet
inline bool
BAlignment::IsVerticalSet() const
{
return (vertical != B_ALIGN_VERTICAL_UNSET);
}
// ==
inline bool
BAlignment::operator==(const BAlignment& other) const
{
return (horizontal == other.horizontal && vertical == other.vertical);
}
// !=
inline bool
BAlignment::operator!=(const BAlignment& other) const
{
return !(*this == other);
}
// =
inline BAlignment&
BAlignment::operator=(const BAlignment& other)
{
horizontal = other.horizontal;
vertical = other.vertical;
return *this;
}
#endif // _ALIGNMENT_H