18d9b6ef4SClemens Zeidler /* 28d9b6ef4SClemens Zeidler * Copyright 2006 - 2010, Haiku, Inc. All rights reserved. 38d9b6ef4SClemens Zeidler * Distributed under the terms of the MIT License. 48d9b6ef4SClemens Zeidler */ 58d9b6ef4SClemens Zeidler #ifndef ALM_LAYOUT_H 68d9b6ef4SClemens Zeidler #define ALM_LAYOUT_H 78d9b6ef4SClemens Zeidler 89503cf19SClemens Zeidler 98d9b6ef4SClemens Zeidler #include <AbstractLayout.h> 108d9b6ef4SClemens Zeidler #include <File.h> 118d9b6ef4SClemens Zeidler #include <List.h> 128d9b6ef4SClemens Zeidler #include <Size.h> 138d9b6ef4SClemens Zeidler #include <SupportDefs.h> 148d9b6ef4SClemens Zeidler #include <View.h> 158d9b6ef4SClemens Zeidler 168d9b6ef4SClemens Zeidler #include "Area.h" 178d9b6ef4SClemens Zeidler #include "Column.h" 188d9b6ef4SClemens Zeidler #include "LinearSpec.h" 198d9b6ef4SClemens Zeidler #include "Row.h" 208d9b6ef4SClemens Zeidler #include "XTab.h" 218d9b6ef4SClemens Zeidler #include "YTab.h" 228d9b6ef4SClemens Zeidler 238d9b6ef4SClemens Zeidler 248d9b6ef4SClemens Zeidler namespace BALM { 258d9b6ef4SClemens Zeidler 269503cf19SClemens Zeidler /*! 279503cf19SClemens Zeidler * A GUI layout engine using the Auckland Layout Model (ALM). 288d9b6ef4SClemens Zeidler */ 298d9b6ef4SClemens Zeidler class BALMLayout : public BAbstractLayout { 308d9b6ef4SClemens Zeidler public: 3196e2013eSClemens Zeidler BALMLayout(float spacing = 0.0f); 328d9b6ef4SClemens Zeidler virtual ~BALMLayout(); 338d9b6ef4SClemens Zeidler 348d9b6ef4SClemens Zeidler XTab* AddXTab(); 358d9b6ef4SClemens Zeidler YTab* AddYTab(); 368d9b6ef4SClemens Zeidler Row* AddRow(); 378d9b6ef4SClemens Zeidler Row* AddRow(YTab* top, YTab* bottom); 388d9b6ef4SClemens Zeidler Column* AddColumn(); 398d9b6ef4SClemens Zeidler Column* AddColumn(XTab* left, XTab* right); 408d9b6ef4SClemens Zeidler 418d9b6ef4SClemens Zeidler XTab* Left() const; 428d9b6ef4SClemens Zeidler XTab* Right() const; 438d9b6ef4SClemens Zeidler YTab* Top() const; 448d9b6ef4SClemens Zeidler YTab* Bottom() const; 458d9b6ef4SClemens Zeidler 468d9b6ef4SClemens Zeidler char* PerformancePath() const; 478d9b6ef4SClemens Zeidler void SetPerformancePath(char* path); 488d9b6ef4SClemens Zeidler 498d9b6ef4SClemens Zeidler LinearSpec* Solver(); 508d9b6ef4SClemens Zeidler 5196e2013eSClemens Zeidler void SetInset(float inset); 5296e2013eSClemens Zeidler float Inset(); 5396e2013eSClemens Zeidler 5496e2013eSClemens Zeidler void SetSpacing(float spacing); 5596e2013eSClemens Zeidler float Spacing(); 5696e2013eSClemens Zeidler 57*21f083afSClemens Zeidler virtual BLayoutItem* AddView(BView* child); 58*21f083afSClemens Zeidler virtual BLayoutItem* AddView(int32 index, BView* child); 59*21f083afSClemens Zeidler virtual Area* AddView(BView* view, XTab* left, YTab* top, 60*21f083afSClemens Zeidler XTab* right, YTab* bottom); 61*21f083afSClemens Zeidler virtual Area* AddView(BView* view, Row* row, Column* column); 62*21f083afSClemens Zeidler virtual Area* AddViewToRight(BView* view, Area* leftArea, 63*21f083afSClemens Zeidler XTab* right = NULL, YTab* top = NULL, 64*21f083afSClemens Zeidler YTab* bottom = NULL); 65*21f083afSClemens Zeidler virtual Area* AddViewToLeft(BView* view, Area* rightArea, 66*21f083afSClemens Zeidler XTab* left = NULL, YTab* top = NULL, 67*21f083afSClemens Zeidler YTab* bottom = NULL); 68*21f083afSClemens Zeidler virtual Area* AddViewToTop(BView* view, Area* bottomArea, 69*21f083afSClemens Zeidler YTab* top = NULL, XTab* left = NULL, 70*21f083afSClemens Zeidler XTab* right = NULL); 71*21f083afSClemens Zeidler virtual Area* AddViewToBottom(BView* view, Area* topArea, 72*21f083afSClemens Zeidler YTab* bottom = NULL, XTab* left = NULL, 73*21f083afSClemens Zeidler XTab* right = NULL); 74*21f083afSClemens Zeidler 75*21f083afSClemens Zeidler virtual bool AddItem(BLayoutItem* item); 76*21f083afSClemens Zeidler virtual bool AddItem(int32 index, BLayoutItem* item); 77*21f083afSClemens Zeidler virtual Area* AddItem(BLayoutItem* item, XTab* left, 78*21f083afSClemens Zeidler YTab* top, XTab* right, YTab* bottom); 79*21f083afSClemens Zeidler virtual Area* AddItem(BLayoutItem* item, Row* row, 80*21f083afSClemens Zeidler Column* column); 81*21f083afSClemens Zeidler virtual Area* AddItemToRight(BLayoutItem* item, 82*21f083afSClemens Zeidler Area* leftArea, XTab* right = NULL, 83*21f083afSClemens Zeidler YTab* top = NULL, YTab* bottom = NULL); 84*21f083afSClemens Zeidler virtual Area* AddItemToLeft(BLayoutItem* item, 85*21f083afSClemens Zeidler Area* rightArea, XTab* left = NULL, 86*21f083afSClemens Zeidler YTab* top = NULL, YTab* bottom = NULL); 87*21f083afSClemens Zeidler virtual Area* AddItemToTop(BLayoutItem* item, 88*21f083afSClemens Zeidler Area* bottomArea, YTab* top = NULL, 89*21f083afSClemens Zeidler XTab* left = NULL, XTab* right = NULL); 90*21f083afSClemens Zeidler virtual Area* AddItemToBottom(BLayoutItem* item, 91*21f083afSClemens Zeidler Area* topArea, YTab* bottom = NULL, 92*21f083afSClemens Zeidler XTab* left = NULL, XTab* right = NULL); 93*21f083afSClemens Zeidler 94*21f083afSClemens Zeidler virtual Area* AreaOf(BView* control); 95*21f083afSClemens Zeidler 96*21f083afSClemens Zeidler virtual BSize BaseMinSize(); 97*21f083afSClemens Zeidler virtual BSize BaseMaxSize(); 98*21f083afSClemens Zeidler virtual BSize BasePreferredSize(); 99*21f083afSClemens Zeidler virtual BAlignment BaseAlignment(); 100*21f083afSClemens Zeidler 101*21f083afSClemens Zeidler virtual void InvalidateLayout(bool children = false); 102*21f083afSClemens Zeidler 103*21f083afSClemens Zeidler virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 104*21f083afSClemens Zeidler virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 105*21f083afSClemens Zeidler virtual void DerivedLayoutItems(); 106*21f083afSClemens Zeidler 1078d9b6ef4SClemens Zeidler private: 108*21f083afSClemens Zeidler /*! Add a view without initialize the Area. */ 109*21f083afSClemens Zeidler BLayoutItem* _CreateLayoutItem(BView* view); 110*21f083afSClemens Zeidler 1110871de7bSClemens Zeidler void _SolveLayout(); 1120871de7bSClemens Zeidler 1138d9b6ef4SClemens Zeidler Area* _AreaForItem(BLayoutItem* item) const; 1148d9b6ef4SClemens Zeidler void _UpdateAreaConstraints(); 1158d9b6ef4SClemens Zeidler 1160871de7bSClemens Zeidler BSize _CalculateMinSize(); 1170871de7bSClemens Zeidler BSize _CalculateMaxSize(); 1180871de7bSClemens Zeidler BSize _CalculatePreferredSize(); 1198d9b6ef4SClemens Zeidler 1208d9b6ef4SClemens Zeidler 1218d9b6ef4SClemens Zeidler LinearSpec fSolver; 1228d9b6ef4SClemens Zeidler 1238d9b6ef4SClemens Zeidler XTab* fLeft; 1248d9b6ef4SClemens Zeidler XTab* fRight; 1258d9b6ef4SClemens Zeidler YTab* fTop; 1268d9b6ef4SClemens Zeidler YTab* fBottom; 1278d9b6ef4SClemens Zeidler BSize fMinSize; 1288d9b6ef4SClemens Zeidler BSize fMaxSize; 1298d9b6ef4SClemens Zeidler BSize fPreferredSize; 1308d9b6ef4SClemens Zeidler char* fPerformancePath; 13196e2013eSClemens Zeidler 13296e2013eSClemens Zeidler float fInset; 13396e2013eSClemens Zeidler float fSpacing; 1348d9b6ef4SClemens Zeidler }; 1358d9b6ef4SClemens Zeidler 1368d9b6ef4SClemens Zeidler } // namespace BALM 1378d9b6ef4SClemens Zeidler 1388d9b6ef4SClemens Zeidler using BALM::BALMLayout; 1398d9b6ef4SClemens Zeidler 1408d9b6ef4SClemens Zeidler #endif // ALM_LAYOUT_H 141