xref: /haiku/headers/os/interface/LayoutItem.h (revision 323b65468e5836bb27a5e373b14027d902349437)
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 
27 	virtual	BSize				MinSize() = 0;
28 	virtual	BSize				MaxSize() = 0;
29 	virtual	BSize				PreferredSize() = 0;
30 	virtual	BAlignment			Alignment() = 0;
31 
32 	virtual	void				SetExplicitMinSize(BSize size) = 0;
33 	virtual	void				SetExplicitMaxSize(BSize size) = 0;
34 	virtual	void				SetExplicitPreferredSize(BSize size) = 0;
35 	virtual	void				SetExplicitAlignment(BAlignment alignment) = 0;
36 
37 	virtual	bool				IsVisible() = 0;
38 	virtual	void				SetVisible(bool visible) = 0;
39 
40 	virtual	BRect				Frame() = 0;
41 	virtual	void				SetFrame(BRect frame) = 0;
42 
43 	virtual	bool				HasHeightForWidth();
44 	virtual	void				GetHeightForWidth(float width, float* min,
45 									float* max, float* preferred);
46 
47 	virtual	BView*				View();
48 
49 	virtual	void				InvalidateLayout(bool children = false);
50 	virtual	void				Relayout(bool immediate = false);
51 
52 			void*				LayoutData() const;
53 			void				SetLayoutData(void* data);
54 
55 			void				AlignInFrame(BRect frame);
56 
57 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
58 	virtual status_t			AllArchived(BMessage* into) const;
59 	virtual	status_t			AllUnarchived(const BMessage* from);
60 
61 protected:
62 
63 			void				SetLayout(BLayout* layout);
64 
65 	// hook methods
66 	virtual	void				AttachedToLayout();
67 	virtual	void				DetachedFromLayout(BLayout* layout);
68 
69 	virtual void				AncestorVisibilityChanged(bool shown);
70 
71 private:
72 			friend class BLayout;
73 
74 			BLayout*			fLayout;
75 			void*				fLayoutData;
76 };
77 
78 
79 #endif	// _LAYOUT_ITEM_H
80