vfs: check userland buffers before reading them.
[haiku.git] / src / tests / libs / alm / Pinwheel.cpp
blobfcdb6e68370926d14435b06bcab673f290d257a4
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 */
8 #include <Application.h>
9 #include <Button.h>
10 #include <TextView.h>
11 #include <List.h>
12 #include <Window.h>
14 // include this for ALM
15 #include "ALMLayout.h"
16 #include "ALMLayoutBuilder.h"
19 class PinwheelWindow : public BWindow {
20 public:
21 PinwheelWindow(BRect frame)
23 BWindow(frame, "ALM Pinwheel", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
25 button1 = new BButton("1");
26 button2 = new BButton("2");
27 button3 = new BButton("3");
28 button4 = new BButton("4");
29 textView1 = new BTextView("textView1");
30 textView1->SetText("5");
32 button1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
33 button2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
34 button3->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
35 button4->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
37 // create a new BALMLayout and use it for this window
38 BALMLayout* layout = new BALMLayout(10, 10);
40 BReference<XTab> xTabs[2];
41 BReference<YTab> yTabs[2];
42 layout->AddXTabs(xTabs, 2);
43 layout->AddYTabs(yTabs, 2);
45 BALM::BALMLayoutBuilder(this, layout)
46 .SetInsets(5)
47 .Add(textView1, xTabs[0], yTabs[0], xTabs[1], yTabs[1])
48 .StartingAt(textView1)
49 .AddAbove(button1, layout->Top(), layout->Left())
50 .AddToRight(button2, layout->Right(), NULL, yTabs[1])
51 .AddBelow(button3, layout->Bottom(), xTabs[0])
52 .AddToLeft(button4, layout->Left(), yTabs[0]);
54 // alternative setup
56 SetLayout(layout);
58 layout->SetInsets(5.);
60 // create extra tabs
61 BReference<XTab> x1 = layout->AddXTab();
62 BReference<XTab> x2 = layout->AddXTab();
63 BReference<YTab> y1 = layout->AddYTab();
64 BReference<YTab> y2 = layout->AddYTab();
66 layout->AddView(button1, layout->Left(), layout->Top(), x2,
67 y1);
68 layout->AddView(button2, x2, layout->Top(), layout->Right(), y2);
69 layout->AddView(button3, x1, y2, layout->Right(),
70 layout->Bottom());
71 layout->AddView(button4, layout->Left(), y1, x1, layout->Bottom());
72 layout->AddView(textView1, x1, y1, x2, y2);
75 // test size limits
76 BSize min = layout->MinSize();
77 BSize max = layout->MaxSize();
78 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
81 private:
82 BButton* button1;
83 BButton* button2;
84 BButton* button3;
85 BButton* button4;
86 BTextView* textView1;
90 class Pinwheel : public BApplication {
91 public:
92 Pinwheel()
94 BApplication("application/x-vnd.haiku.Pinwheel")
96 BRect frameRect;
97 frameRect.Set(100, 100, 300, 300);
98 PinwheelWindow* window = new PinwheelWindow(frameRect);
99 window->Show();
105 main()
107 Pinwheel app;
108 app.Run();
109 return 0;