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