Add two more test, cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40299 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2011-01-27 21:50:42 +00:00
parent 03901b6cae
commit 550ffadf08
5 changed files with 195 additions and 5 deletions

View File

@ -48,6 +48,11 @@ public:
layout->Bottom());
button4->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
B_ALIGN_BOTTOM));
// test size limits
BSize min = layout->MinSize();
BSize max = layout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
private:

View File

@ -0,0 +1,94 @@
/*
* Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
// include this for ALM
#include "ALMLayout.h"
class ComplexButtonsWindow : public BWindow {
public:
ComplexButtonsWindow(BRect frame)
:
BWindow(frame, "ALM Complex Buttons", B_TITLED_WINDOW,
B_QUIT_ON_WINDOW_CLOSE)
{
BButton* button1 = new BButton("A");
BButton* button2 = new BButton("B");
BButton* button3 = new BButton("GHIJ");
BButton* button4 = new BButton("abcdefghijklmnop");
BButton* button5 = new BButton("Foo");
const int32 kOffset = 80;
button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button1->SetExplicitMaxSize(BSize(500, 500));
button1->SetExplicitPreferredSize(BSize(10 + kOffset, B_SIZE_UNSET));
button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button2->SetExplicitMaxSize(BSize(500, 500));
button2->SetExplicitPreferredSize(BSize(10 + kOffset, B_SIZE_UNSET));
button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button3->SetExplicitMaxSize(BSize(500, 500));
button3->SetExplicitPreferredSize(BSize(40 + kOffset, B_SIZE_UNSET));
button4->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button4->SetExplicitMaxSize(BSize(500, 500));
button4->SetExplicitPreferredSize(BSize(160 + kOffset, B_SIZE_UNSET));
button5->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button5->SetExplicitMaxSize(BSize(500, 500));
button5->SetExplicitPreferredSize(BSize(30 + kOffset, B_SIZE_UNSET));
// create a new BALMLayout and use it for this window
fLayout = new BALMLayout();
SetLayout(fLayout);
fLayout->AddView(button1, fLayout->Left(), fLayout->Top(), NULL,
NULL);
fLayout->AddViewToRight(button2);
fLayout->AddViewToRight(button3, fLayout->Right());
fLayout->AddView(button4, fLayout->Left(), fLayout->BottomOf(button1),
NULL, fLayout->Bottom());
fLayout->AddViewToRight(button5, fLayout->Right());
// test size limits
BSize min = fLayout->MinSize();
BSize max = fLayout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
private:
BALMLayout* fLayout;
};
int
main()
{
BApplication app("application/x-vnd.haiku.ComplexButtons");
BRect frameRect;
frameRect.Set(100, 100, 600, 300);
ComplexButtonsWindow* window = new ComplexButtonsWindow(frameRect);
window->Show();
app.Run();
return 0;
}

View File

@ -39,3 +39,15 @@ Application ALMOperator :
:
be liblpsolve55.so be libalm.so $(TARGET_LIBSTDC++)
;
Application ALMThreeButtons :
ThreeButtons.cpp
:
be liblpsolve55.so be libalm.so $(TARGET_LIBSTDC++)
;
Application ALMComplexButtons :
ComplexButtons.cpp
:
be liblpsolve55.so be libalm.so $(TARGET_LIBSTDC++)
;

View File

@ -5,6 +5,7 @@
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <File.h>
#include <Button.h>
@ -44,6 +45,11 @@ public:
r2->HasSameHeightAs(r1);
r3->HasSameHeightAs(r1);
// test size limits
BSize min = layout->MinSize();
BSize max = layout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
};

View File

@ -0,0 +1,73 @@
/*
* Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
// include this for ALM
#include "ALMLayout.h"
class ThreeButtonsWindow : public BWindow {
public:
ThreeButtonsWindow(BRect frame)
:
BWindow(frame, "ALM Three Buttons", B_TITLED_WINDOW,
B_QUIT_ON_WINDOW_CLOSE)
{
BButton* button1 = new BButton("A");
BButton* button2 = new BButton("B");
BButton* button3 = new BButton("C");
button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button1->SetExplicitMaxSize(BSize(500, 50));
button2->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button2->SetExplicitMaxSize(BSize(500, 500));
button3->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
B_ALIGN_USE_FULL_HEIGHT));
button3->SetExplicitMaxSize(BSize(500, 500));
// create a new BALMLayout and use it for this window
fLayout = new BALMLayout();
SetLayout(fLayout);
fLayout->AddView(button1, fLayout->Left(), fLayout->Top(),
fLayout->Right(), NULL);
fLayout->AddViewToBottom(button2);
fLayout->AddViewToBottom(button3, fLayout->Bottom());
// test size limits
BSize min = fLayout->MinSize();
BSize max = fLayout->MaxSize();
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
}
private:
BALMLayout* fLayout;
};
int
main()
{
BApplication app("application/x-vnd.haiku.ThreeButtons");
BRect frameRect;
frameRect.Set(100, 100, 600, 300);
ThreeButtonsWindow* window = new ThreeButtonsWindow(frameRect);
window->Show();
app.Run();
return 0;
}