1 /* 2 * Copyright 2006-2011, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _GRID_LAYOUT_H 6 #define _GRID_LAYOUT_H 7 8 9 #include <TwoDimensionalLayout.h> 10 11 12 class BGridLayout : public BTwoDimensionalLayout { 13 public: 14 BGridLayout(float horizontal 15 = B_USE_DEFAULT_SPACING, 16 float vertical = B_USE_DEFAULT_SPACING); 17 BGridLayout(BMessage* from); 18 virtual ~BGridLayout(); 19 20 int32 CountColumns() const; 21 int32 CountRows() const; 22 23 float HorizontalSpacing() const; 24 float VerticalSpacing() const; 25 26 void SetHorizontalSpacing(float spacing); 27 void SetVerticalSpacing(float spacing); 28 void SetSpacing(float horizontal, float vertical); 29 30 float ColumnWeight(int32 column) const; 31 void SetColumnWeight(int32 column, float weight); 32 33 float MinColumnWidth(int32 column) const; 34 void SetMinColumnWidth(int32 column, float width); 35 36 float MaxColumnWidth(int32 column) const; 37 void SetMaxColumnWidth(int32 column, float width); 38 39 float RowWeight(int32 row) const; 40 void SetRowWeight(int32 row, float weight); 41 42 float MinRowHeight(int row) const; 43 void SetMinRowHeight(int32 row, float height); 44 45 float MaxRowHeight(int32 row) const; 46 void SetMaxRowHeight(int32 row, float height); 47 48 BLayoutItem* ItemAt(int32 column, int32 row) const; 49 50 virtual BLayoutItem* AddView(BView* child); 51 virtual BLayoutItem* AddView(int32 index, BView* child); 52 virtual BLayoutItem* AddView(BView* child, int32 column, int32 row, 53 int32 columnCount = 1, int32 rowCount = 1); 54 55 virtual bool AddItem(BLayoutItem* item); 56 virtual bool AddItem(int32 index, BLayoutItem* item); 57 virtual bool AddItem(BLayoutItem* item, int32 column, 58 int32 row, int32 columnCount = 1, 59 int32 rowCount = 1); 60 61 virtual status_t Archive(BMessage* into, bool deep = true) const; 62 static BArchivable* Instantiate(BMessage* from); 63 64 virtual status_t Perform(perform_code d, void* arg); 65 66 protected: 67 virtual status_t AllArchived(BMessage* into) const; 68 virtual status_t AllUnarchived(const BMessage* from); 69 virtual status_t ItemArchived(BMessage* into, 70 BLayoutItem* item, int32 index) const; 71 virtual status_t ItemUnarchived(const BMessage* from, 72 BLayoutItem* item, int32 index); 73 74 virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 75 virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 76 77 virtual bool HasMultiColumnItems(); 78 virtual bool HasMultiRowItems(); 79 80 virtual int32 InternalCountColumns(); 81 virtual int32 InternalCountRows(); 82 virtual void GetColumnRowConstraints( 83 orientation orientation, 84 int32 index, 85 ColumnRowConstraints* constraints); 86 virtual void GetItemDimensions(BLayoutItem* item, 87 Dimensions* dimensions); 88 private: 89 class DummyLayoutItem; 90 class RowInfoArray; 91 struct ItemLayoutData; 92 93 bool _IsGridCellEmpty(int32 column, int32 row); 94 bool _AreGridCellsEmpty(int32 column, int32 row, 95 int32 columnCount, int32 rowCount); 96 97 bool _InsertItemIntoGrid(BLayoutItem* item); 98 bool _ResizeGrid(int32 columnCount, int32 rowCount); 99 100 ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const; 101 102 private: 103 104 // FBC padding 105 virtual void _ReservedGridLayout1(); 106 virtual void _ReservedGridLayout2(); 107 virtual void _ReservedGridLayout3(); 108 virtual void _ReservedGridLayout4(); 109 virtual void _ReservedGridLayout5(); 110 virtual void _ReservedGridLayout6(); 111 virtual void _ReservedGridLayout7(); 112 virtual void _ReservedGridLayout8(); 113 virtual void _ReservedGridLayout9(); 114 virtual void _ReservedGridLayout10(); 115 116 // forbidden methods 117 BGridLayout(const BGridLayout&); 118 void operator =(const BGridLayout&); 119 120 BLayoutItem*** fGrid; 121 int32 fColumnCount; 122 int32 fRowCount; 123 124 RowInfoArray* fRowInfos; 125 RowInfoArray* fColumnInfos; 126 127 int32 fMultiColumnItems; 128 int32 fMultiRowItems; 129 130 uint32 _reserved[5]; 131 }; 132 133 134 #endif // _GRID_LAYOUT_H 135