xref: /haiku/src/apps/icon-o-matic/gui/ShapeListView.h (revision 445d4fd926c569e7b9ae28017da86280aaecbae2)
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 SHAPE_LIST_VIEW_H
10 #define SHAPE_LIST_VIEW_H
11 
12 
13 #include "ListViews.h"
14 #include "ShapeContainer.h"
15 
16 
17 class BMenu;
18 class BMenuItem;
19 class CommandStack;
20 class ShapeListItem;
21 class StyleContainer;
22 class PathContainer;
23 class Selection;
24 
25 _BEGIN_ICON_NAMESPACE
26 	class Shape;
27 _END_ICON_NAMESPACE
28 
29 _USING_ICON_NAMESPACE
30 
31 
32 enum {
33 	MSG_ADD_SHAPE					= 'adsh',
34 	MSG_ADD_REFERENCE_IMAGE			= 'aimg',
35 };
36 
37 class ShapeListView : public SimpleListView,
38 					  public ShapeContainerListener {
39  public:
40 								ShapeListView(BRect frame,
41 											  const char* name,
42 											  BMessage* selectionMessage = NULL,
43 											  BHandler* target = NULL);
44 	virtual						~ShapeListView();
45 
46 	// SimpleListView interface
47 	virtual	void				SelectionChanged();
48 
49 	virtual	void				MessageReceived(BMessage* message);
50 
51 	virtual	void				MakeDragMessage(BMessage* message) const;
52 
53 	virtual	bool				AcceptDragMessage(const BMessage* message) const;
54 	virtual	void				SetDropTargetRect(const BMessage* message,
55 									BPoint where);
56 	virtual	bool				HandleDropMessage(const BMessage* message,
57 									int32 dropIndex);
58 
59 	virtual	void				MoveItems(BList& items, int32 toIndex);
60 	virtual	void				CopyItems(BList& items, int32 toIndex);
61 	virtual	void				RemoveItemList(BList& items);
62 
63 	virtual	BListItem*			CloneItem(int32 atIndex) const;
64 
65 	virtual	int32				IndexOfSelectable(Selectable* selectable) const;
66 	virtual	Selectable*			SelectableFor(BListItem* item) const;
67 
68 	// ShapeContainerListener interface
69 	virtual	void				ShapeAdded(Shape* shape, int32 index);
70 	virtual	void				ShapeRemoved(Shape* shape);
71 
72 	// ShapeListView
73 			void				SetMenu(BMenu* menu);
74 			void				SetShapeContainer(ShapeContainer* container);
75 			void				SetStyleContainer(StyleContainer* container);
76 			void				SetPathContainer(PathContainer* container);
77 			void				SetCommandStack(CommandStack* stack);
78 
79  private:
80 			bool				_AddShape(Shape* shape, int32 index);
81 			bool				_RemoveShape(Shape* shape);
82 
83 			ShapeListItem*		_ItemForShape(Shape* shape) const;
84 			void				_UpdateMenu();
85 
86 			void				_GetSelectedShapes(BList& shapes) const;
87 
88 			BMessage*			fMessage;
89 
90 			ShapeContainer*		fShapeContainer;
91 			StyleContainer*		fStyleContainer;
92 			PathContainer*		fPathContainer;
93 			CommandStack*		fCommandStack;
94 
95 			BMenu*				fMenu;
96 			BMenuItem*			fAddEmptyMI;
97 			BMenuItem*			fAddWidthPathMI;
98 			BMenuItem*			fAddWidthStyleMI;
99 			BMenuItem*			fAddWidthPathAndStyleMI;
100 			BMenuItem*			fAddReferenceImageMI;
101 			BMenuItem*			fDuplicateMI;
102 			BMenuItem*			fResetTransformationMI;
103 			BMenuItem*			fFreezeTransformationMI;
104 			BMenuItem*			fRemoveMI;
105 };
106 
107 #endif // SHAPE_LIST_VIEW_H
108