1 /* 2 * Copyright 2010, Haiku, Inc. 3 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 7 8 #include <GridView.h> 9 10 11 BGridView::BGridView(float horizontalSpacing, float verticalSpacing) 12 : 13 BView(NULL, 0, new BGridLayout(horizontalSpacing, verticalSpacing)) 14 { 15 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 16 } 17 18 19 BGridView::BGridView(BMessage* from) 20 : 21 BView(from) 22 { 23 } 24 25 26 BGridView::~BGridView() 27 { 28 } 29 30 31 void 32 BGridView::SetLayout(BLayout* layout) 33 { 34 // only BGridLayouts are allowed 35 if (!dynamic_cast<BGridLayout*>(layout)) 36 return; 37 38 BView::SetLayout(layout); 39 } 40 41 42 BGridLayout* 43 BGridView::GridLayout() const 44 { 45 return dynamic_cast<BGridLayout*>(GetLayout()); 46 } 47 48 49 BArchivable* 50 BGridView::Instantiate(BMessage* from) 51 { 52 if (validate_instantiation(from, "BGridView")) 53 return new BGridView(from); 54 return NULL; 55 } 56