xref: /haiku/headers/os/interface/Alignment.h (revision 9d6d3fcf5fe8308cd020cecf89dede440346f8c4)
1 /*
2  * Copyright 2006, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_ALIGNMENT_H
6 #define	_ALIGNMENT_H
7 
8 #include <InterfaceDefs.h>
9 
10 class BAlignment {
11 public:
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
40 inline
41 BAlignment::BAlignment()
42 	: horizontal(B_ALIGN_HORIZONTAL_UNSET),
43 	  vertical(B_ALIGN_VERTICAL_UNSET)
44 {
45 }
46 
47 // copy constructor
48 inline
49 BAlignment::BAlignment(const BAlignment& other)
50 	: horizontal(other.horizontal),
51 	  vertical(other.vertical)
52 {
53 }
54 
55 // constructor
56 inline
57 BAlignment::BAlignment(alignment horizontal, vertical_alignment vertical)
58 	: horizontal(horizontal),
59 	  vertical(vertical)
60 {
61 }
62 
63 // Horizontal
64 inline alignment
65 BAlignment::Horizontal() const
66 {
67 	return horizontal;
68 }
69 
70 // Vertical
71 inline vertical_alignment
72 BAlignment::Vertical() const
73 {
74 	return vertical;
75 }
76 
77 // SetHorizontal
78 inline void
79 BAlignment::SetHorizontal(alignment horizontal)
80 {
81 	this->horizontal = horizontal;
82 }
83 
84 // SetVertical
85 inline void
86 BAlignment::SetVertical(vertical_alignment vertical)
87 {
88 	this->vertical = vertical;
89 }
90 
91 // IsHorizontalSet
92 inline bool
93 BAlignment::IsHorizontalSet() const
94 {
95 	return (horizontal != B_ALIGN_HORIZONTAL_UNSET);
96 }
97 
98 // IsVerticalSet
99 inline bool
100 BAlignment::IsVerticalSet() const
101 {
102 	return (vertical != B_ALIGN_VERTICAL_UNSET);
103 }
104 
105 // ==
106 inline bool
107 BAlignment::operator==(const BAlignment& other) const
108 {
109 	return (horizontal == other.horizontal && vertical == other.vertical);
110 }
111 
112 // !=
113 inline bool
114 BAlignment::operator!=(const BAlignment& other) const
115 {
116 	return !(*this == other);
117 }
118 
119 // =
120 inline BAlignment&
121 BAlignment::operator=(const BAlignment& other)
122 {
123 	horizontal = other.horizontal;
124 	vertical = other.vertical;
125 	return *this;
126 }
127 
128 #endif	// _ALIGNMENT_H
129