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 * Copyright 2012, Haiku, Inc.
6 * Distributed under the terms of the MIT License.
10 #include <Application.h>
16 // include this for ALM
17 #include "ALMLayout.h"
20 class BAlertPolicy
: public BALMLayout::BadLayoutPolicy
{
21 virtual bool OnBadLayout(BALMLayout
* layout
, ResultType result
,
22 BLayoutContext
* context
)
24 BAlert
* alert
= new BAlert("layout failure", "layout failed!",
32 class BadLayoutWindow
: public BWindow
{
34 BadLayoutWindow(BRect frame
)
36 BWindow(frame
, "ALM Bad Layout", B_TITLED_WINDOW
,
37 B_QUIT_ON_WINDOW_CLOSE
)
39 button1
= new BButton("Bad Layout!");
41 // create a new BALMLayout and use it for this window
42 fLayout
= new BALMLayout();
45 // add an area containing the button
46 // use the borders of the layout as the borders for the area
47 fLayout
->AddView(button1
, fLayout
->Left(), fLayout
->Top(),
48 fLayout
->Right(), fLayout
->Bottom());
49 button1
->SetExplicitMinSize(BSize(50, 50));
50 button1
->SetExplicitMaxSize(BSize(500, 500));
51 button1
->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH
,
52 B_ALIGN_USE_FULL_HEIGHT
));
55 BButton
* button2
= new BButton("can't fit!");
56 fLayout
->AddView(button2
, fLayout
->RightOf(button1
), fLayout
->Top(),
57 fLayout
->Right(), fLayout
->Bottom());
58 button2
->SetExplicitMinSize(BSize(50, 50));
60 fLayout
->SetBadLayoutPolicy(new BAlertPolicy());
62 BSize min
= fLayout
->MinSize();
63 BSize max
= fLayout
->MaxSize();
64 SetSizeLimits(min
.Width(), max
.Width(), min
.Height(), max
.Height());
66 printf("moving to standard BALMLayout BadLayoutPolicy\n");
67 fLayout
->SetBadLayoutPolicy(NULL
);
76 class BadLayout
: public BApplication
{
80 BApplication("application/x-vnd.haiku.BadLayout")
83 frameRect
.Set(100, 100, 300, 300);
84 BadLayoutWindow
* window
= new BadLayoutWindow(frameRect
);