2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3 * Distributed under the terms of the MIT License.
8 #include <Application.h>
13 // include this for ALM
14 #include "ALMLayout.h"
15 #include "ALMLayoutBuilder.h"
18 class ComplexButtonsWindow
: public BWindow
{
20 ComplexButtonsWindow(BRect frame
)
22 BWindow(frame
, "ALM Complex Buttons", B_TITLED_WINDOW
,
23 B_QUIT_ON_WINDOW_CLOSE
)
25 BButton
* button1
= new BButton("A");
26 BButton
* button2
= new BButton("B");
27 BButton
* button3
= new BButton("GHIJ");
29 BButton
* button4
= new BButton("abcdefghijklmnop");
30 BButton
* button5
= new BButton("Foo");
32 const int32 kOffset
= 80;
34 button1
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
35 B_ALIGN_USE_FULL_HEIGHT
));
36 button1
->SetExplicitMaxSize(BSize(500, 500));
37 button1
->SetExplicitPreferredSize(BSize(10 + kOffset
, B_SIZE_UNSET
));
39 button2
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
40 B_ALIGN_USE_FULL_HEIGHT
));
41 button2
->SetExplicitMaxSize(BSize(500, 500));
42 button2
->SetExplicitPreferredSize(BSize(10 + kOffset
, B_SIZE_UNSET
));
44 button3
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
45 B_ALIGN_USE_FULL_HEIGHT
));
46 button3
->SetExplicitMaxSize(BSize(500, 500));
47 button3
->SetExplicitPreferredSize(BSize(40 + kOffset
, B_SIZE_UNSET
));
49 button4
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
50 B_ALIGN_USE_FULL_HEIGHT
));
51 button4
->SetExplicitMaxSize(BSize(500, 500));
52 button4
->SetExplicitPreferredSize(BSize(160 + kOffset
, B_SIZE_UNSET
));
54 button5
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
55 B_ALIGN_USE_FULL_HEIGHT
));
56 button5
->SetExplicitMaxSize(BSize(500, 500));
57 button5
->SetExplicitPreferredSize(BSize(30 + kOffset
, B_SIZE_UNSET
));
59 BALMLayout
* fLayout
= new BALMLayout(10, 10);
60 BALM::BALMLayoutBuilder(this, fLayout
)
61 .Add(button1
, fLayout
->Left(), fLayout
->Top())
64 .AddToRight(button3
, fLayout
->Right())
65 .AddBelow(button4
, fLayout
->Bottom(), fLayout
->Left(),
67 .AddToRight(button5
, fLayout
->Right());
70 BSize min
= fLayout
->MinSize();
71 BSize max
= fLayout
->MaxSize();
72 SetSizeLimits(min
.Width(), max
.Width(), min
.Height(), max
.Height());
84 BApplication
app("application/x-vnd.haiku.ComplexButtons");
87 frameRect
.Set(100, 100, 600, 300);
88 ComplexButtonsWindow
* window
= new ComplexButtonsWindow(frameRect
);