xref: /haiku/headers/libs/alm/ALMLayoutBuilder.h (revision 25a7b01d15612846f332751841da3579db313082)
1 /*
2  * Copyright 2012, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	ALM_LAYOUT_BUILDER_H
6 #define	ALM_LAYOUT_BUILDER_H
7 
8 
9 #include "ALMLayout.h"
10 
11 #include <ObjectList.h>
12 
13 
14 class BLayoutItem;
15 class BView;
16 class BWindow;
17 
18 
19 namespace BALM {
20 
21 
22 class BALMLayoutBuilder {
23 public:
24 								BALMLayoutBuilder(BView* view, float hSpacing,
25 									float vSpacing,
26 									BALMLayout* friendLayout = NULL);
27 								BALMLayoutBuilder(BView* view,
28 									BALMLayout* layout);
29 								BALMLayoutBuilder(BWindow* window,
30 									float hSpacing, float vSpacing,
31 									BALMLayout* friendLayout = NULL);
32 								BALMLayoutBuilder(BWindow* window,
33 									BALMLayout* layout);
34 								BALMLayoutBuilder(BALMLayout* layout);
35 
36 	BALMLayoutBuilder&			Add(BView* view, XTab* left, YTab* top,
37 									XTab* right = NULL, YTab* bottom = NULL);
38 	BALMLayoutBuilder&			Add(BView* view, Row* row, Column* column);
39 
40 	BALMLayoutBuilder&			Add(BLayoutItem* item, XTab* left,
41 									YTab* top, XTab* right = NULL,
42 									YTab* bottom = NULL);
43 	BALMLayoutBuilder&			Add(BLayoutItem* item, Row* row,
44 									Column* column);
45 
46 	BALMLayoutBuilder&			SetInsets(float insets);
47 	BALMLayoutBuilder&			SetInsets(float horizontal, float vertical);
48 	BALMLayoutBuilder&			SetInsets(float left, float top, float right,
49 									float bottom);
50 
51 	BALMLayoutBuilder&			SetSpacing(float horizontal, float vertical);
52 
53 	BALMLayoutBuilder&			AddToLeft(BView* view,
54 									XTab* left = NULL, YTab* top = NULL,
55 									YTab* bottom = NULL);
56 	BALMLayoutBuilder&			AddToRight(BView* view,
57 									XTab* right = NULL, YTab* top = NULL,
58 									YTab* bottom = NULL);
59 	BALMLayoutBuilder&			AddAbove(BView* view,
60 									YTab* top = NULL, XTab* left = NULL,
61 									XTab* right = NULL);
62 	BALMLayoutBuilder&			AddBelow(BView* view, YTab* bottom = NULL,
63 									XTab* left = NULL, XTab* right = NULL);
64 
65 	BALMLayoutBuilder&			AddToLeft(BLayoutItem* item,
66 									XTab* left = NULL, YTab* top = NULL,
67 									YTab* bottom = NULL);
68 	BALMLayoutBuilder&			AddToRight(BLayoutItem* item,
69 									XTab* right = NULL, YTab* top = NULL,
70 									YTab* bottom = NULL);
71 	BALMLayoutBuilder&			AddAbove(BLayoutItem* item,
72 									YTab* top = NULL, XTab* left = NULL,
73 									XTab* right = NULL);
74 	BALMLayoutBuilder&			AddBelow(BLayoutItem* item,
75 									YTab* bottom = NULL, XTab* left = NULL,
76 									XTab* right = NULL);
77 
78 
79 		BALMLayoutBuilder&			Push();
80 		BALMLayoutBuilder&			Pop();
81 
82 
83 		// these methods throw away the stack
84 		BALMLayoutBuilder&			StartingAt(BView* view);
85 		BALMLayoutBuilder&			StartingAt(BLayoutItem* item);
86 
87 
88 private:
89 	typedef BObjectList<Area>	AreaStack;
90 
91 		BALMLayout*				fLayout;
92 		AreaStack				fAreaStack;
93 
94 		Area*					_CurrentArea() const;
95 		void					_SetCurrentArea(Area*);
96 };
97 
98 
99 };
100 
101 
102 #endif
103