xref: /haiku/src/apps/icon-o-matic/gui/PathListView.h (revision f11b30463296494633476a81bdb9a64e8cb2e85d)
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 "Container.h"
13 #include "ListViews.h"
14 #include "IconBuild.h"
15 
16 
17 class BMenu;
18 class BMenuItem;
19 
20 _BEGIN_ICON_NAMESPACE
21 	class VectorPath;
22 	class PathSourceShape;
23 	class Shape;
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 ContainerListener<VectorPath> {
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 	// ContainerListener<VectorPath> interface
68 	virtual	void					ItemAdded(VectorPath* path, int32 index);
69 	virtual	void					ItemRemoved(VectorPath* path);
70 
71 	// PathListView
72 			void					SetPathContainer(Container<VectorPath>* container);
73 			void					SetShapeContainer(Container<Shape>* 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 			Container<VectorPath>*	fPathContainer;
107 			Container<Shape>*		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