xref: /haiku/headers/os/interface/GroupLayoutBuilder.h (revision c14bca2958fb7b0c34d5464ccfdd87038f909a0c)
1 /*
2  * Copyright 2006-2010, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_GROUP_LAYOUT_BUILDER_H
6 #define	_GROUP_LAYOUT_BUILDER_H
7 
8 #include <GroupLayout.h>
9 #include <GroupView.h>
10 #include <List.h>
11 
12 class BGroupLayoutBuilder {
13 public:
14 								BGroupLayoutBuilder(
15 									orientation orientation = B_HORIZONTAL,
16 									float spacing = B_USE_DEFAULT_SPACING);
17 								BGroupLayoutBuilder(BGroupLayout* layout);
18 								BGroupLayoutBuilder(BGroupView* view);
19 
20 			BGroupLayout*		RootLayout() const;
21 			BGroupLayout*		TopLayout() const;
22 			BGroupLayoutBuilder& GetTopLayout(BGroupLayout** _layout);
23 			BView*				TopView() const;
24 			BGroupLayoutBuilder& GetTopView(BView** _view);
25 
26 			BGroupLayoutBuilder& Add(BView* view);
27 			BGroupLayoutBuilder& Add(BView* view, float weight);
28 			BGroupLayoutBuilder& Add(BLayoutItem* item);
29 			BGroupLayoutBuilder& Add(BLayoutItem* item, float weight);
30 
31 			BGroupLayoutBuilder& AddGroup(orientation orientation,
32 									float spacing = B_USE_DEFAULT_SPACING,
33 									float weight = 1.0f);
34 			BGroupLayoutBuilder& End();
35 
36 			BGroupLayoutBuilder& AddGlue(float weight = 1.0f);
37 			BGroupLayoutBuilder& AddStrut(float size);
38 
39 			BGroupLayoutBuilder& SetInsets(float left, float top, float right,
40 									float bottom);
41 
42 								operator BGroupLayout*();
43 
44 private:
45 			bool				_PushLayout(BGroupLayout* layout);
46 			void				_PopLayout();
47 
48 private:
49 			BGroupLayout*		fRootLayout;
50 			BList				fLayoutStack;
51 };
52 
53 #endif	// _GROUP_LAYOUT_BUILDER_H
54