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 64d56e7bd6SAlex Wilson virtual status_t Perform(perform_code d, void* arg); 65d56e7bd6SAlex Wilson 66d56e7bd6SAlex Wilson protected: 67d56e7bd6SAlex Wilson virtual status_t AllArchived(BMessage* into) const; 68d56e7bd6SAlex Wilson virtual status_t AllUnarchived(const BMessage* from); 69d1535a45SIngo Weinhold virtual status_t ItemArchived(BMessage* into, 70d1535a45SIngo Weinhold BLayoutItem* item, int32 index) const; 71d1535a45SIngo Weinhold virtual status_t ItemUnarchived(const BMessage* from, 72d1535a45SIngo Weinhold BLayoutItem* item, int32 index); 73d1535a45SIngo Weinhold 746829d417SAlex Wilson virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 756829d417SAlex Wilson virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 769ecf9d1cSIngo Weinhold 779ecf9d1cSIngo Weinhold virtual bool HasMultiColumnItems(); 789ecf9d1cSIngo Weinhold virtual bool HasMultiRowItems(); 799ecf9d1cSIngo Weinhold 809ecf9d1cSIngo Weinhold virtual int32 InternalCountColumns(); 819ecf9d1cSIngo Weinhold virtual int32 InternalCountRows(); 829ecf9d1cSIngo Weinhold virtual void GetColumnRowConstraints( 83*e724b26fSJohn Scipione orientation orientation, 849ecf9d1cSIngo Weinhold int32 index, 859ecf9d1cSIngo Weinhold ColumnRowConstraints* constraints); 869ecf9d1cSIngo Weinhold virtual void GetItemDimensions(BLayoutItem* item, 879ecf9d1cSIngo Weinhold Dimensions* dimensions); 889ecf9d1cSIngo Weinhold private: 899ecf9d1cSIngo Weinhold class DummyLayoutItem; 909ecf9d1cSIngo Weinhold class RowInfoArray; 919ecf9d1cSIngo Weinhold struct ItemLayoutData; 929ecf9d1cSIngo Weinhold 939ecf9d1cSIngo Weinhold bool _IsGridCellEmpty(int32 column, int32 row); 949ecf9d1cSIngo Weinhold bool _AreGridCellsEmpty(int32 column, int32 row, 959ecf9d1cSIngo Weinhold int32 columnCount, int32 rowCount); 969ecf9d1cSIngo Weinhold 97d1535a45SIngo Weinhold bool _InsertItemIntoGrid(BLayoutItem* item); 989ecf9d1cSIngo Weinhold bool _ResizeGrid(int32 columnCount, int32 rowCount); 999ecf9d1cSIngo Weinhold 1009ecf9d1cSIngo Weinhold ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const; 1019ecf9d1cSIngo Weinhold 1029ecf9d1cSIngo Weinhold private: 1038151838eSAlex Wilson 1048151838eSAlex Wilson // FBC padding 1058151838eSAlex Wilson virtual void _ReservedGridLayout1(); 1068151838eSAlex Wilson virtual void _ReservedGridLayout2(); 1078151838eSAlex Wilson virtual void _ReservedGridLayout3(); 1088151838eSAlex Wilson virtual void _ReservedGridLayout4(); 1098151838eSAlex Wilson virtual void _ReservedGridLayout5(); 1108151838eSAlex Wilson virtual void _ReservedGridLayout6(); 1118151838eSAlex Wilson virtual void _ReservedGridLayout7(); 1128151838eSAlex Wilson virtual void _ReservedGridLayout8(); 1138151838eSAlex Wilson virtual void _ReservedGridLayout9(); 1148151838eSAlex Wilson virtual void _ReservedGridLayout10(); 1158151838eSAlex Wilson 116e044d51aSAlex Wilson // forbidden methods 117e044d51aSAlex Wilson BGridLayout(const BGridLayout&); 118e044d51aSAlex Wilson void operator =(const BGridLayout&); 119e044d51aSAlex Wilson 1209ecf9d1cSIngo Weinhold BLayoutItem*** fGrid; 1219ecf9d1cSIngo Weinhold int32 fColumnCount; 1229ecf9d1cSIngo Weinhold int32 fRowCount; 1239ecf9d1cSIngo Weinhold 1249ecf9d1cSIngo Weinhold RowInfoArray* fRowInfos; 1259ecf9d1cSIngo Weinhold RowInfoArray* fColumnInfos; 1269ecf9d1cSIngo Weinhold 1279ecf9d1cSIngo Weinhold int32 fMultiColumnItems; 1289ecf9d1cSIngo Weinhold int32 fMultiRowItems; 1298151838eSAlex Wilson 1308151838eSAlex Wilson uint32 _reserved[5]; 1319ecf9d1cSIngo Weinhold }; 1329ecf9d1cSIngo Weinhold 13324a77ea0SAxel Dörfler 1349ecf9d1cSIngo Weinhold #endif // _GRID_LAYOUT_H 135