1 /* 2 * Copyright 2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _GROUP_LAYOUT_BUILDER_H 6 #define _GROUP_LAYOUT_BUILDER_H 7 8 #include <GroupLayout.h> 9 #include <GroupView.h> 10 #include <List.h> 11 12 class BGroupLayoutBuilder { 13 public: 14 BGroupLayoutBuilder( 15 enum orientation orientation = B_HORIZONTAL, 16 float spacing = 0.0f); 17 BGroupLayoutBuilder(BGroupLayout* layout); 18 BGroupLayoutBuilder(BGroupView* view); 19 20 BGroupLayout* RootLayout() const; 21 BGroupLayout* TopLayout() const; 22 BGroupLayoutBuilder& GetTopLayout(BGroupLayout** _layout); 23 BGroupLayoutBuilder& GetTopView(BView** _view); 24 25 BGroupLayoutBuilder& Add(BView* view); 26 BGroupLayoutBuilder& Add(BView* view, float weight); 27 BGroupLayoutBuilder& Add(BLayoutItem* item); 28 BGroupLayoutBuilder& Add(BLayoutItem* item, float weight); 29 30 BGroupLayoutBuilder& AddGroup(enum orientation orientation, 31 float spacing = 0.0f, float weight = 1.0f); 32 BGroupLayoutBuilder& End(); 33 34 BGroupLayoutBuilder& AddGlue(float weight = 1.0f); 35 BGroupLayoutBuilder& AddStrut(float size); 36 37 BGroupLayoutBuilder& SetInsets(float left, float top, float right, 38 float bottom); 39 40 operator BGroupLayout*(); 41 operator BView*(); 42 43 private: 44 bool _PushLayout(BGroupLayout* layout); 45 void _PopLayout(); 46 47 private: 48 BGroupLayout* fRootLayout; 49 BList fLayoutStack; 50 }; 51 52 #endif // _GROUP_LAYOUT_BUILDER_H 53