Make UEFI boot-platform build again
[haiku.git] / src / libs / alm / ALMGroup.cpp
blobaa7c56799c6b33b66299228205beee169376b42d
1 /*
2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3 * Distributed under the terms of the MIT License.
4 */
5 #include "ALMGroup.h"
8 #include <ALMLayout.h>
9 #include <Tab.h>
12 ALMGroup::ALMGroup(BLayoutItem* item)
14 _Init(item, NULL);
18 ALMGroup::ALMGroup(BView* view)
20 _Init(NULL, view);
24 BLayoutItem*
25 ALMGroup::LayoutItem() const
27 return fLayoutItem;
31 BView*
32 ALMGroup::View() const
34 return fView;
38 const std::vector<ALMGroup>&
39 ALMGroup::Groups() const
41 return fGroups;
45 enum orientation
46 ALMGroup::Orientation() const
48 return fOrientation;
52 ALMGroup&
53 ALMGroup::operator|(const ALMGroup& right)
55 return _AddItem(right, B_HORIZONTAL);
59 ALMGroup&
60 ALMGroup::operator/(const ALMGroup& bottom)
62 return _AddItem(bottom, B_VERTICAL);
66 void
67 ALMGroup::BuildLayout(BALMLayout* layout, XTab* left, YTab* top, XTab* right,
68 YTab* bottom)
70 if (left == NULL)
71 left = layout->Left();
72 if (top == NULL)
73 top = layout->Top();
74 if (right == NULL)
75 right = layout->Right();
76 if (bottom == NULL)
77 bottom = layout->Bottom();
79 _Build(layout, left, top, right, bottom);
83 ALMGroup::ALMGroup()
85 _Init(NULL, NULL);
89 void
90 ALMGroup::_Init(BLayoutItem* item, BView* view, enum orientation orien)
92 fLayoutItem = item;
93 fView = view;
94 fOrientation = orien;
98 void
99 ALMGroup::_Build(BALMLayout* layout, BReference<XTab> left,
100 BReference<YTab> top, BReference<XTab> right, BReference<YTab> bottom) const
102 if (LayoutItem())
103 layout->AddItem(LayoutItem(), left, top, right, bottom);
104 else if (View()) {
105 layout->AddView(View(), left, top, right, bottom);
106 } else {
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;
113 else
114 currentRight = layout->AddXTab();
115 current._Build(layout, left, top, currentRight, bottom);
116 left = currentRight;
117 } else {
118 BReference<YTab> currentBottom;
119 if (i == Groups().size() - 1)
120 currentBottom = bottom;
121 else
122 currentBottom = layout->AddYTab();
123 current._Build(layout, left, top, right, currentBottom);
124 top = currentBottom;
131 ALMGroup&
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;
138 fGroups.clear();
139 _Init(NULL, NULL, orien);
140 fGroups.push_back(clone);
143 _Init(NULL, NULL, orien);
144 fGroups.push_back(item);
145 return *this;