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 <SplitLayoutBuilder.h> 79ecf9d1cSIngo Weinhold 89ecf9d1cSIngo Weinhold #include <new> 99ecf9d1cSIngo Weinhold 109ecf9d1cSIngo Weinhold 119ecf9d1cSIngo Weinhold using std::nothrow; 129ecf9d1cSIngo Weinhold 139ecf9d1cSIngo Weinhold 149ecf9d1cSIngo Weinhold // constructor 159ecf9d1cSIngo Weinhold BSplitLayoutBuilder::BSplitLayoutBuilder(enum orientation orientation, 169ecf9d1cSIngo Weinhold float spacing) 179ecf9d1cSIngo Weinhold : fView(new BSplitView(orientation, spacing)) 189ecf9d1cSIngo Weinhold { 199ecf9d1cSIngo Weinhold } 209ecf9d1cSIngo Weinhold 219ecf9d1cSIngo Weinhold // constructor 229ecf9d1cSIngo Weinhold BSplitLayoutBuilder::BSplitLayoutBuilder(BSplitView* view) 239ecf9d1cSIngo Weinhold : fView(view) 249ecf9d1cSIngo Weinhold { 259ecf9d1cSIngo Weinhold } 269ecf9d1cSIngo Weinhold 279ecf9d1cSIngo Weinhold // SplitView 289ecf9d1cSIngo Weinhold BSplitView* 299ecf9d1cSIngo Weinhold BSplitLayoutBuilder::SplitView() const 309ecf9d1cSIngo Weinhold { 319ecf9d1cSIngo Weinhold return fView; 329ecf9d1cSIngo Weinhold } 339ecf9d1cSIngo Weinhold 349ecf9d1cSIngo Weinhold // GetSplitView 359ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 369ecf9d1cSIngo Weinhold BSplitLayoutBuilder::GetSplitView(BSplitView** view) 379ecf9d1cSIngo Weinhold { 389ecf9d1cSIngo Weinhold *view = fView; 399ecf9d1cSIngo Weinhold return *this; 409ecf9d1cSIngo Weinhold } 419ecf9d1cSIngo Weinhold 429ecf9d1cSIngo Weinhold // Add 439ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 449ecf9d1cSIngo Weinhold BSplitLayoutBuilder::Add(BView* view) 459ecf9d1cSIngo Weinhold { 469ecf9d1cSIngo Weinhold fView->AddChild(view); 479ecf9d1cSIngo Weinhold return *this; 489ecf9d1cSIngo Weinhold } 499ecf9d1cSIngo Weinhold 509ecf9d1cSIngo Weinhold // Add 519ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 529ecf9d1cSIngo Weinhold BSplitLayoutBuilder::Add(BView* view, float weight) 539ecf9d1cSIngo Weinhold { 549ecf9d1cSIngo Weinhold fView->AddChild(view, weight); 559ecf9d1cSIngo Weinhold return *this; 569ecf9d1cSIngo Weinhold } 579ecf9d1cSIngo Weinhold 589ecf9d1cSIngo Weinhold // Add 599ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 609ecf9d1cSIngo Weinhold BSplitLayoutBuilder::Add(BLayoutItem* item) 619ecf9d1cSIngo Weinhold { 629ecf9d1cSIngo Weinhold fView->AddChild(item); 639ecf9d1cSIngo Weinhold return *this; 649ecf9d1cSIngo Weinhold } 659ecf9d1cSIngo Weinhold 669ecf9d1cSIngo Weinhold // Add 679ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 689ecf9d1cSIngo Weinhold BSplitLayoutBuilder::Add(BLayoutItem* item, float weight) 699ecf9d1cSIngo Weinhold { 709ecf9d1cSIngo Weinhold fView->AddChild(item, weight); 719ecf9d1cSIngo Weinhold return *this; 729ecf9d1cSIngo Weinhold } 739ecf9d1cSIngo Weinhold 749ecf9d1cSIngo Weinhold // SetCollapsible 759ecf9d1cSIngo Weinhold BSplitLayoutBuilder& 769ecf9d1cSIngo Weinhold BSplitLayoutBuilder::SetCollapsible(bool collapsible) 779ecf9d1cSIngo Weinhold { 789ecf9d1cSIngo Weinhold int32 count = fView->CountChildren(); 799ecf9d1cSIngo Weinhold if (count > 0) 809ecf9d1cSIngo Weinhold fView->SetCollapsible(count - 1, collapsible); 819ecf9d1cSIngo Weinhold return *this; 829ecf9d1cSIngo Weinhold } 839ecf9d1cSIngo Weinhold 84*4aeb7a3cSStephan Aßmus // SetInsets 85*4aeb7a3cSStephan Aßmus BSplitLayoutBuilder& 86*4aeb7a3cSStephan Aßmus BSplitLayoutBuilder::SetInsets(float left, float top, float right, float bottom) 87*4aeb7a3cSStephan Aßmus { 88*4aeb7a3cSStephan Aßmus fView->SetInsets(left, top, right, bottom); 89*4aeb7a3cSStephan Aßmus 90*4aeb7a3cSStephan Aßmus return *this; 91*4aeb7a3cSStephan Aßmus } 92*4aeb7a3cSStephan Aßmus 939ecf9d1cSIngo Weinhold // cast operator BSplitView* 949ecf9d1cSIngo Weinhold BSplitLayoutBuilder::operator BSplitView*() 959ecf9d1cSIngo Weinhold { 969ecf9d1cSIngo Weinhold return fView; 979ecf9d1cSIngo Weinhold } 989ecf9d1cSIngo Weinhold 99