xref: /haiku/src/apps/icon-o-matic/gui/PathListView.h (revision 9ecf9d1c1d4888d341a6eac72112c72d1ae3a4cb)
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 PATH_LIST_VIEW_H
10 #define PATH_LIST_VIEW_H
11 
12 #include "ListViews.h"
13 #include "PathContainer.h"
14 
15 class CommandStack;
16 class VectorPath;
17 class PathListItem;
18 class Selection;
19 class Shape;
20 class ShapeContainer;
21 class ShapePathListener;
22 
23 class PathListView : public SimpleListView,
24 					 public PathContainerListener {
25  public:
26 								PathListView(BRect frame,
27 											 const char* name,
28 											 BMessage* selectionMessage = NULL,
29 											 BHandler* target = NULL);
30 	virtual						~PathListView();
31 
32 	// SimpleListView interface
33 	virtual	void				SelectionChanged();
34 
35 	virtual	void				MouseDown(BPoint where);
36 	virtual	void				MessageReceived(BMessage* message);
37 
38 	virtual	void				MakeDragMessage(BMessage* message) const;
39 
40 	virtual	bool				AcceptDragMessage(const BMessage* message) const;
41 	virtual	void				SetDropTargetRect(const BMessage* message,
42 												  BPoint where);
43 
44 	virtual	void				MoveItems(BList& items, int32 toIndex);
45 	virtual	void				CopyItems(BList& items, int32 toIndex);
46 	virtual	void				RemoveItemList(BList& items);
47 
48 	virtual	BListItem*			CloneItem(int32 atIndex) const;
49 
50 	// ShapeContainerListener interface
51 	virtual	void				PathAdded(VectorPath* path);
52 	virtual	void				PathRemoved(VectorPath* path);
53 
54 	// PathListView
55 			void				SetPathContainer(PathContainer* container);
56 			void				SetShapeContainer(ShapeContainer* container);
57 			void				SetSelection(Selection* selection);
58 			void				SetCommandStack(CommandStack* stack);
59 
60 			void				SetCurrentShape(Shape* shape);
61 			Shape*				CurrentShape() const
62 									{ return fCurrentShape; }
63 
64  private:
65 			bool				_AddPath(VectorPath* path);
66 			bool				_RemovePath(VectorPath* path);
67 
68 			PathListItem*		_ItemForPath(VectorPath* path) const;
69 
70 	friend class ShapePathListener;
71 			void				_UpdateMarks();
72 			void				_SetPathMarked(VectorPath* path, bool marked);
73 
74 			BMessage*			fMessage;
75 
76 			PathContainer*		fPathContainer;
77 			ShapeContainer*		fShapeContainer;
78 			Selection*			fSelection;
79 			CommandStack*		fCommandStack;
80 
81 			Shape*				fCurrentShape;
82 				// those path items will be marked that
83 				// are referenced by this shape
84 
85 			ShapePathListener*	fShapePathListener;
86 };
87 
88 #endif // PATH_LIST_VIEW_H
89