2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3 * Distributed under the terms of the MIT License.
12 ALMGroup::ALMGroup(BLayoutItem
* item
)
18 ALMGroup::ALMGroup(BView
* view
)
25 ALMGroup::LayoutItem() const
32 ALMGroup::View() const
38 const std::vector
<ALMGroup
>&
39 ALMGroup::Groups() const
46 ALMGroup::Orientation() const
53 ALMGroup::operator|(const ALMGroup
& right
)
55 return _AddItem(right
, B_HORIZONTAL
);
60 ALMGroup::operator/(const ALMGroup
& bottom
)
62 return _AddItem(bottom
, B_VERTICAL
);
67 ALMGroup::BuildLayout(BALMLayout
* layout
, XTab
* left
, YTab
* top
, XTab
* right
,
71 left
= layout
->Left();
75 right
= layout
->Right();
77 bottom
= layout
->Bottom();
79 _Build(layout
, left
, top
, right
, bottom
);
90 ALMGroup::_Init(BLayoutItem
* item
, BView
* view
, enum orientation orien
)
99 ALMGroup::_Build(BALMLayout
* layout
, BReference
<XTab
> left
,
100 BReference
<YTab
> top
, BReference
<XTab
> right
, BReference
<YTab
> bottom
) const
103 layout
->AddItem(LayoutItem(), left
, top
, right
, bottom
);
105 layout
->AddView(View(), left
, top
, right
, bottom
);
107 for (unsigned int i
= 0; i
< Groups().size(); i
++) {
108 const ALMGroup
& current
= Groups()[i
];
109 if (Orientation() == B_HORIZONTAL
) {
110 BReference
<XTab
> currentRight
;
111 if (i
== Groups().size() - 1)
112 currentRight
= right
;
114 currentRight
= layout
->AddXTab();
115 current
._Build(layout
, left
, top
, currentRight
, bottom
);
118 BReference
<YTab
> currentBottom
;
119 if (i
== Groups().size() - 1)
120 currentBottom
= bottom
;
122 currentBottom
= layout
->AddYTab();
123 current
._Build(layout
, left
, top
, right
, currentBottom
);
132 ALMGroup::_AddItem(const ALMGroup
& item
, enum orientation orien
)
134 if (fGroups
.size() == 0)
135 fGroups
.push_back(*this);
136 else if (fOrientation
!= orien
) {
137 ALMGroup clone
= *this;
139 _Init(NULL
, NULL
, orien
);
140 fGroups
.push_back(clone
);
143 _Init(NULL
, NULL
, orien
);
144 fGroups
.push_back(item
);