vfs: check userland buffers before reading them.
[haiku.git] / src / tests / libs / alm / ThreeButtons.cpp
blob582a82a6c4f487ff028769d36de4cc647afe5d2c
1 /*
2 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
3 * Distributed under the terms of the MIT License.
4 */
6 #include <stdio.h>
8 #include <Application.h>
9 #include <Button.h>
10 #include <List.h>
11 #include <Window.h>
13 // include this for ALM
14 #include "ALMLayout.h"
15 #include "ALMLayoutBuilder.h"
18 class ThreeButtonsWindow : public BWindow {
19 public:
20 ThreeButtonsWindow(BRect frame)
22 BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW,
23 B_QUIT_ON_WINDOW_CLOSE)
25 BButton* button1 = new BButton("A");
26 BButton* button2 = new BButton("B");
27 BButton* button3 = new BButton("C");
29 button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
30 B_ALIGN_USE_FULL_HEIGHT));
31 button1->SetExplicitMaxSize(BSize(500, 50));
33 button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
34 B_ALIGN_USE_FULL_HEIGHT));
35 button2->SetExplicitMaxSize(BSize(500, 500));
37 button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
38 B_ALIGN_USE_FULL_HEIGHT));
39 button3->SetExplicitMaxSize(BSize(500, 500));
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());
48 // test size limits
49 BSize min = fLayout->MinSize();
50 BSize max = fLayout->MaxSize();
51 SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
54 private:
55 BALMLayout* fLayout;
60 int
61 main()
63 BApplication app("application/x-vnd.haiku.ThreeButtons");
65 BRect frameRect;
66 frameRect.Set(100, 100, 600, 300);
67 ThreeButtonsWindow* window = new ThreeButtonsWindow(frameRect);
68 window->Show();
70 app.Run();
71 return 0;