19ecf9d1cSIngo Weinhold/*
29ecf9d1cSIngo Weinhold * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
39ecf9d1cSIngo Weinhold * All rights reserved. Distributed under the terms of the MIT License.
49ecf9d1cSIngo Weinhold */
59ecf9d1cSIngo Weinhold
69ecf9d1cSIngo Weinhold#include <GridLayoutBuilder.h>
79ecf9d1cSIngo Weinhold
89ecf9d1cSIngo Weinhold#include <new>
99ecf9d1cSIngo Weinhold
109ecf9d1cSIngo Weinhold#include <SpaceLayoutItem.h>
119ecf9d1cSIngo Weinhold
129ecf9d1cSIngo Weinhold
139ecf9d1cSIngo Weinholdusing std::nothrow;
149ecf9d1cSIngo Weinhold
159ecf9d1cSIngo Weinhold
169ecf9d1cSIngo Weinhold// constructor
179ecf9d1cSIngo WeinholdBGridLayoutBuilder::BGridLayoutBuilder(float horizontalSpacing,
189ecf9d1cSIngo Weinhold		float verticalSpacing)
199ecf9d1cSIngo Weinhold	: fLayout((new BGridView(horizontalSpacing, verticalSpacing))
209ecf9d1cSIngo Weinhold					->GridLayout())
219ecf9d1cSIngo Weinhold{
229ecf9d1cSIngo Weinhold}
239ecf9d1cSIngo Weinhold
249ecf9d1cSIngo Weinhold// constructor
259ecf9d1cSIngo WeinholdBGridLayoutBuilder::BGridLayoutBuilder(BGridLayout* layout)
269ecf9d1cSIngo Weinhold	: fLayout(layout)
279ecf9d1cSIngo Weinhold{
289ecf9d1cSIngo Weinhold}
299ecf9d1cSIngo Weinhold
309ecf9d1cSIngo Weinhold
319ecf9d1cSIngo Weinhold// constructor
329ecf9d1cSIngo WeinholdBGridLayoutBuilder::BGridLayoutBuilder(BGridView* view)
339ecf9d1cSIngo Weinhold	: fLayout(view->GridLayout())
349ecf9d1cSIngo Weinhold{
359ecf9d1cSIngo Weinhold}
369ecf9d1cSIngo Weinhold
379ecf9d1cSIngo Weinhold// GridLayout
389ecf9d1cSIngo WeinholdBGridLayout*
399ecf9d1cSIngo WeinholdBGridLayoutBuilder::GridLayout() const
409ecf9d1cSIngo Weinhold{
419ecf9d1cSIngo Weinhold	return fLayout;
429ecf9d1cSIngo Weinhold}
439ecf9d1cSIngo Weinhold
449ecf9d1cSIngo Weinhold// View
459ecf9d1cSIngo WeinholdBView*
469ecf9d1cSIngo WeinholdBGridLayoutBuilder::View() const
479ecf9d1cSIngo Weinhold{
481d6c7b6cSAlex Wilson	return fLayout->Owner();
499ecf9d1cSIngo Weinhold}
509ecf9d1cSIngo Weinhold
519ecf9d1cSIngo Weinhold// GetGridLayout
529ecf9d1cSIngo WeinholdBGridLayoutBuilder&
539ecf9d1cSIngo WeinholdBGridLayoutBuilder::GetGridLayout(BGridLayout** _layout)
549ecf9d1cSIngo Weinhold{
559ecf9d1cSIngo Weinhold	*_layout = fLayout;
569ecf9d1cSIngo Weinhold	return *this;
579ecf9d1cSIngo Weinhold}
589ecf9d1cSIngo Weinhold
599ecf9d1cSIngo Weinhold// GetView
609ecf9d1cSIngo WeinholdBGridLayoutBuilder&
619ecf9d1cSIngo WeinholdBGridLayoutBuilder::GetView(BView** _view)
629ecf9d1cSIngo Weinhold{
631d6c7b6cSAlex Wilson	*_view = fLayout->Owner();
649ecf9d1cSIngo Weinhold	return *this;
659ecf9d1cSIngo Weinhold}
669ecf9d1cSIngo Weinhold
679ecf9d1cSIngo Weinhold// Add
689ecf9d1cSIngo WeinholdBGridLayoutBuilder&
699ecf9d1cSIngo WeinholdBGridLayoutBuilder::Add(BView* view, int32 column, int32 row,
709ecf9d1cSIngo Weinhold	int32 columnCount, int32 rowCount)
719ecf9d1cSIngo Weinhold{
729ecf9d1cSIngo Weinhold	fLayout->AddView(view, column, row, columnCount, rowCount);
739ecf9d1cSIngo Weinhold	return *this;
749ecf9d1cSIngo Weinhold}
759ecf9d1cSIngo Weinhold
769ecf9d1cSIngo Weinhold// Add
779ecf9d1cSIngo WeinholdBGridLayoutBuilder&
789ecf9d1cSIngo WeinholdBGridLayoutBuilder::Add(BLayoutItem* item, int32 column, int32 row,
799ecf9d1cSIngo Weinhold	int32 columnCount, int32 rowCount)
809ecf9d1cSIngo Weinhold{
819ecf9d1cSIngo Weinhold	fLayout->AddItem(item, column, row, columnCount, rowCount);
829ecf9d1cSIngo Weinhold	return *this;
839ecf9d1cSIngo Weinhold}
849ecf9d1cSIngo Weinhold
859ecf9d1cSIngo Weinhold// SetColumnWeight
869ecf9d1cSIngo WeinholdBGridLayoutBuilder&
879ecf9d1cSIngo WeinholdBGridLayoutBuilder::SetColumnWeight(int32 column, float weight)
889ecf9d1cSIngo Weinhold{
899ecf9d1cSIngo Weinhold	fLayout->SetColumnWeight(column, weight);
909ecf9d1cSIngo Weinhold	return *this;
919ecf9d1cSIngo Weinhold}
929ecf9d1cSIngo Weinhold
939ecf9d1cSIngo Weinhold// SetRowWeight
949ecf9d1cSIngo WeinholdBGridLayoutBuilder&
959ecf9d1cSIngo WeinholdBGridLayoutBuilder::SetRowWeight(int32 row, float weight)
969ecf9d1cSIngo Weinhold{
979ecf9d1cSIngo Weinhold	fLayout->SetRowWeight(row, weight);
989ecf9d1cSIngo Weinhold	return *this;
999ecf9d1cSIngo Weinhold}
1009ecf9d1cSIngo Weinhold
101e3e76a3aSRyan Leavengood// SetInsets
102e3e76a3aSRyan LeavengoodBGridLayoutBuilder&
103e3e76a3aSRyan LeavengoodBGridLayoutBuilder::SetInsets(float left, float top, float right, float bottom)
104e3e76a3aSRyan Leavengood{
105e3e76a3aSRyan Leavengood	fLayout->SetInsets(left, top, right, bottom);
106e3e76a3aSRyan Leavengood	return *this;
107e3e76a3aSRyan Leavengood}
108e3e76a3aSRyan Leavengood
1099ecf9d1cSIngo Weinhold// cast operator BGridLayout*
1109ecf9d1cSIngo WeinholdBGridLayoutBuilder::operator BGridLayout*()
1119ecf9d1cSIngo Weinhold{
1129ecf9d1cSIngo Weinhold	return fLayout;
1139ecf9d1cSIngo Weinhold}
1149ecf9d1cSIngo Weinhold
115