xref: /haiku/src/apps/icon-o-matic/gui/PathListView.h (revision 445d4fd926c569e7b9ae28017da86280aaecbae2)
1 /*
2  * Copyright 2006-2007, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 #ifndef PATH_LIST_VIEW_H
9 #define PATH_LIST_VIEW_H
10 
11 
12 #include "ListViews.h"
13 #include "PathContainer.h"
14 
15 
16 class BMenu;
17 class BMenuItem;
18 
19 _BEGIN_ICON_NAMESPACE
20 	class VectorPath;
21 	class PathSourceShape;
22 	class Shape;
23 	class ShapeContainer;
24 _END_ICON_NAMESPACE
25 
26 class CommandStack;
27 class PathListItem;
28 class Selection;
29 class ShapePathListener;
30 
31 
32 _USING_ICON_NAMESPACE
33 
34 
35 class PathListView : public SimpleListView,
36 					 public PathContainerListener {
37  public:
38 								PathListView(BRect frame,
39 											 const char* name,
40 											 BMessage* selectionMessage = NULL,
41 											 BHandler* target = NULL);
42 	virtual						~PathListView();
43 
44 	// SimpleListView interface
45 	virtual	void				SelectionChanged();
46 
47 	virtual	void				MouseDown(BPoint where);
48 	virtual	void				MessageReceived(BMessage* message);
49 
50 	virtual	void				MakeDragMessage(BMessage* message) const;
51 
52 	virtual	bool				AcceptDragMessage(const BMessage* message) const;
53 	virtual	void				SetDropTargetRect(const BMessage* message,
54 									BPoint where);
55 	virtual	bool				HandleDropMessage(const BMessage* message,
56 									int32 dropIndex);
57 
58 	virtual	void				MoveItems(BList& items, int32 toIndex);
59 	virtual	void				CopyItems(BList& items, int32 toIndex);
60 	virtual	void				RemoveItemList(BList& items);
61 
62 	virtual	BListItem*			CloneItem(int32 atIndex) const;
63 
64 	virtual	int32				IndexOfSelectable(Selectable* selectable) const;
65 	virtual	Selectable*			SelectableFor(BListItem* item) const;
66 
67 	// ShapeContainerListener interface
68 	virtual	void				PathAdded(VectorPath* path, int32 index);
69 	virtual	void				PathRemoved(VectorPath* path);
70 
71 	// PathListView
72 			void				SetPathContainer(PathContainer* container);
73 			void				SetShapeContainer(ShapeContainer* container);
74 			void				SetCommandStack(CommandStack* stack);
75 			void				SetMenu(BMenu* menu);
76 
77 			void				SetCurrentShape(Shape* shape);
78 			PathSourceShape*	CurrentShape() const
79 									{ return fCurrentShape; }
80 
81  private:
82 			bool				_AddPath(VectorPath* path, int32 index);
83 			bool				_RemovePath(VectorPath* path);
84 
85 			PathListItem*		_ItemForPath(VectorPath* path) const;
86 
87 	friend class ShapePathListener;
88 			void				_UpdateMarks();
89 			void				_SetPathMarked(VectorPath* path, bool marked);
90 			void				_UpdateMenu();
91 
92 			BMessage*			fMessage;
93 
94 			BMenu*				fMenu;
95 			BMenuItem*			fAddMI;
96 			BMenuItem*			fAddRectMI;
97 			BMenuItem*			fAddCircleMI;
98 			BMenuItem*			fAddArcMI;
99 			BMenuItem*			fDuplicateMI;
100 			BMenuItem*			fReverseMI;
101 			BMenuItem*			fCleanUpMI;
102 			BMenuItem*			fRotateIndicesLeftMI;
103 			BMenuItem*			fRotateIndicesRightMI;
104 			BMenuItem*			fRemoveMI;
105 
106 			PathContainer*		fPathContainer;
107 			ShapeContainer*		fShapeContainer;
108 			CommandStack*		fCommandStack;
109 
110 			PathSourceShape*	fCurrentShape;
111 				// those path items will be marked that
112 				// are referenced by this shape
113 
114 			ShapePathListener*	fShapePathListener;
115 };
116 
117 #endif // PATH_LIST_VIEW_H
118