xref: /haiku/headers/os/interface/TwoDimensionalLayout.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
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				SetInsets(float horizontal, float vertical);
23 			void				SetInsets(float insets);
24 			void				GetInsets(float* left, float* top, float* right,
25 									float* bottom) const;
26 
27 			void				AlignLayoutWith(BTwoDimensionalLayout* other,
28 									enum orientation orientation);
29 
30 	virtual	BSize				BaseMinSize();
31 	virtual	BSize				BaseMaxSize();
32 	virtual	BSize				BasePreferredSize();
33 	virtual	BAlignment			BaseAlignment();
34 
35 	virtual	bool				HasHeightForWidth();
36 	virtual	void				GetHeightForWidth(float width, float* min,
37 									float* max, float* preferred);
38 
39 	virtual	void				SetFrame(BRect frame);
40 
41 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
42 
43 	virtual status_t			Perform(perform_code d, void* arg);
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 status_t			AllArchived(BMessage* into) const;
60 	virtual	status_t			AllUnarchived(const BMessage* from);
61 
62 	virtual status_t			ItemArchived(BMessage* into, BLayoutItem* item,
63 									int32 index) const;
64 	virtual	status_t			ItemUnarchived(const BMessage* from,
65 									BLayoutItem* item, int32 index);
66 	virtual	void				LayoutInvalidated(bool children = false);
67 
68 	virtual	void				DoLayout();
69 
70 			BSize				AddInsets(BSize size);
71 			void				AddInsets(float* minHeight, float* maxHeight,
72 									float* preferredHeight);
73 			BSize				SubtractInsets(BSize size);
74 
75 	virtual	void				PrepareItems(enum orientation orientation);
76 	virtual	bool				HasMultiColumnItems();
77 	virtual	bool				HasMultiRowItems();
78 
79 	virtual	int32				InternalCountColumns() = 0;
80 	virtual	int32				InternalCountRows() = 0;
81 	virtual	void				GetColumnRowConstraints(
82 									enum orientation orientation,
83 									int32 index,
84 									ColumnRowConstraints* constraints) = 0;
85 	virtual	void				GetItemDimensions(BLayoutItem* item,
86 									Dimensions* dimensions) = 0;
87 
88 private:
89 			class CompoundLayouter;
90 			class LocalLayouter;
91 			class VerticalCompoundLayouter;
92 
93 			friend class LocalLayouter;
94 
95 			void				_ValidateMinMax();
96 
97 protected:
98 			float				fLeftInset;
99 			float				fRightInset;
100 			float				fTopInset;
101 			float				fBottomInset;
102 			float				fHSpacing;
103 			float				fVSpacing;
104 
105 private:
106 
107 	// FBC padding
108 	virtual	void				_ReservedTwoDimensionalLayout1();
109 	virtual	void				_ReservedTwoDimensionalLayout2();
110 	virtual	void				_ReservedTwoDimensionalLayout3();
111 	virtual	void				_ReservedTwoDimensionalLayout4();
112 	virtual	void				_ReservedTwoDimensionalLayout5();
113 	virtual	void				_ReservedTwoDimensionalLayout6();
114 	virtual	void				_ReservedTwoDimensionalLayout7();
115 	virtual	void				_ReservedTwoDimensionalLayout8();
116 	virtual	void				_ReservedTwoDimensionalLayout9();
117 	virtual	void				_ReservedTwoDimensionalLayout10();
118 
119 	// forbidden methods
120 								BTwoDimensionalLayout(
121 									const BTwoDimensionalLayout&);
122 			void				operator =(const BTwoDimensionalLayout&);
123 
124 			LocalLayouter*		fLocalLayouter;
125 
126 			uint32				_reserved[5];
127 };
128 
129 #endif // _TWO_DIMENSIONAL_LAYOUT_H
130