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