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 Selection; 21 22 namespace BPrivate { 23 namespace Icon { 24 class Shape; 25 } 26 } 27 using namespace BPrivate::Icon; 28 29 enum { 30 MSG_ADD_SHAPE = 'adsh', 31 }; 32 33 class ShapeListView : public SimpleListView, 34 public ShapeContainerListener { 35 public: 36 ShapeListView(BRect frame, 37 const char* name, 38 BMessage* selectionMessage = NULL, 39 BHandler* target = NULL); 40 virtual ~ShapeListView(); 41 42 // SimpleListView interface 43 virtual void SelectionChanged(); 44 45 virtual void MessageReceived(BMessage* message); 46 47 virtual void MakeDragMessage(BMessage* message) const; 48 49 virtual bool AcceptDragMessage(const BMessage* message) const; 50 virtual void SetDropTargetRect(const BMessage* message, 51 BPoint where); 52 53 virtual void MoveItems(BList& items, int32 toIndex); 54 virtual void CopyItems(BList& items, int32 toIndex); 55 virtual void RemoveItemList(BList& items); 56 57 virtual BListItem* CloneItem(int32 atIndex) const; 58 59 virtual int32 IndexOfSelectable(Selectable* selectable) const; 60 virtual Selectable* SelectableFor(BListItem* item) const; 61 62 // ShapeContainerListener interface 63 virtual void ShapeAdded(Shape* shape, int32 index); 64 virtual void ShapeRemoved(Shape* shape); 65 66 // ShapeListView 67 void SetMenu(BMenu* menu); 68 void SetShapeContainer(ShapeContainer* container); 69 void SetCommandStack(CommandStack* stack); 70 71 private: 72 bool _AddShape(Shape* shape, int32 index); 73 bool _RemoveShape(Shape* shape); 74 75 ShapeListItem* _ItemForShape(Shape* shape) const; 76 void _UpdateMenu(); 77 78 void _GetSelectedShapes(BList& shapes) const; 79 80 BMessage* fMessage; 81 82 ShapeContainer* fShapeContainer; 83 CommandStack* fCommandStack; 84 85 BMenu* fMenu; 86 BMenuItem* fAddEmptyMI; 87 BMenuItem* fAddWidthPathMI; 88 BMenuItem* fAddWidthStyleMI; 89 BMenuItem* fAddWidthPathAndStyleMI; 90 BMenuItem* fDuplicateMI; 91 BMenuItem* fResetTransformationMI; 92 BMenuItem* fFreezeTransformationMI; 93 BMenuItem* fRemoveMI; 94 }; 95 96 #endif // SHAPE_LIST_VIEW_H 97