xref: /haiku/src/tests/kits/interface/layout/widget_layout_test/GroupView.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef WIDGET_LAYOUT_TEST_GROUP_VIEW_H
6 #define WIDGET_LAYOUT_TEST_GROUP_VIEW_H
7 
8 
9 #include "View.h"
10 
11 
12 // GroupView
13 class GroupView : public View {
14 public:
15 								GroupView(enum orientation orientation,
16 									int32 lineCount = 1);
17 	virtual						~GroupView();
18 
19 			void				SetSpacing(float horizontal, float vertical);
20 			void				SetInsets(float left, float top, float right,
21 									float bottom);
22 
23 	virtual	BSize 				MinSize();
24 	virtual	BSize 				MaxSize();
25 	virtual	BSize 				PreferredSize();
26 	virtual	BAlignment			Alignment();
27 
28 	virtual	void				InvalidateLayout();
29 	virtual	void				Layout();
30 
31 private:
32 	struct LayoutInfo;
33 
34 private:
35 			void				_ValidateMinMax();
36 			void				_LayoutLine(int32 size, LayoutInfo* infos,
37 									int32 infoCount);
38 
39 			BSize				_AddInsetsAndSpacing(BSize size);
40 			BSize				_SubtractInsetsAndSpacing(BSize size);
41 
42 			int32				_RowCount() const;
43 			int32				_ColumnCount() const;
44 			View*				_ChildAt(int32 column, int32 row) const;
45 
46 private:
47 			enum orientation	fOrientation;
48 			int32				fLineCount;
49 			float				fColumnSpacing;
50 			float				fRowSpacing;
51 			BRect				fInsets;
52 			bool				fMinMaxValid;
53 			int32				fMinWidth;
54 			int32				fMinHeight;
55 			int32				fMaxWidth;
56 			int32				fMaxHeight;
57 			int32				fPreferredWidth;
58 			int32				fPreferredHeight;
59 			LayoutInfo*			fColumnInfos;
60 			LayoutInfo*			fRowInfos;
61 			int32				fColumnCount;
62 			int32				fRowCount;
63 };
64 
65 
66 // Glue
67 class Glue : public View {
68 public:
69 								Glue();
70 };
71 
72 
73 // Strut
74 class Strut : public View {
75 public:
76 								Strut(float pixelWidth, float pixelHeight);
77 
78 	virtual	BSize				MinSize();
79 	virtual	BSize				MaxSize();
80 
81 private:
82 			BSize				fSize;
83 };
84 
85 
86 // HStrut
87 class HStrut : public Strut {
88 public:
89 								HStrut(float width);
90 };
91 
92 
93 // VStrut
94 class VStrut : public Strut {
95 public:
96 								VStrut(float height);
97 };
98 
99 
100 #endif	// WIDGET_LAYOUT_TEST_GROUP_VIEW_H
101