xref: /haiku/headers/os/interface/SplitView.h (revision 5e96d7d537fbec23bad4ae9b4c8e7b02e769f0c6)
1 /*
2  * Copyright 2006-2010, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	_SPLIT_VIEW_H
6 #define	_SPLIT_VIEW_H
7 
8 #include <View.h>
9 
10 class BSplitLayout;
11 
12 
13 class BSplitView : public BView {
14 public:
15 								BSplitView(
16 									orientation orientation = B_HORIZONTAL,
17 									float spacing = B_USE_DEFAULT_SPACING);
18 								BSplitView(BMessage* from);
19 	virtual						~BSplitView();
20 
21 			void				SetInsets(float left, float top, float right,
22 									float bottom);
23 			void				SetInsets(float horizontal, float vertical);
24 			void				SetInsets(float insets);
25 			void				GetInsets(float* left, float* top,
26 									float* right, float* bottom) const;
27 
28 			float				Spacing() const;
29 			void				SetSpacing(float spacing);
30 
31 			orientation			Orientation() const;
32 			void				SetOrientation(orientation orientation);
33 
34 			float				SplitterSize() const;
35 			void				SetSplitterSize(float size);
36 
37 			int32				CountItems() const;
38 			float				ItemWeight(int32 index) const;
39 			float				ItemWeight(BLayoutItem* item) const;
40 			void				SetItemWeight(int32 index, float weight,
41 									bool invalidateLayout);
42 			void				SetItemWeight(BLayoutItem* item, float weight);
43 
44 			bool				IsCollapsible(int32 index) const;
45 			void				SetCollapsible(bool collapsible);
46 			void				SetCollapsible(int32 index, bool collapsible);
47 			void				SetCollapsible(int32 first, int32 last,
48 									bool collapsible);
49 
50 			bool				IsItemCollapsed(int32 index) const;
51 			void				SetItemCollapsed(int32 index, bool collapsed);
52 
53 //			void				AddChild(BView* child);
54 			void				AddChild(BView* child, BView* sibling = NULL);
55 			bool				AddChild(BView* child, float weight);
56 			bool				AddChild(int32 index, BView* child,
57 									float weight);
58 
59 			bool				AddChild(BLayoutItem* child);
60 			bool				AddChild(BLayoutItem* child, float weight);
61 			bool				AddChild(int32 index, BLayoutItem* child,
62 									float weight);
63 
64 	virtual	void				Draw(BRect updateRect);
65 	virtual	void				DrawAfterChildren(BRect updateRect);
66 	virtual	void				MouseDown(BPoint where);
67 	virtual	void				MouseUp(BPoint where);
68 	virtual	void				MouseMoved(BPoint where, uint32 transit,
69 									const BMessage* message);
70 
71 	virtual	void				MessageReceived(BMessage* message);
72 
73 
74 	virtual	void				SetLayout(BLayout* layout);
75 									// overridden to avoid use
76 
77 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
78 	static	BArchivable*		Instantiate(BMessage* from);
79 
80 	virtual	status_t			Perform(perform_code d, void* arg);
81 
82 protected:
83 	virtual	status_t			AllArchived(BMessage* into) const;
84 	virtual status_t			AllUnarchived(const BMessage* from);
85 
86 	virtual	void				DrawSplitter(BRect frame,
87 									const BRect& updateRect,
88 									orientation orientation,
89 									bool pressed);
90 
91 private:
92 
93 	// FBC padding
94 	virtual	void				_ReservedSplitView1();
95 	virtual	void				_ReservedSplitView2();
96 	virtual	void				_ReservedSplitView3();
97 	virtual	void				_ReservedSplitView4();
98 	virtual	void				_ReservedSplitView5();
99 	virtual	void				_ReservedSplitView6();
100 	virtual	void				_ReservedSplitView7();
101 	virtual	void				_ReservedSplitView8();
102 	virtual	void				_ReservedSplitView9();
103 	virtual	void				_ReservedSplitView10();
104 
105 	// forbidden methods
106 								BSplitView(const BSplitView&);
107 			void				operator =(const BSplitView&);
108 
109 	static	void				_DrawDefaultSplitter(BView* view, BRect frame,
110 									const BRect& updateRect,
111 									orientation orientation,
112 									bool pressed);
113 
114 private:
115 			BSplitLayout*		fSplitLayout;
116 			uint32				_reserved[3];
117 };
118 
119 
120 #endif	// _SPLIT_VIEW_H
121