tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / layouter / OneElementLayouter.cpp
blob76736f9799780c45d0bb9ca430dc29bcadd60df9
1 /*
2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #include "OneElementLayouter.h"
8 #include <Size.h>
11 class OneElementLayouter::MyLayoutInfo : public LayoutInfo {
12 public:
13 float fSize;
15 MyLayoutInfo()
16 : fSize(0)
20 virtual float ElementLocation(int32 element)
22 return 0;
25 virtual float ElementSize(int32 element)
27 return fSize;
32 // constructor
33 OneElementLayouter::OneElementLayouter()
34 : fMin(-1),
35 fMax(B_SIZE_UNLIMITED),
36 fPreferred(-1)
40 // destructor
41 OneElementLayouter::~OneElementLayouter()
45 // AddConstraints
46 void
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);
58 // SetWeight
59 void
60 OneElementLayouter::SetWeight(int32 element, float weight)
62 // not needed
65 // MinSize
66 float
67 OneElementLayouter::MinSize()
69 return fMin;
72 // MaxSize
73 float
74 OneElementLayouter::MaxSize()
76 return fMax;
79 // PreferredSize
80 float
81 OneElementLayouter::PreferredSize()
83 return fPreferred;
86 // CreateLayoutInfo
87 LayoutInfo*
88 OneElementLayouter::CreateLayoutInfo()
90 return new MyLayoutInfo;
93 // Layout
94 void
95 OneElementLayouter::Layout(LayoutInfo* layoutInfo, float size)
97 ((MyLayoutInfo*)layoutInfo)->fSize = max_c(size, fMin);
100 // CloneLayouter
101 Layouter*
102 OneElementLayouter::CloneLayouter()
104 OneElementLayouter* layouter = new OneElementLayouter;
105 layouter->fMin = fMin;
106 layouter->fMax = fMax;
107 layouter->fPreferred = fPreferred;
109 return layouter;