xref: /haiku/src/tests/libs/alm/TableDemo.cpp (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
3  * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
4  * Distributed under the terms of the MIT License.
5  */
6 
7 #include <Application.h>
8 #include <File.h>
9 #include <Button.h>
10 #include <Window.h>
11 
12 #include "BALMLayout.h"
13 
14 
15 class TableDemoWindow : public BWindow {
16 public:
17 	TableDemoWindow(BRect frame)
18 		: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
19 	{
20 		// create a new BALMLayout and use  it for this window
21 		BALMLayout* layout = new BALMLayout();
22 		SetLayout(layout);
23 
24 		Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
25 		Row* r1 = layout->AddRow(layout->Top(), NULL);
26 		Row* r3 = layout->AddRow(NULL, layout->Bottom());
27 		r1->SetNext(r3);
28 		Row* r2 = layout->AddRow();
29 		r2->InsertAfter(r1);
30 
31 		BButton* b1 = new BButton("A1");
32 		Area* a1 = layout->AddArea(r1, c1, b1);
33 		a1->SetHorizontalAlignment(B_ALIGN_LEFT);
34 		a1->SetVerticalAlignment(B_ALIGN_TOP);
35 
36 		BButton* b2 = new BButton("A2");
37 		Area* a2 = layout->AddArea(r2, c1, b2);
38 		a2->SetHorizontalAlignment(B_ALIGN_HORIZONTAL_CENTER);
39 		a2->SetVerticalAlignment(B_ALIGN_VERTICAL_CENTER);
40 
41 		BButton* b3 = new BButton("A3");
42 		Area* a3 = layout->AddArea(r3, c1, b3);
43 		a3->SetHorizontalAlignment(B_ALIGN_RIGHT);
44 		a3->SetVerticalAlignment(B_ALIGN_BOTTOM);
45 
46 		r2->HasSameHeightAs(r1);
47 		r3->HasSameHeightAs(r1);
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