xref: /haiku/src/apps/icon-o-matic/generic/property/view/PropertyListView.h (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
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 
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 #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 			void				UpdateStrings();
71 
72 	// interface for Property framework
73 			void				UpdateObject(uint32 propertyID);
74 
75 			bool				TabFocus(bool shift);
76 
77 			void				Select(PropertyItemView* item);
78 			void				DeselectAll();
79 
80 			void				Clicked(PropertyItemView* item);
81 			void				DoubleClicked(PropertyItemView* item);
82 
83 protected:
84 			PropertyItemView*	_ItemAt(int32 index) const;
85 			int32				_CountItems() const;
86 
87 private:
88 			void				_UpdateSavedProperties();
89 
90 			bool				_AddItem(PropertyItemView* item);
91 			PropertyItemView*	_RemoveItem(int32 index);
92 
93 			void				_MakeEmpty();
94 
95 			BRect				_ItemsRect() const;
96 			void				_LayoutItems();
97 
98 			void				_CheckMenuStatus();
99 
100 			BClipboard*			fClipboard;
101 
102 			BMenu*				fSelectM;
103 			BMenuItem*			fSelectAllMI;
104 			BMenuItem*			fSelectNoneMI;
105 			BMenuItem*			fInvertSelectionMI;
106 
107 			BMenu*				fPropertyM;
108 			BMenuItem*			fCopyMI;
109 			BMenuItem*			fPasteMI;
110 
111 			PropertyObject*		fPropertyObject;
112 			PropertyObject*		fSavedProperties;
113 
114 			PropertyItemView*	fLastClickedItem;
115 
116 			bool				fSuspendUpdates;
117 
118 			MouseWheelFilter*	fMouseWheelFilter;
119 			TabFilter*			fTabFilter;
120 };
121 
122 #endif // PROPERTY_LIST_VIEW_H
123