1 /* 2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 #include <GridLayoutBuilder.h> 7 8 #include <new> 9 10 #include <SpaceLayoutItem.h> 11 12 13 using std::nothrow; 14 15 16 // constructor 17 BGridLayoutBuilder::BGridLayoutBuilder(float horizontalSpacing, 18 float verticalSpacing) 19 : fLayout((new BGridView(horizontalSpacing, verticalSpacing)) 20 ->GridLayout()) 21 { 22 } 23 24 // constructor 25 BGridLayoutBuilder::BGridLayoutBuilder(BGridLayout* layout) 26 : fLayout(layout) 27 { 28 } 29 30 31 // constructor 32 BGridLayoutBuilder::BGridLayoutBuilder(BGridView* view) 33 : fLayout(view->GridLayout()) 34 { 35 } 36 37 // GridLayout 38 BGridLayout* 39 BGridLayoutBuilder::GridLayout() const 40 { 41 return fLayout; 42 } 43 44 // View 45 BView* 46 BGridLayoutBuilder::View() const 47 { 48 return fLayout->Owner(); 49 } 50 51 // GetGridLayout 52 BGridLayoutBuilder& 53 BGridLayoutBuilder::GetGridLayout(BGridLayout** _layout) 54 { 55 *_layout = fLayout; 56 return *this; 57 } 58 59 // GetView 60 BGridLayoutBuilder& 61 BGridLayoutBuilder::GetView(BView** _view) 62 { 63 *_view = fLayout->Owner(); 64 return *this; 65 } 66 67 // Add 68 BGridLayoutBuilder& 69 BGridLayoutBuilder::Add(BView* view, int32 column, int32 row, 70 int32 columnCount, int32 rowCount) 71 { 72 fLayout->AddView(view, column, row, columnCount, rowCount); 73 return *this; 74 } 75 76 // Add 77 BGridLayoutBuilder& 78 BGridLayoutBuilder::Add(BLayoutItem* item, int32 column, int32 row, 79 int32 columnCount, int32 rowCount) 80 { 81 fLayout->AddItem(item, column, row, columnCount, rowCount); 82 return *this; 83 } 84 85 // SetColumnWeight 86 BGridLayoutBuilder& 87 BGridLayoutBuilder::SetColumnWeight(int32 column, float weight) 88 { 89 fLayout->SetColumnWeight(column, weight); 90 return *this; 91 } 92 93 // SetRowWeight 94 BGridLayoutBuilder& 95 BGridLayoutBuilder::SetRowWeight(int32 row, float weight) 96 { 97 fLayout->SetRowWeight(row, weight); 98 return *this; 99 } 100 101 // SetInsets 102 BGridLayoutBuilder& 103 BGridLayoutBuilder::SetInsets(float left, float top, float right, float bottom) 104 { 105 fLayout->SetInsets(left, top, right, bottom); 106 return *this; 107 } 108 109 // cast operator BGridLayout* 110 BGridLayoutBuilder::operator BGridLayout*() 111 { 112 return fLayout; 113 } 114 115