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