tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / SplitLayout.h
bloba570bf153dc7436031bc2b34f8682196366ef196
1 /*
2 * Copyright 2006-2010, Haiku Inc.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _SPLIT_LAYOUT_H
6 #define _SPLIT_LAYOUT_H
9 #include <AbstractLayout.h>
10 #include <Point.h>
13 namespace BPrivate {
14 namespace Layout {
15 class Layouter;
16 class LayoutInfo;
20 using BPrivate::Layout::Layouter;
21 using BPrivate::Layout::LayoutInfo;
24 class BSplitLayout : public BAbstractLayout {
25 public:
26 BSplitLayout(orientation orientation,
27 float spacing = 0.0f);
28 BSplitLayout(BMessage* from);
29 virtual ~BSplitLayout();
31 void SetInsets(float left, float top, float right,
32 float bottom);
33 void GetInsets(float* left, float* top, float* right,
34 float* bottom) const;
36 float Spacing() const;
37 void SetSpacing(float spacing);
39 orientation Orientation() const;
40 void SetOrientation(orientation orientation);
42 float SplitterSize() const;
43 void SetSplitterSize(float size);
45 virtual BLayoutItem* AddView(BView* child);
46 virtual BLayoutItem* AddView(int32 index, BView* child);
47 virtual BLayoutItem* AddView(BView* child, float weight);
48 virtual BLayoutItem* AddView(int32 index, BView* child,
49 float weight);
51 virtual bool AddItem(BLayoutItem* item);
52 virtual bool AddItem(int32 index, BLayoutItem* item);
53 virtual bool AddItem(BLayoutItem* item, float weight);
54 virtual bool AddItem(int32 index, BLayoutItem* item,
55 float weight);
58 float ItemWeight(int32 index) const;
59 float ItemWeight(BLayoutItem* item) const;
60 void SetItemWeight(int32 index, float weight,
61 bool invalidateLayout);
62 void SetItemWeight(BLayoutItem* item, float weight);
64 bool IsCollapsible(int32 index) const;
65 void SetCollapsible(bool collapsible);
66 void SetCollapsible(int32 index, bool collapsible);
67 void SetCollapsible(int32 first, int32 last,
68 bool collapsible);
70 bool IsItemCollapsed(int32 index) const;
71 void SetItemCollapsed(int32 index, bool visible);
73 virtual BSize BaseMinSize();
74 virtual BSize BaseMaxSize();
75 virtual BSize BasePreferredSize();
76 virtual BAlignment BaseAlignment();
78 virtual bool HasHeightForWidth();
79 virtual void GetHeightForWidth(float width, float* min,
80 float* max, float* preferred);
82 virtual void LayoutInvalidated(bool children);
83 virtual void DoLayout();
85 // interface for BSplitView
86 BRect SplitterItemFrame(int32 index) const;
87 bool IsAboveSplitter(const BPoint& point) const;
89 bool StartDraggingSplitter(BPoint point);
90 bool DragSplitter(BPoint point);
91 bool StopDraggingSplitter();
92 int32 DraggedSplitter() const;
94 // archiving methods
95 virtual status_t Archive(BMessage* into, bool deep = true) const;
96 static BArchivable* Instantiate(BMessage* from);
98 virtual status_t ItemArchived(BMessage* into, BLayoutItem* item,
99 int32 index) const;
100 virtual status_t ItemUnarchived(const BMessage* from,
101 BLayoutItem* item, int32 index);
103 protected:
104 virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
105 virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
107 private:
108 class ItemLayoutInfo;
109 class ValueRange;
110 class SplitterItem;
112 void _InvalidateLayout(bool invalidateView,
113 bool children = false);
114 void _InvalidateCachedHeightForWidth();
116 SplitterItem* _SplitterItemAt(const BPoint& point,
117 int32* index = NULL) const;
118 SplitterItem* _SplitterItemAt(int32 index) const;
120 void _GetSplitterValueRange(int32 index,
121 ValueRange& range);
122 int32 _SplitterValue(int32 index) const;
124 void _LayoutItem(BLayoutItem* item, BRect frame,
125 bool visible);
126 void _LayoutItem(BLayoutItem* item,
127 ItemLayoutInfo* info);
129 bool _SetSplitterValue(int32 index, int32 value);
131 ItemLayoutInfo* _ItemLayoutInfo(BLayoutItem* item) const;
134 void _UpdateSplitterWeights();
136 void _ValidateMinMax();
138 void _InternalGetHeightForWidth(float width,
139 bool realLayout, float* minHeight,
140 float* maxHeight, float* preferredHeight);
142 float _SplitterSpace() const;
144 BSize _AddInsets(BSize size);
145 void _AddInsets(float* minHeight, float* maxHeight,
146 float* preferredHeight);
147 BSize _SubtractInsets(BSize size);
149 private:
150 orientation fOrientation;
151 float fLeftInset;
152 float fRightInset;
153 float fTopInset;
154 float fBottomInset;
155 float fSplitterSize;
156 float fSpacing;
158 BList fSplitterItems;
159 BList fVisibleItems;
161 BSize fMin;
162 BSize fMax;
163 BSize fPreferred;
165 Layouter* fHorizontalLayouter;
166 Layouter* fVerticalLayouter;
168 LayoutInfo* fHorizontalLayoutInfo;
169 LayoutInfo* fVerticalLayoutInfo;
171 BList fHeightForWidthItems;
172 // Incorporates the children's height for width constraints for a
173 // concrete width. Cloned lazily from fVerticalLayout when needed.
174 Layouter* fHeightForWidthVerticalLayouter;
175 LayoutInfo* fHeightForWidthHorizontalLayoutInfo;
176 // for computing height for width info
178 bool fLayoutValid;
180 float fCachedHeightForWidthWidth;
181 float fHeightForWidthVerticalLayouterWidth;
182 float fCachedMinHeightForWidth;
183 float fCachedMaxHeightForWidth;
184 float fCachedPreferredHeightForWidth;
186 BPoint fDraggingStartPoint;
187 int32 fDraggingStartValue;
188 int32 fDraggingCurrentValue;
189 int32 fDraggingSplitterIndex;
192 #endif // _SPLIT_LAYOUT_H