1/*
2 * Copyright 2006-2007, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus <superstippi@gmx.de>
7 */
8
9#ifndef PROPERTY_LIST_VIEW_H
10#define PROPERTY_LIST_VIEW_H
11
12#include <List.h>
13#include <View.h>
14
15#include "MouseWheelFilter.h"
16#include "Scrollable.h"
17
18class BClipboard;
19class BMenu;
20class BMenuItem;
21class CommandStack;
22class Property;
23class PropertyItemView;
24class PropertyObject;
25class ScrollView;
26class TabFilter;
27
28class PropertyListView : public BView,
29						 public Scrollable,
30						 private BList,
31						 public MouseWheelTarget {
32 public:
33								PropertyListView();
34	virtual						~PropertyListView();
35
36	// BView interface
37	virtual	void				AttachedToWindow();
38	virtual	void				DetachedFromWindow();
39	virtual	void				FrameResized(float width, float height);
40	virtual	void				Draw(BRect updateRect);
41	virtual	void				MakeFocus(bool focus);
42	virtual	void				MouseDown(BPoint where);
43	virtual	void				MessageReceived(BMessage* message);
44
45#ifdef __HAIKU__
46	virtual	BSize				MinSize();
47	virtual	BSize				MaxSize();
48	virtual	BSize				PreferredSize();
49#endif
50
51	// Scrollable interface
52	virtual	void				ScrollOffsetChanged(BPoint oldOffset,
53													BPoint newOffset);
54
55	// MouseWheelTarget interface
56	virtual	bool				MouseWheelChanged(float x, float y) { return false; }
57
58	// PropertyListView
59			void				SetTo(PropertyObject* object);
60				// takes ownership of the object
61	virtual	void				PropertyChanged(const Property* previous,
62												const Property* current);
63				// implement to know when a property changed
64	virtual	void				PasteProperties(const PropertyObject* object);
65				// implement to know when a property changed
66	virtual	bool				IsEditingMultipleObjects();
67
68			void				SetMenu(BMenu* menu);
69			::ScrollView*		ScrollView() const;
70
71	// interface for Property framework
72			void				UpdateObject(uint32 propertyID);
73
74			bool				TabFocus(bool shift);
75
76			void				Select(PropertyItemView* item);
77			void				DeselectAll();
78
79			void				Clicked(PropertyItemView* item);
80			void				DoubleClicked(PropertyItemView* item);
81
82protected:
83			PropertyItemView*	_ItemAt(int32 index) const;
84			int32				_CountItems() const;
85
86private:
87			void				_UpdateSavedProperties();
88
89			bool				_AddItem(PropertyItemView* item);
90			PropertyItemView*	_RemoveItem(int32 index);
91
92			void				_MakeEmpty();
93
94			BRect				_ItemsRect() const;
95			void				_LayoutItems();
96
97			void				_CheckMenuStatus();
98
99			BClipboard*			fClipboard;
100
101			BMenu*				fSelectM;
102			BMenuItem*			fSelectAllMI;
103			BMenuItem*			fSelectNoneMI;
104			BMenuItem*			fInvertSelectionMI;
105
106			BMenu*				fPropertyM;
107			BMenuItem*			fCopyMI;
108			BMenuItem*			fPasteMI;
109
110			PropertyObject*		fPropertyObject;
111			PropertyObject*		fSavedProperties;
112
113			PropertyItemView*	fLastClickedItem;
114
115			bool				fSuspendUpdates;
116
117			MouseWheelFilter*	fMouseWheelFilter;
118			TabFilter*			fTabFilter;
119};
120
121#endif // PROPERTY_LIST_VIEW_H
122