2008-02-25 04:54:05 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz
|
|
|
|
* Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
#ifndef AREA_H
|
|
|
|
#define AREA_H
|
|
|
|
|
|
|
|
#include <Alignment.h>
|
|
|
|
#include <List.h>
|
|
|
|
#include <Size.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <View.h>
|
|
|
|
|
2009-10-28 12:00:14 +03:00
|
|
|
#include "XTab.h"
|
|
|
|
#include "YTab.h"
|
|
|
|
#include "Area.h"
|
|
|
|
#include "Row.h"
|
|
|
|
#include "Column.h"
|
|
|
|
#include "Constraint.h"
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
namespace BALM {
|
|
|
|
|
|
|
|
class BALMLayout;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rectangular area in the GUI, defined by a tab on each side.
|
|
|
|
*/
|
|
|
|
class Area {
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
public:
|
|
|
|
XTab* Left() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetLeft(XTab* left);
|
2008-02-06 13:51:44 +03:00
|
|
|
XTab* Right() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetRight(XTab* right);
|
2008-02-06 13:51:44 +03:00
|
|
|
YTab* Top() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetTop(YTab* top);
|
2008-02-06 13:51:44 +03:00
|
|
|
YTab* Bottom() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetBottom(YTab* bottom);
|
2008-03-11 00:43:32 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
Row* GetRow() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetRow(Row* row);
|
2008-02-06 13:51:44 +03:00
|
|
|
Column* GetColumn() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetColumn(Column* column);
|
2008-03-11 00:43:32 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
BView* Content() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetContent(BView* content);
|
2008-02-06 13:51:44 +03:00
|
|
|
XTab* ContentLeft() const;
|
|
|
|
YTab* ContentTop() const;
|
|
|
|
XTab* ContentRight() const;
|
|
|
|
YTab* ContentBottom() const;
|
|
|
|
BSize MinContentSize() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetMinContentSize(BSize min);
|
2008-02-06 13:51:44 +03:00
|
|
|
BSize MaxContentSize() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetMaxContentSize(BSize max);
|
2009-10-28 12:00:14 +03:00
|
|
|
BSize PreferredContentSize() const;
|
|
|
|
void SetPreferredContentSize(BSize preferred);
|
2008-02-06 13:51:44 +03:00
|
|
|
double ContentAspectRatio() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetContentAspectRatio(double ratio);
|
2009-10-28 12:00:14 +03:00
|
|
|
|
|
|
|
BSize ShrinkPenalties() const;
|
|
|
|
void SetShrinkPenalties(BSize shrink);
|
|
|
|
BSize GrowPenalties() const;
|
|
|
|
void SetGrowPenalties(BSize grow);
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
BAlignment Alignment() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetAlignment(BAlignment alignment);
|
2009-10-28 12:00:14 +03:00
|
|
|
void SetHorizontalAlignment(alignment horizontal);
|
|
|
|
void SetVerticalAlignment(vertical_alignment vertical);
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
int32 LeftInset() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetLeftInset(int32 left);
|
2008-02-06 13:51:44 +03:00
|
|
|
int32 TopInset() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetTopInset(int32 top);
|
2008-02-06 13:51:44 +03:00
|
|
|
int32 RightInset() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetRightInset(int32 right);
|
2008-02-06 13:51:44 +03:00
|
|
|
int32 BottomInset() const;
|
2008-02-25 04:54:05 +03:00
|
|
|
void SetBottomInset(int32 bottom);
|
2009-10-28 12:00:14 +03:00
|
|
|
|
|
|
|
void SetDefaultBehavior();
|
|
|
|
bool AutoPreferredContentSize() const;
|
|
|
|
void SetAutoPreferredContentSize(bool value);
|
|
|
|
|
2009-12-06 16:14:45 +03:00
|
|
|
operator BString() const;
|
|
|
|
void GetString(BString& string) const;
|
2008-03-11 00:43:32 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
Constraint* HasSameWidthAs(Area* area);
|
|
|
|
Constraint* HasSameHeightAs(Area* area);
|
2009-10-28 12:00:14 +03:00
|
|
|
BList* HasSameSizeAs(Area* area);
|
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
~Area();
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
protected:
|
|
|
|
Area(BALMLayout* ls, XTab* left, YTab* top,
|
2009-12-06 16:14:45 +03:00
|
|
|
XTab* right, YTab* bottom,
|
|
|
|
BView* content,
|
2008-02-06 13:51:44 +03:00
|
|
|
BSize minContentSize);
|
2009-12-06 16:14:45 +03:00
|
|
|
Area(BALMLayout* ls, Row* row, Column* column,
|
2008-02-06 13:51:44 +03:00
|
|
|
BView* content,
|
|
|
|
BSize minContentSize);
|
2008-02-25 04:54:05 +03:00
|
|
|
void DoLayout();
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
private:
|
2008-03-11 00:43:32 +03:00
|
|
|
void InitChildArea();
|
|
|
|
void UpdateHorizontal();
|
|
|
|
void UpdateVertical();
|
2009-12-06 16:14:45 +03:00
|
|
|
void Init(BALMLayout* ls, XTab* left, YTab* top,
|
|
|
|
XTab* right, YTab* bottom,
|
|
|
|
BView* content,
|
2008-03-11 00:43:32 +03:00
|
|
|
BSize minContentSize);
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
public:
|
2008-03-11 00:43:32 +03:00
|
|
|
static BSize kMaxSize;
|
|
|
|
static BSize kMinSize;
|
|
|
|
static BSize kUndefinedSize;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
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;
|
2009-10-28 12:00:14 +03:00
|
|
|
BSize fPreferredContentSize;
|
|
|
|
BSize fShrinkPenalties;
|
|
|
|
BSize fGrowPenalties;
|
2008-02-06 13:51:44 +03:00
|
|
|
double fContentAspectRatio;
|
|
|
|
Constraint* fContentAspectRatioC;
|
2009-10-28 12:00:14 +03:00
|
|
|
bool fAutoPreferredContentSize;
|
|
|
|
Constraint* fPreferredContentWidth;
|
|
|
|
Constraint* fPreferredContentHeight;
|
2008-02-06 13:51:44 +03:00
|
|
|
Area* fChildArea;
|
|
|
|
BAlignment fAlignment;
|
|
|
|
int32 fLeftInset;
|
|
|
|
int32 fTopInset;
|
|
|
|
int32 fRightInset;
|
|
|
|
int32 fBottomInset;
|
|
|
|
Constraint* fLeftConstraint;
|
|
|
|
Constraint* fTopConstraint;
|
|
|
|
Constraint* fRightConstraint;
|
|
|
|
Constraint* fBottomConstraint;
|
2009-12-06 16:14:45 +03:00
|
|
|
|
2008-02-06 13:51:44 +03:00
|
|
|
public:
|
2009-10-28 12:00:14 +03:00
|
|
|
friend class BALMLayout;
|
2008-02-06 13:51:44 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BALM
|
|
|
|
|
|
|
|
using BALM::Area;
|
|
|
|
|
|
|
|
#endif // AREA_H
|
2008-03-11 00:43:32 +03:00
|
|
|
|