xref: /haiku/src/kits/interface/GridView.cpp (revision 323b65468e5836bb27a5e373b14027d902349437)
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(const char* name, float horizontalSpacing,
20 	float verticalSpacing)
21 	:
22 	BView(name, 0, new BGridLayout(horizontalSpacing, verticalSpacing))
23 {
24 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
25 }
26 
27 
28 BGridView::BGridView(BMessage* from)
29 	:
30 	BView(from)
31 {
32 }
33 
34 
35 BGridView::~BGridView()
36 {
37 }
38 
39 
40 void
41 BGridView::SetLayout(BLayout* layout)
42 {
43 	// only BGridLayouts are allowed
44 	if (!dynamic_cast<BGridLayout*>(layout))
45 		return;
46 
47 	BView::SetLayout(layout);
48 }
49 
50 
51 BGridLayout*
52 BGridView::GridLayout() const
53 {
54 	return dynamic_cast<BGridLayout*>(GetLayout());
55 }
56 
57 
58 BArchivable*
59 BGridView::Instantiate(BMessage* from)
60 {
61 	if (validate_instantiation(from, "BGridView"))
62 		return new BGridView(from);
63 	return NULL;
64 }
65