xref: /haiku/src/apps/icon-o-matic/gui/StyleListView.h (revision 8d2bf6953e851d431fc67de1bc970c40afa79e9f)
1 /*
2  * Copyright 2006-2007, 2011, Stephan Aßmus <superstippi@gmx.de>.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef STYLE_LIST_VIEW_H
6 #define STYLE_LIST_VIEW_H
7 
8 
9 #include "ListViews.h"
10 #include "StyleContainer.h"
11 
12 
13 class BMenu;
14 class BMenuItem;
15 class CommandStack;
16 class CurrentColor;
17 class Selection;
18 class ShapeStyleListener;
19 class StyleListItem;
20 
21 _BEGIN_ICON_NAMESPACE
22 	class Shape;
23 	class ShapeContainer;
24 	class ShapeListener;
25 	class Style;
26 _END_ICON_NAMESPACE
27 
28 _USING_ICON_NAMESPACE
29 
30 
31 class StyleListView : public SimpleListView, public StyleContainerListener {
32 public:
33 								StyleListView(BRect frame, const char* name,
34 									BMessage* selectionMessage = NULL,
35 									BHandler* target = NULL);
36 	virtual						~StyleListView();
37 
38 	// SimpleListView interface
39 	virtual	void				MessageReceived(BMessage* message);
40 
41 	virtual	void				SelectionChanged();
42 
43 	virtual	void				MouseDown(BPoint where);
44 
45 	virtual	void				MakeDragMessage(BMessage* message) const;
46 
47 	virtual	bool				AcceptDragMessage(
48 									const BMessage* message) const;
49 	virtual	void				SetDropTargetRect(const BMessage* message,
50 									BPoint where);
51 	virtual	bool				HandleDropMessage(const BMessage* message,
52 									int32 dropIndex);
53 
54 	virtual	void				MoveItems(BList& items, int32 toIndex);
55 	virtual	void				CopyItems(BList& items, int32 toIndex);
56 	virtual	void				RemoveItemList(BList& items);
57 
58 	virtual	BListItem*			CloneItem(int32 atIndex) const;
59 
60 	virtual	int32				IndexOfSelectable(Selectable* selectable) const;
61 	virtual	Selectable*			SelectableFor(BListItem* item) const;
62 
63 	// StyleContainerListener interface
64 	virtual	void				StyleAdded(Style* style, int32 index);
65 	virtual	void				StyleRemoved(Style* style);
66 
67 	// StyleListView
68 			void				SetMenu(BMenu* menu);
69 			void				SetStyleContainer(StyleContainer* container);
70 			void				SetShapeContainer(ShapeContainer* container);
71 			void				SetCommandStack(CommandStack* stack);
72 			void				SetCurrentColor(CurrentColor* color);
73 
74 			void				SetCurrentShape(Shape* shape);
75 			Shape*				CurrentShape() const
76 									{ return fCurrentShape; }
77 
78 private:
79 			bool				_AddStyle(Style* style, int32 index);
80 			bool				_RemoveStyle(Style* style);
81 
82 			StyleListItem*		_ItemForStyle(Style* style) const;
83 
84 			friend class ShapeStyleListener;
85 			void				_UpdateMarks();
86 			void				_SetStyleMarked(Style* style, bool marked);
87 			void				_UpdateMenu();
88 
89 			BMessage*			fMessage;
90 
91 			StyleContainer*		fStyleContainer;
92 			ShapeContainer*		fShapeContainer;
93 			CommandStack*		fCommandStack;
94 			CurrentColor*		fCurrentColor;
95 
96 			Shape*				fCurrentShape;
97 				// the style item will be marked that
98 				// is referenced by this shape
99 
100 			ShapeStyleListener*	fShapeListener;
101 
102 			BMenu*				fMenu;
103 			BMenuItem*			fAddMI;
104 			BMenuItem*			fDuplicateMI;
105 			BMenuItem*			fResetTransformationMI;
106 			BMenuItem*			fRemoveMI;
107 };
108 
109 
110 #endif // STYLE_LIST_VIEW_H
111