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.
9 #include <Application.h>
11 #include <MenuField.h>
12 #include <PopUpMenu.h>
13 #include <RadioButton.h>
14 #include <SpaceLayoutItem.h>
15 #include <StatusBar.h>
16 #include <StringView.h>
20 #include "ALMLayout.h"
21 #include "ALMLayoutBuilder.h"
24 using namespace LinearProgramming
;
27 class ViewsWindow
: public BWindow
{
29 ViewsWindow(BRect frame
)
31 BWindow(frame
, "ALM Views", B_TITLED_WINDOW
, B_QUIT_ON_WINDOW_CLOSE
)
33 BButton
* button1
= new BButton("BButton");
34 BRadioButton
* radioButton
= new BRadioButton("BRadioButton", NULL
);
35 BButton
* button3
= new BButton("3");
36 BButton
* button4
= new BButton("4");
37 button4
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
38 B_ALIGN_VERTICAL_CENTER
));
39 BButton
* button5
= new BButton("5");
40 BButton
* button6
= new BButton("6");
41 BTextView
* textView1
= new BTextView("textView1");
42 textView1
->SetText("BTextView");
43 BStatusBar
* statusBar
= new BStatusBar("BStatusBar", "label",
45 statusBar
->Update(50);
47 BMenu
* menu
= new BMenu("Menu 1");
48 BMenuField
* menu1
= new BMenuField("MenuField 1", menu
);
49 menu
->AddItem(new BPopUpMenu("Menu 1"));
50 BStringView
* stringView1
= new BStringView("string 1", "string 1");
52 menu
= new BMenu("Menu 2 + long text");
53 BMenuField
* menu2
= new BMenuField("MenuField 2", menu
);
54 menu
->AddItem(new BPopUpMenu("Menu 2"));
55 BStringView
* stringView2
= new BStringView("string 2", "string 2");
57 BALM::BALMLayout
* layout
= new BALMLayout(10, 10);
58 BALM::BALMLayoutBuilder(this, layout
)
60 .Add(button1
, layout
->Left(), layout
->Top())
62 .AddToRight(radioButton
)
63 .AddToRight(BSpaceLayoutItem::CreateGlue())
65 .StartingAt(radioButton
)
66 .AddBelow(textView1
, NULL
, NULL
, layout
->RightOf(button3
))
68 .AddToRight(button5
, layout
->Right())
70 .AddBelow(menu1
, layout
->AddYTab(), layout
->Left(),
72 .AddToRight(stringView1
)
73 .AddToRight(BSpaceLayoutItem::CreateGlue(), layout
->Right())
74 .AddBelow(statusBar
, NULL
, layout
->Left(), layout
->Right());
76 // start over so that layout->RightOf() can return accurate results
77 BALM::BALMLayoutBuilder(layout
)
78 .StartingAt(statusBar
)
79 .AddBelow(menu2
, layout
->Bottom(), layout
->Left(),
80 layout
->RightOf(menu1
))
81 .AddToRight(stringView2
)
82 .AddToRight(BSpaceLayoutItem::CreateGlue(), layout
->Right());
84 layout
->Solver()->AddConstraint(2, layout
->TopOf(menu1
), -1,
85 layout
->Bottom(), OperatorType(kEQ
), 0);
88 BSize min
= layout
->MinSize();
89 BSize max
= layout
->MaxSize();
90 SetSizeLimits(min
.Width(), max
.Width(), min
.Height(), max
.Height());
96 class Views
: public BApplication
{
100 BApplication("application/x-vnd.haiku.Views")
103 frameRect
.Set(100, 100, 300, 300);
104 ViewsWindow
* window
= new ViewsWindow(frameRect
);