xref: /haiku/headers/os/interface/SplitView.h (revision 25a7b01d15612846f332751841da3579db313082)
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 									enum orientation orientation
17 										= B_HORIZONTAL,
18 									float spacing = B_USE_DEFAULT_SPACING);
19 								BSplitView(BMessage* from);
20 	virtual						~BSplitView();
21 
22 			void				SetInsets(float left, float top, float right,
23 									float bottom);
24 			void				SetInsets(float horizontal, float vertical);
25 			void				SetInsets(float insets);
26 			void				GetInsets(float* left, float* top,
27 									float* right, float* bottom) const;
28 
29 			float				Spacing() const;
30 			void				SetSpacing(float spacing);
31 
32 			orientation			Orientation() const;
33 			void				SetOrientation(enum orientation orientation);
34 
35 			float				SplitterSize() const;
36 			void				SetSplitterSize(float size);
37 
38 			int32				CountItems() const;
39 			float				ItemWeight(int32 index) const;
40 			float				ItemWeight(BLayoutItem* item) const;
41 			void				SetItemWeight(int32 index, float weight,
42 									bool invalidateLayout);
43 			void				SetItemWeight(BLayoutItem* item, float weight);
44 
45 			bool				IsCollapsible(int32 index) const;
46 			void				SetCollapsible(bool collapsible);
47 			void				SetCollapsible(int32 index, bool collapsible);
48 			void				SetCollapsible(int32 first, int32 last,
49 									bool collapsible);
50 
51 			bool				IsItemCollapsed(int32 index) const;
52 			void				SetItemCollapsed(int32 index, bool collapsed);
53 
54 //			void				AddChild(BView* child);
55 			void				AddChild(BView* child, BView* sibling = NULL);
56 			bool				AddChild(BView* child, float weight);
57 			bool				AddChild(int32 index, BView* child,
58 									float weight);
59 
60 			bool				AddChild(BLayoutItem* child);
61 			bool				AddChild(BLayoutItem* child, float weight);
62 			bool				AddChild(int32 index, BLayoutItem* child,
63 									float weight);
64 
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 									enum 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 									enum orientation orientation,
113 									bool pressed);
114 
115 private:
116 			BSplitLayout*		fSplitLayout;
117 			uint32				_reserved[3];
118 };
119 
120 
121 #endif	// _SPLIT_VIEW_H
122