1 #ifndef AREA_H 2 #define AREA_H 3 4 #include "Constraint.h" 5 #include "SoftConstraint.h" 6 7 #include <Alignment.h> 8 #include <List.h> 9 #include <Size.h> 10 #include <SupportDefs.h> 11 #include <View.h> 12 13 14 namespace BALM { 15 16 class Column; 17 class BALMLayout; 18 class Row; 19 class XTab; 20 class YTab; 21 22 /** 23 * Rectangular area in the GUI, defined by a tab on each side. 24 */ 25 class Area { 26 27 public: 28 bool AutoPrefContentSize() const; 29 void SetAutoPrefContentSize(bool value); 30 XTab* Left() const; 31 void SetLeft(XTab* left); 32 XTab* Right() const; 33 void SetRight(XTab* right); 34 YTab* Top() const; 35 void SetTop(YTab* top); 36 YTab* Bottom() const; 37 void SetBottom(YTab* bottom); 38 Row* GetRow() const; 39 void SetRow(Row* row); 40 Column* GetColumn() const; 41 void SetColumn(Column* column); 42 BView* Content() const; 43 void SetContent(BView* content); 44 XTab* ContentLeft() const; 45 YTab* ContentTop() const; 46 XTab* ContentRight() const; 47 YTab* ContentBottom() const; 48 BSize MinContentSize() const; 49 void SetMinContentSize(BSize min); 50 BSize MaxContentSize() const; 51 void SetMaxContentSize(BSize max); 52 BSize PrefContentSize() const; 53 void SetPrefContentSize(BSize pref); 54 BSize ShrinkRigidity() const; 55 void SetShrinkRigidity(BSize shrink); 56 BSize ExpandRigidity() const; 57 void SetExpandRigidity(BSize expand); 58 double ContentAspectRatio() const; 59 void SetContentAspectRatio(double ratio); 60 BAlignment Alignment() const; 61 void SetAlignment(BAlignment alignment); 62 void SetHAlignment(alignment horizontal); 63 void SetVAlignment(vertical_alignment vertical); 64 int32 LeftInset() const; 65 void SetLeftInset(int32 left); 66 int32 TopInset() const; 67 void SetTopInset(int32 top); 68 int32 RightInset() const; 69 void SetRightInset(int32 right); 70 int32 BottomInset() const; 71 void SetBottomInset(int32 bottom); 72 void SetDefaultPrefContentSize(); 73 //~ string ToString(); 74 Constraint* HasSameWidthAs(Area* area); 75 Constraint* HasSameHeightAs(Area* area); 76 BList* HasSameSizetAs(Area* area); 77 ~Area(); 78 79 protected: 80 Area(BALMLayout* ls, XTab* left, YTab* top, 81 XTab* right, YTab* bottom, 82 BView* content, 83 BSize minContentSize); 84 Area(BALMLayout* ls, Row* row, Column* column, 85 BView* content, 86 BSize minContentSize); 87 void DoLayout(); 88 89 private: 90 void InitChildArea(); 91 void UpdateHorizontal(); 92 void UpdateVertical(); 93 void Init(BALMLayout* ls, XTab* left, YTab* top, 94 XTab* right, YTab* bottom, 95 BView* content, 96 BSize minContentSize); 97 98 public: 99 static BSize kMaxSize; 100 static BSize kMinSize; 101 static BSize kUndefinedSize; 102 103 protected: 104 BView* fContent; 105 BList* fConstraints; 106 107 private: 108 BALMLayout* fLS; 109 XTab* fLeft; 110 XTab* fRight; 111 YTab* fTop; 112 YTab* fBottom; 113 Row* fRow; 114 Column* fColumn; 115 BSize fMinContentSize; 116 BSize fMaxContentSize; 117 Constraint* fMinContentWidth; 118 Constraint* fMaxContentWidth; 119 Constraint* fMinContentHeight; 120 Constraint* fMaxContentHeight; 121 BSize fPrefContentSize; 122 BSize fShrinkRigidity; 123 BSize fExpandRigidity; 124 double fContentAspectRatio; 125 Constraint* fContentAspectRatioC; 126 bool fAutoPrefContentSize; 127 SoftConstraint* fPrefContentWidth; 128 SoftConstraint* fPrefContentHeight; 129 Area* fChildArea; 130 BAlignment fAlignment; 131 int32 fLeftInset; 132 int32 fTopInset; 133 int32 fRightInset; 134 int32 fBottomInset; 135 Constraint* fLeftConstraint; 136 Constraint* fTopConstraint; 137 Constraint* fRightConstraint; 138 Constraint* fBottomConstraint; 139 140 public: 141 friend class BALMLayout; 142 143 }; 144 145 } // namespace BALM 146 147 using BALM::Area; 148 149 #endif // AREA_H 150