19ecf9d1cSIngo Weinhold /* 224a77ea0SAxel Dörfler * Copyright 2006-2011, 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 824a77ea0SAxel Dörfler 99ecf9d1cSIngo Weinhold #include <TwoDimensionalLayout.h> 109ecf9d1cSIngo Weinhold 119ecf9d1cSIngo Weinhold 129ecf9d1cSIngo Weinhold class BGridLayout : public BTwoDimensionalLayout { 139ecf9d1cSIngo Weinhold public: 1482ab3167SAlex Wilson BGridLayout(float horizontal 1582ab3167SAlex Wilson = B_USE_DEFAULT_SPACING, 1682ab3167SAlex Wilson float vertical = B_USE_DEFAULT_SPACING); 17d1535a45SIngo Weinhold BGridLayout(BMessage* from); 189ecf9d1cSIngo Weinhold virtual ~BGridLayout(); 199ecf9d1cSIngo Weinhold 20c4945a42SIngo Weinhold int32 CountColumns() const; 21c4945a42SIngo Weinhold int32 CountRows() const; 22c4945a42SIngo Weinhold 239ecf9d1cSIngo Weinhold float HorizontalSpacing() const; 249ecf9d1cSIngo Weinhold float VerticalSpacing() const; 259ecf9d1cSIngo Weinhold 269ecf9d1cSIngo Weinhold void SetHorizontalSpacing(float spacing); 279ecf9d1cSIngo Weinhold void SetVerticalSpacing(float spacing); 289ecf9d1cSIngo Weinhold void SetSpacing(float horizontal, float vertical); 299ecf9d1cSIngo Weinhold 309ecf9d1cSIngo Weinhold float ColumnWeight(int32 column) const; 319ecf9d1cSIngo Weinhold void SetColumnWeight(int32 column, float weight); 329ecf9d1cSIngo Weinhold 339ecf9d1cSIngo Weinhold float MinColumnWidth(int32 column) const; 349ecf9d1cSIngo Weinhold void SetMinColumnWidth(int32 column, float width); 359ecf9d1cSIngo Weinhold 369ecf9d1cSIngo Weinhold float MaxColumnWidth(int32 column) const; 379ecf9d1cSIngo Weinhold void SetMaxColumnWidth(int32 column, float width); 389ecf9d1cSIngo Weinhold 399ecf9d1cSIngo Weinhold float RowWeight(int32 row) const; 409ecf9d1cSIngo Weinhold void SetRowWeight(int32 row, float weight); 419ecf9d1cSIngo Weinhold 429ecf9d1cSIngo Weinhold float MinRowHeight(int row) const; 439ecf9d1cSIngo Weinhold void SetMinRowHeight(int32 row, float height); 449ecf9d1cSIngo Weinhold 459ecf9d1cSIngo Weinhold float MaxRowHeight(int32 row) const; 469ecf9d1cSIngo Weinhold void SetMaxRowHeight(int32 row, float height); 479ecf9d1cSIngo Weinhold 4824a77ea0SAxel Dörfler BLayoutItem* ItemAt(int32 column, int32 row) const; 4924a77ea0SAxel Dörfler 509ecf9d1cSIngo Weinhold virtual BLayoutItem* AddView(BView* child); 519ecf9d1cSIngo Weinhold virtual BLayoutItem* AddView(int32 index, BView* child); 529ecf9d1cSIngo Weinhold virtual BLayoutItem* AddView(BView* child, int32 column, int32 row, 539ecf9d1cSIngo Weinhold int32 columnCount = 1, int32 rowCount = 1); 549ecf9d1cSIngo Weinhold 559ecf9d1cSIngo Weinhold virtual bool AddItem(BLayoutItem* item); 569ecf9d1cSIngo Weinhold virtual bool AddItem(int32 index, BLayoutItem* item); 579ecf9d1cSIngo Weinhold virtual bool AddItem(BLayoutItem* item, int32 column, 589ecf9d1cSIngo Weinhold int32 row, int32 columnCount = 1, 599ecf9d1cSIngo Weinhold int32 rowCount = 1); 609ecf9d1cSIngo Weinhold 61d1535a45SIngo Weinhold virtual status_t Archive(BMessage* into, bool deep = true) const; 62d1535a45SIngo Weinhold static BArchivable* Instantiate(BMessage* from); 63d1535a45SIngo Weinhold 64d1535a45SIngo Weinhold virtual status_t ItemArchived(BMessage* into, 65d1535a45SIngo Weinhold BLayoutItem* item, int32 index) const; 66d1535a45SIngo Weinhold virtual status_t ItemUnarchived(const BMessage* from, 67d1535a45SIngo Weinhold BLayoutItem* item, int32 index); 68d1535a45SIngo Weinhold 69a851b3adSAlex Wilson virtual status_t Perform(perform_code d, void* arg); 70a851b3adSAlex Wilson 719ecf9d1cSIngo Weinhold protected: 726829d417SAlex Wilson virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 736829d417SAlex Wilson virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 749ecf9d1cSIngo Weinhold 759ecf9d1cSIngo Weinhold virtual bool HasMultiColumnItems(); 769ecf9d1cSIngo Weinhold virtual bool HasMultiRowItems(); 779ecf9d1cSIngo Weinhold 789ecf9d1cSIngo Weinhold virtual int32 InternalCountColumns(); 799ecf9d1cSIngo Weinhold virtual int32 InternalCountRows(); 809ecf9d1cSIngo Weinhold virtual void GetColumnRowConstraints( 819ecf9d1cSIngo Weinhold enum orientation orientation, 829ecf9d1cSIngo Weinhold int32 index, 839ecf9d1cSIngo Weinhold ColumnRowConstraints* constraints); 849ecf9d1cSIngo Weinhold virtual void GetItemDimensions(BLayoutItem* item, 859ecf9d1cSIngo Weinhold Dimensions* dimensions); 869ecf9d1cSIngo Weinhold private: 879ecf9d1cSIngo Weinhold class DummyLayoutItem; 889ecf9d1cSIngo Weinhold class RowInfoArray; 899ecf9d1cSIngo Weinhold struct ItemLayoutData; 909ecf9d1cSIngo Weinhold 919ecf9d1cSIngo Weinhold bool _IsGridCellEmpty(int32 column, int32 row); 929ecf9d1cSIngo Weinhold bool _AreGridCellsEmpty(int32 column, int32 row, 939ecf9d1cSIngo Weinhold int32 columnCount, int32 rowCount); 949ecf9d1cSIngo Weinhold 95d1535a45SIngo Weinhold bool _InsertItemIntoGrid(BLayoutItem* item); 969ecf9d1cSIngo Weinhold bool _ResizeGrid(int32 columnCount, int32 rowCount); 979ecf9d1cSIngo Weinhold 989ecf9d1cSIngo Weinhold ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const; 999ecf9d1cSIngo Weinhold 1009ecf9d1cSIngo Weinhold private: 101*8151838eSAlex Wilson 102*8151838eSAlex Wilson // FBC padding 103*8151838eSAlex Wilson virtual void _ReservedGridLayout1(); 104*8151838eSAlex Wilson virtual void _ReservedGridLayout2(); 105*8151838eSAlex Wilson virtual void _ReservedGridLayout3(); 106*8151838eSAlex Wilson virtual void _ReservedGridLayout4(); 107*8151838eSAlex Wilson virtual void _ReservedGridLayout5(); 108*8151838eSAlex Wilson virtual void _ReservedGridLayout6(); 109*8151838eSAlex Wilson virtual void _ReservedGridLayout7(); 110*8151838eSAlex Wilson virtual void _ReservedGridLayout8(); 111*8151838eSAlex Wilson virtual void _ReservedGridLayout9(); 112*8151838eSAlex Wilson virtual void _ReservedGridLayout10(); 113*8151838eSAlex Wilson 1149ecf9d1cSIngo Weinhold BLayoutItem*** fGrid; 1159ecf9d1cSIngo Weinhold int32 fColumnCount; 1169ecf9d1cSIngo Weinhold int32 fRowCount; 1179ecf9d1cSIngo Weinhold 1189ecf9d1cSIngo Weinhold RowInfoArray* fRowInfos; 1199ecf9d1cSIngo Weinhold RowInfoArray* fColumnInfos; 1209ecf9d1cSIngo Weinhold 1219ecf9d1cSIngo Weinhold int32 fMultiColumnItems; 1229ecf9d1cSIngo Weinhold int32 fMultiRowItems; 123*8151838eSAlex Wilson 124*8151838eSAlex Wilson uint32 _reserved[5]; 1259ecf9d1cSIngo Weinhold }; 1269ecf9d1cSIngo Weinhold 12724a77ea0SAxel Dörfler 1289ecf9d1cSIngo Weinhold #endif // _GRID_LAYOUT_H 129