xref: /haiku/headers/os/interface/GroupLayout.h (revision 55b40aa53a835472ec7952b138ae4256203d02e4)
1 /*
2  * Copyright 2006, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_GROUP_LAYOUT_H
6 #define	_GROUP_LAYOUT_H
7 
8 #include <TwoDimensionalLayout.h>
9 
10 class BGroupLayout : public BTwoDimensionalLayout {
11 public:
12 								BGroupLayout(enum orientation orientation,
13 									float spacing = 0.0f);
14 	virtual						~BGroupLayout();
15 
16 			float				Spacing() const;
17 			void				SetSpacing(float spacing);
18 
19 			orientation			Orientation() const;
20 			void				SetOrientation(enum orientation orientation);
21 
22 			float				ItemWeight(int32 index) const;
23 			void				SetItemWeight(int32 index, float weight);
24 
25 	virtual	BLayoutItem*		AddView(BView* child);
26 	virtual	BLayoutItem*		AddView(int32 index, BView* child);
27 	virtual	BLayoutItem*		AddView(BView* child, float weight);
28 	virtual	BLayoutItem*		AddView(int32 index, BView* child,
29 									float weight);
30 
31 	virtual	bool				AddItem(BLayoutItem* item);
32 	virtual	bool				AddItem(int32 index, BLayoutItem* item);
33 	virtual	bool				AddItem(BLayoutItem* item, float weight);
34 	virtual	bool				AddItem(int32 index, BLayoutItem* item,
35 									float weight);
36 
37 protected:
38 	virtual	void				ItemAdded(BLayoutItem* item);
39 	virtual	void				ItemRemoved(BLayoutItem* item);
40 
41 	virtual	void				PrepareItems(enum orientation orientation);
42 
43 	virtual	int32				InternalCountColumns();
44 	virtual	int32				InternalCountRows();
45 	virtual	void				GetColumnRowConstraints(
46 									enum orientation orientation,
47 									int32 index,
48 									ColumnRowConstraints* constraints);
49 	virtual	void	 			GetItemDimensions(BLayoutItem* item,
50 									Dimensions* dimensions);
51 
52 private:
53 			struct ItemLayoutData;
54 
55 			ItemLayoutData*		_LayoutDataForItem(BLayoutItem* item) const;
56 
57 			orientation			fOrientation;
58 			BList				fVisibleItems;
59 };
60 
61 #endif	// _GROUP_LAYOUT_H
62