1 /* 2 * Copyright 2006-2007, 2011, Stephan Aßmus <superstippi@gmx.de>. 3 * Copyright 2023, Haiku. 4 * Distributed under the terms of the MIT License. 5 * 6 * Authors: 7 * Zardshard 8 */ 9 #ifndef STYLE_LIST_VIEW_H 10 #define STYLE_LIST_VIEW_H 11 12 13 #include "ListViews.h" 14 #include "Container.h" 15 16 17 class BMenu; 18 class BMenuItem; 19 class CommandStack; 20 class CurrentColor; 21 class Selection; 22 class ShapeStyleListener; 23 class StyleListItem; 24 25 _BEGIN_ICON_NAMESPACE 26 class PathSourceShape; 27 class Shape; 28 class Style; 29 _END_ICON_NAMESPACE 30 31 _USING_ICON_NAMESPACE 32 33 34 class StyleListView : public SimpleListView, public ContainerListener<Style> { 35 public: 36 enum { 37 kSelectionArchiveCode = 'sstl', 38 }; 39 StyleListView(BRect frame, const char* name, 40 BMessage* selectionMessage = NULL, 41 BHandler* target = NULL); 42 virtual ~StyleListView(); 43 44 // SimpleListView interface 45 virtual void MessageReceived(BMessage* message); 46 47 virtual void SelectionChanged(); 48 49 virtual void MouseDown(BPoint where); 50 51 virtual status_t ArchiveSelection(BMessage* into, bool deep = true) const; 52 virtual bool InstantiateSelection(const BMessage* archive, int32 dropIndex); 53 54 virtual void MoveItems(BList& items, int32 toIndex); 55 virtual void CopyItems(BList& items, int32 toIndex); 56 virtual void RemoveItemList(BList& items); 57 58 virtual BListItem* CloneItem(int32 atIndex) const; 59 60 virtual int32 IndexOfSelectable(Selectable* selectable) const; 61 virtual Selectable* SelectableFor(BListItem* item) const; 62 63 // ContainerListener<Style> interface 64 virtual void ItemAdded(Style* style, int32 index); 65 virtual void ItemRemoved(Style* style); 66 67 // StyleListView 68 void SetMenu(BMenu* menu); 69 void SetStyleContainer(Container<Style>* container); 70 void SetShapeContainer(Container<Shape>* container); 71 void SetCommandStack(CommandStack* stack); 72 void SetCurrentColor(CurrentColor* color); 73 74 void SetCurrentShape(Shape* shape); CurrentShape()75 PathSourceShape* CurrentShape() const 76 { return fCurrentShape; } 77 78 private: 79 bool _AddStyle(Style* style, int32 index); 80 bool _RemoveStyle(Style* style); 81 82 StyleListItem* _ItemForStyle(Style* style) const; 83 84 friend class ShapeStyleListener; 85 void _UpdateMarks(); 86 void _SetStyleMarked(Style* style, bool marked); 87 void _UpdateMenu(); 88 89 BMessage* fMessage; 90 91 Container<Style>* fStyleContainer; 92 Container<Shape>* fShapeContainer; 93 CommandStack* fCommandStack; 94 CurrentColor* fCurrentColor; 95 96 PathSourceShape* fCurrentShape; 97 // the style item will be marked that 98 // is referenced by this shape 99 100 ShapeStyleListener* fShapeListener; 101 102 BMenu* fMenu; 103 BMenuItem* fAddMI; 104 BMenuItem* fDuplicateMI; 105 BMenuItem* fResetTransformationMI; 106 BMenuItem* fRemoveMI; 107 }; 108 109 110 #endif // STYLE_LIST_VIEW_H 111