xref: /haiku/headers/libs/alm/ALMLayout.h (revision 8d9b6ef4284d47e3bea44ba8c64e4e8c84be4e1a)
1*8d9b6ef4SClemens Zeidler /*
2*8d9b6ef4SClemens Zeidler  * Copyright 2006 - 2010, Haiku, Inc. All rights reserved.
3*8d9b6ef4SClemens Zeidler  * Distributed under the terms of the MIT License.
4*8d9b6ef4SClemens Zeidler  */
5*8d9b6ef4SClemens Zeidler #ifndef	ALM_LAYOUT_H
6*8d9b6ef4SClemens Zeidler #define	ALM_LAYOUT_H
7*8d9b6ef4SClemens Zeidler 
8*8d9b6ef4SClemens Zeidler #include <AbstractLayout.h>
9*8d9b6ef4SClemens Zeidler #include <File.h>
10*8d9b6ef4SClemens Zeidler #include <List.h>
11*8d9b6ef4SClemens Zeidler #include <Size.h>
12*8d9b6ef4SClemens Zeidler #include <SupportDefs.h>
13*8d9b6ef4SClemens Zeidler #include <View.h>
14*8d9b6ef4SClemens Zeidler 
15*8d9b6ef4SClemens Zeidler #include "Area.h"
16*8d9b6ef4SClemens Zeidler #include "Column.h"
17*8d9b6ef4SClemens Zeidler #include "LayoutStyleType.h"
18*8d9b6ef4SClemens Zeidler #include "LinearSpec.h"
19*8d9b6ef4SClemens Zeidler #include "Row.h"
20*8d9b6ef4SClemens Zeidler #include "XTab.h"
21*8d9b6ef4SClemens Zeidler #include "YTab.h"
22*8d9b6ef4SClemens Zeidler 
23*8d9b6ef4SClemens Zeidler 
24*8d9b6ef4SClemens Zeidler namespace BALM {
25*8d9b6ef4SClemens Zeidler 
26*8d9b6ef4SClemens Zeidler /**
27*8d9b6ef4SClemens Zeidler  * A GUI layout engine using the ALM.
28*8d9b6ef4SClemens Zeidler  */
29*8d9b6ef4SClemens Zeidler class BALMLayout : public BAbstractLayout {
30*8d9b6ef4SClemens Zeidler public:
31*8d9b6ef4SClemens Zeidler 								BALMLayout();
32*8d9b6ef4SClemens Zeidler 	virtual						~BALMLayout();
33*8d9b6ef4SClemens Zeidler 
34*8d9b6ef4SClemens Zeidler 			void				SolveLayout();
35*8d9b6ef4SClemens Zeidler 
36*8d9b6ef4SClemens Zeidler 			XTab*				AddXTab();
37*8d9b6ef4SClemens Zeidler 			YTab*				AddYTab();
38*8d9b6ef4SClemens Zeidler 			Row*				AddRow();
39*8d9b6ef4SClemens Zeidler 			Row*				AddRow(YTab* top, YTab* bottom);
40*8d9b6ef4SClemens Zeidler 			Column*				AddColumn();
41*8d9b6ef4SClemens Zeidler 			Column*				AddColumn(XTab* left, XTab* right);
42*8d9b6ef4SClemens Zeidler 
43*8d9b6ef4SClemens Zeidler 			Area*				AddArea(XTab* left, YTab* top, XTab* right,
44*8d9b6ef4SClemens Zeidler 									YTab* bottom, BView* content, BSize minContentSize);
45*8d9b6ef4SClemens Zeidler 			Area*				AddArea(Row* row, Column* column,
46*8d9b6ef4SClemens Zeidler 									BView* content, BSize minContentSize);
47*8d9b6ef4SClemens Zeidler 			Area*				AddArea(XTab* left, YTab* top, XTab* right,
48*8d9b6ef4SClemens Zeidler 									YTab* bottom, BView* content);
49*8d9b6ef4SClemens Zeidler 			Area*				AddArea(Row* row, Column* column,
50*8d9b6ef4SClemens Zeidler 									BView* content);
51*8d9b6ef4SClemens Zeidler 			Area*				AreaOf(BView* control);
52*8d9b6ef4SClemens Zeidler 
53*8d9b6ef4SClemens Zeidler 			XTab*				Left() const;
54*8d9b6ef4SClemens Zeidler 			XTab*				Right() const;
55*8d9b6ef4SClemens Zeidler 			YTab*				Top() const;
56*8d9b6ef4SClemens Zeidler 			YTab*				Bottom() const;
57*8d9b6ef4SClemens Zeidler 
58*8d9b6ef4SClemens Zeidler 			void				RecoverLayout(BView* parent);
59*8d9b6ef4SClemens Zeidler 
60*8d9b6ef4SClemens Zeidler 			LayoutStyleType		LayoutStyle() const;
61*8d9b6ef4SClemens Zeidler 			void				SetLayoutStyle(LayoutStyleType style);
62*8d9b6ef4SClemens Zeidler 
63*8d9b6ef4SClemens Zeidler 			BSize				BaseMinSize();
64*8d9b6ef4SClemens Zeidler 			BSize				BaseMaxSize();
65*8d9b6ef4SClemens Zeidler 			BSize				BasePreferredSize();
66*8d9b6ef4SClemens Zeidler 			BAlignment			BaseAlignment();
67*8d9b6ef4SClemens Zeidler 
68*8d9b6ef4SClemens Zeidler 	virtual	void				InvalidateLayout(bool children = false);
69*8d9b6ef4SClemens Zeidler 
70*8d9b6ef4SClemens Zeidler 	virtual	bool				ItemAdded(BLayoutItem* item, int32 atIndex);
71*8d9b6ef4SClemens Zeidler 	virtual	void				ItemRemoved(BLayoutItem* item, int32 fromIndex);
72*8d9b6ef4SClemens Zeidler 	virtual	void				DerivedLayoutItems();
73*8d9b6ef4SClemens Zeidler 
74*8d9b6ef4SClemens Zeidler 			char*				PerformancePath() const;
75*8d9b6ef4SClemens Zeidler 			void				SetPerformancePath(char* path);
76*8d9b6ef4SClemens Zeidler 
77*8d9b6ef4SClemens Zeidler 			LinearSpec*			Solver();
78*8d9b6ef4SClemens Zeidler 
79*8d9b6ef4SClemens Zeidler private:
80*8d9b6ef4SClemens Zeidler 			Area*				_AreaForItem(BLayoutItem* item) const;
81*8d9b6ef4SClemens Zeidler 			void				_UpdateAreaConstraints();
82*8d9b6ef4SClemens Zeidler 
83*8d9b6ef4SClemens Zeidler 			BSize				CalculateMinSize();
84*8d9b6ef4SClemens Zeidler 			BSize				CalculateMaxSize();
85*8d9b6ef4SClemens Zeidler 			BSize				CalculatePreferredSize();
86*8d9b6ef4SClemens Zeidler 
87*8d9b6ef4SClemens Zeidler private:
88*8d9b6ef4SClemens Zeidler 			LayoutStyleType		fLayoutStyle;
89*8d9b6ef4SClemens Zeidler 			bool				fActivated;
90*8d9b6ef4SClemens Zeidler 
91*8d9b6ef4SClemens Zeidler 			LinearSpec			fSolver;
92*8d9b6ef4SClemens Zeidler 
93*8d9b6ef4SClemens Zeidler 			XTab*				fLeft;
94*8d9b6ef4SClemens Zeidler 			XTab*				fRight;
95*8d9b6ef4SClemens Zeidler 			YTab*				fTop;
96*8d9b6ef4SClemens Zeidler 			YTab*				fBottom;
97*8d9b6ef4SClemens Zeidler 			BSize				fMinSize;
98*8d9b6ef4SClemens Zeidler 			BSize				fMaxSize;
99*8d9b6ef4SClemens Zeidler 			BSize				fPreferredSize;
100*8d9b6ef4SClemens Zeidler 			char*				fPerformancePath;
101*8d9b6ef4SClemens Zeidler };
102*8d9b6ef4SClemens Zeidler 
103*8d9b6ef4SClemens Zeidler }	// namespace BALM
104*8d9b6ef4SClemens Zeidler 
105*8d9b6ef4SClemens Zeidler using BALM::BALMLayout;
106*8d9b6ef4SClemens Zeidler 
107*8d9b6ef4SClemens Zeidler #endif	// ALM_LAYOUT_H
108