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