xref: /haiku/src/tests/libs/alm/NestedLayout.cpp (revision 25a7b01d15612846f332751841da3579db313082)
1*1c8104a7SAlex Wilson /*
2*1c8104a7SAlex Wilson  * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
3*1c8104a7SAlex Wilson  * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
4*1c8104a7SAlex Wilson  * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
5*1c8104a7SAlex Wilson  * Copyright 2012, Haiku, Inc.
6*1c8104a7SAlex Wilson  * Distributed under the terms of the MIT License.
7*1c8104a7SAlex Wilson  */
8*1c8104a7SAlex Wilson 
9*1c8104a7SAlex Wilson #include <Application.h>
10*1c8104a7SAlex Wilson #include <Button.h>
11*1c8104a7SAlex Wilson #include <LayoutBuilder.h>
12*1c8104a7SAlex Wilson #include <List.h>
13*1c8104a7SAlex Wilson #include <Window.h>
14*1c8104a7SAlex Wilson 
15*1c8104a7SAlex Wilson // include this for ALM
16*1c8104a7SAlex Wilson #include "ALMLayout.h"
17*1c8104a7SAlex Wilson 
18*1c8104a7SAlex Wilson 
19*1c8104a7SAlex Wilson class NestedLayoutWindow : public BWindow {
20*1c8104a7SAlex Wilson public:
NestedLayoutWindow(BRect frame)21*1c8104a7SAlex Wilson 	NestedLayoutWindow(BRect frame)
22*1c8104a7SAlex Wilson 		:
23*1c8104a7SAlex Wilson 		BWindow(frame, "ALM Nested Layout", B_TITLED_WINDOW,
24*1c8104a7SAlex Wilson 			B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
25*1c8104a7SAlex Wilson 	{
26*1c8104a7SAlex Wilson 		button1 = new BButton("There should be space above this button!");
27*1c8104a7SAlex Wilson 
28*1c8104a7SAlex Wilson 		fLayout = new BALMLayout();
29*1c8104a7SAlex Wilson 		BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
30*1c8104a7SAlex Wilson 			.SetInsets(0)
31*1c8104a7SAlex Wilson 			.AddStrut(30)
32*1c8104a7SAlex Wilson 			.Add(fLayout);
33*1c8104a7SAlex Wilson 
34*1c8104a7SAlex Wilson 		// add an area containing the button
35*1c8104a7SAlex Wilson 		// use the borders of the layout as the borders for the area
36*1c8104a7SAlex Wilson 		fLayout->AddView(button1, fLayout->Left(), fLayout->Top(),
37*1c8104a7SAlex Wilson 			fLayout->Right(), fLayout->Bottom());
38*1c8104a7SAlex Wilson 		button1->SetExplicitMinSize(BSize(0, 50));
39*1c8104a7SAlex Wilson 		button1->SetExplicitMaxSize(BSize(500, 500));
40*1c8104a7SAlex Wilson 		button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
41*1c8104a7SAlex Wilson 			B_ALIGN_USE_FULL_HEIGHT));
42*1c8104a7SAlex Wilson 	}
43*1c8104a7SAlex Wilson 
44*1c8104a7SAlex Wilson private:
45*1c8104a7SAlex Wilson 	BALMLayout* fLayout;
46*1c8104a7SAlex Wilson 	BButton* button1;
47*1c8104a7SAlex Wilson };
48*1c8104a7SAlex Wilson 
49*1c8104a7SAlex Wilson 
50*1c8104a7SAlex Wilson class NestedLayout : public BApplication {
51*1c8104a7SAlex Wilson public:
NestedLayout()52*1c8104a7SAlex Wilson 	NestedLayout()
53*1c8104a7SAlex Wilson 		:
54*1c8104a7SAlex Wilson 		BApplication("application/x-vnd.haiku.NestedLayout")
55*1c8104a7SAlex Wilson 	{
56*1c8104a7SAlex Wilson 		BRect frameRect;
57*1c8104a7SAlex Wilson 		frameRect.Set(100, 100, 300, 300);
58*1c8104a7SAlex Wilson 		NestedLayoutWindow* window = new NestedLayoutWindow(frameRect);
59*1c8104a7SAlex Wilson 		window->Show();
60*1c8104a7SAlex Wilson 	}
61*1c8104a7SAlex Wilson };
62*1c8104a7SAlex Wilson 
63*1c8104a7SAlex Wilson 
64*1c8104a7SAlex Wilson int
main()65*1c8104a7SAlex Wilson main()
66*1c8104a7SAlex Wilson {
67*1c8104a7SAlex Wilson 	NestedLayout app;
68*1c8104a7SAlex Wilson 	app.Run();
69*1c8104a7SAlex Wilson 	return 0;
70*1c8104a7SAlex Wilson }
71