1 /* 2 * Copyright 2006-2007, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 #ifndef SHAPE_LIST_VIEW_H 9 #define SHAPE_LIST_VIEW_H 10 11 12 #include "ListViews.h" 13 #include "ShapeContainer.h" 14 15 16 class BMenu; 17 class BMenuItem; 18 class CommandStack; 19 class ShapeListItem; 20 class StyleContainer; 21 class PathContainer; 22 class Selection; 23 24 _BEGIN_ICON_NAMESPACE 25 class Shape; 26 _END_ICON_NAMESPACE 27 28 _USING_ICON_NAMESPACE 29 30 31 enum { 32 MSG_ADD_SHAPE = 'adsh', 33 }; 34 35 class ShapeListView : public SimpleListView, 36 public ShapeContainerListener { 37 public: 38 ShapeListView(BRect frame, 39 const char* name, 40 BMessage* selectionMessage = NULL, 41 BHandler* target = NULL); 42 virtual ~ShapeListView(); 43 44 // SimpleListView interface 45 virtual void SelectionChanged(); 46 47 virtual void MessageReceived(BMessage* message); 48 49 virtual void MakeDragMessage(BMessage* message) const; 50 51 virtual bool AcceptDragMessage(const BMessage* message) const; 52 virtual void SetDropTargetRect(const BMessage* message, 53 BPoint where); 54 virtual bool HandleDropMessage(const BMessage* message, 55 int32 dropIndex); 56 57 virtual void MoveItems(BList& items, int32 toIndex); 58 virtual void CopyItems(BList& items, int32 toIndex); 59 virtual void RemoveItemList(BList& items); 60 61 virtual BListItem* CloneItem(int32 atIndex) const; 62 63 virtual int32 IndexOfSelectable(Selectable* selectable) const; 64 virtual Selectable* SelectableFor(BListItem* item) const; 65 66 // ShapeContainerListener interface 67 virtual void ShapeAdded(Shape* shape, int32 index); 68 virtual void ShapeRemoved(Shape* shape); 69 70 // ShapeListView 71 void SetMenu(BMenu* menu); 72 void SetShapeContainer(ShapeContainer* container); 73 void SetStyleContainer(StyleContainer* container); 74 void SetPathContainer(PathContainer* container); 75 void SetCommandStack(CommandStack* stack); 76 77 private: 78 bool _AddShape(Shape* shape, int32 index); 79 bool _RemoveShape(Shape* shape); 80 81 ShapeListItem* _ItemForShape(Shape* shape) const; 82 void _UpdateMenu(); 83 84 void _GetSelectedShapes(BList& shapes) const; 85 86 BMessage* fMessage; 87 88 ShapeContainer* fShapeContainer; 89 StyleContainer* fStyleContainer; 90 PathContainer* fPathContainer; 91 CommandStack* fCommandStack; 92 93 BMenu* fMenu; 94 BMenuItem* fAddEmptyMI; 95 BMenuItem* fAddWidthPathMI; 96 BMenuItem* fAddWidthStyleMI; 97 BMenuItem* fAddWidthPathAndStyleMI; 98 BMenuItem* fDuplicateMI; 99 BMenuItem* fResetTransformationMI; 100 BMenuItem* fFreezeTransformationMI; 101 BMenuItem* fRemoveMI; 102 }; 103 104 #endif // SHAPE_LIST_VIEW_H 105