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 "Container.h"
14#include "ListViews.h"
15#include "IconBuild.h"
16
17
18class BMenu;
19class BMenuItem;
20class CommandStack;
21class ShapeListItem;
22class Selection;
23
24_BEGIN_ICON_NAMESPACE
25	class Style;
26	class Shape;
27	class VectorPath;
28_END_ICON_NAMESPACE
29
30_USING_ICON_NAMESPACE
31
32
33enum {
34	MSG_ADD_SHAPE					= 'adsh',
35	MSG_ADD_REFERENCE_IMAGE			= 'aimg',
36};
37
38class ShapeListView : public SimpleListView,
39					  public ContainerListener<Shape> {
40 public:
41	enum {
42		kSelectionArchiveCode		= 'sshp',
43	};
44									ShapeListView(BRect frame,
45												  const char* name,
46												  BMessage* selectionMessage = NULL,
47												  BHandler* target = NULL);
48	virtual							~ShapeListView();
49
50	// SimpleListView interface
51	virtual	void					SelectionChanged();
52
53	virtual	void					MessageReceived(BMessage* message);
54
55	virtual	status_t				ArchiveSelection(BMessage* into, bool deep = true) const;
56	virtual	bool					InstantiateSelection(const BMessage* archive, 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<Shape> interface
68	virtual	void					ItemAdded(Shape* shape, int32 index);
69	virtual	void					ItemRemoved(Shape* shape);
70
71	// ShapeListView
72			void					SetMenu(BMenu* menu);
73			void					SetShapeContainer(Container<Shape>* container);
74			void					SetStyleContainer(Container<Style>* container);
75			void					SetPathContainer(Container<VectorPath>* container);
76			void					SetCommandStack(CommandStack* stack);
77
78 private:
79			bool					_AddShape(Shape* shape, int32 index);
80			bool					_RemoveShape(Shape* shape);
81
82			ShapeListItem*			_ItemForShape(Shape* shape) const;
83			void					_UpdateMenu();
84
85			void					_GetSelectedShapes(BList& shapes) const;
86
87			BMessage*				fMessage;
88
89			Container<Shape>*		fShapeContainer;
90			Container<Style>*		fStyleContainer;
91			Container<VectorPath>*	fPathContainer;
92			CommandStack*			fCommandStack;
93
94			BMenu*					fMenu;
95			BMenuItem*				fAddEmptyMI;
96			BMenuItem*				fAddWidthPathMI;
97			BMenuItem*				fAddWidthStyleMI;
98			BMenuItem*				fAddWidthPathAndStyleMI;
99			BMenuItem*				fAddReferenceImageMI;
100			BMenuItem*				fDuplicateMI;
101			BMenuItem*				fResetTransformationMI;
102			BMenuItem*				fFreezeTransformationMI;
103			BMenuItem*				fRemoveMI;
104};
105
106#endif // SHAPE_LIST_VIEW_H
107