2008-02-25 01:54:05 +00:00
|
|
|
/*
|
2010-09-21 23:31:50 +00:00
|
|
|
* Copyright 2006 - 2010, Haiku, Inc. All rights reserved.
|
2008-02-25 01:54:05 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2008-02-06 10:51:44 +00:00
|
|
|
#ifndef AREA_H
|
|
|
|
#define AREA_H
|
|
|
|
|
2010-09-22 21:53:32 +00:00
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
#include <Alignment.h>
|
|
|
|
#include <List.h>
|
|
|
|
#include <Size.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <View.h>
|
|
|
|
|
2010-09-20 22:47:13 +00:00
|
|
|
#include "Column.h"
|
|
|
|
#include "LinearSpec.h"
|
|
|
|
#include "Row.h"
|
2009-10-28 09:00:14 +00:00
|
|
|
#include "XTab.h"
|
|
|
|
#include "YTab.h"
|
2010-09-20 06:09:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Constraint;
|
2009-10-28 09:00:14 +00:00
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
namespace BALM {
|
|
|
|
|
2010-09-20 06:09:19 +00:00
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
/**
|
|
|
|
* Rectangular area in the GUI, defined by a tab on each side.
|
|
|
|
*/
|
|
|
|
class Area {
|
|
|
|
public:
|
2010-09-20 06:26:32 +00:00
|
|
|
~Area();
|
|
|
|
|
2010-09-21 07:04:40 +00:00
|
|
|
BView* View();
|
|
|
|
|
2010-09-20 06:26:32 +00:00
|
|
|
XTab* Left() const;
|
|
|
|
XTab* Right() const;
|
|
|
|
YTab* Top() const;
|
|
|
|
YTab* Bottom() const;
|
2010-09-22 05:50:51 +00:00
|
|
|
void SetLeft(XTab* left);
|
|
|
|
void SetRight(XTab* right);
|
|
|
|
void SetTop(YTab* top);
|
2010-09-20 06:26:32 +00:00
|
|
|
void SetBottom(YTab* bottom);
|
|
|
|
|
|
|
|
Row* GetRow() const;
|
|
|
|
Column* GetColumn() const;
|
2010-09-22 05:50:51 +00:00
|
|
|
void SetRow(Row* row);
|
2010-09-20 06:26:32 +00:00
|
|
|
void SetColumn(Column* column);
|
|
|
|
|
|
|
|
double ContentAspectRatio() const;
|
|
|
|
void SetContentAspectRatio(double ratio);
|
|
|
|
|
2010-09-21 07:04:40 +00:00
|
|
|
BSize ShrinkPenalties() const;
|
|
|
|
BSize GrowPenalties() const;
|
2010-09-22 05:50:51 +00:00
|
|
|
void SetShrinkPenalties(BSize shrink);
|
2010-09-21 07:04:40 +00:00
|
|
|
void SetGrowPenalties(BSize grow);
|
|
|
|
|
2010-09-20 06:26:32 +00:00
|
|
|
int32 LeftInset() const;
|
|
|
|
int32 TopInset() const;
|
|
|
|
int32 RightInset() const;
|
|
|
|
int32 BottomInset() const;
|
2010-09-22 05:50:51 +00:00
|
|
|
void SetLeftInset(int32 left);
|
|
|
|
void SetTopInset(int32 top);
|
|
|
|
void SetRightInset(int32 right);
|
2010-09-20 06:26:32 +00:00
|
|
|
void SetBottomInset(int32 bottom);
|
|
|
|
|
|
|
|
operator BString() const;
|
|
|
|
void GetString(BString& string) const;
|
|
|
|
|
2010-09-23 00:04:08 +00:00
|
|
|
Constraint* SetWidthAs(Area* area, float factor = 1.0f);
|
|
|
|
Constraint* SetHeightAs(Area* area, float factor = 1.0f);
|
2009-12-06 13:14:45 +00:00
|
|
|
|
2010-09-21 23:18:43 +00:00
|
|
|
void InvalidateSizeConstraints();
|
|
|
|
|
2010-09-22 05:50:51 +00:00
|
|
|
private:
|
2010-09-22 04:51:09 +00:00
|
|
|
Area(BLayoutItem* item);
|
2010-09-21 07:04:40 +00:00
|
|
|
|
2010-09-22 05:50:51 +00:00
|
|
|
void _Init(LinearSpec* ls, XTab* left, YTab* top,
|
2010-09-23 07:16:49 +00:00
|
|
|
XTab* right, YTab* bottom);
|
|
|
|
void _Init(LinearSpec* ls, Row* row, Column* column);
|
2010-09-21 07:04:40 +00:00
|
|
|
|
2010-09-22 05:50:51 +00:00
|
|
|
void _DoLayout();
|
2009-12-06 13:14:45 +00:00
|
|
|
|
2010-09-21 23:18:43 +00:00
|
|
|
void _UpdateMinSizeConstraint(BSize min);
|
|
|
|
void _UpdateMaxSizeConstraint(BSize max);
|
|
|
|
void _UpdatePreferredConstraint(BSize preferred);
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
private:
|
2010-09-21 07:04:40 +00:00
|
|
|
BLayoutItem* fLayoutItem;
|
2010-09-23 00:53:33 +00:00
|
|
|
|
2010-09-20 22:47:13 +00:00
|
|
|
LinearSpec* fLS;
|
2010-09-22 04:51:09 +00:00
|
|
|
|
2010-09-20 06:26:32 +00:00
|
|
|
XTab* fLeft;
|
|
|
|
XTab* fRight;
|
|
|
|
YTab* fTop;
|
|
|
|
YTab* fBottom;
|
2010-09-22 04:51:09 +00:00
|
|
|
|
|
|
|
Row* fRow;
|
|
|
|
Column* fColumn;
|
|
|
|
|
|
|
|
BSize fShrinkPenalties;
|
|
|
|
BSize fGrowPenalties;
|
|
|
|
|
2010-09-23 00:53:33 +00:00
|
|
|
BSize fTopLeftInset;
|
|
|
|
BSize fRightBottomInset;
|
2009-12-06 13:14:45 +00:00
|
|
|
|
2010-09-22 05:55:15 +00:00
|
|
|
BList fConstraints;
|
|
|
|
Constraint* fMinContentWidth;
|
|
|
|
Constraint* fMaxContentWidth;
|
|
|
|
Constraint* fMinContentHeight;
|
|
|
|
Constraint* fMaxContentHeight;
|
|
|
|
Constraint* fPreferredContentWidth;
|
|
|
|
Constraint* fPreferredContentHeight;
|
|
|
|
double fContentAspectRatio;
|
|
|
|
Constraint* fContentAspectRatioC;
|
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
public:
|
2010-09-22 04:51:09 +00:00
|
|
|
friend class BALMLayout;
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BALM
|
|
|
|
|
|
|
|
using BALM::Area;
|
|
|
|
|
|
|
|
#endif // AREA_H
|
2008-03-10 21:43:32 +00:00
|
|
|
|