xref: /haiku/src/tests/libs/alm/Pinwheel.cpp (revision 19ddd4f1cbfa94c7ef0cd23c1de1f12077036a46)
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 #include <Application.h>
9 #include <Button.h>
10 #include <TextView.h>
11 #include <List.h>
12 #include <Window.h>
13 
14 // include this for ALM
15 #include "ALMLayout.h"
16 
17 
18 class PinwheelWindow : public BWindow {
19 public:
20 	PinwheelWindow(BRect frame)
21 		:
22 		BWindow(frame, "ALM Pinwheel", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
23 	{
24 		button1 = new BButton("1");
25 		button2 = new BButton("2");
26 		button3 = new BButton("3");
27 		button4 = new BButton("4");
28 		textView1 = new BTextView("textView1");
29 		textView1->SetText("5");
30 
31 		button1->SetExplicitMinSize(BSize(0, 0));
32 		button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
33 		button2->SetExplicitMinSize(BSize(0, 0));
34 		button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
35 		button3->SetExplicitMinSize(BSize(0, 0));
36 		button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
37 		button4->SetExplicitMinSize(BSize(0, 0));
38 		button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
39 
40 		// create a new BALMLayout and use  it for this window
41 		BALMLayout* layout = new BALMLayout(10.);
42 		SetLayout(layout);
43 
44 		layout->SetInset(5.);
45 
46 		// create extra tabs
47 		XTab* x1 = layout->AddXTab();
48 		XTab* x2 = layout->AddXTab();
49 		YTab* y1 = layout->AddYTab();
50 		YTab* y2 = layout->AddYTab();
51 
52 		Area* a1 = layout->AddView(button1, layout->Left(), layout->Top(), x2,
53 			y1);
54 		layout->AddView(button2, x2, layout->Top(), layout->Right(), y2);
55 		Area* a3 = layout->AddView(button3, x1, y2, layout->Right(),
56 			layout->Bottom());
57 		layout->AddView(button4, layout->Left(), y1, x1, layout->Bottom());
58 		layout->AddView(textView1, x1, y1, x2, y2);
59 
60 		a1->SetWidthAs(a3);
61 		a1->SetHeightAs(a3);
62 
63 		// alternative setup
64 		/*
65 		layout->AddView(button1);
66 		Area* a1 = layout->AreaOf(button1);
67 		Area* a2 = layout->AddViewToRight(button2, a1, layout->Right(), NULL,
68 			layout->AddYTab());
69 		Area* a3 = layout->AddViewToBottom(button3, a2, layout->Bottom(),
70 			layout->AddXTab(), NULL);
71 		Area* a4 = layout->AddViewToLeft(button4, a3, layout->Left(),
72 			a1->Bottom());
73 
74 		layout->AddView(textView1, a4->Right(), a1->Bottom(), a2->Left(),
75 			a3->Top());
76 		a1->SetWidthAs(a3);
77 		a1->SetHeightAs(a3);
78 		*/
79 	}
80 
81 private:
82 	BButton* button1;
83 	BButton* button2;
84 	BButton* button3;
85 	BButton* button4;
86 	BTextView* textView1;
87 };
88 
89 
90 class Pinwheel : public BApplication {
91 public:
92 	Pinwheel()
93 		:
94 		BApplication("application/x-vnd.haiku.Pinwheel")
95 	{
96 		BRect frameRect;
97 		frameRect.Set(100, 100, 300, 300);
98 		PinwheelWindow* window = new PinwheelWindow(frameRect);
99 		window->Show();
100 	}
101 };
102 
103 
104 int
105 main()
106 {
107 	Pinwheel app;
108 	app.Run();
109 	return 0;
110 }
111 
112