1550ffadfSClemens Zeidler/*
2550ffadfSClemens Zeidler * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3550ffadfSClemens Zeidler * Distributed under the terms of the MIT License.
4550ffadfSClemens Zeidler */
5550ffadfSClemens Zeidler
6550ffadfSClemens Zeidler#include <stdio.h>
7550ffadfSClemens Zeidler
8550ffadfSClemens Zeidler#include <Application.h>
9550ffadfSClemens Zeidler#include <Button.h>
10550ffadfSClemens Zeidler#include <List.h>
11550ffadfSClemens Zeidler#include <Window.h>
12550ffadfSClemens Zeidler
13550ffadfSClemens Zeidler// include this for ALM
14550ffadfSClemens Zeidler#include "ALMLayout.h"
152bf5ded1SAlex Wilson#include "ALMLayoutBuilder.h"
16550ffadfSClemens Zeidler
17550ffadfSClemens Zeidler
18550ffadfSClemens Zeidlerclass ThreeButtonsWindow : public BWindow {
19550ffadfSClemens Zeidlerpublic:
20550ffadfSClemens Zeidler	ThreeButtonsWindow(BRect frame)
21550ffadfSClemens Zeidler		:
22550ffadfSClemens Zeidler		BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW,
23550ffadfSClemens Zeidler			B_QUIT_ON_WINDOW_CLOSE)
24550ffadfSClemens Zeidler	{
25550ffadfSClemens Zeidler		BButton* button1 = new BButton("A");
26550ffadfSClemens Zeidler		BButton* button2 = new BButton("B");
27550ffadfSClemens Zeidler		BButton* button3 = new BButton("C");
28550ffadfSClemens Zeidler
29550ffadfSClemens Zeidler		button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
30550ffadfSClemens Zeidler			B_ALIGN_USE_FULL_HEIGHT));
31550ffadfSClemens Zeidler		button1->SetExplicitMaxSize(BSize(500, 50));
32550ffadfSClemens Zeidler
33550ffadfSClemens Zeidler		button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
34550ffadfSClemens Zeidler			B_ALIGN_USE_FULL_HEIGHT));
35550ffadfSClemens Zeidler		button2->SetExplicitMaxSize(BSize(500, 500));
36550ffadfSClemens Zeidler
37550ffadfSClemens Zeidler		button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
38550ffadfSClemens Zeidler			B_ALIGN_USE_FULL_HEIGHT));
39550ffadfSClemens Zeidler		button3->SetExplicitMaxSize(BSize(500, 500));
40550ffadfSClemens Zeidler
412bf5ded1SAlex Wilson		fLayout = new BALMLayout(0, 0);
422bf5ded1SAlex Wilson		BALM::BALMLayoutBuilder(this, fLayout)
432bf5ded1SAlex Wilson			.Add(button1, fLayout->Left(), fLayout->Top(), fLayout->Right())
442bf5ded1SAlex Wilson			.StartingAt(button1)
452bf5ded1SAlex Wilson				.AddBelow(button2)
462bf5ded1SAlex Wilson				.AddBelow(button3, fLayout->Bottom());
472bf5ded1SAlex Wilson
48550ffadfSClemens Zeidler		// test size limits
49550ffadfSClemens Zeidler		BSize min = fLayout->MinSize();
50550ffadfSClemens Zeidler		BSize max = fLayout->MaxSize();
51550ffadfSClemens Zeidler		SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
52550ffadfSClemens Zeidler	}
53550ffadfSClemens Zeidler
54550ffadfSClemens Zeidlerprivate:
55550ffadfSClemens Zeidler	BALMLayout* fLayout;
56550ffadfSClemens Zeidler
57550ffadfSClemens Zeidler};
58550ffadfSClemens Zeidler
59550ffadfSClemens Zeidler
60550ffadfSClemens Zeidlerint
61550ffadfSClemens Zeidlermain()
62550ffadfSClemens Zeidler{
63550ffadfSClemens Zeidler	BApplication app("application/x-vnd.haiku.ThreeButtons");
64550ffadfSClemens Zeidler
65550ffadfSClemens Zeidler	BRect frameRect;
66550ffadfSClemens Zeidler	frameRect.Set(100, 100, 600, 300);
67550ffadfSClemens Zeidler	ThreeButtonsWindow* window = new ThreeButtonsWindow(frameRect);
68550ffadfSClemens Zeidler	window->Show();
69550ffadfSClemens Zeidler
70550ffadfSClemens Zeidler	app.Run();
71550ffadfSClemens Zeidler	return 0;
72550ffadfSClemens Zeidler}
73