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(enum orientation orientation, 13 float spacing = 0.0f); 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(enum 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 virtual status_t AllUnarchived(const BMessage* from); 40 static BArchivable* Instantiate(BMessage* from); 41 42 virtual status_t ItemArchived(BMessage* into, BLayoutItem* item, 43 int32 index) const; 44 virtual status_t ItemUnarchived(const BMessage* from, 45 BLayoutItem* item, int32 index); 46 47 protected: 48 virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 49 virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 50 51 virtual void PrepareItems(enum orientation orientation); 52 53 virtual int32 InternalCountColumns(); 54 virtual int32 InternalCountRows(); 55 virtual void GetColumnRowConstraints( 56 enum orientation orientation, 57 int32 index, 58 ColumnRowConstraints* constraints); 59 virtual void GetItemDimensions(BLayoutItem* item, 60 Dimensions* dimensions); 61 62 private: 63 struct ItemLayoutData; 64 65 ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const; 66 67 orientation fOrientation; 68 BList fVisibleItems; 69 }; 70 71 #endif // _GROUP_LAYOUT_H 72