1#include <Application.h>
2#include <Button.h>
3#include <List.h>
4#include <Window.h>
5
6#include "ALMLayout.h"
7
8
9class AreasWindow : public BWindow {
10public:
11	AreasWindow(BRect frame)
12		:
13		BWindow(frame, "ALM Areas", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
14	{
15		button1 = new BButton("1");
16		button2 = new BButton("2");
17		button3 = new BButton("3");
18		button4 = new BButton("4");
19
20		button1->SetExplicitMinSize(BSize(0, 0));
21		button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
22
23		// create a new BALMLayout and use  it for this window
24		BALMLayout* layout = new BALMLayout(6);
25		SetLayout(layout);
26
27		// create extra tabs
28		BReference<YTab> y1 = layout->AddYTab();
29		BReference<YTab> y2 = layout->AddYTab();
30		BReference<YTab> y3 = layout->AddYTab();
31
32		Area* a1 = layout->AddView(button1, layout->Left(), layout->Top(),
33			layout->Right(), y1);
34		a1->SetTopInset(10);
35		a1->SetLeftInset(10);
36		a1->SetRightInset(10);
37
38		layout->AddView(button2, layout->Left(), y1, layout->Right(), y2);
39		button2->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
40
41		Area* a3 = layout->AddView(button3, layout->Left(), y2, layout->Right(),
42			y3);
43		button3->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
44			B_ALIGN_VERTICAL_CENTER));
45		a3->SetHeightAs(a1);
46
47		layout->AddView(button4, layout->Left(), y3, layout->Right(),
48			layout->Bottom());
49		button4->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
50			B_ALIGN_BOTTOM));
51
52		// test size limits
53		BSize min = layout->MinSize();
54		BSize max = layout->MaxSize();
55		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
56	}
57
58private:
59	BButton* button1;
60	BButton* button2;
61	BButton* button3;
62	BButton* button4;
63};
64
65
66class Areas : public BApplication {
67public:
68	Areas()
69		:
70		BApplication("application/x-vnd.haiku.Areas")
71	{
72		BRect frameRect;
73		frameRect.Set(100, 100, 300, 300);
74		AreasWindow* window = new AreasWindow(frameRect);
75		window->Show();
76	}
77};
78
79
80int
81main()
82{
83	Areas app;
84	app.Run();
85	return 0;
86}
87
88