xref: /haiku/headers/libs/alm/ALMLayoutBuilder.h (revision 25a7b01d15612846f332751841da3579db313082)
150cc24b3SAlex Wilson /*
250cc24b3SAlex Wilson  * Copyright 2012, Haiku, Inc. All rights reserved.
350cc24b3SAlex Wilson  * Distributed under the terms of the MIT License.
450cc24b3SAlex Wilson  */
550cc24b3SAlex Wilson #ifndef	ALM_LAYOUT_BUILDER_H
650cc24b3SAlex Wilson #define	ALM_LAYOUT_BUILDER_H
750cc24b3SAlex Wilson 
850cc24b3SAlex Wilson 
950cc24b3SAlex Wilson #include "ALMLayout.h"
1050cc24b3SAlex Wilson 
11*5f4e71baSAlex Wilson #include <ObjectList.h>
12*5f4e71baSAlex Wilson 
1350cc24b3SAlex Wilson 
14a25ffa4fSAlex Wilson class BLayoutItem;
15a25ffa4fSAlex Wilson class BView;
1650cc24b3SAlex Wilson class BWindow;
1750cc24b3SAlex Wilson 
1850cc24b3SAlex Wilson 
1950cc24b3SAlex Wilson namespace BALM {
2050cc24b3SAlex Wilson 
2150cc24b3SAlex Wilson 
2250cc24b3SAlex Wilson class BALMLayoutBuilder {
2350cc24b3SAlex Wilson public:
2450cc24b3SAlex Wilson 								BALMLayoutBuilder(BView* view, float hSpacing,
2550cc24b3SAlex Wilson 									float vSpacing,
2650cc24b3SAlex Wilson 									BALMLayout* friendLayout = NULL);
2750cc24b3SAlex Wilson 								BALMLayoutBuilder(BView* view,
2850cc24b3SAlex Wilson 									BALMLayout* layout);
2950cc24b3SAlex Wilson 								BALMLayoutBuilder(BWindow* window,
3050cc24b3SAlex Wilson 									float hSpacing, float vSpacing,
3150cc24b3SAlex Wilson 									BALMLayout* friendLayout = NULL);
3250cc24b3SAlex Wilson 								BALMLayoutBuilder(BWindow* window,
3350cc24b3SAlex Wilson 									BALMLayout* layout);
3450cc24b3SAlex Wilson 								BALMLayoutBuilder(BALMLayout* layout);
3550cc24b3SAlex Wilson 
3650cc24b3SAlex Wilson 	BALMLayoutBuilder&			Add(BView* view, XTab* left, YTab* top,
3750cc24b3SAlex Wilson 									XTab* right = NULL, YTab* bottom = NULL);
3850cc24b3SAlex Wilson 	BALMLayoutBuilder&			Add(BView* view, Row* row, Column* column);
3950cc24b3SAlex Wilson 
4050cc24b3SAlex Wilson 	BALMLayoutBuilder&			Add(BLayoutItem* item, XTab* left,
4150cc24b3SAlex Wilson 									YTab* top, XTab* right = NULL,
4250cc24b3SAlex Wilson 									YTab* bottom = NULL);
4350cc24b3SAlex Wilson 	BALMLayoutBuilder&			Add(BLayoutItem* item, Row* row,
4450cc24b3SAlex Wilson 									Column* column);
4550cc24b3SAlex Wilson 
4650cc24b3SAlex Wilson 	BALMLayoutBuilder&			SetInsets(float insets);
4750cc24b3SAlex Wilson 	BALMLayoutBuilder&			SetInsets(float horizontal, float vertical);
4850cc24b3SAlex Wilson 	BALMLayoutBuilder&			SetInsets(float left, float top, float right,
4950cc24b3SAlex Wilson 									float bottom);
5050cc24b3SAlex Wilson 
5150cc24b3SAlex Wilson 	BALMLayoutBuilder&			SetSpacing(float horizontal, float vertical);
5250cc24b3SAlex Wilson 
53*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddToLeft(BView* view,
5450cc24b3SAlex Wilson 									XTab* left = NULL, YTab* top = NULL,
5550cc24b3SAlex Wilson 									YTab* bottom = NULL);
56*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddToRight(BView* view,
5750cc24b3SAlex Wilson 									XTab* right = NULL, YTab* top = NULL,
5850cc24b3SAlex Wilson 									YTab* bottom = NULL);
59*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddAbove(BView* view,
6050cc24b3SAlex Wilson 									YTab* top = NULL, XTab* left = NULL,
6150cc24b3SAlex Wilson 									XTab* right = NULL);
62*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddBelow(BView* view, YTab* bottom = NULL,
6350cc24b3SAlex Wilson 									XTab* left = NULL, XTab* right = NULL);
6450cc24b3SAlex Wilson 
65*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddToLeft(BLayoutItem* item,
6650cc24b3SAlex Wilson 									XTab* left = NULL, YTab* top = NULL,
6750cc24b3SAlex Wilson 									YTab* bottom = NULL);
68*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddToRight(BLayoutItem* item,
6950cc24b3SAlex Wilson 									XTab* right = NULL, YTab* top = NULL,
7050cc24b3SAlex Wilson 									YTab* bottom = NULL);
71*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddAbove(BLayoutItem* item,
7250cc24b3SAlex Wilson 									YTab* top = NULL, XTab* left = NULL,
7350cc24b3SAlex Wilson 									XTab* right = NULL);
74*5f4e71baSAlex Wilson 	BALMLayoutBuilder&			AddBelow(BLayoutItem* item,
7550cc24b3SAlex Wilson 									YTab* bottom = NULL, XTab* left = NULL,
7650cc24b3SAlex Wilson 									XTab* right = NULL);
7750cc24b3SAlex Wilson 
7850cc24b3SAlex Wilson 
79*5f4e71baSAlex Wilson 		BALMLayoutBuilder&			Push();
80*5f4e71baSAlex Wilson 		BALMLayoutBuilder&			Pop();
81*5f4e71baSAlex Wilson 
82*5f4e71baSAlex Wilson 
8350cc24b3SAlex Wilson 		// these methods throw away the stack
84*5f4e71baSAlex Wilson 		BALMLayoutBuilder&			StartingAt(BView* view);
85*5f4e71baSAlex Wilson 		BALMLayoutBuilder&			StartingAt(BLayoutItem* item);
8650cc24b3SAlex Wilson 
8750cc24b3SAlex Wilson 
8850cc24b3SAlex Wilson private:
89*5f4e71baSAlex Wilson 	typedef BObjectList<Area>	AreaStack;
9050cc24b3SAlex Wilson 
9150cc24b3SAlex Wilson 		BALMLayout*				fLayout;
92*5f4e71baSAlex Wilson 		AreaStack				fAreaStack;
93*5f4e71baSAlex Wilson 
94*5f4e71baSAlex Wilson 		Area*					_CurrentArea() const;
95*5f4e71baSAlex Wilson 		void					_SetCurrentArea(Area*);
9650cc24b3SAlex Wilson };
9750cc24b3SAlex Wilson 
9850cc24b3SAlex Wilson 
9950cc24b3SAlex Wilson };
10050cc24b3SAlex Wilson 
10150cc24b3SAlex Wilson 
10250cc24b3SAlex Wilson #endif
103