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 <Referenceable.h> 10 #include <Rect.h> 11 #include <Size.h> 12 #include <String.h> 13 14 15 class BLayoutItem; 16 class BView; 17 18 19 namespace LinearProgramming { 20 class LinearSpec; 21 class Constraint; 22 }; 23 24 25 namespace BALM { 26 27 28 class Column; 29 class Row; 30 class XTab; 31 class YTab; 32 33 34 35 36 class RowColumnManager; 37 38 39 /** 40 * Rectangular area in the GUI, defined by a tab on each side. 41 */ 42 class Area { 43 public: 44 ~Area(); 45 46 int32 ID() const; 47 void SetID(int32 id); 48 49 BLayoutItem* Item(); 50 51 XTab* Left() const; 52 XTab* Right() const; 53 YTab* Top() const; 54 YTab* Bottom() const; 55 void SetLeft(XTab* left); 56 void SetRight(XTab* right); 57 void SetTop(YTab* top); 58 void SetBottom(YTab* bottom); 59 60 Row* GetRow() const; 61 Column* GetColumn() const; 62 63 double ContentAspectRatio() const; 64 void SetContentAspectRatio(double ratio); 65 66 BSize ShrinkPenalties() const; 67 BSize GrowPenalties() const; 68 void SetShrinkPenalties(BSize shrink); 69 void SetGrowPenalties(BSize grow); 70 71 void GetInsets(float* left, float* top, float* right, 72 float* bottom) const; 73 float LeftInset() const; 74 float TopInset() const; 75 float RightInset() const; 76 float BottomInset() const; 77 78 void SetInsets(float insets); 79 void SetInsets(float horizontal, float vertical); 80 void SetInsets(float left, float top, float right, 81 float bottom); 82 void SetLeftInset(float left); 83 void SetTopInset(float top); 84 void SetRightInset(float right); 85 void SetBottomInset(float bottom); 86 87 BString ToString() const; 88 89 LinearProgramming::Constraint* 90 SetWidthAs(Area* area, float factor = 1.0f); 91 92 LinearProgramming::Constraint* 93 SetHeightAs(Area* area, float factor = 1.0f); 94 95 void InvalidateSizeConstraints(); 96 97 BRect Frame() const; 98 99 private: 100 Area(BLayoutItem* item); 101 102 void _Init(LinearProgramming::LinearSpec* ls, 103 XTab* left, YTab* top, XTab* right, 104 YTab* bottom, RowColumnManager* manager); 105 void _Init(LinearProgramming::LinearSpec* ls, 106 Row* row, Column* column, 107 RowColumnManager* manager); 108 109 void _DoLayout(); 110 111 void _UpdateMinSizeConstraint(BSize min); 112 void _UpdateMaxSizeConstraint(BSize max); 113 private: 114 friend class BALMLayout; 115 friend class RowColumnManager; 116 117 BLayoutItem* fLayoutItem; 118 int32 fID; 119 120 LinearProgramming::LinearSpec* fLS; 121 122 BReference<XTab> fLeft; 123 BReference<XTab> fRight; 124 BReference<YTab> fTop; 125 BReference<YTab> fBottom; 126 127 Row* fRow; 128 Column* fColumn; 129 130 BSize fShrinkPenalties; 131 BSize fGrowPenalties; 132 133 BSize fLeftTopInset; 134 BSize fRightBottomInset; 135 136 double fContentAspectRatio; 137 RowColumnManager* fRowColumnManager; 138 139 LinearProgramming::Constraint* fMinContentWidth; 140 LinearProgramming::Constraint* fMaxContentWidth; 141 LinearProgramming::Constraint* fMinContentHeight; 142 LinearProgramming::Constraint* fMaxContentHeight; 143 LinearProgramming::Constraint* fContentAspectRatioC; 144 145 uint32 _reserved[2]; 146 }; 147 148 } // namespace BALM 149 150 using BALM::Area; 151 152 #endif // AREA_H 153 154