xref: /haiku/src/tests/libs/alm/TableDemo.cpp (revision a6e73cb9e8addfe832c064bfcb68067f1c2fa3eb)
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 
17 class TableDemoWindow : public BWindow {
18 public:
19 	TableDemoWindow(BRect frame)
20 		: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
21 	{
22 		// create a new BALMLayout and use  it for this window
23 		BALMLayout* layout = new BALMLayout();
24 		SetLayout(layout);
25 
26 		Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
27 		Row* r1 = layout->AddRow(layout->Top(), NULL);
28 		Row* r2 = layout->AddRow(r1->Bottom(), NULL);
29 		Row* r3 = layout->AddRow(r2->Bottom(), layout->Bottom());
30 
31 		BButton* b1 = new BButton("A1");
32 		layout->AddView(b1, r1, c1);
33 		b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
34 
35 		BButton* b2 = new BButton("A2");
36 		layout->AddView(b2, r2, c1);
37 		b2->SetExplicitAlignment(BAlignment(
38 			B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
39 
40 		BButton* b3 = new BButton("A3");
41 		layout->AddView(b3, r3, c1);
42 		b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
43 
44 		// test size limits
45 		BSize min = layout->MinSize();
46 		BSize max = layout->MaxSize();
47 		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
48 	}
49 };
50 
51 
52 class TableDemo : public BApplication {
53 public:
54 	TableDemo()
55 		: BApplication("application/x-vnd.haiku.table-demo")
56 	{
57 		BRect frameRect;
58 		frameRect.Set(100, 100, 400, 400);
59 		TableDemoWindow* window = new TableDemoWindow(frameRect);
60 		window->Show();
61 	}
62 };
63 
64 
65 int
66 main()
67 {
68 	TableDemo app;
69 	app.Run();
70 	return 0;
71 }
72 
73