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 18 class BMenu; 19 class BMenuItem; 20 class CommandStack; 21 class ShapeListItem; 22 class 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 33 enum { 34 MSG_ADD_SHAPE = 'adsh', 35 MSG_ADD_REFERENCE_IMAGE = 'aimg', 36 }; 37 38 class ShapeListView : public SimpleListView, 39 public ContainerListener<Shape> { 40 public: 41 ShapeListView(BRect frame, 42 const char* name, 43 BMessage* selectionMessage = NULL, 44 BHandler* target = NULL); 45 virtual ~ShapeListView(); 46 47 // SimpleListView interface 48 virtual void SelectionChanged(); 49 50 virtual void MessageReceived(BMessage* message); 51 52 virtual void MakeDragMessage(BMessage* message) const; 53 54 virtual bool AcceptDragMessage(const BMessage* message) const; 55 virtual void SetDropTargetRect(const BMessage* message, 56 BPoint where); 57 virtual bool HandleDropMessage(const BMessage* message, 58 int32 dropIndex); 59 60 virtual void MoveItems(BList& items, int32 toIndex); 61 virtual void CopyItems(BList& items, int32 toIndex); 62 virtual void RemoveItemList(BList& items); 63 64 virtual BListItem* CloneItem(int32 atIndex) const; 65 66 virtual int32 IndexOfSelectable(Selectable* selectable) const; 67 virtual Selectable* SelectableFor(BListItem* item) const; 68 69 // ContainerListener<Shape> interface 70 virtual void ItemAdded(Shape* shape, int32 index); 71 virtual void ItemRemoved(Shape* shape); 72 73 // ShapeListView 74 void SetMenu(BMenu* menu); 75 void SetShapeContainer(Container<Shape>* container); 76 void SetStyleContainer(Container<Style>* container); 77 void SetPathContainer(Container<VectorPath>* container); 78 void SetCommandStack(CommandStack* stack); 79 80 private: 81 bool _AddShape(Shape* shape, int32 index); 82 bool _RemoveShape(Shape* shape); 83 84 ShapeListItem* _ItemForShape(Shape* shape) const; 85 void _UpdateMenu(); 86 87 void _GetSelectedShapes(BList& shapes) const; 88 89 BMessage* fMessage; 90 91 Container<Shape>* fShapeContainer; 92 Container<Style>* fStyleContainer; 93 Container<VectorPath>* fPathContainer; 94 CommandStack* fCommandStack; 95 96 BMenu* fMenu; 97 BMenuItem* fAddEmptyMI; 98 BMenuItem* fAddWidthPathMI; 99 BMenuItem* fAddWidthStyleMI; 100 BMenuItem* fAddWidthPathAndStyleMI; 101 BMenuItem* fAddReferenceImageMI; 102 BMenuItem* fDuplicateMI; 103 BMenuItem* fResetTransformationMI; 104 BMenuItem* fFreezeTransformationMI; 105 BMenuItem* fRemoveMI; 106 }; 107 108 #endif // SHAPE_LIST_VIEW_H 109