vfs: check userland buffers before reading them.
[haiku.git] / headers / libs / alm / Area.h
blobe5a3c02a3a231336d2ec73361a003a8d3183e6b3
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
9 #include <Referenceable.h>
10 #include <Rect.h>
11 #include <Size.h>
12 #include <String.h>
15 class BLayoutItem;
16 class BView;
19 namespace LinearProgramming {
20 class LinearSpec;
21 class Constraint;
24 namespace BPrivate {
25 class SharedSolver;
29 namespace BALM {
32 class Column;
33 class Row;
34 class XTab;
35 class YTab;
40 class RowColumnManager;
43 /**
44 * Rectangular area in the GUI, defined by a tab on each side.
46 class Area {
47 public:
48 ~Area();
50 int32 ID() const;
51 void SetID(int32 id);
53 BLayoutItem* Item();
55 XTab* Left() const;
56 XTab* Right() const;
57 YTab* Top() const;
58 YTab* Bottom() const;
59 void SetLeft(BReference<XTab> left);
60 void SetRight(BReference<XTab> right);
61 void SetTop(BReference<YTab> top);
62 void SetBottom(BReference<YTab> bottom);
64 Row* GetRow() const;
65 Column* GetColumn() const;
67 double ContentAspectRatio() const;
68 void SetContentAspectRatio(double ratio);
70 BSize ShrinkPenalties() const;
71 BSize GrowPenalties() const;
72 void SetShrinkPenalties(BSize shrink);
73 void SetGrowPenalties(BSize grow);
75 void GetInsets(float* left, float* top, float* right,
76 float* bottom) const;
77 float LeftInset() const;
78 float TopInset() const;
79 float RightInset() const;
80 float BottomInset() const;
82 void SetInsets(float insets);
83 void SetInsets(float horizontal, float vertical);
84 void SetInsets(float left, float top, float right,
85 float bottom);
86 void SetLeftInset(float left);
87 void SetTopInset(float top);
88 void SetRightInset(float right);
89 void SetBottomInset(float bottom);
91 BString ToString() const;
93 LinearProgramming::Constraint*
94 SetWidthAs(Area* area, float factor = 1.0f);
96 LinearProgramming::Constraint*
97 SetHeightAs(Area* area, float factor = 1.0f);
99 void InvalidateSizeConstraints();
101 BRect Frame() const;
103 private:
104 Area(BLayoutItem* item);
106 void _Init(LinearProgramming::LinearSpec* ls,
107 XTab* left, YTab* top, XTab* right,
108 YTab* bottom, RowColumnManager* manager);
109 void _Init(LinearProgramming::LinearSpec* ls,
110 Row* row, Column* column,
111 RowColumnManager* manager);
113 void _DoLayout(const BPoint& offset);
115 void _UpdateMinSizeConstraint(BSize min);
116 void _UpdateMaxSizeConstraint(BSize max);
117 private:
118 friend class BALMLayout;
119 friend class RowColumnManager;
120 friend class BPrivate::SharedSolver;
122 BLayoutItem* fLayoutItem;
123 int32 fID;
125 LinearProgramming::LinearSpec* fLS;
127 BReference<XTab> fLeft;
128 BReference<XTab> fRight;
129 BReference<YTab> fTop;
130 BReference<YTab> fBottom;
132 Row* fRow;
133 Column* fColumn;
135 BSize fShrinkPenalties;
136 BSize fGrowPenalties;
138 BSize fLeftTopInset;
139 BSize fRightBottomInset;
141 double fContentAspectRatio;
142 RowColumnManager* fRowColumnManager;
144 LinearProgramming::Constraint* fMinContentWidth;
145 LinearProgramming::Constraint* fMaxContentWidth;
146 LinearProgramming::Constraint* fMinContentHeight;
147 LinearProgramming::Constraint* fMaxContentHeight;
148 LinearProgramming::Constraint* fContentAspectRatioC;
150 uint32 _reserved[2];
153 } // namespace BALM
155 using BALM::Area;
157 #endif // AREA_H