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 16 17 class ThreeButtonsWindow : public BWindow { 18 public: 19 ThreeButtonsWindow(BRect frame) 20 : 21 BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW, 22 B_QUIT_ON_WINDOW_CLOSE) 23 { 24 BButton* button1 = new BButton("A"); 25 BButton* button2 = new BButton("B"); 26 BButton* button3 = new BButton("C"); 27 28 button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 29 B_ALIGN_USE_FULL_HEIGHT)); 30 button1->SetExplicitMaxSize(BSize(500, 50)); 31 32 button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 33 B_ALIGN_USE_FULL_HEIGHT)); 34 button2->SetExplicitMaxSize(BSize(500, 500)); 35 36 button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, 37 B_ALIGN_USE_FULL_HEIGHT)); 38 button3->SetExplicitMaxSize(BSize(500, 500)); 39 40 // create a new BALMLayout and use it for this window 41 fLayout = new BALMLayout(); 42 SetLayout(fLayout); 43 44 fLayout->AddView(button1, fLayout->Left(), fLayout->Top(), 45 fLayout->Right(), NULL); 46 fLayout->AddViewToBottom(button2); 47 fLayout->AddViewToBottom(button3, fLayout->Bottom()); 48 49 // test size limits 50 BSize min = fLayout->MinSize(); 51 BSize max = fLayout->MaxSize(); 52 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); 53 } 54 55 private: 56 BALMLayout* fLayout; 57 58 }; 59 60 61 int 62 main() 63 { 64 BApplication app("application/x-vnd.haiku.ThreeButtons"); 65 66 BRect frameRect; 67 frameRect.Set(100, 100, 600, 300); 68 ThreeButtonsWindow* window = new ThreeButtonsWindow(frameRect); 69 window->Show(); 70 71 app.Run(); 72 return 0; 73 } 74