xref: /haiku/headers/os/interface/GroupLayout.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2006-2010, Haiku, Inc. All rights reserved.
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(orientation orientation,
13 									float spacing = B_USE_DEFAULT_SPACING);
14 								BGroupLayout(BMessage* from);
15 	virtual						~BGroupLayout();
16 
17 			float				Spacing() const;
18 			void				SetSpacing(float spacing);
19 
20 			orientation			Orientation() const;
21 			void				SetOrientation(orientation orientation);
22 
23 			float				ItemWeight(int32 index) const;
24 			void				SetItemWeight(int32 index, float weight);
25 
26 	virtual	BLayoutItem*		AddView(BView* child);
27 	virtual	BLayoutItem*		AddView(int32 index, BView* child);
28 	virtual	BLayoutItem*		AddView(BView* child, float weight);
29 	virtual	BLayoutItem*		AddView(int32 index, BView* child,
30 									float weight);
31 
32 	virtual	bool				AddItem(BLayoutItem* item);
33 	virtual	bool				AddItem(int32 index, BLayoutItem* item);
34 	virtual	bool				AddItem(BLayoutItem* item, float weight);
35 	virtual	bool				AddItem(int32 index, BLayoutItem* item,
36 									float weight);
37 
38 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
39 	static	BArchivable*		Instantiate(BMessage* from);
40 
41 	virtual	status_t			Perform(perform_code d, void* arg);
42 
43 protected:
44 	virtual status_t			AllArchived(BMessage* into) const;
45 	virtual	status_t			AllUnarchived(const BMessage* from);
46 	virtual status_t			ItemArchived(BMessage* into, BLayoutItem* item,
47 									int32 index) const;
48 	virtual	status_t			ItemUnarchived(const BMessage* from,
49 									BLayoutItem* item, int32 index);
50 
51 	virtual	bool				ItemAdded(BLayoutItem* item, int32 atIndex);
52 	virtual	void				ItemRemoved(BLayoutItem* item, int32 fromIndex);
53 
54 	virtual	void				PrepareItems(orientation orientation);
55 
56 	virtual	int32				InternalCountColumns();
57 	virtual	int32				InternalCountRows();
58 	virtual	void				GetColumnRowConstraints(
59 									orientation orientation,
60 									int32 index,
61 									ColumnRowConstraints* constraints);
62 	virtual	void				GetItemDimensions(BLayoutItem* item,
63 									Dimensions* dimensions);
64 
65 private:
66 
67 	// FBC padding
68 	virtual	void				_ReservedGroupLayout1();
69 	virtual	void				_ReservedGroupLayout2();
70 	virtual	void				_ReservedGroupLayout3();
71 	virtual	void				_ReservedGroupLayout4();
72 	virtual	void				_ReservedGroupLayout5();
73 	virtual	void				_ReservedGroupLayout6();
74 	virtual	void				_ReservedGroupLayout7();
75 	virtual	void				_ReservedGroupLayout8();
76 	virtual	void				_ReservedGroupLayout9();
77 	virtual	void				_ReservedGroupLayout10();
78 
79 	// forbidden methods
80 								BGroupLayout(const BGroupLayout&);
81 			void				operator =(const BGroupLayout&);
82 
83 			struct ItemLayoutData;
84 
85 			ItemLayoutData*		_LayoutDataForItem(BLayoutItem* item) const;
86 
87 			orientation			fOrientation;
88 			BList				fVisibleItems;
89 
90 			uint32				_reserved[5];
91 };
92 
93 #endif	// _GROUP_LAYOUT_H
94