xref: /haiku/src/tests/libs/alm/TableDemo.cpp (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 /*
2  * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
3  * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
4  * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
5  * Distributed under the terms of the MIT License.
6  */
7 
8 
9 #include <Application.h>
10 #include <File.h>
11 #include <Button.h>
12 #include <Window.h>
13 
14 #include "ALMLayout.h"
15 
16 #include "Row.h"
17 #include "Column.h"
18 
19 
20 class TableDemoWindow : public BWindow {
21 public:
22 	TableDemoWindow(BRect frame)
23 		: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
24 	{
25 		// create a new BALMLayout and use  it for this window
26 		BALMLayout* layout = new BALMLayout();
27 		SetLayout(layout);
28 
29 		Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
30 		Row* r1 = layout->AddRow(layout->Top(), NULL);
31 		Row* r2 = layout->AddRow(r1->Bottom(), NULL);
32 		Row* r3 = layout->AddRow(r2->Bottom(), layout->Bottom());
33 
34 		BButton* b1 = new BButton("A1");
35 		layout->AddView(b1, r1, c1);
36 		b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
37 
38 		BButton* b2 = new BButton("A2");
39 		layout->AddView(b2, r2, c1);
40 		b2->SetExplicitAlignment(BAlignment(
41 			B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
42 
43 		BButton* b3 = new BButton("A3");
44 		layout->AddView(b3, r3, c1);
45 		b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
46 
47 		// test size limits
48 		BSize min = layout->MinSize();
49 		BSize max = layout->MaxSize();
50 		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
51 	}
52 };
53 
54 
55 class TableDemo : public BApplication {
56 public:
57 	TableDemo()
58 		: BApplication("application/x-vnd.haiku.table-demo")
59 	{
60 		BRect frameRect;
61 		frameRect.Set(100, 100, 400, 400);
62 		TableDemoWindow* window = new TableDemoWindow(frameRect);
63 		window->Show();
64 	}
65 };
66 
67 
68 int
69 main()
70 {
71 	TableDemo app;
72 	app.Run();
73 	return 0;
74 }
75 
76