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