2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
6 #include "OneElementLayouter.h"
11 class OneElementLayouter::MyLayoutInfo
: public LayoutInfo
{
20 virtual float ElementLocation(int32 element
)
25 virtual float ElementSize(int32 element
)
33 OneElementLayouter::OneElementLayouter()
35 fMax(B_SIZE_UNLIMITED
),
41 OneElementLayouter::~OneElementLayouter()
47 OneElementLayouter::AddConstraints(int32 element
, int32 length
,
48 float min
, float max
, float preferred
)
50 fMin
= max_c(fMin
, min
);
51 fMax
= min_c(fMax
, max
);
52 fMax
= max_c(fMax
, fMin
);
53 fPreferred
= max_c(fPreferred
, preferred
);
54 fPreferred
= max_c(fPreferred
, fMin
);
55 fPreferred
= min_c(fPreferred
, fMax
);
60 OneElementLayouter::SetWeight(int32 element
, float weight
)
67 OneElementLayouter::MinSize()
74 OneElementLayouter::MaxSize()
81 OneElementLayouter::PreferredSize()
88 OneElementLayouter::CreateLayoutInfo()
90 return new MyLayoutInfo
;
95 OneElementLayouter::Layout(LayoutInfo
* layoutInfo
, float size
)
97 ((MyLayoutInfo
*)layoutInfo
)->fSize
= max_c(size
, fMin
);
102 OneElementLayouter::CloneLayouter()
104 OneElementLayouter
* layouter
= new OneElementLayouter
;
105 layouter
->fMin
= fMin
;
106 layouter
->fMax
= fMax
;
107 layouter
->fPreferred
= fPreferred
;