1/* 2 * Copyright 2006, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _ALIGNMENT_H 6#define _ALIGNMENT_H 7 8#include <InterfaceDefs.h> 9 10class BAlignment { 11public: 12 alignment horizontal; 13 vertical_alignment vertical; 14 15 inline BAlignment(); 16 inline BAlignment(const BAlignment& other); 17 inline BAlignment(alignment horizontal, 18 vertical_alignment vertical); 19 20 inline alignment Horizontal() const; 21 inline vertical_alignment Vertical() const; 22 23 float RelativeHorizontal() const; 24 float RelativeVertical() const; 25 26 inline void SetHorizontal(alignment horizontal); 27 inline void SetVertical(vertical_alignment vertical); 28 29 inline bool IsHorizontalSet() const; 30 inline bool IsVerticalSet() const; 31 32 inline bool operator==(const BAlignment& other) const; 33 inline bool operator!=(const BAlignment& other) const; 34 35 inline BAlignment& operator=(const BAlignment& other); 36}; 37 38 39// constructor 40inline 41BAlignment::BAlignment() 42 : horizontal(B_ALIGN_HORIZONTAL_UNSET), 43 vertical(B_ALIGN_VERTICAL_UNSET) 44{ 45} 46 47// copy constructor 48inline 49BAlignment::BAlignment(const BAlignment& other) 50 : horizontal(other.horizontal), 51 vertical(other.vertical) 52{ 53} 54 55// constructor 56inline 57BAlignment::BAlignment(alignment horizontal, vertical_alignment vertical) 58 : horizontal(horizontal), 59 vertical(vertical) 60{ 61} 62 63// Horizontal 64inline alignment 65BAlignment::Horizontal() const 66{ 67 return horizontal; 68} 69 70// Vertical 71inline vertical_alignment 72BAlignment::Vertical() const 73{ 74 return vertical; 75} 76 77// SetHorizontal 78inline void 79BAlignment::SetHorizontal(alignment horizontal) 80{ 81 this->horizontal = horizontal; 82} 83 84// SetVertical 85inline void 86BAlignment::SetVertical(vertical_alignment vertical) 87{ 88 this->vertical = vertical; 89} 90 91// IsHorizontalSet 92inline bool 93BAlignment::IsHorizontalSet() const 94{ 95 return (horizontal != B_ALIGN_HORIZONTAL_UNSET); 96} 97 98// IsVerticalSet 99inline bool 100BAlignment::IsVerticalSet() const 101{ 102 return (vertical != B_ALIGN_VERTICAL_UNSET); 103} 104 105// == 106inline bool 107BAlignment::operator==(const BAlignment& other) const 108{ 109 return (horizontal == other.horizontal && vertical == other.vertical); 110} 111 112// != 113inline bool 114BAlignment::operator!=(const BAlignment& other) const 115{ 116 return !(*this == other); 117} 118 119// = 120inline BAlignment& 121BAlignment::operator=(const BAlignment& other) 122{ 123 horizontal = other.horizontal; 124 vertical = other.vertical; 125 return *this; 126} 127 128#endif // _ALIGNMENT_H 129