xref: /haiku/src/apps/icon-o-matic/gui/PathListView.h (revision 4b0dffe500671f2cbf8dd203fb610ef6323cb123)
1 /*
2  * Copyright 2006-2007, 2023, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  *		Zardshard
8  */
9 #ifndef PATH_LIST_VIEW_H
10 #define PATH_LIST_VIEW_H
11 
12 
13 #include "Container.h"
14 #include "ListViews.h"
15 #include "IconBuild.h"
16 
17 
18 class BMenu;
19 class BMenuItem;
20 
21 _BEGIN_ICON_NAMESPACE
22 	class VectorPath;
23 	class PathSourceShape;
24 	class Shape;
25 _END_ICON_NAMESPACE
26 
27 class CommandStack;
28 class PathListItem;
29 class Selection;
30 class ShapePathListener;
31 
32 
33 _USING_ICON_NAMESPACE
34 
35 
36 class PathListView : public SimpleListView,
37 					 public ContainerListener<VectorPath> {
38  public:
39 	enum {
40 		kSelectionArchiveCode		= 'spth',
41 	};
42 									PathListView(BRect frame,
43 												 const char* name,
44 												 BMessage* selectionMessage = NULL,
45 												 BHandler* target = NULL);
46 	virtual							~PathListView();
47 
48 	// SimpleListView interface
49 	virtual	void					SelectionChanged();
50 
51 	virtual	void					MouseDown(BPoint where);
52 	virtual	void					MessageReceived(BMessage* message);
53 
54 	virtual	status_t				ArchiveSelection(BMessage* into, bool deep = true) const;
55 	virtual	bool					InstantiateSelection(const BMessage* archive, 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 	// ContainerListener<VectorPath> interface
67 	virtual	void					ItemAdded(VectorPath* path, int32 index);
68 	virtual	void					ItemRemoved(VectorPath* path);
69 
70 	// PathListView
71 			void					SetPathContainer(Container<VectorPath>* container);
72 			void					SetShapeContainer(Container<Shape>* container);
73 			void					SetCommandStack(CommandStack* stack);
74 			void					SetMenu(BMenu* menu);
75 
76 			void					SetCurrentShape(Shape* shape);
CurrentShape()77 			PathSourceShape*		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 			Container<VectorPath>*	fPathContainer;
106 			Container<Shape>*		fShapeContainer;
107 			CommandStack*			fCommandStack;
108 
109 			PathSourceShape*		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