xref: /haiku/src/apps/icon-o-matic/generic/property/view/PropertyListView.h (revision 1acbe440b8dd798953bec31d18ee589aa3f71b73)
1 /*
2  * Copyright 2006, Haiku.
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 
18 class BClipboard;
19 class BMenu;
20 class BMenuItem;
21 class CommandStack;
22 class Property;
23 class PropertyItemView;
24 class PropertyObject;
25 class ScrollView;
26 class TabFilter;
27 
28 class 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 	// Scrollable interface
46 	virtual	void				ScrollOffsetChanged(BPoint oldOffset,
47 													BPoint newOffset);
48 
49 	// MouseWheelTarget interface
50 	virtual	bool				MouseWheelChanged(float x, float y) { return false; }
51 
52 	// PropertyListView
53 			void				SetTo(PropertyObject* object);
54 				// takes ownership of the object
55 	virtual	void				PropertyChanged(const Property* previous,
56 												const Property* current);
57 				// implement to know when a property changed
58 	virtual	void				PasteProperties(const PropertyObject* object);
59 				// implement to know when a property changed
60 	virtual	bool				IsEditingMultipleObjects();
61 
62 			void				SetMenu(BMenu* menu);
63 			::ScrollView*		ScrollView() const;
64 			void				UpdateStrings();
65 
66 	// interface for Property framework
67 			void				UpdateObject(uint32 propertyID);
68 
69 			bool				TabFocus(bool shift);
70 
71 			void				Select(PropertyItemView* item);
72 			void				DeselectAll();
73 
74 			void				Clicked(PropertyItemView* item);
75 			void				DoubleClicked(PropertyItemView* item);
76 
77  private:
78 			void				_UpdateSavedProperties();
79 
80 			bool				_AddItem(PropertyItemView* item);
81 			PropertyItemView*	_RemoveItem(int32 index);
82 			PropertyItemView*	_ItemAt(int32 index) const;
83 			int32				_CountItems() const;
84 
85 			void				_MakeEmpty();
86 
87 			BRect				_ItemsRect() const;
88 			void				_LayoutItems();
89 
90 			void				_CheckMenuStatus();
91 
92 			BClipboard*			fClipboard;
93 
94 			BMenu*				fSelectM;
95 			BMenuItem*			fSelectAllMI;
96 			BMenuItem*			fSelectNoneMI;
97 			BMenuItem*			fInvertSelectionMI;
98 
99 			BMenu*				fPropertyM;
100 			BMenuItem*			fCopyMI;
101 			BMenuItem*			fPasteMI;
102 
103 			PropertyObject*		fPropertyObject;
104 			PropertyObject*		fSavedProperties;
105 
106 			PropertyItemView*	fLastClickedItem;
107 
108 			bool				fSuspendUpdates;
109 
110 			MouseWheelFilter*	fMouseWheelFilter;
111 			TabFilter*			fTabFilter;
112 };
113 
114 #endif // PROPERTY_LIST_VIEW_H
115