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.
|
|
|
|
*/
|
2010-09-21 23:31:50 +00:00
|
|
|
#ifndef ALM_LAYOUT_H
|
|
|
|
#define ALM_LAYOUT_H
|
2008-02-06 10:51:44 +00:00
|
|
|
|
2010-09-22 21:53:32 +00:00
|
|
|
|
2010-08-17 18:43:41 +00:00
|
|
|
#include <AbstractLayout.h>
|
2008-02-06 10:51:44 +00:00
|
|
|
#include <Size.h>
|
|
|
|
|
2009-10-28 09:00:14 +00:00
|
|
|
#include "Area.h"
|
2008-02-06 10:51:44 +00:00
|
|
|
#include "LinearSpec.h"
|
2010-09-30 01:32:48 +00:00
|
|
|
#include "Tab.h"
|
2008-02-06 10:51:44 +00:00
|
|
|
|
|
|
|
|
2012-01-17 14:28:01 +13:00
|
|
|
class BView;
|
|
|
|
class BLayoutItem;
|
|
|
|
|
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
namespace BALM {
|
2010-09-23 00:04:08 +00:00
|
|
|
|
2011-03-14 00:24:12 +00:00
|
|
|
|
2012-01-17 14:28:01 +13:00
|
|
|
class Column;
|
2012-01-17 15:50:57 +13:00
|
|
|
class ALMGroup;
|
2012-01-17 14:28:01 +13:00
|
|
|
class Row;
|
2011-03-14 00:24:12 +00:00
|
|
|
class RowColumnManager;
|
|
|
|
|
|
|
|
|
2010-09-22 21:53:32 +00:00
|
|
|
/*!
|
|
|
|
* A GUI layout engine using the Auckland Layout Model (ALM).
|
2008-02-06 10:51:44 +00:00
|
|
|
*/
|
2010-09-20 22:47:13 +00:00
|
|
|
class BALMLayout : public BAbstractLayout {
|
2008-02-06 10:51:44 +00:00
|
|
|
public:
|
2012-01-16 11:54:25 +13:00
|
|
|
BALMLayout(float hSpacing = 0.0f,
|
|
|
|
float vSpacing = 0.0f,
|
2010-10-21 11:19:18 +00:00
|
|
|
BALMLayout* friendLayout = NULL);
|
2010-09-21 07:04:40 +00:00
|
|
|
virtual ~BALMLayout();
|
|
|
|
|
2011-11-30 17:55:36 +13:00
|
|
|
BReference<XTab> AddXTab();
|
2012-01-17 10:37:12 +13:00
|
|
|
void AddXTabs(BReference<XTab>* tabs, uint32 count);
|
2011-11-30 17:55:36 +13:00
|
|
|
BReference<YTab> AddYTab();
|
2012-01-17 10:37:12 +13:00
|
|
|
void AddYTabs(BReference<YTab>* tabs, uint32 count);
|
2011-11-30 17:55:36 +13:00
|
|
|
|
2011-03-14 00:24:12 +00:00
|
|
|
int32 CountXTabs() const;
|
|
|
|
int32 CountYTabs() const;
|
|
|
|
XTab* XTabAt(int32 index) const;
|
|
|
|
YTab* YTabAt(int32 index) const;
|
2011-11-30 17:55:36 +13:00
|
|
|
/*! Order the tab list and return a reference to the list. */
|
|
|
|
const XTabList& OrderedXTabs();
|
|
|
|
const YTabList& OrderedYTabs();
|
2011-03-14 00:24:12 +00:00
|
|
|
|
2010-09-20 06:26:32 +00:00
|
|
|
Row* AddRow(YTab* top, YTab* bottom);
|
|
|
|
Column* AddColumn(XTab* left, XTab* right);
|
2010-09-22 21:53:32 +00:00
|
|
|
|
2010-09-20 06:26:32 +00:00
|
|
|
XTab* Left() const;
|
|
|
|
XTab* Right() const;
|
|
|
|
YTab* Top() const;
|
|
|
|
YTab* Bottom() const;
|
2008-02-06 10:51:44 +00:00
|
|
|
|
2012-01-17 14:28:01 +13:00
|
|
|
LinearProgramming::LinearSpec* Solver() const;
|
2010-09-20 22:47:13 +00:00
|
|
|
|
2012-01-16 11:54:25 +13:00
|
|
|
void SetInsets(float insets);
|
|
|
|
void SetInsets(float x, float y);
|
|
|
|
void SetInsets(float left, float top, float right,
|
|
|
|
float bottom);
|
|
|
|
void GetInsets(float* left, float* top, float* right,
|
|
|
|
float* bottom) const;
|
2010-09-23 00:53:33 +00:00
|
|
|
|
2012-01-16 11:54:25 +13:00
|
|
|
void SetSpacing(float hSpacing, float vSpacing);
|
|
|
|
void GetSpacing(float* _hSpacing,
|
|
|
|
float* _vSpacing) const;
|
2010-09-29 03:30:47 +00:00
|
|
|
|
2012-01-11 17:19:29 +13:00
|
|
|
Area* AreaFor(int32 id) const;
|
2010-09-30 01:32:48 +00:00
|
|
|
Area* AreaFor(const BView* view) const;
|
2010-09-29 03:30:47 +00:00
|
|
|
Area* AreaFor(const BLayoutItem* item) const;
|
2012-01-10 17:43:58 +13:00
|
|
|
int32 CountAreas() const;
|
2011-03-14 00:24:12 +00:00
|
|
|
Area* AreaAt(int32 index) const;
|
2010-09-29 03:30:47 +00:00
|
|
|
|
2010-09-30 01:32:48 +00:00
|
|
|
XTab* LeftOf(const BView* view) const;
|
|
|
|
XTab* LeftOf(const BLayoutItem* item) const;
|
|
|
|
XTab* RightOf(const BView* view) const;
|
|
|
|
XTab* RightOf(const BLayoutItem* item) const;
|
|
|
|
YTab* TopOf(const BView* view) const;
|
|
|
|
YTab* TopOf(const BLayoutItem* item) const;
|
|
|
|
YTab* BottomOf(const BView* view) const;
|
|
|
|
YTab* BottomOf(const BLayoutItem* item) const;
|
|
|
|
|
2010-09-23 07:16:49 +00:00
|
|
|
virtual BLayoutItem* AddView(BView* child);
|
|
|
|
virtual BLayoutItem* AddView(int32 index, BView* child);
|
|
|
|
virtual Area* AddView(BView* view, XTab* left, YTab* top,
|
2010-09-30 01:32:48 +00:00
|
|
|
XTab* right = NULL, YTab* bottom = NULL);
|
2010-09-23 07:16:49 +00:00
|
|
|
virtual Area* AddView(BView* view, Row* row, Column* column);
|
|
|
|
|
|
|
|
virtual bool AddItem(BLayoutItem* item);
|
|
|
|
virtual bool AddItem(int32 index, BLayoutItem* item);
|
|
|
|
virtual Area* AddItem(BLayoutItem* item, XTab* left,
|
2010-09-30 01:32:48 +00:00
|
|
|
YTab* top, XTab* right = NULL,
|
|
|
|
YTab* bottom = NULL);
|
2010-09-23 07:16:49 +00:00
|
|
|
virtual Area* AddItem(BLayoutItem* item, Row* row,
|
|
|
|
Column* column);
|
2011-11-30 17:55:36 +13:00
|
|
|
|
2012-01-10 17:43:58 +13:00
|
|
|
bool SaveLayout(BMessage* archive) const;
|
|
|
|
bool RestoreLayout(const BMessage* archive);
|
|
|
|
|
2010-09-23 07:16:49 +00:00
|
|
|
virtual BSize BaseMinSize();
|
|
|
|
virtual BSize BaseMaxSize();
|
|
|
|
virtual BSize BasePreferredSize();
|
|
|
|
virtual BAlignment BaseAlignment();
|
|
|
|
|
2011-10-22 14:54:43 -06:00
|
|
|
protected:
|
2010-09-23 07:16:49 +00:00
|
|
|
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
|
|
|
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
2011-10-22 14:54:43 -06:00
|
|
|
|
|
|
|
virtual void LayoutInvalidated(bool children);
|
|
|
|
virtual void DoLayout();
|
2010-09-23 07:16:49 +00:00
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
private:
|
2011-11-30 17:55:36 +13:00
|
|
|
friend class XTab;
|
|
|
|
friend class YTab;
|
2012-01-16 11:54:25 +13:00
|
|
|
friend class Area;
|
|
|
|
|
2012-01-17 16:07:48 +13:00
|
|
|
float InsetForTab(XTab* tab) const;
|
|
|
|
float InsetForTab(YTab* tab) const;
|
2011-11-30 17:55:36 +13:00
|
|
|
|
2012-01-16 12:36:51 +13:00
|
|
|
BLayoutItem* _LayoutItemToAdd(BView* view);
|
2010-09-23 07:16:49 +00:00
|
|
|
|
2010-09-21 23:18:43 +00:00
|
|
|
void _UpdateAreaConstraints();
|
2010-09-21 07:04:40 +00:00
|
|
|
|
2010-09-22 05:29:50 +00:00
|
|
|
BSize _CalculateMinSize();
|
|
|
|
BSize _CalculateMaxSize();
|
|
|
|
BSize _CalculatePreferredSize();
|
2008-02-06 10:51:44 +00:00
|
|
|
|
2012-01-17 14:28:01 +13:00
|
|
|
LinearProgramming::LinearSpec* fSolver;
|
|
|
|
LinearProgramming::LinearSpec fOwnSolver;
|
2010-09-20 22:47:13 +00:00
|
|
|
|
2011-11-30 17:55:36 +13:00
|
|
|
BReference<XTab> fLeft;
|
|
|
|
BReference<XTab> fRight;
|
|
|
|
BReference<YTab> fTop;
|
|
|
|
BReference<YTab> fBottom;
|
2010-09-20 06:26:32 +00:00
|
|
|
BSize fMinSize;
|
|
|
|
BSize fMaxSize;
|
|
|
|
BSize fPreferredSize;
|
2010-09-23 00:53:33 +00:00
|
|
|
|
2012-01-16 11:54:25 +13:00
|
|
|
float fLeftInset;
|
|
|
|
float fRightInset;
|
|
|
|
float fTopInset;
|
|
|
|
float fBottomInset;
|
|
|
|
|
|
|
|
float fHSpacing;
|
|
|
|
float fVSpacing;
|
2010-09-29 03:30:47 +00:00
|
|
|
|
2011-03-14 00:24:12 +00:00
|
|
|
XTabList fXTabList;
|
|
|
|
YTabList fYTabList;
|
|
|
|
|
|
|
|
RowColumnManager* fRowColumnManager;
|
2008-02-06 10:51:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BALM
|
|
|
|
|
2012-01-17 10:37:12 +13:00
|
|
|
|
2008-02-06 10:51:44 +00:00
|
|
|
using BALM::BALMLayout;
|
|
|
|
|
2012-01-17 10:37:12 +13:00
|
|
|
|
2010-09-21 23:31:50 +00:00
|
|
|
#endif // ALM_LAYOUT_H
|