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 STYLE_LIST_VIEW_H 9 #define STYLE_LIST_VIEW_H 10 11 12 #include "ListViews.h" 13 #include "StyleContainer.h" 14 15 16 class BMenu; 17 class BMenuItem; 18 class CommandStack; 19 class Selection; 20 class ShapeStyleListener; 21 class StyleListItem; 22 23 namespace BPrivate { 24 namespace Icon { 25 class Shape; 26 class ShapeContainer; 27 class ShapeListener; 28 class Style; 29 } 30 } 31 using namespace BPrivate::Icon; 32 33 class StyleListView : public SimpleListView, 34 public StyleContainerListener { 35 public: 36 StyleListView(BRect frame, 37 const char* name, 38 BMessage* selectionMessage = NULL, 39 BHandler* target = NULL); 40 virtual ~StyleListView(); 41 42 // SimpleListView interface 43 virtual void MessageReceived(BMessage* message); 44 45 virtual void SelectionChanged(); 46 47 virtual void MouseDown(BPoint where); 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 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 74 void SetCurrentShape(Shape* shape); 75 Shape* 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 StyleContainer* fStyleContainer; 92 ShapeContainer* fShapeContainer; 93 CommandStack* fCommandStack; 94 95 Shape* 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 #endif // STYLE_LIST_VIEW_H 109