1 /* 2 * Copyright 2006 - 2010, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef AREA_H 6 #define AREA_H 7 8 9 #include <Alignment.h> 10 #include <List.h> 11 #include <Size.h> 12 #include <SupportDefs.h> 13 #include <View.h> 14 15 #include "Column.h" 16 #include "LinearSpec.h" 17 #include "Row.h" 18 #include "Tab.h" 19 20 21 class Constraint; 22 23 24 namespace BALM { 25 26 27 /** 28 * Rectangular area in the GUI, defined by a tab on each side. 29 */ 30 class Area { 31 public: 32 ~Area(); 33 34 BView* View(); 35 36 XTab* Left() const; 37 XTab* Right() const; 38 YTab* Top() const; 39 YTab* Bottom() const; 40 void SetLeft(XTab* left); 41 void SetRight(XTab* right); 42 void SetTop(YTab* top); 43 void SetBottom(YTab* bottom); 44 45 Row* GetRow() const; 46 Column* GetColumn() const; 47 void SetRow(Row* row); 48 void SetColumn(Column* column); 49 50 double ContentAspectRatio() const; 51 void SetContentAspectRatio(double ratio); 52 53 BSize ShrinkPenalties() const; 54 BSize GrowPenalties() const; 55 void SetShrinkPenalties(BSize shrink); 56 void SetGrowPenalties(BSize grow); 57 58 int32 LeftInset() const; 59 int32 TopInset() const; 60 int32 RightInset() const; 61 int32 BottomInset() const; 62 void SetLeftInset(int32 left); 63 void SetTopInset(int32 top); 64 void SetRightInset(int32 right); 65 void SetBottomInset(int32 bottom); 66 67 operator BString() const; 68 void GetString(BString& string) const; 69 70 Constraint* SetWidthAs(Area* area, float factor = 1.0f); 71 Constraint* SetHeightAs(Area* area, float factor = 1.0f); 72 73 void InvalidateSizeConstraints(); 74 75 private: 76 Area(BLayoutItem* item); 77 78 void _Init(LinearSpec* ls, XTab* left, YTab* top, 79 XTab* right, YTab* bottom); 80 void _Init(LinearSpec* ls, Row* row, Column* column); 81 82 void _DoLayout(); 83 84 void _UpdateMinSizeConstraint(BSize min); 85 void _UpdateMaxSizeConstraint(BSize max); 86 void _UpdatePreferredConstraint(BSize preferred); 87 88 private: 89 BLayoutItem* fLayoutItem; 90 91 LinearSpec* fLS; 92 93 XTab* fLeft; 94 XTab* fRight; 95 YTab* fTop; 96 YTab* fBottom; 97 98 Row* fRow; 99 Column* fColumn; 100 101 BSize fShrinkPenalties; 102 BSize fGrowPenalties; 103 104 BSize fTopLeftInset; 105 BSize fRightBottomInset; 106 107 BList fConstraints; 108 Constraint* fMinContentWidth; 109 Constraint* fMaxContentWidth; 110 Constraint* fMinContentHeight; 111 Constraint* fMaxContentHeight; 112 Constraint* fPreferredContentWidth; 113 Constraint* fPreferredContentHeight; 114 double fContentAspectRatio; 115 Constraint* fContentAspectRatioC; 116 117 public: 118 friend class BALMLayout; 119 120 }; 121 122 } // namespace BALM 123 124 using BALM::Area; 125 126 #endif // AREA_H 127 128