1 /* 2 * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz 3 * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz 4 * Distributed under the terms of the MIT License. 5 */ 6 7 #ifndef AREA_H 8 #define AREA_H 9 10 #include <Alignment.h> 11 #include <List.h> 12 #include <Size.h> 13 #include <SupportDefs.h> 14 #include <View.h> 15 16 #include "XTab.h" 17 #include "YTab.h" 18 #include "Area.h" 19 #include "Row.h" 20 #include "Column.h" 21 #include "Constraint.h" 22 23 24 namespace BALM { 25 26 class BALMLayout; 27 28 /** 29 * Rectangular area in the GUI, defined by a tab on each side. 30 */ 31 class Area { 32 33 public: 34 XTab* Left() const; 35 void SetLeft(XTab* left); 36 XTab* Right() const; 37 void SetRight(XTab* right); 38 YTab* Top() const; 39 void SetTop(YTab* top); 40 YTab* Bottom() const; 41 void SetBottom(YTab* bottom); 42 43 Row* GetRow() const; 44 void SetRow(Row* row); 45 Column* GetColumn() const; 46 void SetColumn(Column* column); 47 48 BView* Content() const; 49 void SetContent(BView* content); 50 XTab* ContentLeft() const; 51 YTab* ContentTop() const; 52 XTab* ContentRight() const; 53 YTab* ContentBottom() const; 54 BSize MinContentSize() const; 55 void SetMinContentSize(BSize min); 56 BSize MaxContentSize() const; 57 void SetMaxContentSize(BSize max); 58 BSize PreferredContentSize() const; 59 void SetPreferredContentSize(BSize preferred); 60 double ContentAspectRatio() const; 61 void SetContentAspectRatio(double ratio); 62 63 BSize ShrinkPenalties() const; 64 void SetShrinkPenalties(BSize shrink); 65 BSize GrowPenalties() const; 66 void SetGrowPenalties(BSize grow); 67 68 BAlignment Alignment() const; 69 void SetAlignment(BAlignment alignment); 70 void SetHorizontalAlignment(alignment horizontal); 71 void SetVerticalAlignment(vertical_alignment vertical); 72 73 int32 LeftInset() const; 74 void SetLeftInset(int32 left); 75 int32 TopInset() const; 76 void SetTopInset(int32 top); 77 int32 RightInset() const; 78 void SetRightInset(int32 right); 79 int32 BottomInset() const; 80 void SetBottomInset(int32 bottom); 81 82 void SetDefaultBehavior(); 83 bool AutoPreferredContentSize() const; 84 void SetAutoPreferredContentSize(bool value); 85 86 operator BString() const; 87 void GetString(BString& string) const; 88 89 Constraint* HasSameWidthAs(Area* area); 90 Constraint* HasSameHeightAs(Area* area); 91 BList* HasSameSizeAs(Area* area); 92 93 ~Area(); 94 95 protected: 96 Area(BALMLayout* ls, XTab* left, YTab* top, 97 XTab* right, YTab* bottom, 98 BView* content, 99 BSize minContentSize); 100 Area(BALMLayout* ls, Row* row, Column* column, 101 BView* content, 102 BSize minContentSize); 103 void DoLayout(); 104 105 private: 106 void InitChildArea(); 107 void UpdateHorizontal(); 108 void UpdateVertical(); 109 void Init(BALMLayout* ls, XTab* left, YTab* top, 110 XTab* right, YTab* bottom, 111 BView* content, 112 BSize minContentSize); 113 114 public: 115 static BSize kMaxSize; 116 static BSize kMinSize; 117 static BSize kUndefinedSize; 118 119 protected: 120 BView* fContent; 121 BList* fConstraints; 122 123 private: 124 BALMLayout* fLS; 125 XTab* fLeft; 126 XTab* fRight; 127 YTab* fTop; 128 YTab* fBottom; 129 Row* fRow; 130 Column* fColumn; 131 BSize fMinContentSize; 132 BSize fMaxContentSize; 133 Constraint* fMinContentWidth; 134 Constraint* fMaxContentWidth; 135 Constraint* fMinContentHeight; 136 Constraint* fMaxContentHeight; 137 BSize fPreferredContentSize; 138 BSize fShrinkPenalties; 139 BSize fGrowPenalties; 140 double fContentAspectRatio; 141 Constraint* fContentAspectRatioC; 142 bool fAutoPreferredContentSize; 143 Constraint* fPreferredContentWidth; 144 Constraint* fPreferredContentHeight; 145 Area* fChildArea; 146 BAlignment fAlignment; 147 int32 fLeftInset; 148 int32 fTopInset; 149 int32 fRightInset; 150 int32 fBottomInset; 151 Constraint* fLeftConstraint; 152 Constraint* fTopConstraint; 153 Constraint* fRightConstraint; 154 Constraint* fBottomConstraint; 155 156 public: 157 friend class BALMLayout; 158 159 }; 160 161 } // namespace BALM 162 163 using BALM::Area; 164 165 #endif // AREA_H 166 167