xref: /haiku/headers/os/interface/GridLayout.h (revision 6829d4174ba57d752c8d470a55789112db477daf)
19ecf9d1cSIngo Weinhold /*
2d1535a45SIngo Weinhold  * Copyright 2006-2010, Haiku, Inc. All rights reserved.
39ecf9d1cSIngo Weinhold  * Distributed under the terms of the MIT License.
49ecf9d1cSIngo Weinhold  */
59ecf9d1cSIngo Weinhold #ifndef	_GRID_LAYOUT_H
69ecf9d1cSIngo Weinhold #define	_GRID_LAYOUT_H
79ecf9d1cSIngo Weinhold 
89ecf9d1cSIngo Weinhold #include <TwoDimensionalLayout.h>
99ecf9d1cSIngo Weinhold 
109ecf9d1cSIngo Weinhold 
119ecf9d1cSIngo Weinhold class BGridLayout : public BTwoDimensionalLayout {
129ecf9d1cSIngo Weinhold public:
139ecf9d1cSIngo Weinhold 								BGridLayout(float horizontal = 0.0f,
149ecf9d1cSIngo Weinhold 									float vertical = 0.0f);
15d1535a45SIngo Weinhold 								BGridLayout(BMessage* from);
169ecf9d1cSIngo Weinhold 	virtual						~BGridLayout();
179ecf9d1cSIngo Weinhold 
18c4945a42SIngo Weinhold 			int32				CountColumns() const;
19c4945a42SIngo Weinhold 			int32				CountRows() const;
20c4945a42SIngo Weinhold 
219ecf9d1cSIngo Weinhold 			float				HorizontalSpacing() const;
229ecf9d1cSIngo Weinhold 			float				VerticalSpacing() const;
239ecf9d1cSIngo Weinhold 
249ecf9d1cSIngo Weinhold 			void				SetHorizontalSpacing(float spacing);
259ecf9d1cSIngo Weinhold 			void				SetVerticalSpacing(float spacing);
269ecf9d1cSIngo Weinhold 			void				SetSpacing(float horizontal, float vertical);
279ecf9d1cSIngo Weinhold 
289ecf9d1cSIngo Weinhold 			float				ColumnWeight(int32 column) const;
299ecf9d1cSIngo Weinhold 			void				SetColumnWeight(int32 column, float weight);
309ecf9d1cSIngo Weinhold 
319ecf9d1cSIngo Weinhold 			float				MinColumnWidth(int32 column) const;
329ecf9d1cSIngo Weinhold 			void				SetMinColumnWidth(int32 column, float width);
339ecf9d1cSIngo Weinhold 
349ecf9d1cSIngo Weinhold 			float				MaxColumnWidth(int32 column) const;
359ecf9d1cSIngo Weinhold 			void				SetMaxColumnWidth(int32 column, float width);
369ecf9d1cSIngo Weinhold 
379ecf9d1cSIngo Weinhold 			float				RowWeight(int32 row) const;
389ecf9d1cSIngo Weinhold 			void				SetRowWeight(int32 row, float weight);
399ecf9d1cSIngo Weinhold 
409ecf9d1cSIngo Weinhold 			float				MinRowHeight(int row) const;
419ecf9d1cSIngo Weinhold 			void				SetMinRowHeight(int32 row, float height);
429ecf9d1cSIngo Weinhold 
439ecf9d1cSIngo Weinhold 			float				MaxRowHeight(int32 row) const;
449ecf9d1cSIngo Weinhold 			void				SetMaxRowHeight(int32 row, float height);
459ecf9d1cSIngo Weinhold 
469ecf9d1cSIngo Weinhold 	virtual	BLayoutItem*		AddView(BView* child);
479ecf9d1cSIngo Weinhold 	virtual	BLayoutItem*		AddView(int32 index, BView* child);
489ecf9d1cSIngo Weinhold 	virtual	BLayoutItem*		AddView(BView* child, int32 column, int32 row,
499ecf9d1cSIngo Weinhold 									int32 columnCount = 1, int32 rowCount = 1);
509ecf9d1cSIngo Weinhold 
519ecf9d1cSIngo Weinhold 	virtual	bool				AddItem(BLayoutItem* item);
529ecf9d1cSIngo Weinhold 	virtual	bool				AddItem(int32 index, BLayoutItem* item);
539ecf9d1cSIngo Weinhold 	virtual	bool				AddItem(BLayoutItem* item, int32 column,
549ecf9d1cSIngo Weinhold 									int32 row, int32 columnCount = 1,
559ecf9d1cSIngo Weinhold 									int32 rowCount = 1);
569ecf9d1cSIngo Weinhold 
57d1535a45SIngo Weinhold 	virtual	status_t			Archive(BMessage* into, bool deep = true) const;
58d1535a45SIngo Weinhold 	static	BArchivable*		Instantiate(BMessage* from);
59d1535a45SIngo Weinhold 
60d1535a45SIngo Weinhold 	virtual status_t			ItemArchived(BMessage* into,
61d1535a45SIngo Weinhold 									BLayoutItem* item, int32 index) const;
62d1535a45SIngo Weinhold 	virtual status_t			ItemUnarchived(const BMessage* from,
63d1535a45SIngo Weinhold 									BLayoutItem* item, int32 index);
64d1535a45SIngo Weinhold 
659ecf9d1cSIngo Weinhold protected:
66*6829d417SAlex Wilson 	virtual	bool				ItemAdded(BLayoutItem* item, int32 atIndex);
67*6829d417SAlex Wilson 	virtual	void				ItemRemoved(BLayoutItem* item, int32 fromIndex);
689ecf9d1cSIngo Weinhold 
699ecf9d1cSIngo Weinhold 	virtual	bool				HasMultiColumnItems();
709ecf9d1cSIngo Weinhold 	virtual	bool				HasMultiRowItems();
719ecf9d1cSIngo Weinhold 
729ecf9d1cSIngo Weinhold 	virtual	int32				InternalCountColumns();
739ecf9d1cSIngo Weinhold 	virtual	int32				InternalCountRows();
749ecf9d1cSIngo Weinhold 	virtual	void				GetColumnRowConstraints(
759ecf9d1cSIngo Weinhold 									enum orientation orientation,
769ecf9d1cSIngo Weinhold 									int32 index,
779ecf9d1cSIngo Weinhold 									ColumnRowConstraints* constraints);
789ecf9d1cSIngo Weinhold 	virtual	void				GetItemDimensions(BLayoutItem* item,
799ecf9d1cSIngo Weinhold 									Dimensions* dimensions);
809ecf9d1cSIngo Weinhold 
819ecf9d1cSIngo Weinhold private:
829ecf9d1cSIngo Weinhold 			class DummyLayoutItem;
839ecf9d1cSIngo Weinhold 			class RowInfoArray;
849ecf9d1cSIngo Weinhold 			struct ItemLayoutData;
859ecf9d1cSIngo Weinhold 
869ecf9d1cSIngo Weinhold 			bool				_IsGridCellEmpty(int32 column, int32 row);
879ecf9d1cSIngo Weinhold 			bool				_AreGridCellsEmpty(int32 column, int32 row,
889ecf9d1cSIngo Weinhold 									int32 columnCount, int32 rowCount);
899ecf9d1cSIngo Weinhold 
90d1535a45SIngo Weinhold 			bool				_InsertItemIntoGrid(BLayoutItem* item);
919ecf9d1cSIngo Weinhold 			bool				_ResizeGrid(int32 columnCount, int32 rowCount);
929ecf9d1cSIngo Weinhold 
939ecf9d1cSIngo Weinhold 			ItemLayoutData*		_LayoutDataForItem(BLayoutItem* item) const;
949ecf9d1cSIngo Weinhold 
959ecf9d1cSIngo Weinhold private:
969ecf9d1cSIngo Weinhold 			BLayoutItem***		fGrid;
979ecf9d1cSIngo Weinhold 			int32				fColumnCount;
989ecf9d1cSIngo Weinhold 			int32				fRowCount;
999ecf9d1cSIngo Weinhold 
1009ecf9d1cSIngo Weinhold 			RowInfoArray*		fRowInfos;
1019ecf9d1cSIngo Weinhold 			RowInfoArray*		fColumnInfos;
1029ecf9d1cSIngo Weinhold 
1039ecf9d1cSIngo Weinhold 			int32				fMultiColumnItems;
1049ecf9d1cSIngo Weinhold 			int32				fMultiRowItems;
1059ecf9d1cSIngo Weinhold };
1069ecf9d1cSIngo Weinhold 
1079ecf9d1cSIngo Weinhold #endif	// _GRID_LAYOUT_H
108