xref: /haiku/src/tests/kits/interface/layout/widget_layout_test/GroupView.h (revision a5b50d1fadc9ac0a86bae715ba325818d196ff30)
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				Layout();
29 
30 private:
31 	struct LayoutInfo;
32 
33 private:
34 			void				_ValidateMinMax();
35 			void				_LayoutLine(int32 size, LayoutInfo* infos,
36 									int32 infoCount);
37 
38 			BSize				_AddInsetsAndSpacing(BSize size);
39 			BSize				_SubtractInsetsAndSpacing(BSize size);
40 
41 			int32				_RowCount() const;
42 			int32				_ColumnCount() const;
43 			View*				_ChildAt(int32 column, int32 row) const;
44 
45 private:
46 			enum orientation	fOrientation;
47 			int32				fLineCount;
48 			float				fColumnSpacing;
49 			float				fRowSpacing;
50 			BRect				fInsets;
51 			bool				fMinMaxValid;
52 			int32				fMinWidth;
53 			int32				fMinHeight;
54 			int32				fMaxWidth;
55 			int32				fMaxHeight;
56 			int32				fPreferredWidth;
57 			int32				fPreferredHeight;
58 			LayoutInfo*			fColumnInfos;
59 			LayoutInfo*			fRowInfos;
60 			int32				fColumnCount;
61 			int32				fRowCount;
62 };
63 
64 
65 // Glue
66 class Glue : public View {
67 public:
68 								Glue();
69 };
70 
71 
72 // Strut
73 class Strut : public View {
74 public:
75 								Strut(float pixelWidth, float pixelHeight);
76 
77 	virtual	BSize				MinSize();
78 	virtual	BSize				MaxSize();
79 
80 private:
81 			BSize				fSize;
82 };
83 
84 
85 // HStrut
86 class HStrut : public Strut {
87 public:
88 								HStrut(float width);
89 };
90 
91 
92 // VStrut
93 class VStrut : public Strut {
94 public:
95 								VStrut(float height);
96 };
97 
98 
99 #endif	// WIDGET_LAYOUT_TEST_GROUP_VIEW_H
100