* Applied a patch by Christof Lutteroth that updates ALM, and brings new test

apps.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33805 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-28 09:00:14 +00:00
parent dcfdc8374a
commit ea607d6f7f
14 changed files with 541 additions and 512 deletions
+34 -27
View File
@@ -7,22 +7,23 @@
#ifndef AREA_H #ifndef AREA_H
#define AREA_H #define AREA_H
#include "Constraint.h"
#include <Alignment.h> #include <Alignment.h>
#include <List.h> #include <List.h>
#include <Size.h> #include <Size.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <View.h> #include <View.h>
#include "XTab.h"
#include "YTab.h"
#include "Area.h"
#include "Row.h"
#include "Column.h"
#include "Constraint.h"
namespace BALM { namespace BALM {
class Column;
class BALMLayout; class BALMLayout;
class Row;
class XTab;
class YTab;
/** /**
* Rectangular area in the GUI, defined by a tab on each side. * Rectangular area in the GUI, defined by a tab on each side.
@@ -30,9 +31,6 @@ class YTab;
class Area { class Area {
public: public:
bool AutoPrefContentSize() const;
void SetAutoPrefContentSize(bool value);
XTab* Left() const; XTab* Left() const;
void SetLeft(XTab* left); void SetLeft(XTab* left);
XTab* Right() const; XTab* Right() const;
@@ -57,18 +55,21 @@ public:
void SetMinContentSize(BSize min); void SetMinContentSize(BSize min);
BSize MaxContentSize() const; BSize MaxContentSize() const;
void SetMaxContentSize(BSize max); void SetMaxContentSize(BSize max);
BSize PrefContentSize() const; BSize PreferredContentSize() const;
void SetPrefContentSize(BSize pref); void SetPreferredContentSize(BSize preferred);
BSize ShrinkRigidity() const;
void SetShrinkRigidity(BSize shrink);
BSize ExpandRigidity() const;
void SetExpandRigidity(BSize expand);
double ContentAspectRatio() const; double ContentAspectRatio() const;
void SetContentAspectRatio(double ratio); void SetContentAspectRatio(double ratio);
BSize ShrinkPenalties() const;
void SetShrinkPenalties(BSize shrink);
BSize GrowPenalties() const;
void SetGrowPenalties(BSize grow);
BAlignment Alignment() const; BAlignment Alignment() const;
void SetAlignment(BAlignment alignment); void SetAlignment(BAlignment alignment);
void SetHAlignment(alignment horizontal); void SetHorizontalAlignment(alignment horizontal);
void SetVAlignment(vertical_alignment vertical); void SetVerticalAlignment(vertical_alignment vertical);
int32 LeftInset() const; int32 LeftInset() const;
void SetLeftInset(int32 left); void SetLeftInset(int32 left);
int32 TopInset() const; int32 TopInset() const;
@@ -77,12 +78,18 @@ public:
void SetRightInset(int32 right); void SetRightInset(int32 right);
int32 BottomInset() const; int32 BottomInset() const;
void SetBottomInset(int32 bottom); void SetBottomInset(int32 bottom);
void SetDefaultPrefContentSize();
//~ string ToString(); void SetDefaultBehavior();
bool AutoPreferredContentSize() const;
void SetAutoPreferredContentSize(bool value);
BString* ToBString();
const char* ToString();
Constraint* HasSameWidthAs(Area* area); Constraint* HasSameWidthAs(Area* area);
Constraint* HasSameHeightAs(Area* area); Constraint* HasSameHeightAs(Area* area);
BList* HasSameSizetAs(Area* area); BList* HasSameSizeAs(Area* area);
~Area(); ~Area();
protected: protected:
@@ -127,14 +134,14 @@ private:
Constraint* fMaxContentWidth; Constraint* fMaxContentWidth;
Constraint* fMinContentHeight; Constraint* fMinContentHeight;
Constraint* fMaxContentHeight; Constraint* fMaxContentHeight;
BSize fPrefContentSize; BSize fPreferredContentSize;
BSize fShrinkRigidity; BSize fShrinkPenalties;
BSize fExpandRigidity; BSize fGrowPenalties;
double fContentAspectRatio; double fContentAspectRatio;
Constraint* fContentAspectRatioC; Constraint* fContentAspectRatioC;
bool fAutoPrefContentSize; bool fAutoPreferredContentSize;
Constraint* fPrefContentWidth; Constraint* fPreferredContentWidth;
Constraint* fPrefContentHeight; Constraint* fPreferredContentHeight;
Area* fChildArea; Area* fChildArea;
BAlignment fAlignment; BAlignment fAlignment;
int32 fLeftInset; int32 fLeftInset;
@@ -147,7 +154,7 @@ private:
Constraint* fBottomConstraint; Constraint* fBottomConstraint;
public: public:
friend class BALMLayout; friend class BALMLayout;
}; };
+6 -6
View File
@@ -15,16 +15,16 @@
#include <View.h> #include <View.h>
#include "LayoutStyleType.h" #include "LayoutStyleType.h"
#include "XTab.h"
#include "YTab.h"
#include "Area.h"
#include "Row.h"
#include "Column.h"
#include "Constraint.h"
#include "LinearSpec.h" #include "LinearSpec.h"
namespace BALM { namespace BALM {
class Area;
class Column;
class Row;
class XTab;
class YTab;
/** /**
* A GUI layout engine using the ALM. * A GUI layout engine using the ALM.
+106 -75
View File
@@ -34,9 +34,9 @@ BSize Area::kUndefinedSize(-1, -1);
* @return the auto preferred content size * @return the auto preferred content size
*/ */
bool bool
Area::AutoPrefContentSize() const Area::AutoPreferredContentSize() const
{ {
return fAutoPrefContentSize; return fAutoPreferredContentSize;
} }
@@ -46,9 +46,9 @@ Area::AutoPrefContentSize() const
* @param value the auto preferred content size * @param value the auto preferred content size
*/ */
void void
Area::SetAutoPrefContentSize(bool value) Area::SetAutoPreferredContentSize(bool value)
{ {
fAutoPrefContentSize = value; fAutoPreferredContentSize = value;
} }
@@ -360,38 +360,42 @@ Area::SetMaxContentSize(BSize max)
* Gets Preferred size of the area's content. * Gets Preferred size of the area's content.
*/ */
BSize BSize
Area::PrefContentSize() const Area::PreferredContentSize() const
{ {
return (fChildArea == NULL) ? fPrefContentSize : fChildArea->fPrefContentSize; return (fChildArea == NULL) ? fPreferredContentSize
: fChildArea->fPreferredContentSize;
} }
/** /**
* Sets Preferred size of the area's content. * Sets Preferred size of the area's content.
* May be different from the preferred size of the area. * May be different from the preferred size of the area.
* Manual changes of PrefContentSize are ignored unless autoPrefContentSize is set to false. * Manual changes of PreferredContentSize are ignored unless
* autoPreferredContentSize is set to false.
*/ */
void void
Area::SetPrefContentSize(BSize pref) Area::SetPreferredContentSize(BSize preferred)
{ {
if (fChildArea == NULL) { if (fChildArea == NULL) {
fPrefContentSize = pref; fPreferredContentSize = preferred;
if (fPrefContentWidth == NULL) { if (fPreferredContentWidth == NULL) {
fPrefContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, OperatorType(EQ), fPreferredContentWidth = fLS->AddConstraint(
fPrefContentSize.Width(), fShrinkRigidity.Width(), -1.0, fLeft, 1.0, fRight, OperatorType(EQ),
fExpandRigidity.Width()); fPreferredContentSize.Width(), fShrinkPenalties.Width(),
fConstraints->AddItem(fPrefContentWidth); fGrowPenalties.Width());
fConstraints->AddItem(fPreferredContentWidth);
fPrefContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, OperatorType(EQ), fPreferredContentHeight = fLS->AddConstraint(
fPrefContentSize.Height(), fShrinkRigidity.Height(), -1.0, fTop, 1.0, fBottom, OperatorType(EQ),
fExpandRigidity.Height()); fPreferredContentSize.Height(), fShrinkPenalties.Height(),
fConstraints->AddItem(fPrefContentHeight); fGrowPenalties.Height());
fConstraints->AddItem(fPreferredContentHeight);
} else { } else {
fPrefContentWidth->SetRightSide(pref.Width()); fPreferredContentWidth->SetRightSide(preferred.Width());
fPrefContentHeight->SetRightSide(pref.Height()); fPreferredContentHeight->SetRightSide(preferred.Height());
} }
} else } else
fChildArea->SetPrefContentSize(pref); fChildArea->SetPreferredContentSize(preferred);
fLS->InvalidateLayout(); fLS->InvalidateLayout();
} }
@@ -401,47 +405,47 @@ Area::SetPrefContentSize(BSize pref)
* The bigger the less likely is such shrinking. * The bigger the less likely is such shrinking.
*/ */
BSize BSize
Area::ShrinkRigidity() const Area::ShrinkPenalties() const
{ {
return (fChildArea == NULL) ? fShrinkRigidity : fChildArea->fShrinkRigidity; return (fChildArea == NULL) ? fShrinkPenalties : fChildArea->fShrinkPenalties;
} }
void Area::SetShrinkRigidity(BSize shrink) { void Area::SetShrinkPenalties(BSize shrink) {
if (fChildArea == NULL) { if (fChildArea == NULL) {
fShrinkRigidity = shrink; fShrinkPenalties = shrink;
if (fPrefContentWidth != NULL) { if (fPreferredContentWidth != NULL) {
fPrefContentWidth->SetPenaltyNeg(shrink.Width()); fPreferredContentWidth->SetPenaltyNeg(shrink.Width());
fPrefContentHeight->SetPenaltyNeg(shrink.Height()); fPreferredContentHeight->SetPenaltyNeg(shrink.Height());
} }
} else } else
fChildArea->SetShrinkRigidity(shrink); fChildArea->SetShrinkPenalties(shrink);
fLS->InvalidateLayout(); fLS->InvalidateLayout();
} }
/** /**
* The reluctance with which the area's content expands over its preferred size. * The reluctance with which the area's content grows over its preferred size.
* The bigger the less likely is such expansion. * The bigger the less likely is such growth.
*/ */
BSize BSize
Area::ExpandRigidity() const Area::GrowPenalties() const
{ {
return (fChildArea == NULL) ? fExpandRigidity : fChildArea->fExpandRigidity; return (fChildArea == NULL) ? fGrowPenalties : fChildArea->fGrowPenalties;
} }
void void
Area::SetExpandRigidity(BSize expand) Area::SetGrowPenalties(BSize grow)
{ {
if (fChildArea == NULL) { if (fChildArea == NULL) {
fExpandRigidity = expand; fGrowPenalties = grow;
if (fPrefContentWidth != NULL) { if (fPreferredContentWidth != NULL) {
fPrefContentWidth->SetPenaltyPos(expand.Width()); fPreferredContentWidth->SetPenaltyPos(grow.Width());
fPrefContentHeight->SetPenaltyPos(expand.Height()); fPreferredContentHeight->SetPenaltyPos(grow.Height());
} }
} else } else
fChildArea->SetExpandRigidity(expand); fChildArea->SetGrowPenalties(grow);
fLS->InvalidateLayout(); fLS->InvalidateLayout();
} }
@@ -506,7 +510,7 @@ Area::SetAlignment(BAlignment alignment)
/** /**
* Sets horizontal alignment of the content in its area. * Sets horizontal alignment of the content in its area.
*/ */
void Area::SetHAlignment(alignment horizontal) { void Area::SetHorizontalAlignment(alignment horizontal) {
fAlignment.SetHorizontal(horizontal); fAlignment.SetHorizontal(horizontal);
UpdateHorizontal(); UpdateHorizontal();
fLS->InvalidateLayout(); fLS->InvalidateLayout();
@@ -517,7 +521,7 @@ void Area::SetHAlignment(alignment horizontal) {
* Sets vertical alignment of the content in its area. * Sets vertical alignment of the content in its area.
*/ */
void void
Area::SetVAlignment(vertical_alignment vertical) Area::SetVerticalAlignment(vertical_alignment vertical)
{ {
fAlignment.SetVertical(vertical); fAlignment.SetVertical(vertical);
UpdateVertical(); UpdateVertical();
@@ -613,20 +617,20 @@ Area::SetBottomInset(int32 bottom)
/** /**
* Sets the preferred size according to the content's PreferredSize method, * Sets the preferred size according to the content's PreferredSize method,
* and the rigidities according to heuristics. * and the penalties according to heuristics.
*/ */
void void
Area::SetDefaultPrefContentSize() Area::SetDefaultBehavior()
{ {
if (Content() == NULL) { if (Content() == NULL) {
SetPrefContentSize(BSize(0, 0)); SetPreferredContentSize(BSize(0, 0));
SetShrinkRigidity(BSize(0, 0)); SetShrinkPenalties(BSize(0, 0));
SetExpandRigidity(BSize(0, 0)); SetGrowPenalties(BSize(0, 0));
return; return;
} }
if (PrefContentSize() != Content()->PreferredSize()){ if (PreferredContentSize() != Content()->PreferredSize()){
SetPrefContentSize(Content()->PreferredSize()); SetPreferredContentSize(Content()->PreferredSize());
fLS->InvalidateLayout(); fLS->InvalidateLayout();
} }
@@ -636,21 +640,44 @@ Area::SetDefaultPrefContentSize()
|| dynamic_cast<BStringView*>(Content()) != NULL || dynamic_cast<BStringView*>(Content()) != NULL
|| dynamic_cast<BPictureButton*>(Content()) != NULL || dynamic_cast<BPictureButton*>(Content()) != NULL
|| dynamic_cast<BStatusBar*>(Content()) != NULL) { || dynamic_cast<BStatusBar*>(Content()) != NULL) {
//~ || Content is LinkLabel fShrinkPenalties = BSize(4, 4);
//~ || Content is NumericUpDown) { fGrowPenalties = BSize(3, 3);
fShrinkRigidity = BSize(4, 4);
fExpandRigidity = BSize(3, 3);
} else { } else {
fShrinkRigidity = BSize(2, 2); fShrinkPenalties = BSize(2, 2);
fExpandRigidity = BSize(1, 1); fGrowPenalties = BSize(1, 1);
} }
} }
//~ string Area::ToString() { BString*
//~ return "Area(" + fLeft->ToString() + "," + fTop->ToString() + "," Area::ToBString()
//~ + fRight->ToString() + "," + fBottom->ToString() + ")"; {
//~ } BString* str = new BString();
BString* leftStr = fLeft->ToBString();
BString* topStr = fTop->ToBString();
BString* rightStr = fRight->ToBString();
BString* bottomStr = fBottom->ToBString();
*str << "Area(" << *leftStr << ", "
<< *topStr << ", "
<< *rightStr << ", "
<< *bottomStr << ")";
delete leftStr;
delete topStr;
delete rightStr;
delete bottomStr;
return str;
}
const char*
Area::ToString()
{
BString* str = new BString();
char* result = (char*) malloc(str->Length() + 1);
str->CopyInto(result, 0, str->Length());
delete str;
return result;
}
/** /**
@@ -690,7 +717,7 @@ Area::HasSameHeightAs(Area* area)
* @return a list containing a same-width and same-height constraint * @return a list containing a same-width and same-height constraint
*/ */
BList* BList*
Area::HasSameSizetAs(Area* area) Area::HasSameSizeAs(Area* area)
{ {
BList* constraints = new BList(2); BList* constraints = new BList(2);
constraints->AddItem(this->HasSameWidthAs(area)); constraints->AddItem(this->HasSameWidthAs(area));
@@ -752,16 +779,16 @@ Area::Init(BALMLayout* ls, XTab* left, YTab* top, XTab* right, YTab* bottom,
fMaxContentWidth = NULL; fMaxContentWidth = NULL;
fMaxContentHeight = NULL; fMaxContentHeight = NULL;
fPrefContentSize = kUndefinedSize; fPreferredContentSize = kUndefinedSize;
fShrinkRigidity = BSize(2, 2); fShrinkPenalties = BSize(2, 2);
fExpandRigidity = BSize(1, 1); fGrowPenalties = BSize(1, 1);
fContentAspectRatio = 0; fContentAspectRatio = 0;
fContentAspectRatioC = NULL; fContentAspectRatioC = NULL;
fAutoPrefContentSize = false; fAutoPreferredContentSize = false;
fPrefContentWidth = NULL; fPreferredContentWidth = NULL;
fPrefContentHeight = NULL; fPreferredContentHeight = NULL;
fChildArea = NULL; fChildArea = NULL;
@@ -855,25 +882,29 @@ Area::InitChildArea()
fChildArea->fMaxContentSize = fMaxContentSize; fChildArea->fMaxContentSize = fMaxContentSize;
fChildArea->fMaxContentWidth = fMaxContentWidth; fChildArea->fMaxContentWidth = fMaxContentWidth;
fMaxContentWidth->SetLeftSide(-1.0, fChildArea->Left(), 1.0, fChildArea->Right()); fMaxContentWidth->SetLeftSide(
-1.0, fChildArea->Left(), 1.0, fChildArea->Right());
fChildArea->fMaxContentHeight = fMaxContentHeight; fChildArea->fMaxContentHeight = fMaxContentHeight;
fMaxContentHeight->SetLeftSide(-1.0, fChildArea->Top(), 1.0, fChildArea->Bottom()); fMaxContentHeight->SetLeftSide(
-1.0, fChildArea->Top(), 1.0, fChildArea->Bottom());
} }
// if there are preferred content size constraints on this area, // if there are preferred content size constraints on this area,
// change them so that they refer to the tabs of the childArea // change them so that they refer to the tabs of the childArea
// and copy the preferred content size settings to the childArea // and copy the preferred content size settings to the childArea
if (fPrefContentHeight != NULL) { if (fPreferredContentHeight != NULL) {
fChildArea->fPrefContentSize = fPrefContentSize; fChildArea->fPreferredContentSize = fPreferredContentSize;
fChildArea->fShrinkRigidity = fShrinkRigidity; fChildArea->fShrinkPenalties = fShrinkPenalties;
fChildArea->fExpandRigidity = fExpandRigidity; fChildArea->fGrowPenalties = fGrowPenalties;
fChildArea->fPrefContentWidth = fPrefContentWidth; fChildArea->fPreferredContentWidth = fPreferredContentWidth;
fPrefContentWidth->SetLeftSide(-1.0, fChildArea->Left(), 1.0, fChildArea->Right()); fPreferredContentWidth->SetLeftSide(
-1.0, fChildArea->Left(), 1.0, fChildArea->Right());
fChildArea->fPrefContentHeight = fPrefContentHeight; fChildArea->fPreferredContentHeight = fPreferredContentHeight;
fPrefContentHeight->SetLeftSide(-1.0, fChildArea->Top(), 1.0, fChildArea->Bottom()); fPreferredContentHeight->SetLeftSide(
-1.0, fChildArea->Top(), 1.0, fChildArea->Bottom());
} }
} }
+8 -8
View File
@@ -52,14 +52,14 @@ BALMLayout::BALMLayout()
void void
BALMLayout::SolveLayout() BALMLayout::SolveLayout()
{ {
// if autoPrefContentSize is set on an area, readjust its prefContentSize and // if autoPreferredContentSize is set on an area,
// rigidity settings // readjust its preferredContentSize and penalties settings
int32 sizeAreas = fAreas->CountItems(); int32 sizeAreas = fAreas->CountItems();
Area* currentArea; Area* currentArea;
for (int32 i = 0; i < sizeAreas; i++) { for (int32 i = 0; i < sizeAreas; i++) {
currentArea = (Area*)fAreas->ItemAt(i); currentArea = (Area*)fAreas->ItemAt(i);
if (currentArea->AutoPrefContentSize()) if (currentArea->AutoPreferredContentSize())
currentArea->SetDefaultPrefContentSize(); currentArea->SetDefaultBehavior();
} }
// try to solve the layout until the result is OPTIMAL or INFEASIBLE, maximally // try to solve the layout until the result is OPTIMAL or INFEASIBLE, maximally
@@ -229,8 +229,8 @@ BALMLayout::AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom,
if (content != NULL) if (content != NULL)
View()->AddChild(content); View()->AddChild(content);
Area* area = new Area(this, left, top, right, bottom, content, BSize(0, 0)); Area* area = new Area(this, left, top, right, bottom, content, BSize(0, 0));
area->SetDefaultPrefContentSize(); area->SetDefaultBehavior();
area->SetAutoPrefContentSize(false); area->SetAutoPreferredContentSize(false);
fAreas->AddItem(area); fAreas->AddItem(area);
return area; return area;
} }
@@ -251,8 +251,8 @@ BALMLayout::AddArea(Row* row, Column* column, BView* content)
if (content != NULL) if (content != NULL)
View()->AddChild(content); View()->AddChild(content);
Area* area = new Area(this, row, column, content, BSize(0, 0)); Area* area = new Area(this, row, column, content, BSize(0, 0));
area->SetDefaultPrefContentSize(); area->SetDefaultBehavior();
area->SetAutoPrefContentSize(false); area->SetAutoPreferredContentSize(false);
fAreas->AddItem(area); fAreas->AddItem(area);
return area; return area;
} }
+85
View File
@@ -0,0 +1,85 @@
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
#include "BALMLayout.h"
class AreasWindow : public BWindow {
public:
AreasWindow(BRect frame)
: BWindow(frame, "ALM Areas",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
button1 = new BButton("1");
button2 = new BButton("2");
button3 = new BButton("3");
button4 = new BButton("4");
// create a new BALMLayout and use it for this window
BALMLayout* layout = new BALMLayout();
SetLayout(layout);
// create extra tabs
YTab* y1 = layout->AddYTab();
YTab* y2 = layout->AddYTab();
YTab* y3 = layout->AddYTab();
Area* a1 = layout->AddArea(
layout->Left(), layout->Top(),
layout->Right(), y1,
button1);
a1->SetTopInset(10);
a1->SetLeftInset(10);
a1->SetRightInset(10);
Area* a2 = layout->AddArea(
layout->Left(), y1,
layout->Right(), y2,
button2);
a2->SetHorizontalAlignment(B_ALIGN_LEFT);
Area* a3 = layout->AddArea(
layout->Left(), y2,
layout->Right(), y3,
button3);
a3->SetHorizontalAlignment(B_ALIGN_HORIZONTAL_CENTER);
a3->HasSameHeightAs(a1);
Area* a4 = layout->AddArea(
layout->Left(), y3,
layout->Right(), layout->Bottom(),
button4);
a4->SetHorizontalAlignment(B_ALIGN_RIGHT);
}
private:
BButton* button1;
BButton* button2;
BButton* button3;
BButton* button4;
};
class Areas : public BApplication {
public:
Areas()
: BApplication("application/x-vnd.haiku.Areas")
{
BRect frameRect;
frameRect.Set(100, 100, 300, 300);
AreasWindow* window = new AreasWindow(frameRect);
window->Show();
}
};
int
main()
{
Areas app;
app.Run();
return 0;
}
+58
View File
@@ -0,0 +1,58 @@
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
// include this for ALM
#include "XTab.h"
#include "YTab.h"
#include "Area.h"
#include "BALMLayout.h"
class HelloWorldWindow : public BWindow {
public:
HelloWorldWindow(BRect frame)
: BWindow(frame, "ALM Hello World",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
button1 = new BButton("Hello World!");
// create a new BALMLayout and use it for this window
fLayout = new BALMLayout();
SetLayout(fLayout);
// add an area containing the button
// use the borders of the layout as the borders for the area
Area* a = fLayout->AddArea(
fLayout->Left(), fLayout->Top(),
fLayout->Right(), fLayout->Bottom(),
button1);
}
private:
BALMLayout* fLayout;
BButton* button1;
};
class HelloWorld : public BApplication {
public:
HelloWorld()
: BApplication("application/x-vnd.haiku.HelloWorld")
{
BRect frameRect;
frameRect.Set(100, 100, 300, 300);
HelloWorldWindow* window = new HelloWorldWindow(frameRect);
window->Show();
}
};
int
main()
{
HelloWorld app;
app.Run();
return 0;
}
+14 -8
View File
@@ -4,26 +4,32 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
UseLibraryHeaders lp_solve linprog alm ; UseLibraryHeaders lp_solve linprog alm ;
Application ALMTableTest : Application ALMHelloWorld :
TableTest.cpp HelloWorld.cpp
: :
be liblpsolve55.so liblinprog.so libalm.so $(TARGET_LIBSUPC++) be liblpsolve55.so liblinprog.so libalm.so $(TARGET_LIBSUPC++)
; ;
Application ALMTest1 : Application ALMTwoViews :
Test1.cpp TwoViews.cpp
: :
be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++) be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++)
; ;
Application ALMTest2 : Application ALMPinwheel :
Test2.cpp Pinwheel.cpp
: :
be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++) be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++)
; ;
Application ALMSimpleTest : Application ALMAreas :
SimpleTest.cpp Areas.cpp
:
be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++)
;
Application ALMTableDemo :
TableDemo.cpp
: :
be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++) be liblpsolve55.so be liblinprog.so libalm.so $(TARGET_LIBSUPC++)
; ;
+90
View File
@@ -0,0 +1,90 @@
#include <Application.h>
#include <Button.h>
#include <TextView.h>
#include <List.h>
#include <Window.h>
// include this for ALM
#include "XTab.h"
#include "YTab.h"
#include "Area.h"
#include "BALMLayout.h"
class PinwheelWindow : public BWindow {
public:
PinwheelWindow(BRect frame)
: BWindow(frame, "ALM Pinwheel",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
button1 = new BButton("1");
button2 = new BButton("2");
button3 = new BButton("3");
button4 = new BButton("4");
textView1 = new BTextView("textView1");
textView1->SetText("5");
// create a new BALMLayout and use it for this window
BALMLayout* layout = new BALMLayout();
SetLayout(layout);
// create extra tabs
XTab* x1 = layout->AddXTab();
XTab* x2 = layout->AddXTab();
YTab* y1 = layout->AddYTab();
YTab* y2 = layout->AddYTab();
Area* a1 = layout->AddArea(
layout->Left(), layout->Top(),
x2, y1,
button1);
Area* a2 = layout->AddArea(
x2, layout->Top(),
layout->Right(), y2,
button2);
Area* a3 = layout->AddArea(
x1, y2,
layout->Right(), layout->Bottom(),
button3);
Area* a4 = layout->AddArea(
layout->Left(), y1,
x1, layout->Bottom(),
button4);
Area* a5 = layout->AddArea(
x1, y1,
x2, y2,
textView1);
a1->HasSameSizeAs(a3);
}
private:
BButton* button1;
BButton* button2;
BButton* button3;
BButton* button4;
BTextView* textView1;
};
class Pinwheel : public BApplication {
public:
Pinwheel()
: BApplication("application/x-vnd.haiku.Pinwheel")
{
BRect frameRect;
frameRect.Set(100, 100, 300, 300);
PinwheelWindow* window = new PinwheelWindow(frameRect);
window->Show();
}
};
int
main()
{
Pinwheel app;
app.Run();
return 0;
}
-74
View File
@@ -1,74 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
#include "Area.h"
#include "BALMLayout.h"
#include "OperatorType.h"
#include "XTab.h"
#include "YTab.h"
using namespace BALM;
class SimpleTestWindow : public BWindow {
public:
SimpleTestWindow(BRect frame)
: BWindow(frame, "SimpleTest", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
fLS = new BALMLayout();
SetLayout(fLS);
button1 = new BButton("button1");
SetBALMLayout();
Show();
}
void
SetBALMLayout()
{
Area* a = fLS->AddArea(fLS->Left(), fLS->Top(), fLS->Right(), fLS->Bottom(), button1);
a->SetLeftInset(10);
fLS->Save("/boot/home/Desktop/test1_ls.txt");
// fLS->AddConstraint(2.0, x1, -1.0, fLS->Right(), OperatorType(EQ), 0.0);
// fLS->AddConstraint(2.0, y1, -1.0, fLS->Bottom(), OperatorType(EQ), 0.0);
}
private:
BALMLayout* fLS;
BButton* button1;
};
class SimpleTest : public BApplication {
public:
SimpleTest()
: BApplication("application/x-vnd.haiku.simpletest")
{
BRect frameRect;
frameRect.Set(100, 100, 392, 366);
SimpleTestWindow* theWindow = new SimpleTestWindow(frameRect);
}
};
int
main()
{
SimpleTest test;
test.Run();
return 0;
}
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <File.h>
#include <Button.h>
#include <Window.h>
#include "BALMLayout.h"
class TableDemoWindow : public BWindow {
public:
TableDemoWindow(BRect frame)
: BWindow(frame, "ALM Table Demo", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
// create a new BALMLayout and use it for this window
BALMLayout* layout = new BALMLayout();
SetLayout(layout);
Column* c1 = layout->AddColumn(layout->Left(), layout->Right());
Row* r1 = layout->AddRow(layout->Top(), NULL);
Row* r3 = layout->AddRow(NULL, layout->Bottom());
r1->SetNext(r3);
Row* r2 = layout->AddRow();
r2->InsertAfter(r1);
BButton* b1 = new BButton("A1");
Area* a1 = layout->AddArea(r1, c1, b1);
a1->SetHorizontalAlignment(B_ALIGN_LEFT);
a1->SetVerticalAlignment(B_ALIGN_TOP);
BButton* b2 = new BButton("A2");
Area* a2 = layout->AddArea(r2, c1, b2);
a2->SetHorizontalAlignment(B_ALIGN_HORIZONTAL_CENTER);
a2->SetVerticalAlignment(B_ALIGN_VERTICAL_CENTER);
BButton* b3 = new BButton("A3");
Area* a3 = layout->AddArea(r3, c1, b3);
a3->SetHorizontalAlignment(B_ALIGN_RIGHT);
a3->SetVerticalAlignment(B_ALIGN_BOTTOM);
r2->HasSameHeightAs(r1);
r3->HasSameHeightAs(r1);
}
};
class TableDemo : public BApplication {
public:
TableDemo()
: BApplication("application/x-vnd.haiku.table-demo")
{
BRect frameRect;
frameRect.Set(100, 100, 400, 400);
TableDemoWindow* window = new TableDemoWindow(frameRect);
window->Show();
}
};
int
main()
{
TableDemo app;
app.Run();
return 0;
}
-80
View File
@@ -1,80 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <File.h>
#include <Button.h>
#include <Window.h>
#include "Area.h"
#include "Column.h"
#include "BALMLayout.h"
#include "Row.h"
using namespace BALM;
class TableTestWindow : public BWindow {
public:
TableTestWindow(BRect frame)
: BWindow(frame, "TableTest", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
BALMLayout* fLS = new BALMLayout();
SetLayout(fLS);
fLS->SetPerformancePath("/boot/home/Desktop/table_test_performance.txt");
Column* c1 = fLS->AddColumn(fLS->Left(), fLS->Right());
Row* r1 = fLS->AddRow(fLS->Top(), NULL);
Row* r3 = fLS->AddRow(NULL, fLS->Bottom());
r1->SetNext(r3);
Row* r2 = fLS->AddRow();
r2->InsertAfter(r1);
BButton* b1 = new BButton("A1");
Area* a1 = fLS->AddArea(r1, c1, b1);
a1->SetHAlignment(B_ALIGN_LEFT);
a1->SetVAlignment(B_ALIGN_TOP);
BButton* b2 = new BButton("A2");
Area* a2 = fLS->AddArea(r2, c1, b2);
a2->SetHAlignment(B_ALIGN_HORIZONTAL_CENTER);
a2->SetVAlignment(B_ALIGN_VERTICAL_CENTER);
BButton* b3 = new BButton("A3");
Area* a3 = fLS->AddArea(r3, c1, b3);
a3->SetHAlignment(B_ALIGN_RIGHT);
a3->SetVAlignment(B_ALIGN_BOTTOM);
r2->HasSameHeightAs(r1);
r3->HasSameHeightAs(r1);
Show();
}
};
class TableTest : public BApplication {
public:
TableTest()
: BApplication("application/x-vnd.haiku.table-test")
{
BRect frameRect;
frameRect.Set(100, 100, 400, 400);
TableTestWindow* theWindow = new TableTestWindow(frameRect);
}
};
int
main()
{
TableTest test;
test.Run();
return 0;
}
-84
View File
@@ -1,84 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <Window.h>
#include "Area.h"
#include "BALMLayout.h"
#include "OperatorType.h"
#include "XTab.h"
#include "YTab.h"
using namespace BALM;
class Test1Window : public BWindow {
public:
Test1Window(BRect frame)
: BWindow(frame, "Test1", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
fLS = new BALMLayout();
SetLayout(fLS);
button1 = new BButton("button1");
button2 = new BButton("button2");
button3 = new BButton("button3");
fLS->SetPerformancePath("/boot/home/Desktop/test1_performance.txt");
SetBALMLayout();
Show();
}
void
SetBALMLayout()
{
XTab* x1 = fLS->AddXTab();
YTab* y1 = fLS->AddYTab();
fLS->AddArea(fLS->Left(), fLS->Top(), x1, y1, button1);
fLS->AddArea(x1, fLS->Top(), fLS->Right(), y1, button2);
fLS->AddArea(fLS->Left(), y1, fLS->Right(), fLS->Bottom(), button3);
fLS->AddConstraint(2.0, x1, -1.0, fLS->Right(), OperatorType(EQ), 0.0);
fLS->AddConstraint(2.0, y1, -1.0, fLS->Bottom(), OperatorType(EQ), 0.0);
}
private:
BALMLayout* fLS;
BButton* button1;
BButton* button2;
BButton* button3;
};
class Test1 : public BApplication {
public:
Test1()
: BApplication("application/x-vnd.haiku.test1")
{
BRect frameRect;
frameRect.Set(100, 100, 392, 366);
Test1Window* theWindow = new Test1Window(frameRect);
}
};
int
main()
{
Test1 test;
test.Run();
return 0;
}
-150
View File
@@ -1,150 +0,0 @@
/*
* Copyright 2007-2008, Christof Lutteroth, [email protected]
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Button.h>
#include <List.h>
#include <StringView.h>
#include <TextControl.h>
#include <TextView.h>
#include <Window.h>
#include "Area.h"
#include "BALMLayout.h"
#include "OperatorType.h"
#include "XTab.h"
#include "YTab.h"
using namespace BALM;
class Test2Window : public BWindow {
public:
Test2Window(BRect frame)
: BWindow(frame, "Test2", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
fLS = new BALMLayout();
SetLayout(fLS);
button1 = new BButton("button1");
button2 = new BButton("button2");
button3 = new BButton("button3");
button4 = new BButton("button4");
button5 = new BButton("button5");
button6 = new BButton("button6");
checkedListBox1 = new BButton("checkedListBox1");
textBox1 = new BButton("textBox1");
textBox2 = new BButton("textBox2");
richTextBox1 = new BButton("richTextBox1");
//~ textBox1 = new BTextView(frame, "textBox1", NULL, NULL);
//~ textBox2 = new BTextView(frame, "textBox2", NULL, NULL);
//~ richTextBox1 = new BTextControl(NULL, "richTextBox1", NULL);
listView1 = new BButton("listView1");
label1 = new BStringView(frame, "label1", "label1");
label2 = new BStringView(frame, "label2", "label2");
label3 = new BStringView(frame, "label3", "label3");
fLS->SetPerformancePath("/boot/home/Desktop/test2_performance.txt");
SetBALMLayout();
Show();
}
void
SetBALMLayout()
{
XTab* x1 = fLS->AddXTab();
XTab* x2 = fLS->AddXTab();
XTab* x3 = fLS->AddXTab();
YTab* y1 = fLS->AddYTab();
YTab* y2 = fLS->AddYTab();
YTab* y3 = fLS->AddYTab();
YTab* y4 = fLS->AddYTab();
YTab* y5 = fLS->AddYTab();
fLS->AddArea(fLS->Left(), fLS->Top(), x1, y1, button1);
fLS->AddArea(x1, fLS->Top(), x2, y1, button2);
fLS->AddArea(fLS->Left(), y1, x1, y2, button3);
fLS->AddArea(x1, y1, x2, y2, button4);
fLS->AddArea(fLS->Left(), y2, x1, y3, button5);
fLS->AddArea(x1, y2, x2, y3, button6);
fLS->AddConstraint(2.0, x1, -1.0, x2, OperatorType(EQ), 0.0);
fLS->AddConstraint(2.0, y1, -1.0, y2, OperatorType(EQ), 0.0);
fLS->AddConstraint(1.0, y1, 1.0, y2, -1.0, y3, OperatorType(EQ), 0.0);
fLS->AddArea(fLS->Left(), y3, x2, y4, checkedListBox1);
fLS->AddArea(x2, fLS->Top(), fLS->Right(), y2, textBox1);
fLS->AddArea(fLS->Left(), y4, x3, y5, listView1);
fLS->AddArea(x3, y2, fLS->Right(), y5, textBox2);
Area* richTextBox1Area = fLS->AddArea(x2, y2, x3, y4, richTextBox1);
richTextBox1Area->SetLeftInset(10);
richTextBox1Area->SetTopInset(10);
richTextBox1Area->SetRightInset(10);
richTextBox1Area->SetBottomInset(10);
Area* label1Area = fLS->AddArea(fLS->Left(), y5, x2, fLS->Bottom(), label1);
label1Area->SetHAlignment(B_ALIGN_LEFT);
label1Area->SetTopInset(4);
label1Area->SetBottomInset(4);
Area* label2Area = fLS->AddArea(x2, y5, x3, fLS->Bottom(), label2);
label2Area->SetHAlignment(B_ALIGN_HORIZONTAL_CENTER);
label2Area->SetTopInset(4);
label2Area->SetBottomInset(4);
Area* label3Area = fLS->AddArea(x3, y5, fLS->Right(), fLS->Bottom(), label3);
label3Area->SetHAlignment(B_ALIGN_RIGHT);
label3Area->SetTopInset(4);
label3Area->SetBottomInset(4);
}
private:
BALMLayout* fLS;
BButton* button1;
BButton* button2;
BButton* button3;
BButton* button4;
BButton* button5;
BButton* button6;
BButton* checkedListBox1;
BButton* textBox1;
BButton* textBox2;
BButton* richTextBox1;
//~ BTextView* textBox1;
//~ BTextView* textBox2;
//~ BTextControl* richTextBox1;
BButton* listView1;
BStringView* label1;
BStringView* label2;
BStringView* label3;
};
class Test2 : public BApplication {
public:
Test2()
: BApplication("application/x-vnd.haiku.test2")
{
BRect frameRect;
frameRect.Set(100, 100, 610, 456);
Test2Window* theWindow = new Test2Window(frameRect);
}
};
int
main()
{
Test2 test;
test.Run();
return 0;
}
+68
View File
@@ -0,0 +1,68 @@
#include <Application.h>
#include <Button.h>
#include <TextView.h>
#include <List.h>
#include <Window.h>
#include "BALMLayout.h"
class TwoViewsWindow : public BWindow {
public:
TwoViewsWindow(BRect frame)
: BWindow(frame, "ALM Two Views",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
{
button1 = new BButton("View 1");
textView1 = new BTextView("textView1");
textView1->SetText("View 2");
// create a new BALMLayout and use it for this window
BALMLayout* layout = new BALMLayout();
SetLayout(layout);
// create an extra tab
XTab* x1 = layout->AddXTab();
Area* a1 = layout->AddArea(
layout->Left(), layout->Top(),
x1, layout->Bottom(),
button1);
Area* a2 = layout->AddArea(
x1, layout->Top(),
layout->Right(), layout->Bottom(),
textView1);
// add a constraint: 2*x1 == right
// i.e. x1 is in the middle of the layout
layout->AddConstraint(2, x1, -1, layout->Right(),
OperatorType(EQ), 0);
}
private:
BButton* button1;
BTextView* textView1;
};
class TwoViews : public BApplication {
public:
TwoViews()
: BApplication("application/x-vnd.haiku.TwoViews")
{
BRect frameRect;
frameRect.Set(100, 100, 300, 300);
TwoViewsWindow* window = new TwoViewsWindow(frameRect);
window->Show();
}
};
int
main()
{
TwoViews app;
app.Run();
return 0;
}