xref: /haiku/src/tests/libs/alm/OperatorLayout.cpp (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
1 /*
2  * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <Application.h>
8 #include <Button.h>
9 #include <ControlLook.h>
10 #include <SpaceLayoutItem.h>
11 #include <Window.h>
12 
13 #include "ALMLayout.h"
14 #include "ALMGroup.h"
15 
16 
17 class OperatorWindow : public BWindow {
18 public:
19 	OperatorWindow(BRect frame)
20 		:
21 		BWindow(frame, "ALM Operator", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
22 	{
23 		BButton* button1 = new BButton("1");
24 		BButton* button2 = new BButton("2");
25 		BButton* button3 = new BButton("3");
26 		BButton* button4 = new BButton("4");
27 		BButton* button5 = new BButton("5");
28 
29 		button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
30 		button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
31 		button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
32 		button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
33 		button5->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
34 
35 		// create a new BALMLayout and use  it for this window
36 		float spacing = be_control_look->DefaultItemSpacing();
37 		BALMLayout* layout = new BALMLayout(spacing);
38 		SetLayout(layout);
39 		layout->SetInsets(spacing);
40 
41 		(ALMGroup(button1) | (ALMGroup(button2)
42 		/ (ALMGroup(button3) | ALMGroup(BSpaceLayoutItem::CreateGlue())
43 			| ALMGroup(button4))
44 		/ ALMGroup(button5))).BuildLayout(layout);
45 
46 		// test size limits
47 		BSize min = layout->MinSize();
48 		BSize max = layout->MaxSize();
49 		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
50 	}
51 
52 };
53 
54 
55 int
56 main()
57 {
58 	BApplication app("application/x-vnd.haiku.ALMOperator");
59 
60 	OperatorWindow* window = new OperatorWindow(BRect(100, 100, 300, 300));
61 	window->Show();
62 
63 	app.Run();
64 	return 0;
65 }
66 
67