More cleanup and BList -> BObjectList.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38742 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+103
-103
@@ -32,129 +32,129 @@ class BALMLayout;
|
|||||||
* Rectangular area in the GUI, defined by a tab on each side.
|
* Rectangular area in the GUI, defined by a tab on each side.
|
||||||
*/
|
*/
|
||||||
class Area {
|
class Area {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XTab* Left() const;
|
~Area();
|
||||||
void SetLeft(XTab* left);
|
|
||||||
XTab* Right() const;
|
|
||||||
void SetRight(XTab* right);
|
|
||||||
YTab* Top() const;
|
|
||||||
void SetTop(YTab* top);
|
|
||||||
YTab* Bottom() const;
|
|
||||||
void SetBottom(YTab* bottom);
|
|
||||||
|
|
||||||
Row* GetRow() const;
|
XTab* Left() const;
|
||||||
void SetRow(Row* row);
|
void SetLeft(XTab* left);
|
||||||
Column* GetColumn() const;
|
XTab* Right() const;
|
||||||
void SetColumn(Column* column);
|
void SetRight(XTab* right);
|
||||||
|
YTab* Top() const;
|
||||||
|
void SetTop(YTab* top);
|
||||||
|
YTab* Bottom() const;
|
||||||
|
void SetBottom(YTab* bottom);
|
||||||
|
|
||||||
BView* Content() const;
|
Row* GetRow() const;
|
||||||
void SetContent(BView* content);
|
void SetRow(Row* row);
|
||||||
XTab* ContentLeft() const;
|
Column* GetColumn() const;
|
||||||
YTab* ContentTop() const;
|
void SetColumn(Column* column);
|
||||||
XTab* ContentRight() const;
|
|
||||||
YTab* ContentBottom() const;
|
|
||||||
BSize MinContentSize() const;
|
|
||||||
void SetMinContentSize(BSize min);
|
|
||||||
BSize MaxContentSize() const;
|
|
||||||
void SetMaxContentSize(BSize max);
|
|
||||||
BSize PreferredContentSize() const;
|
|
||||||
void SetPreferredContentSize(BSize preferred);
|
|
||||||
double ContentAspectRatio() const;
|
|
||||||
void SetContentAspectRatio(double ratio);
|
|
||||||
|
|
||||||
BSize ShrinkPenalties() const;
|
BView* Content() const;
|
||||||
void SetShrinkPenalties(BSize shrink);
|
void SetContent(BView* content);
|
||||||
BSize GrowPenalties() const;
|
XTab* ContentLeft() const;
|
||||||
void SetGrowPenalties(BSize grow);
|
YTab* ContentTop() const;
|
||||||
|
XTab* ContentRight() const;
|
||||||
|
YTab* ContentBottom() const;
|
||||||
|
BSize MinContentSize() const;
|
||||||
|
void SetMinContentSize(BSize min);
|
||||||
|
BSize MaxContentSize() const;
|
||||||
|
void SetMaxContentSize(BSize max);
|
||||||
|
BSize PreferredContentSize() const;
|
||||||
|
void SetPreferredContentSize(BSize preferred);
|
||||||
|
double ContentAspectRatio() const;
|
||||||
|
void SetContentAspectRatio(double ratio);
|
||||||
|
|
||||||
BAlignment Alignment() const;
|
BSize ShrinkPenalties() const;
|
||||||
void SetAlignment(BAlignment alignment);
|
void SetShrinkPenalties(BSize shrink);
|
||||||
void SetHorizontalAlignment(alignment horizontal);
|
BSize GrowPenalties() const;
|
||||||
void SetVerticalAlignment(vertical_alignment vertical);
|
void SetGrowPenalties(BSize grow);
|
||||||
|
|
||||||
int32 LeftInset() const;
|
BAlignment Alignment() const;
|
||||||
void SetLeftInset(int32 left);
|
void SetAlignment(BAlignment alignment);
|
||||||
int32 TopInset() const;
|
void SetHorizontalAlignment(alignment horizontal);
|
||||||
void SetTopInset(int32 top);
|
void SetVerticalAlignment(
|
||||||
int32 RightInset() const;
|
vertical_alignment vertical);
|
||||||
void SetRightInset(int32 right);
|
|
||||||
int32 BottomInset() const;
|
|
||||||
void SetBottomInset(int32 bottom);
|
|
||||||
|
|
||||||
void SetDefaultBehavior();
|
int32 LeftInset() const;
|
||||||
bool AutoPreferredContentSize() const;
|
void SetLeftInset(int32 left);
|
||||||
void SetAutoPreferredContentSize(bool value);
|
int32 TopInset() const;
|
||||||
|
void SetTopInset(int32 top);
|
||||||
|
int32 RightInset() const;
|
||||||
|
void SetRightInset(int32 right);
|
||||||
|
int32 BottomInset() const;
|
||||||
|
void SetBottomInset(int32 bottom);
|
||||||
|
|
||||||
operator BString() const;
|
void SetDefaultBehavior();
|
||||||
void GetString(BString& string) const;
|
bool AutoPreferredContentSize() const;
|
||||||
|
void SetAutoPreferredContentSize(bool value);
|
||||||
|
|
||||||
Constraint* HasSameWidthAs(Area* area);
|
operator BString() const;
|
||||||
Constraint* HasSameHeightAs(Area* area);
|
void GetString(BString& string) const;
|
||||||
BList* HasSameSizeAs(Area* area);
|
|
||||||
|
|
||||||
~Area();
|
Constraint* HasSameWidthAs(Area* area);
|
||||||
|
Constraint* HasSameHeightAs(Area* area);
|
||||||
|
BList* HasSameSizeAs(Area* area);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Area(BALMLayout* ls, XTab* left, YTab* top,
|
Area(BALMLayout* ls, XTab* left, YTab* top,
|
||||||
XTab* right, YTab* bottom,
|
XTab* right, YTab* bottom,
|
||||||
BView* content,
|
BView* content,
|
||||||
BSize minContentSize);
|
BSize minContentSize);
|
||||||
Area(BALMLayout* ls, Row* row, Column* column,
|
Area(BALMLayout* ls, Row* row, Column* column,
|
||||||
BView* content,
|
BView* content,
|
||||||
BSize minContentSize);
|
BSize minContentSize);
|
||||||
void DoLayout();
|
void DoLayout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitChildArea();
|
void InitChildArea();
|
||||||
void UpdateHorizontal();
|
void UpdateHorizontal();
|
||||||
void UpdateVertical();
|
void UpdateVertical();
|
||||||
void Init(BALMLayout* ls, XTab* left, YTab* top,
|
void Init(BALMLayout* ls, XTab* left, YTab* top,
|
||||||
XTab* right, YTab* bottom,
|
XTab* right, YTab* bottom,
|
||||||
BView* content,
|
BView* content,
|
||||||
BSize minContentSize);
|
BSize minContentSize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BSize kMaxSize;
|
static BSize kMaxSize;
|
||||||
static BSize kMinSize;
|
static BSize kMinSize;
|
||||||
static BSize kUndefinedSize;
|
static BSize kUndefinedSize;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BView* fContent;
|
BView* fContent;
|
||||||
BList* fConstraints;
|
BList* fConstraints;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BALMLayout* fLS;
|
BALMLayout* fLS;
|
||||||
XTab* fLeft;
|
XTab* fLeft;
|
||||||
XTab* fRight;
|
XTab* fRight;
|
||||||
YTab* fTop;
|
YTab* fTop;
|
||||||
YTab* fBottom;
|
YTab* fBottom;
|
||||||
Row* fRow;
|
Row* fRow;
|
||||||
Column* fColumn;
|
Column* fColumn;
|
||||||
BSize fMinContentSize;
|
BSize fMinContentSize;
|
||||||
BSize fMaxContentSize;
|
BSize fMaxContentSize;
|
||||||
Constraint* fMinContentWidth;
|
Constraint* fMinContentWidth;
|
||||||
Constraint* fMaxContentWidth;
|
Constraint* fMaxContentWidth;
|
||||||
Constraint* fMinContentHeight;
|
Constraint* fMinContentHeight;
|
||||||
Constraint* fMaxContentHeight;
|
Constraint* fMaxContentHeight;
|
||||||
BSize fPreferredContentSize;
|
BSize fPreferredContentSize;
|
||||||
BSize fShrinkPenalties;
|
BSize fShrinkPenalties;
|
||||||
BSize fGrowPenalties;
|
BSize fGrowPenalties;
|
||||||
double fContentAspectRatio;
|
double fContentAspectRatio;
|
||||||
Constraint* fContentAspectRatioC;
|
Constraint* fContentAspectRatioC;
|
||||||
bool fAutoPreferredContentSize;
|
bool fAutoPreferredContentSize;
|
||||||
Constraint* fPreferredContentWidth;
|
Constraint* fPreferredContentWidth;
|
||||||
Constraint* fPreferredContentHeight;
|
Constraint* fPreferredContentHeight;
|
||||||
Area* fChildArea;
|
Area* fChildArea;
|
||||||
BAlignment fAlignment;
|
BAlignment fAlignment;
|
||||||
int32 fLeftInset;
|
int32 fLeftInset;
|
||||||
int32 fTopInset;
|
int32 fTopInset;
|
||||||
int32 fRightInset;
|
int32 fRightInset;
|
||||||
int32 fBottomInset;
|
int32 fBottomInset;
|
||||||
Constraint* fLeftConstraint;
|
Constraint* fLeftConstraint;
|
||||||
Constraint* fTopConstraint;
|
Constraint* fTopConstraint;
|
||||||
Constraint* fRightConstraint;
|
Constraint* fRightConstraint;
|
||||||
Constraint* fBottomConstraint;
|
Constraint* fBottomConstraint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BALMLayout;
|
friend class BALMLayout;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Copyright 2007-2008, James Kim, [email protected]
|
* Copyright 2007-2008, James Kim, [email protected]
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BALM_LAYOUT_H
|
#ifndef BALM_LAYOUT_H
|
||||||
#define BALM_LAYOUT_H
|
#define BALM_LAYOUT_H
|
||||||
|
|
||||||
@@ -14,14 +13,13 @@
|
|||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
#include "Area.h"
|
||||||
|
#include "Column.h"
|
||||||
#include "LayoutStyleType.h"
|
#include "LayoutStyleType.h"
|
||||||
|
#include "LinearSpec.h"
|
||||||
|
#include "Row.h"
|
||||||
#include "XTab.h"
|
#include "XTab.h"
|
||||||
#include "YTab.h"
|
#include "YTab.h"
|
||||||
#include "Area.h"
|
|
||||||
#include "Row.h"
|
|
||||||
#include "Column.h"
|
|
||||||
#include "Constraint.h"
|
|
||||||
#include "LinearSpec.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace BALM {
|
namespace BALM {
|
||||||
@@ -30,77 +28,76 @@ namespace BALM {
|
|||||||
* A GUI layout engine using the ALM.
|
* A GUI layout engine using the ALM.
|
||||||
*/
|
*/
|
||||||
class BALMLayout : public BAbstractLayout, public LinearSpec {
|
class BALMLayout : public BAbstractLayout, public LinearSpec {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BALMLayout();
|
BALMLayout();
|
||||||
void SolveLayout();
|
void SolveLayout();
|
||||||
|
|
||||||
XTab* AddXTab();
|
XTab* AddXTab();
|
||||||
YTab* AddYTab();
|
YTab* AddYTab();
|
||||||
Row* AddRow();
|
Row* AddRow();
|
||||||
Row* AddRow(YTab* top, YTab* bottom);
|
Row* AddRow(YTab* top, YTab* bottom);
|
||||||
Column* AddColumn();
|
Column* AddColumn();
|
||||||
Column* AddColumn(XTab* left, XTab* right);
|
Column* AddColumn(XTab* left, XTab* right);
|
||||||
|
|
||||||
Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom,
|
Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom,
|
||||||
BView* content, BSize minContentSize);
|
BView* content, BSize minContentSize);
|
||||||
Area* AddArea(Row* row, Column* column, BView* content,
|
Area* AddArea(Row* row, Column* column, BView* content,
|
||||||
BSize minContentSize);
|
BSize minContentSize);
|
||||||
Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom,
|
Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom,
|
||||||
BView* content);
|
BView* content);
|
||||||
Area* AddArea(Row* row, Column* column, BView* content);
|
Area* AddArea(Row* row, Column* column, BView* content);
|
||||||
Area* AreaOf(BView* control);
|
Area* AreaOf(BView* control);
|
||||||
BList* Areas() const;
|
BList* Areas() const;
|
||||||
|
|
||||||
XTab* Left() const;
|
XTab* Left() const;
|
||||||
XTab* Right() const;
|
XTab* Right() const;
|
||||||
YTab* Top() const;
|
YTab* Top() const;
|
||||||
YTab* Bottom() const;
|
YTab* Bottom() const;
|
||||||
|
|
||||||
void RecoverLayout(BView* parent);
|
void RecoverLayout(BView* parent);
|
||||||
|
|
||||||
LayoutStyleType LayoutStyle() const;
|
LayoutStyleType LayoutStyle() const;
|
||||||
void SetLayoutStyle(LayoutStyleType style);
|
void SetLayoutStyle(LayoutStyleType style);
|
||||||
|
|
||||||
BLayoutItem* AddView(BView* child);
|
BLayoutItem* AddView(BView* child);
|
||||||
BLayoutItem* AddView(int32 index, BView* child);
|
BLayoutItem* AddView(int32 index, BView* child);
|
||||||
bool AddItem(BLayoutItem* item);
|
bool AddItem(BLayoutItem* item);
|
||||||
bool AddItem(int32 index, BLayoutItem* item);
|
bool AddItem(int32 index, BLayoutItem* item);
|
||||||
bool RemoveView(BView* child);
|
bool RemoveView(BView* child);
|
||||||
bool RemoveItem(BLayoutItem* item);
|
bool RemoveItem(BLayoutItem* item);
|
||||||
BLayoutItem* RemoveItem(int32 index);
|
BLayoutItem* RemoveItem(int32 index);
|
||||||
|
|
||||||
BSize BaseMinSize();
|
BSize BaseMinSize();
|
||||||
BSize BaseMaxSize();
|
BSize BaseMaxSize();
|
||||||
BSize BasePreferredSize();
|
BSize BasePreferredSize();
|
||||||
BAlignment BaseAlignment();
|
BAlignment BaseAlignment();
|
||||||
bool HasHeightForWidth();
|
bool HasHeightForWidth();
|
||||||
void GetHeightForWidth(float width, float* min,
|
void GetHeightForWidth(float width, float* min,
|
||||||
float* max, float* preferred);
|
float* max, float* preferred);
|
||||||
void InvalidateLayout(bool children = false);
|
void InvalidateLayout(bool children = false);
|
||||||
virtual void DerivedLayoutItems();
|
virtual void DerivedLayoutItems();
|
||||||
|
|
||||||
char* PerformancePath() const;
|
char* PerformancePath() const;
|
||||||
void SetPerformancePath(char* path);
|
void SetPerformancePath(char* path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BSize CalculateMinSize();
|
BSize CalculateMinSize();
|
||||||
BSize CalculateMaxSize();
|
BSize CalculateMaxSize();
|
||||||
BSize CalculatePreferredSize();
|
BSize CalculatePreferredSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LayoutStyleType fLayoutStyle;
|
LayoutStyleType fLayoutStyle;
|
||||||
bool fActivated;
|
bool fActivated;
|
||||||
|
|
||||||
BList* fAreas;
|
BList* fAreas;
|
||||||
XTab* fLeft;
|
XTab* fLeft;
|
||||||
XTab* fRight;
|
XTab* fRight;
|
||||||
YTab* fTop;
|
YTab* fTop;
|
||||||
YTab* fBottom;
|
YTab* fBottom;
|
||||||
BSize fMinSize;
|
BSize fMinSize;
|
||||||
BSize fMaxSize;
|
BSize fMaxSize;
|
||||||
BSize fPreferredSize;
|
BSize fPreferredSize;
|
||||||
char* fPerformancePath;
|
char* fPerformancePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BALM
|
} // namespace BALM
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ typedef BObjectList<Constraint> ConstraintList;
|
|||||||
} // namespace LinearProgramming
|
} // namespace LinearProgramming
|
||||||
|
|
||||||
using LinearProgramming::Constraint;
|
using LinearProgramming::Constraint;
|
||||||
|
using LinearProgramming::ConstraintList;
|
||||||
|
|
||||||
#endif // CONSTRAINT_H
|
#endif // CONSTRAINT_H
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include "Constraint.h"
|
#include "Constraint.h"
|
||||||
|
|
||||||
#include "OperatorType.h"
|
#include "OperatorType.h"
|
||||||
#include "OptimizationType.h"
|
#include "OptimizationType.h"
|
||||||
#include "PenaltyFunction.h"
|
#include "PenaltyFunction.h"
|
||||||
@@ -25,14 +24,9 @@
|
|||||||
|
|
||||||
#include "lp_lib.h"
|
#include "lp_lib.h"
|
||||||
|
|
||||||
|
|
||||||
namespace LinearProgramming {
|
namespace LinearProgramming {
|
||||||
|
|
||||||
class Constraint;
|
|
||||||
class ObjFunctionSummand;
|
|
||||||
class PenaltyFunction;
|
|
||||||
class Variable;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Specification of a linear programming problem.
|
* Specification of a linear programming problem.
|
||||||
*/
|
*/
|
||||||
@@ -106,8 +100,8 @@ public:
|
|||||||
void GetString(BString& string) const;
|
void GetString(BString& string) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BList* Variables() const;
|
VariableList* Variables() const;
|
||||||
BList* Constraints() const;
|
ConstraintList* Constraints() const;
|
||||||
|
|
||||||
int32 fCountColumns;
|
int32 fCountColumns;
|
||||||
|
|
||||||
@@ -116,8 +110,8 @@ private:
|
|||||||
OptimizationType fOptimization;
|
OptimizationType fOptimization;
|
||||||
lprec* fLP;
|
lprec* fLP;
|
||||||
SummandList* fObjFunction;
|
SummandList* fObjFunction;
|
||||||
BList fVariables;
|
VariableList fVariables;
|
||||||
BList fConstraints;
|
ConstraintList fConstraints;
|
||||||
ResultType fResult;
|
ResultType fResult;
|
||||||
double fObjectiveValue;
|
double fObjectiveValue;
|
||||||
double fSolvingTime;
|
double fSolvingTime;
|
||||||
|
|||||||
@@ -76,8 +76,13 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef BObjectList<Variable> VariableList;
|
||||||
|
|
||||||
|
|
||||||
} // namespace LinearProgramming
|
} // namespace LinearProgramming
|
||||||
|
|
||||||
using LinearProgramming::Variable;
|
using LinearProgramming::Variable;
|
||||||
|
using LinearProgramming::VariableList;
|
||||||
|
|
||||||
#endif // VARIABLE_H
|
#endif // VARIABLE_H
|
||||||
|
|||||||
@@ -542,10 +542,10 @@ LinearSpec::SetOptimization(OptimizationType value)
|
|||||||
*
|
*
|
||||||
* @return the variables
|
* @return the variables
|
||||||
*/
|
*/
|
||||||
BList*
|
VariableList*
|
||||||
LinearSpec::Variables() const
|
LinearSpec::Variables() const
|
||||||
{
|
{
|
||||||
return const_cast<BList*>(&fVariables);
|
return const_cast<VariableList*>(&fVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -554,10 +554,10 @@ LinearSpec::Variables() const
|
|||||||
*
|
*
|
||||||
* @return the constraints
|
* @return the constraints
|
||||||
*/
|
*/
|
||||||
BList*
|
ConstraintList*
|
||||||
LinearSpec::Constraints() const
|
LinearSpec::Constraints() const
|
||||||
{
|
{
|
||||||
return const_cast<BList*>(&fConstraints);
|
return const_cast<ConstraintList*>(&fConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -289,11 +289,10 @@ Variable::Invalidate()
|
|||||||
fLS->Variables()->RemoveItem(this);
|
fLS->Variables()->RemoveItem(this);
|
||||||
|
|
||||||
// invalidate all constraints that use this variable
|
// invalidate all constraints that use this variable
|
||||||
BList markedForInvalidation;
|
ConstraintList markedForInvalidation;
|
||||||
BList* constraints = fLS->Constraints();
|
ConstraintList* constraints = fLS->Constraints();
|
||||||
for (int i = 0; i < constraints->CountItems(); i++) {
|
for (int i = 0; i < constraints->CountItems(); i++) {
|
||||||
Constraint* constraint = static_cast<Constraint*>(
|
Constraint* constraint = constraints->ItemAt(i);
|
||||||
constraints->ItemAt(i));
|
|
||||||
|
|
||||||
if (!constraint->IsValid())
|
if (!constraint->IsValid())
|
||||||
continue;
|
continue;
|
||||||
@@ -308,8 +307,7 @@ Variable::Invalidate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < markedForInvalidation.CountItems(); i++)
|
for (int i = 0; i < markedForInvalidation.CountItems(); i++)
|
||||||
static_cast<Constraint*>(markedForInvalidation.ItemAt(i))
|
markedForInvalidation.ItemAt(i)->Invalidate();
|
||||||
->Invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user