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 "Container.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 PathSourceShape; 23 class Shape; 24 class Style; 25 _END_ICON_NAMESPACE 26 27 _USING_ICON_NAMESPACE 28 29 30 class StyleListView : public SimpleListView, public ContainerListener<Style> { 31 public: 32 StyleListView(BRect frame, const char* name, 33 BMessage* selectionMessage = NULL, 34 BHandler* target = NULL); 35 virtual ~StyleListView(); 36 37 // SimpleListView interface 38 virtual void MessageReceived(BMessage* message); 39 40 virtual void SelectionChanged(); 41 42 virtual void MouseDown(BPoint where); 43 44 virtual void MakeDragMessage(BMessage* message) const; 45 46 virtual bool AcceptDragMessage( 47 const BMessage* message) const; 48 virtual void SetDropTargetRect(const BMessage* message, 49 BPoint where); 50 virtual bool HandleDropMessage(const BMessage* message, 51 int32 dropIndex); 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 // ContainerListener<Style> interface 63 virtual void ItemAdded(Style* style, int32 index); 64 virtual void ItemRemoved(Style* style); 65 66 // StyleListView 67 void SetMenu(BMenu* menu); 68 void SetStyleContainer(Container<Style>* container); 69 void SetShapeContainer(Container<Shape>* container); 70 void SetCommandStack(CommandStack* stack); 71 void SetCurrentColor(CurrentColor* color); 72 73 void SetCurrentShape(Shape* shape); 74 PathSourceShape* CurrentShape() const 75 { return fCurrentShape; } 76 77 private: 78 bool _AddStyle(Style* style, int32 index); 79 bool _RemoveStyle(Style* style); 80 81 StyleListItem* _ItemForStyle(Style* style) const; 82 83 friend class ShapeStyleListener; 84 void _UpdateMarks(); 85 void _SetStyleMarked(Style* style, bool marked); 86 void _UpdateMenu(); 87 88 BMessage* fMessage; 89 90 Container<Style>* fStyleContainer; 91 Container<Shape>* fShapeContainer; 92 CommandStack* fCommandStack; 93 CurrentColor* fCurrentColor; 94 95 PathSourceShape* fCurrentShape; 96 // the style item will be marked that 97 // is referenced by this shape 98 99 ShapeStyleListener* fShapeListener; 100 101 BMenu* fMenu; 102 BMenuItem* fAddMI; 103 BMenuItem* fDuplicateMI; 104 BMenuItem* fResetTransformationMI; 105 BMenuItem* fRemoveMI; 106 }; 107 108 109 #endif // STYLE_LIST_VIEW_H 110