xref: /haiku/src/apps/icon-o-matic/gui/TransformerListView.h (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
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 TRANSFORMER_LIST_VIEW_H
10 #define TRANSFORMER_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 class CommandStack;
21 class TransformerItem;
22 class Selection;
23 
24 _BEGIN_ICON_NAMESPACE
25 	class Shape;
26 	class Transformer;
27 _END_ICON_NAMESPACE
28 
29 
30 class TransformerListView : public SimpleListView,
31 							public ContainerListener<Transformer> {
32  public:
33 	enum {
34 		kSelectionArchiveCode		= 'strn',
35 	};
36 								TransformerListView(BRect frame,
37 											  const char* name,
38 											  BMessage* selectionMessage = NULL,
39 											  BHandler* target = NULL);
40 	virtual						~TransformerListView();
41 
42 	// SimpleListView interface
43 	virtual	void				Draw(BRect updateRect);
44 
45 	virtual	void				SelectionChanged();
46 
47 	virtual	void				MessageReceived(BMessage* message);
48 
49 	virtual	status_t			ArchiveSelection(BMessage* into, bool deep = true) const;
50 	virtual	bool				InstantiateSelection(const BMessage* archive, int32 dropIndex);
51 
52 	virtual	void				MoveItems(BList& items, int32 toIndex);
53 	virtual	void				CopyItems(BList& items, int32 toIndex);
54 	virtual	void				RemoveItemList(BList& items);
55 
56 	virtual	BListItem*			CloneItem(int32 atIndex) const;
57 
58 	virtual	int32				IndexOfSelectable(Selectable* selectable) const;
59 	virtual	Selectable*			SelectableFor(BListItem* item) const;
60 
61 	// ContainerListener<Transformer> interface
62 	virtual	void				ItemAdded(Transformer* transformer, int32 index);
63 	virtual	void				ItemRemoved(Transformer* transformer);
64 
65 	// TransformerListView
66 			void				SetMenu(BMenu* menu);
67 			void				SetShape(Shape* shape);
68 			void				SetCommandStack(CommandStack* stack);
69 
70  private:
71 			bool				_AddTransformer(
72 									Transformer* transformer, int32 index);
73 			bool				_RemoveTransformer(
74 									Transformer* transformer);
75 
76 			TransformerItem*	_ItemForTransformer(
77 									Transformer* transformer) const;
78 
79 			void				_UpdateMenu();
80 
81 			BMessage*			fMessage;
82 
83 			Shape*				fShape;
84 			CommandStack*		fCommandStack;
85 
86 			BMenu*				fMenu;
87 			BMenuItem*			fContourMI;
88 			BMenuItem*			fStrokeMI;
89 			BMenuItem*			fPerspectiveMI;
90 };
91 
92 #endif // TRANSFORMER_LIST_VIEW_H
93