xref: /haiku/headers/os/interface/LayoutItem.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2006-2010, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_LAYOUT_ITEM_H
6 #define	_LAYOUT_ITEM_H
7 
8 
9 #include <Alignment.h>
10 #include <Archivable.h>
11 #include <Rect.h>
12 #include <Size.h>
13 
14 
15 class BLayout;
16 class BView;
17 
18 
19 class BLayoutItem : public BArchivable {
20 public:
21 								BLayoutItem();
22 								BLayoutItem(BMessage* from);
23 	virtual						~BLayoutItem();
24 
25 			BLayout*			Layout() const;
26 			bool				RemoveSelf();
27 
28 	virtual	BSize				MinSize() = 0;
29 	virtual	BSize				MaxSize() = 0;
30 	virtual	BSize				PreferredSize() = 0;
31 	virtual	BAlignment			Alignment() = 0;
32 
33 	virtual	void				SetExplicitMinSize(BSize size) = 0;
34 	virtual	void				SetExplicitMaxSize(BSize size) = 0;
35 	virtual	void				SetExplicitPreferredSize(BSize size) = 0;
36 			void				SetExplicitSize(BSize size);
37 	virtual	void				SetExplicitAlignment(BAlignment alignment) = 0;
38 
39 	virtual	bool				IsVisible() = 0;
40 	virtual	void				SetVisible(bool visible) = 0;
41 
42 	virtual	BRect				Frame() = 0;
43 	virtual	void				SetFrame(BRect frame) = 0;
44 
45 	virtual	bool				HasHeightForWidth();
46 	virtual	void				GetHeightForWidth(float width, float* min,
47 									float* max, float* preferred);
48 
49 	virtual	BView*				View();
50 
51 	virtual	void				InvalidateLayout(bool children = false);
52 	virtual	void				Relayout(bool immediate = false);
53 
54 			void*				LayoutData() const;
55 			void				SetLayoutData(void* data);
56 
57 			void				AlignInFrame(BRect frame);
58 
59 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
60 
61 	virtual status_t			Perform(perform_code d, void* arg);
62 
63 protected:
64 	// archiving methods
65 	virtual status_t			AllArchived(BMessage* into) const;
66 	virtual	status_t			AllUnarchived(const BMessage* from);
67 
68 	// hook methods
69 	virtual	void				LayoutInvalidated(bool children);
70 
71 	virtual	void				AttachedToLayout();
72 	virtual	void				DetachedFromLayout(BLayout* layout);
73 
74 	virtual void				AncestorVisibilityChanged(bool shown);
75 
76 private:
77 			void				SetLayout(BLayout* layout);
78 
79 	virtual	void				_ReservedLayoutItem1();
80 	virtual	void				_ReservedLayoutItem2();
81 	virtual	void				_ReservedLayoutItem3();
82 	virtual	void				_ReservedLayoutItem4();
83 	virtual	void				_ReservedLayoutItem5();
84 	virtual	void				_ReservedLayoutItem6();
85 	virtual	void				_ReservedLayoutItem7();
86 	virtual	void				_ReservedLayoutItem8();
87 	virtual	void				_ReservedLayoutItem9();
88 	virtual	void				_ReservedLayoutItem10();
89 
90 	// forbidden methods
91 								BLayoutItem(const BLayoutItem&);
92 			void				operator =(const BLayoutItem&);
93 
94 			friend class BLayout;
95 
96 			BLayout*			fLayout;
97 			void*				fLayoutData;
98 
99 			uint32				_reserved[5];
100 };
101 
102 
103 #endif	// _LAYOUT_ITEM_H
104