xref: /haiku/headers/os/interface/SplitView.h (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2006-2015, 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				AttachedToWindow();
65 	virtual	void				Draw(BRect updateRect);
66 	virtual	void				DrawAfterChildren(BRect updateRect);
67 	virtual	void				MouseDown(BPoint where);
68 	virtual	void				MouseUp(BPoint where);
69 	virtual	void				MouseMoved(BPoint where, uint32 transit,
70 									const BMessage* message);
71 
72 	virtual	void				MessageReceived(BMessage* message);
73 
74 
75 	virtual	void				SetLayout(BLayout* layout);
76 									// overridden to avoid use
77 
78 	virtual status_t			Archive(BMessage* into, bool deep = true) const;
79 	static	BArchivable*		Instantiate(BMessage* from);
80 
81 	virtual	status_t			Perform(perform_code d, void* arg);
82 
83 protected:
84 	virtual	status_t			AllArchived(BMessage* into) const;
85 	virtual status_t			AllUnarchived(const BMessage* from);
86 
87 	virtual	void				DrawSplitter(BRect frame,
88 									const BRect& updateRect,
89 									orientation orientation,
90 									bool pressed);
91 
92 private:
93 
94 	// FBC padding
95 	virtual	void				_ReservedSplitView1();
96 	virtual	void				_ReservedSplitView2();
97 	virtual	void				_ReservedSplitView3();
98 	virtual	void				_ReservedSplitView4();
99 	virtual	void				_ReservedSplitView5();
100 	virtual	void				_ReservedSplitView6();
101 	virtual	void				_ReservedSplitView7();
102 	virtual	void				_ReservedSplitView8();
103 	virtual	void				_ReservedSplitView9();
104 	virtual	void				_ReservedSplitView10();
105 
106 	// forbidden methods
107 								BSplitView(const BSplitView&);
108 			void				operator =(const BSplitView&);
109 
110 	static	void				_DrawDefaultSplitter(BView* view, BRect frame,
111 									const BRect& updateRect,
112 									orientation orientation,
113 									bool pressed);
114 
115 private:
116 			BSplitLayout*		fSplitLayout;
117 			uint32				_reserved[3];
118 };
119 
120 
121 #endif	// _SPLIT_VIEW_H
122