xref: /haiku/headers/libs/alm/Area.h (revision 4b3b81da9e459443d75329cfd08bc9a57ad02653)
1 /*
2  * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
3  * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
4  * Distributed under the terms of the MIT License.
5  */
6 
7 #ifndef	AREA_H
8 #define	AREA_H
9 
10 #include "Constraint.h"
11 
12 #include <Alignment.h>
13 #include <List.h>
14 #include <Size.h>
15 #include <SupportDefs.h>
16 #include <View.h>
17 
18 
19 namespace BALM {
20 
21 class Column;
22 class BALMLayout;
23 class Row;
24 class XTab;
25 class YTab;
26 
27 /**
28  * Rectangular area in the GUI, defined by a tab on each side.
29  */
30 class Area {
31 
32 public:
33 	bool				AutoPrefContentSize() const;
34 	void				SetAutoPrefContentSize(bool value);
35 
36 	XTab*				Left() const;
37 	void				SetLeft(XTab* left);
38 	XTab*				Right() const;
39 	void				SetRight(XTab* right);
40 	YTab*				Top() const;
41 	void				SetTop(YTab* top);
42 	YTab*				Bottom() const;
43 	void				SetBottom(YTab* bottom);
44 
45 	Row*				GetRow() const;
46 	void				SetRow(Row* row);
47 	Column*				GetColumn() const;
48 	void				SetColumn(Column* column);
49 
50 	BView*				Content() const;
51 	void				SetContent(BView* content);
52 	XTab*				ContentLeft() const;
53 	YTab*				ContentTop() const;
54 	XTab*				ContentRight() const;
55 	YTab*				ContentBottom() const;
56 	BSize				MinContentSize() const;
57 	void				SetMinContentSize(BSize min);
58 	BSize				MaxContentSize() const;
59 	void				SetMaxContentSize(BSize max);
60 	BSize				PrefContentSize() const;
61 	void				SetPrefContentSize(BSize pref);
62 	BSize				ShrinkRigidity() const;
63 	void				SetShrinkRigidity(BSize shrink);
64 	BSize				ExpandRigidity() const;
65 	void				SetExpandRigidity(BSize expand);
66 	double				ContentAspectRatio() const;
67 	void				SetContentAspectRatio(double ratio);
68 	BAlignment			Alignment() const;
69 	void				SetAlignment(BAlignment alignment);
70 	void				SetHAlignment(alignment horizontal);
71 	void				SetVAlignment(vertical_alignment vertical);
72 	int32				LeftInset() const;
73 	void				SetLeftInset(int32 left);
74 	int32				TopInset() const;
75 	void				SetTopInset(int32 top);
76 	int32				RightInset() const;
77 	void				SetRightInset(int32 right);
78 	int32				BottomInset() const;
79 	void				SetBottomInset(int32 bottom);
80 	void				SetDefaultPrefContentSize();
81 	//~ string			ToString();
82 
83 	Constraint*			HasSameWidthAs(Area* area);
84 	Constraint*			HasSameHeightAs(Area* area);
85 	BList*				HasSameSizetAs(Area* area);
86 						~Area();
87 
88 protected:
89 						Area(BALMLayout* ls, XTab* left, YTab* top,
90 								XTab* right, YTab* bottom,
91 								BView* content,
92 								BSize minContentSize);
93 						Area(BALMLayout* ls, Row* row, Column* column,
94 								BView* content,
95 								BSize minContentSize);
96 	void				DoLayout();
97 
98 private:
99 	void				InitChildArea();
100 	void				UpdateHorizontal();
101 	void				UpdateVertical();
102 	void				Init(BALMLayout* ls, XTab* left, YTab* top,
103 							XTab* right, YTab* bottom,
104 							BView* content,
105 							BSize minContentSize);
106 
107 public:
108 	static BSize		kMaxSize;
109 	static BSize		kMinSize;
110 	static BSize		kUndefinedSize;
111 
112 protected:
113 	BView*				fContent;
114 	BList*				fConstraints;
115 
116 private:
117 	BALMLayout*			fLS;
118 	XTab*				fLeft;
119 	XTab*				fRight;
120 	YTab*				fTop;
121 	YTab*				fBottom;
122 	Row*				fRow;
123 	Column*				fColumn;
124 	BSize				fMinContentSize;
125 	BSize				fMaxContentSize;
126 	Constraint*			fMinContentWidth;
127 	Constraint*			fMaxContentWidth;
128 	Constraint*			fMinContentHeight;
129 	Constraint*			fMaxContentHeight;
130 	BSize				fPrefContentSize;
131 	BSize				fShrinkRigidity;
132 	BSize				fExpandRigidity;
133 	double				fContentAspectRatio;
134 	Constraint*			fContentAspectRatioC;
135 	bool				fAutoPrefContentSize;
136 	Constraint*			fPrefContentWidth;
137 	Constraint*			fPrefContentHeight;
138 	Area*				fChildArea;
139 	BAlignment			fAlignment;
140 	int32				fLeftInset;
141 	int32				fTopInset;
142 	int32				fRightInset;
143 	int32				fBottomInset;
144 	Constraint*			fLeftConstraint;
145 	Constraint*			fTopConstraint;
146 	Constraint*			fRightConstraint;
147 	Constraint*			fBottomConstraint;
148 
149 public:
150 	friend class			BALMLayout;
151 
152 };
153 
154 }	// namespace BALM
155 
156 using BALM::Area;
157 
158 #endif	// AREA_H
159 
160