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