Patch by Alex Wilson:
* Added archiving/unarchiving support. * Style cleanup (also some by myself). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37540 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cbac1a2355
commit
7ed1644c55
@ -13,6 +13,7 @@
|
||||
class BAbstractLayoutItem : public BLayoutItem {
|
||||
public:
|
||||
BAbstractLayoutItem();
|
||||
BAbstractLayoutItem(BMessage* from);
|
||||
virtual ~BAbstractLayoutItem();
|
||||
|
||||
virtual BSize MinSize();
|
||||
@ -30,6 +31,8 @@ public:
|
||||
virtual BSize BasePreferredSize();
|
||||
virtual BAlignment BaseAlignment();
|
||||
|
||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||
|
||||
private:
|
||||
BSize fMinSize;
|
||||
BSize fMaxSize;
|
||||
|
@ -1,107 +1,155 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku, Inc.
|
||||
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <AbstractLayoutItem.h>
|
||||
|
||||
#include <LayoutUtils.h>
|
||||
#include <Message.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const char* kMinSizeField = "BAbstractLayoutItem:minSize";
|
||||
const char* kMaxSizeField = "BAbstractLayoutItem:maxSize";
|
||||
const char* kPreferredSizeField = "BAbstractLayoutItem:preferredSize";
|
||||
const char* kAlignmentField = "BAbstractLayoutItem:alignment";
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
BAbstractLayoutItem::BAbstractLayoutItem()
|
||||
: fMinSize(),
|
||||
fMaxSize(),
|
||||
fPreferredSize(),
|
||||
fAlignment()
|
||||
:
|
||||
fMinSize(),
|
||||
fMaxSize(),
|
||||
fPreferredSize(),
|
||||
fAlignment()
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
BAbstractLayoutItem::BAbstractLayoutItem(BMessage* from)
|
||||
:
|
||||
BLayoutItem(from),
|
||||
fMinSize(),
|
||||
fMaxSize(),
|
||||
fPreferredSize(),
|
||||
fAlignment()
|
||||
{
|
||||
from->FindSize(kMinSizeField, &fMinSize);
|
||||
from->FindSize(kMaxSizeField, &fMaxSize);
|
||||
from->FindSize(kPreferredSizeField, &fPreferredSize);
|
||||
from->FindAlignment(kAlignmentField, &fAlignment);
|
||||
}
|
||||
|
||||
|
||||
BAbstractLayoutItem::~BAbstractLayoutItem()
|
||||
{
|
||||
}
|
||||
|
||||
// MinSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::MinSize()
|
||||
{
|
||||
return BLayoutUtils::ComposeSize(fMinSize, BaseMinSize());
|
||||
}
|
||||
|
||||
// MaxSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::MaxSize()
|
||||
{
|
||||
return BLayoutUtils::ComposeSize(fMaxSize, BaseMaxSize());
|
||||
}
|
||||
|
||||
// PreferredSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::PreferredSize()
|
||||
{
|
||||
return BLayoutUtils::ComposeSize(fMaxSize, BasePreferredSize());
|
||||
}
|
||||
|
||||
// Alignment
|
||||
|
||||
BAlignment
|
||||
BAbstractLayoutItem::Alignment()
|
||||
{
|
||||
return BLayoutUtils::ComposeAlignment(fAlignment, BaseAlignment());
|
||||
}
|
||||
|
||||
// SetExplicitMinSize
|
||||
|
||||
void
|
||||
BAbstractLayoutItem::SetExplicitMinSize(BSize size)
|
||||
{
|
||||
fMinSize = size;
|
||||
}
|
||||
|
||||
// SetExplicitMaxSize
|
||||
|
||||
void
|
||||
BAbstractLayoutItem::SetExplicitMaxSize(BSize size)
|
||||
{
|
||||
fMaxSize = size;
|
||||
}
|
||||
|
||||
// SetExplicitPreferredSize
|
||||
|
||||
void
|
||||
BAbstractLayoutItem::SetExplicitPreferredSize(BSize size)
|
||||
{
|
||||
fPreferredSize = size;
|
||||
}
|
||||
|
||||
// SetExplicitAlignment
|
||||
|
||||
void
|
||||
BAbstractLayoutItem::SetExplicitAlignment(BAlignment alignment)
|
||||
{
|
||||
fAlignment = alignment;
|
||||
}
|
||||
|
||||
// BaseMinSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::BaseMinSize()
|
||||
{
|
||||
return BSize(0, 0);
|
||||
}
|
||||
|
||||
// BaseMaxSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::BaseMaxSize()
|
||||
{
|
||||
return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
|
||||
}
|
||||
|
||||
// BasePreferredSize
|
||||
|
||||
BSize
|
||||
BAbstractLayoutItem::BasePreferredSize()
|
||||
{
|
||||
return BSize(0, 0);
|
||||
}
|
||||
|
||||
// BaseAlignment
|
||||
|
||||
BAlignment
|
||||
BAbstractLayoutItem::BaseAlignment()
|
||||
{
|
||||
return BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BAbstractLayoutItem::Archive(BMessage* into, bool deep) const
|
||||
{
|
||||
BArchiver archiver(into);
|
||||
status_t err = BLayoutItem::Archive(into, deep);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMinSizeField, fMinSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMaxSizeField, fMaxSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kPreferredSizeField, fPreferredSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddAlignment(kAlignmentField, fAlignment);
|
||||
|
||||
return archiver.Finish(err);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user