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:
parent
03901b6cae
commit
550ffadf08
@ -47,7 +47,12 @@ public:
|
|||||||
layout->AddView(button4, layout->Left(), y3, layout->Right(),
|
layout->AddView(button4, layout->Left(), y3, layout->Right(),
|
||||||
layout->Bottom());
|
layout->Bottom());
|
||||||
button4->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
|
button4->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
|
||||||
B_ALIGN_BOTTOM));
|
B_ALIGN_BOTTOM));
|
||||||
|
|
||||||
|
// test size limits
|
||||||
|
BSize min = layout->MinSize();
|
||||||
|
BSize max = layout->MaxSize();
|
||||||
|
SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
94
src/tests/libs/alm/ComplexButtons.cpp
Normal file
94
src/tests/libs/alm/ComplexButtons.cpp
Normal 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;
|
||||||
|
}
|
@ -39,3 +39,15 @@ Application ALMOperator :
|
|||||||
:
|
:
|
||||||
be liblpsolve55.so be libalm.so $(TARGET_LIBSTDC++)
|
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++)
|
||||||
|
;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
@ -21,14 +22,14 @@ public:
|
|||||||
// create a new BALMLayout and use it for this window
|
// create a new BALMLayout and use it for this window
|
||||||
BALMLayout* layout = new BALMLayout();
|
BALMLayout* layout = new BALMLayout();
|
||||||
SetLayout(layout);
|
SetLayout(layout);
|
||||||
|
|
||||||
Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
|
Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
|
||||||
Row* r1 = layout->AddRow(layout->Top(), NULL);
|
Row* r1 = layout->AddRow(layout->Top(), NULL);
|
||||||
Row* r3 = layout->AddRow(NULL, layout->Bottom());
|
Row* r3 = layout->AddRow(NULL, layout->Bottom());
|
||||||
r1->SetNext(r3);
|
r1->SetNext(r3);
|
||||||
Row* r2 = layout->AddRow();
|
Row* r2 = layout->AddRow();
|
||||||
r2->InsertAfter(r1);
|
r2->InsertAfter(r1);
|
||||||
|
|
||||||
BButton* b1 = new BButton("A1");
|
BButton* b1 = new BButton("A1");
|
||||||
layout->AddView(b1, r1, c1);
|
layout->AddView(b1, r1, c1);
|
||||||
b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
|
b1->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
|
||||||
@ -37,13 +38,18 @@ public:
|
|||||||
layout->AddView(b2, r2, c1);
|
layout->AddView(b2, r2, c1);
|
||||||
b2->SetExplicitAlignment(BAlignment(
|
b2->SetExplicitAlignment(BAlignment(
|
||||||
B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
|
||||||
BButton* b3 = new BButton("A3");
|
BButton* b3 = new BButton("A3");
|
||||||
layout->AddView(b3, r3, c1);
|
layout->AddView(b3, r3, c1);
|
||||||
b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
|
b3->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
|
||||||
|
|
||||||
r2->HasSameHeightAs(r1);
|
r2->HasSameHeightAs(r1);
|
||||||
r3->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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
73
src/tests/libs/alm/ThreeButtons.cpp
Normal file
73
src/tests/libs/alm/ThreeButtons.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user