1 /* 2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de> 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <stdio.h> 7 8 #include <Application.h> 9 #include <Button.h> 10 #include <List.h> 11 #include <Window.h> 12 13 // include this for ALM 14 #include "ALMLayout.h" 15 #include "ALMLayoutBuilder.h" 16 17 18 class ThreeButtonsWindow : public BWindow { 19 public: 20 ThreeButtonsWindow(BRect frame) 21 : 22 BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW, 23 B_QUIT_ON_WINDOW_CLOSE) 24 { 25 BButton* button1 = new BButton("A"); 26 BButton* button2 = new BButton("B"); 27 BButton* button3 = new BButton("C"); 28 29 button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 30 B_ALIGN_USE_FULL_HEIGHT)); 31 button1->SetExplicitMaxSize(BSize(500, 50)); 32 33 button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 34 B_ALIGN_USE_FULL_HEIGHT)); 35 button2->SetExplicitMaxSize(BSize(500, 500)); 36 37 button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 38 B_ALIGN_USE_FULL_HEIGHT)); 39 button3->SetExplicitMaxSize(BSize(500, 500)); 40 41 fLayout = new BALMLayout(0, 0); 42 BALM::BALMLayoutBuilder(this, fLayout) 43 .Add(button1, fLayout->Left(), fLayout->Top(), fLayout->Right()) 44 .StartingAt(button1) 45 .AddBelow(button2) 46 .AddBelow(button3, fLayout->Bottom()); 47 48 // test size limits 49 BSize min = fLayout->MinSize(); 50 BSize max = fLayout->MaxSize(); 51 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); 52 } 53 54 private: 55 BALMLayout* fLayout; 56 57 }; 58 59 60 int 61 main() 62 { 63 BApplication app("application/x-vnd.haiku.ThreeButtons"); 64 65 BRect frameRect; 66 frameRect.Set(100, 100, 600, 300); 67 ThreeButtonsWindow* window = new ThreeButtonsWindow(frameRect); 68 window->Show(); 69 70 app.Run(); 71 return 0; 72 } 73