xref: /haiku/src/tests/libs/alm/HelloWorld.cpp (revision 89d652d5e0defd9d095c778709cef82f5f10c357)
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 <List.h>
11 #include <Window.h>
12 
13 // include this for ALM
14 #include "ALMLayout.h"
15 
16 
17 class HelloWorldWindow : public BWindow {
18 public:
19 	HelloWorldWindow(BRect frame)
20 		:
21 		BWindow(frame, "ALM Hello World", B_TITLED_WINDOW,
22 			B_QUIT_ON_WINDOW_CLOSE)
23 	{
24 		button1 = new BButton("Hello World!");
25 
26 		// create a new BALMLayout and use  it for this window
27 		fLayout = new BALMLayout();
28 		SetLayout(fLayout);
29 
30 		// add an area containing the button
31 		// use the borders of the layout as the borders for the area
32 		fLayout->AddView(button1, fLayout->Left(), fLayout->Top(),
33 			fLayout->Right(), fLayout->Bottom());
34 		button1->SetExplicitMinSize(BSize(0, 50));
35 		button1->SetExplicitMaxSize(BSize(500, 500));
36 		button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
37 			B_ALIGN_USE_FULL_HEIGHT));
38 
39 		// test size limits
40 		BSize min = fLayout->MinSize();
41 		BSize max = fLayout->MaxSize();
42 		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
43 	}
44 
45 private:
46 	BALMLayout* fLayout;
47 	BButton* button1;
48 };
49 
50 
51 class HelloWorld : public BApplication {
52 public:
53 	HelloWorld()
54 		:
55 		BApplication("application/x-vnd.haiku.HelloWorld")
56 	{
57 		BRect frameRect;
58 		frameRect.Set(100, 100, 300, 300);
59 		HelloWorldWindow* window = new HelloWorldWindow(frameRect);
60 		window->Show();
61 	}
62 };
63 
64 
65 int
66 main()
67 {
68 	HelloWorld app;
69 	app.Run();
70 	return 0;
71 }
72