1 /* 2 * Copyright 2006-2010, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TWO_DIMENSIONAL_LAYOUT_H 6 #define _TWO_DIMENSIONAL_LAYOUT_H 7 8 9 #include <AbstractLayout.h> 10 11 class BLayoutContext; 12 13 14 class BTwoDimensionalLayout : public BAbstractLayout { 15 public: 16 BTwoDimensionalLayout(); 17 BTwoDimensionalLayout(BMessage* from); 18 virtual ~BTwoDimensionalLayout(); 19 20 void SetInsets(float left, float top, float right, 21 float bottom); 22 void GetInsets(float* left, float* top, float* right, 23 float* bottom) const; 24 25 void AlignLayoutWith(BTwoDimensionalLayout* other, 26 enum orientation orientation); 27 28 virtual BSize BaseMinSize(); 29 virtual BSize BaseMaxSize(); 30 virtual BSize BasePreferredSize(); 31 virtual BAlignment BaseAlignment(); 32 33 virtual bool HasHeightForWidth(); 34 virtual void GetHeightForWidth(float width, float* min, 35 float* max, float* preferred); 36 37 virtual void SetFrame(BRect frame); 38 39 virtual void InvalidateLayout(bool children = false); 40 41 virtual status_t Archive(BMessage* into, bool deep = true) const; 42 virtual status_t AllArchived(BMessage* into) const; 43 virtual status_t AllUnarchived(const BMessage* from); 44 45 protected: 46 struct ColumnRowConstraints { 47 float weight; 48 float min; 49 float max; 50 }; 51 52 struct Dimensions { 53 int32 x; 54 int32 y; 55 int32 width; 56 int32 height; 57 }; 58 59 virtual void DerivedLayoutItems(); 60 61 BSize AddInsets(BSize size); 62 void AddInsets(float* minHeight, float* maxHeight, 63 float* preferredHeight); 64 BSize SubtractInsets(BSize size); 65 66 virtual void PrepareItems(enum orientation orientation); 67 virtual bool HasMultiColumnItems(); 68 virtual bool HasMultiRowItems(); 69 70 virtual int32 InternalCountColumns() = 0; 71 virtual int32 InternalCountRows() = 0; 72 virtual void GetColumnRowConstraints( 73 enum orientation orientation, 74 int32 index, 75 ColumnRowConstraints* constraints) = 0; 76 virtual void GetItemDimensions(BLayoutItem* item, 77 Dimensions* dimensions) = 0; 78 79 private: 80 class CompoundLayouter; 81 class LocalLayouter; 82 class VerticalCompoundLayouter; 83 84 friend class LocalLayouter; 85 86 void _ValidateMinMax(); 87 88 protected: 89 float fLeftInset; 90 float fRightInset; 91 float fTopInset; 92 float fBottomInset; 93 float fHSpacing; 94 float fVSpacing; 95 96 private: 97 LocalLayouter* fLocalLayouter; 98 }; 99 100 #endif // _TWO_DIMENSIONAL_LAYOUT_H 101