1 /* 2 * Copyright 2006-2010, Haiku, Inc. All rights reserved. 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 BView* TopView() const; 24 BGroupLayoutBuilder& GetTopView(BView** _view); 25 26 BGroupLayoutBuilder& Add(BView* view); 27 BGroupLayoutBuilder& Add(BView* view, float weight); 28 BGroupLayoutBuilder& Add(BLayoutItem* item); 29 BGroupLayoutBuilder& Add(BLayoutItem* item, float weight); 30 31 BGroupLayoutBuilder& AddGroup(enum orientation orientation, 32 float spacing = 0.0f, float weight = 1.0f); 33 BGroupLayoutBuilder& End(); 34 35 BGroupLayoutBuilder& AddGlue(float weight = 1.0f); 36 BGroupLayoutBuilder& AddStrut(float size); 37 38 BGroupLayoutBuilder& SetInsets(float left, float top, float right, 39 float bottom); 40 41 operator BGroupLayout*(); 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