2 * Copyright 2010, Haiku, Inc.
3 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
4 * All rights reserved. Distributed under the terms of the MIT License.
8 #include <AbstractLayoutItem.h>
10 #include <LayoutUtils.h>
15 const char* const kSizesField
= "BAbstractLayoutItem:sizes";
16 // kSizesField == {min, max, preferred}
17 const char* const kAlignmentField
= "BAbstractLayoutItem:alignment";
21 BAbstractLayoutItem::BAbstractLayoutItem()
31 BAbstractLayoutItem::BAbstractLayoutItem(BMessage
* from
)
39 from
->FindSize(kSizesField
, 0, &fMinSize
);
40 from
->FindSize(kSizesField
, 1, &fMaxSize
);
41 from
->FindSize(kSizesField
, 2, &fPreferredSize
);
42 from
->FindAlignment(kAlignmentField
, &fAlignment
);
46 BAbstractLayoutItem::~BAbstractLayoutItem()
52 BAbstractLayoutItem::MinSize()
54 return BLayoutUtils::ComposeSize(fMinSize
, BaseMinSize());
59 BAbstractLayoutItem::MaxSize()
61 return BLayoutUtils::ComposeSize(fMaxSize
, BaseMaxSize());
66 BAbstractLayoutItem::PreferredSize()
68 return BLayoutUtils::ComposeSize(fMaxSize
, BasePreferredSize());
73 BAbstractLayoutItem::Alignment()
75 return BLayoutUtils::ComposeAlignment(fAlignment
, BaseAlignment());
80 BAbstractLayoutItem::SetExplicitMinSize(BSize size
)
87 BAbstractLayoutItem::SetExplicitMaxSize(BSize size
)
94 BAbstractLayoutItem::SetExplicitPreferredSize(BSize size
)
96 fPreferredSize
= size
;
101 BAbstractLayoutItem::SetExplicitAlignment(BAlignment alignment
)
103 fAlignment
= alignment
;
108 BAbstractLayoutItem::BaseMinSize()
115 BAbstractLayoutItem::BaseMaxSize()
117 return BSize(B_SIZE_UNLIMITED
, B_SIZE_UNLIMITED
);
122 BAbstractLayoutItem::BasePreferredSize()
129 BAbstractLayoutItem::BaseAlignment()
131 return BAlignment(B_ALIGN_HORIZONTAL_CENTER
, B_ALIGN_VERTICAL_CENTER
);
136 BAbstractLayoutItem::Archive(BMessage
* into
, bool deep
) const
138 BArchiver
archiver(into
);
139 status_t err
= BLayoutItem::Archive(into
, deep
);
142 err
= into
->AddSize(kSizesField
, fMinSize
);
145 err
= into
->AddSize(kSizesField
, fMaxSize
);
148 err
= into
->AddSize(kSizesField
, fPreferredSize
);
151 err
= into
->AddAlignment(kAlignmentField
, fAlignment
);
153 return archiver
.Finish(err
);
158 BAbstractLayoutItem::AllUnarchived(const BMessage
* archive
)
160 return BLayoutItem::AllUnarchived(archive
);
165 BAbstractLayoutItem::AllArchived(BMessage
* archive
) const
167 return BLayoutItem::AllArchived(archive
);
172 BAbstractLayoutItem::LayoutInvalidated(bool children
)
174 BLayoutItem::LayoutInvalidated(children
);
179 BAbstractLayoutItem::AttachedToLayout()
181 BLayoutItem::AttachedToLayout();
186 BAbstractLayoutItem::DetachedFromLayout(BLayout
* layout
)
188 BLayoutItem::DetachedFromLayout(layout
);
193 BAbstractLayoutItem::AncestorVisibilityChanged(bool shown
)
195 BLayoutItem::AncestorVisibilityChanged(shown
);
200 BAbstractLayoutItem::Perform(perform_code d
, void* arg
)
202 return BLayoutItem::Perform(d
, arg
);
206 void BAbstractLayoutItem::_ReservedAbstractLayoutItem1() {}
207 void BAbstractLayoutItem::_ReservedAbstractLayoutItem2() {}
208 void BAbstractLayoutItem::_ReservedAbstractLayoutItem3() {}
209 void BAbstractLayoutItem::_ReservedAbstractLayoutItem4() {}
210 void BAbstractLayoutItem::_ReservedAbstractLayoutItem5() {}
211 void BAbstractLayoutItem::_ReservedAbstractLayoutItem6() {}
212 void BAbstractLayoutItem::_ReservedAbstractLayoutItem7() {}
213 void BAbstractLayoutItem::_ReservedAbstractLayoutItem8() {}
214 void BAbstractLayoutItem::_ReservedAbstractLayoutItem9() {}
215 void BAbstractLayoutItem::_ReservedAbstractLayoutItem10() {}