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