1 /* 2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de> 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <Application.h> 8 #include <Button.h> 9 #include <ControlLook.h> 10 #include <SpaceLayoutItem.h> 11 #include <Window.h> 12 13 #include "ALMLayout.h" 14 15 16 class OperatorWindow : public BWindow { 17 public: 18 OperatorWindow(BRect frame) 19 : 20 BWindow(frame, "ALM Operator", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) 21 { 22 BButton* button1 = new BButton("1"); 23 BButton* button2 = new BButton("2"); 24 BButton* button3 = new BButton("3"); 25 BButton* button4 = new BButton("4"); 26 BButton* button5 = new BButton("5"); 27 28 button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 29 button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 30 button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 31 button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 32 button5->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 33 34 // create a new BALMLayout and use it for this window 35 float spacing = be_control_look->DefaultItemSpacing(); 36 BALMLayout* layout = new BALMLayout(spacing); 37 SetLayout(layout); 38 layout->SetInset(spacing); 39 40 GroupItem item = GroupItem(button1) | (GroupItem(button2) 41 / (GroupItem(button3) | GroupItem(BSpaceLayoutItem::CreateGlue()) 42 | GroupItem(button4)) 43 / GroupItem(button5)); 44 layout->BuildLayout(item); 45 46 // test size limits 47 BSize min = layout->MinSize(); 48 BSize max = layout->MaxSize(); 49 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); 50 } 51 52 }; 53 54 55 int 56 main() 57 { 58 BApplication app("application/x-vnd.haiku.ALMOperator"); 59 60 OperatorWindow* window = new OperatorWindow(BRect(100, 100, 300, 300)); 61 window->Show(); 62 63 app.Run(); 64 return 0; 65 } 66 67