1 /* 2 * Copyright 2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef SIMPLE_LAYOUTER_H 6 #define SIMPLE_LAYOUTER_H 7 8 #include "Layouter.h" 9 10 class BList; 11 12 namespace BPrivate { 13 namespace Layout { 14 15 class SimpleLayouter : public Layouter { 16 public: 17 SimpleLayouter(int32 elementCount, 18 int32 spacing); 19 virtual ~SimpleLayouter(); 20 21 virtual void AddConstraints(int32 element, int32 length, 22 float min, float max, float preferred); 23 virtual void SetWeight(int32 element, float weight); 24 25 virtual float MinSize(); 26 virtual float MaxSize(); 27 virtual float PreferredSize(); 28 29 virtual LayoutInfo* CreateLayoutInfo(); 30 31 virtual void Layout(LayoutInfo* layoutInfo, float size); 32 33 virtual Layouter* CloneLayouter(); 34 35 static void DistributeSize(int32 size, float weights[], 36 int32 sizes[], int32 count); 37 38 private: 39 static long _CalculateSumWeight(BList& elementInfos); 40 41 void _ValidateMinMax(); 42 void _LayoutMax(); 43 void _LayoutStandard(); 44 45 private: 46 class ElementLayoutInfo; 47 class ElementInfo; 48 class MyLayoutInfo; 49 50 int32 fElementCount; 51 int32 fSpacing; 52 ElementInfo* fElements; 53 54 int32 fMin; 55 int32 fMax; 56 int32 fPreferred; 57 58 bool fMinMaxValid; 59 60 MyLayoutInfo* fLayoutInfo; 61 }; 62 63 } // namespace Layout 64 } // namespace BPrivate 65 66 using BPrivate::Layout::SimpleLayouter; 67 68 #endif // SIMPLE_LAYOUTER_H 69