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
BSplitLayoutBuilder(orientation orientation,float spacing)15 BSplitLayoutBuilder::BSplitLayoutBuilder(orientation orientation,
16 float spacing)
17 : fView(new BSplitView(orientation, spacing))
18 {
19 }
20
21 // constructor
BSplitLayoutBuilder(BSplitView * view)22 BSplitLayoutBuilder::BSplitLayoutBuilder(BSplitView* view)
23 : fView(view)
24 {
25 }
26
27 // SplitView
28 BSplitView*
SplitView() const29 BSplitLayoutBuilder::SplitView() const
30 {
31 return fView;
32 }
33
34 // GetSplitView
35 BSplitLayoutBuilder&
GetSplitView(BSplitView ** view)36 BSplitLayoutBuilder::GetSplitView(BSplitView** view)
37 {
38 *view = fView;
39 return *this;
40 }
41
42 // Add
43 BSplitLayoutBuilder&
Add(BView * view)44 BSplitLayoutBuilder::Add(BView* view)
45 {
46 fView->AddChild(view);
47 return *this;
48 }
49
50 // Add
51 BSplitLayoutBuilder&
Add(BView * view,float weight)52 BSplitLayoutBuilder::Add(BView* view, float weight)
53 {
54 fView->AddChild(view, weight);
55 return *this;
56 }
57
58 // Add
59 BSplitLayoutBuilder&
Add(BLayoutItem * item)60 BSplitLayoutBuilder::Add(BLayoutItem* item)
61 {
62 fView->AddChild(item);
63 return *this;
64 }
65
66 // Add
67 BSplitLayoutBuilder&
Add(BLayoutItem * item,float weight)68 BSplitLayoutBuilder::Add(BLayoutItem* item, float weight)
69 {
70 fView->AddChild(item, weight);
71 return *this;
72 }
73
74 // SetCollapsible
75 BSplitLayoutBuilder&
SetCollapsible(bool collapsible)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&
SetInsets(float left,float top,float right,float bottom)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*
operator BSplitView*()94 BSplitLayoutBuilder::operator BSplitView*()
95 {
96 return fView;
97 }
98
99