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 * Copyright 2012, Haiku, Inc. 6 * Distributed under the terms of the MIT License. 7 */ 8 9 #include <Application.h> 10 #include <Button.h> 11 #include <LayoutBuilder.h> 12 #include <List.h> 13 #include <Window.h> 14 15 // include this for ALM 16 #include "ALMLayout.h" 17 18 19 class NestedLayoutWindow : public BWindow { 20 public: 21 NestedLayoutWindow(BRect frame) 22 : 23 BWindow(frame, "ALM Nested Layout", B_TITLED_WINDOW, 24 B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) 25 { 26 button1 = new BButton("There should be space above this button!"); 27 28 fLayout = new BALMLayout(); 29 BLayoutBuilder::Group<>(this, B_VERTICAL, 0) 30 .SetInsets(0) 31 .AddStrut(30) 32 .Add(fLayout); 33 34 // add an area containing the button 35 // use the borders of the layout as the borders for the area 36 fLayout->AddView(button1, fLayout->Left(), fLayout->Top(), 37 fLayout->Right(), fLayout->Bottom()); 38 button1->SetExplicitMinSize(BSize(0, 50)); 39 button1->SetExplicitMaxSize(BSize(500, 500)); 40 button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 41 B_ALIGN_USE_FULL_HEIGHT)); 42 } 43 44 private: 45 BALMLayout* fLayout; 46 BButton* button1; 47 }; 48 49 50 class NestedLayout : public BApplication { 51 public: 52 NestedLayout() 53 : 54 BApplication("application/x-vnd.haiku.NestedLayout") 55 { 56 BRect frameRect; 57 frameRect.Set(100, 100, 300, 300); 58 NestedLayoutWindow* window = new NestedLayoutWindow(frameRect); 59 window->Show(); 60 } 61 }; 62 63 64 int 65 main() 66 { 67 NestedLayout app; 68 app.Run(); 69 return 0; 70 } 71