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 * Distributed under the terms of the MIT License. 6 */ 7 8 #include <Application.h> 9 #include <File.h> 10 #include <Button.h> 11 #include <Window.h> 12 13 #include "ALMLayout.h" 14 15 16 class TableDemoWindow : public BWindow { 17 public: 18 TableDemoWindow(BRect frame) 19 : BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) 20 { 21 // create a new BALMLayout and use it for this window 22 BALMLayout* layout = new BALMLayout(); 23 SetLayout(layout); 24 25 Column* c1 = layout->AddColumn(layout->Left(), layout->Right()); 26 Row* r1 = layout->AddRow(layout->Top(), NULL); 27 Row* r3 = layout->AddRow(NULL, layout->Bottom()); 28 r1->SetNext(r3); 29 Row* r2 = layout->AddRow(); 30 r2->InsertAfter(r1); 31 32 BButton* b1 = new BButton("A1"); 33 layout->AddView(b1, r1, c1); 34 b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); 35 36 BButton* b2 = new BButton("A2"); 37 layout->AddView(b2, r2, c1); 38 b2->SetExplicitAlignment(BAlignment( 39 B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)); 40 41 BButton* b3 = new BButton("A3"); 42 layout->AddView(b3, r3, c1); 43 b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM)); 44 45 r2->HasSameHeightAs(r1); 46 r3->HasSameHeightAs(r1); 47 } 48 }; 49 50 51 class TableDemo : public BApplication { 52 public: 53 TableDemo() 54 : BApplication("application/x-vnd.haiku.table-demo") 55 { 56 BRect frameRect; 57 frameRect.Set(100, 100, 400, 400); 58 TableDemoWindow* window = new TableDemoWindow(frameRect); 59 window->Show(); 60 } 61 }; 62 63 64 int 65 main() 66 { 67 TableDemo app; 68 app.Run(); 69 return 0; 70 } 71 72