xref: /haiku/src/kits/interface/SplitLayoutBuilder.cpp (revision a3e794ae459fec76826407f8ba8c94cd3535f128)
1 /*
2  * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #include <SplitLayoutBuilder.h>
7 
8 #include <new>
9 
10 
11 using std::nothrow;
12 
13 
14 // constructor
15 BSplitLayoutBuilder::BSplitLayoutBuilder(orientation orientation,
16 		float spacing)
17 	: fView(new BSplitView(orientation, spacing))
18 {
19 }
20 
21 // constructor
22 BSplitLayoutBuilder::BSplitLayoutBuilder(BSplitView* view)
23 	: fView(view)
24 {
25 }
26 
27 // SplitView
28 BSplitView*
29 BSplitLayoutBuilder::SplitView() const
30 {
31 	return fView;
32 }
33 
34 // GetSplitView
35 BSplitLayoutBuilder&
36 BSplitLayoutBuilder::GetSplitView(BSplitView** view)
37 {
38 	*view = fView;
39 	return *this;
40 }
41 
42 // Add
43 BSplitLayoutBuilder&
44 BSplitLayoutBuilder::Add(BView* view)
45 {
46 	fView->AddChild(view);
47 	return *this;
48 }
49 
50 // Add
51 BSplitLayoutBuilder&
52 BSplitLayoutBuilder::Add(BView* view, float weight)
53 {
54 	fView->AddChild(view, weight);
55 	return *this;
56 }
57 
58 // Add
59 BSplitLayoutBuilder&
60 BSplitLayoutBuilder::Add(BLayoutItem* item)
61 {
62 	fView->AddChild(item);
63 	return *this;
64 }
65 
66 // Add
67 BSplitLayoutBuilder&
68 BSplitLayoutBuilder::Add(BLayoutItem* item, float weight)
69 {
70 	fView->AddChild(item, weight);
71 	return *this;
72 }
73 
74 // SetCollapsible
75 BSplitLayoutBuilder&
76 BSplitLayoutBuilder::SetCollapsible(bool collapsible)
77 {
78 	int32 count = fView->CountChildren();
79 	if (count > 0)
80 		fView->SetCollapsible(count - 1, collapsible);
81 	return *this;
82 }
83 
84 // SetInsets
85 BSplitLayoutBuilder&
86 BSplitLayoutBuilder::SetInsets(float left, float top, float right, float bottom)
87 {
88 	fView->SetInsets(left, top, right, bottom);
89 
90 	return *this;
91 }
92 
93 // cast operator BSplitView*
94 BSplitLayoutBuilder::operator BSplitView*()
95 {
96 	return fView;
97 }
98 
99