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 <Button.h> 10 #include <TextView.h> 11 #include <List.h> 12 #include <Window.h> 13 14 // include this for ALM 15 #include "ALMLayout.h" 16 17 18 class PinwheelWindow : public BWindow { 19 public: 20 PinwheelWindow(BRect frame) 21 : 22 BWindow(frame, "ALM Pinwheel", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) 23 { 24 button1 = new BButton("1"); 25 button2 = new BButton("2"); 26 button3 = new BButton("3"); 27 button4 = new BButton("4"); 28 textView1 = new BTextView("textView1"); 29 textView1->SetText("5"); 30 31 button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 32 button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 33 button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 34 button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); 35 36 // create a new BALMLayout and use it for this window 37 BALMLayout* layout = new BALMLayout(10.); 38 SetLayout(layout); 39 40 layout->SetInset(5.); 41 42 // create extra tabs 43 XTab* x1 = layout->AddXTab(); 44 XTab* x2 = layout->AddXTab(); 45 YTab* y1 = layout->AddYTab(); 46 YTab* y2 = layout->AddYTab(); 47 48 Area* a1 = layout->AddView(button1, layout->Left(), layout->Top(), x2, 49 y1); 50 layout->AddView(button2, x2, layout->Top(), layout->Right(), y2); 51 Area* a3 = layout->AddView(button3, x1, y2, layout->Right(), 52 layout->Bottom()); 53 layout->AddView(button4, layout->Left(), y1, x1, layout->Bottom()); 54 layout->AddView(textView1, x1, y1, x2, y2); 55 56 a1->SetWidthAs(a3); 57 a1->SetHeightAs(a3); 58 59 // alternative setup 60 /* 61 layout->AddView(button1); 62 Area* a1 = layout->AreaOf(button1); 63 Area* a2 = layout->AddViewToRight(button2, a1, layout->Right(), NULL, 64 layout->AddYTab()); 65 Area* a3 = layout->AddViewToBottom(button3, a2, layout->Bottom(), 66 layout->AddXTab(), NULL); 67 Area* a4 = layout->AddViewToLeft(button4, a3, layout->Left(), 68 a1->Bottom()); 69 70 layout->AddView(textView1, a4->Right(), a1->Bottom(), a2->Left(), 71 a3->Top()); 72 a1->SetWidthAs(a3); 73 a1->SetHeightAs(a3); 74 */ 75 76 // test size limits 77 BSize min = layout->MinSize(); 78 BSize max = layout->MaxSize(); 79 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); 80 } 81 82 private: 83 BButton* button1; 84 BButton* button2; 85 BButton* button3; 86 BButton* button4; 87 BTextView* textView1; 88 }; 89 90 91 class Pinwheel : public BApplication { 92 public: 93 Pinwheel() 94 : 95 BApplication("application/x-vnd.haiku.Pinwheel") 96 { 97 BRect frameRect; 98 frameRect.Set(100, 100, 300, 300); 99 PinwheelWindow* window = new PinwheelWindow(frameRect); 100 window->Show(); 101 } 102 }; 103 104 105 int 106 main() 107 { 108 Pinwheel app; 109 app.Run(); 110 return 0; 111 } 112 113