1 /* 2 * Copyright 2007, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 #ifndef ICON_H 9 #define ICON_H 10 11 12 #include "Container.h" 13 #include "IconBuild.h" 14 15 #ifdef ICON_O_MATIC 16 # include <List.h> 17 # include <Referenceable.h> 18 19 # include "Observer.h" 20 #else 21 # include <SupportDefs.h> 22 #endif 23 24 class BRect; 25 26 27 _BEGIN_ICON_NAMESPACE 28 29 30 class Shape; 31 class Style; 32 class VectorPath; 33 34 #ifdef ICON_O_MATIC 35 class IconListener { 36 public: 37 IconListener(); 38 virtual ~IconListener(); 39 40 virtual void AreaInvalidated(const BRect& area) = 0; 41 }; 42 #endif 43 44 #ifdef ICON_O_MATIC 45 class Icon : public ContainerListener<Shape>, 46 public Observer, 47 public BReferenceable { 48 #else 49 class Icon { 50 #endif 51 52 public: 53 Icon(); 54 Icon(const Icon& other); 55 virtual ~Icon(); 56 57 status_t InitCheck() const; 58 59 const Container<Style>* Styles() const 60 { return &fStyles; } 61 Container<Style>* Styles() 62 { return &fStyles; } 63 const Container<VectorPath>* Paths() const 64 { return &fPaths; } 65 Container<VectorPath>* Paths() 66 { return &fPaths; } 67 const Container<Shape>* Shapes() const 68 { return &fShapes; } 69 Container<Shape>* Shapes() 70 { return &fShapes; } 71 72 Icon* Clone() const; 73 void MakeEmpty(); 74 75 private: 76 77 Container<Style> fStyles; 78 Container<VectorPath> fPaths; 79 Container<Shape> fShapes; 80 81 #ifdef ICON_O_MATIC 82 public: 83 // ContainerListener<Shape> interface 84 virtual void ItemAdded(Shape* shape, int32 index); 85 virtual void ItemRemoved(Shape* shape); 86 87 // Observer interface 88 virtual void ObjectChanged(const Observable* object); 89 90 // Icon 91 bool AddListener(IconListener* listener); 92 bool RemoveListener(IconListener* listener); 93 94 private: 95 void _NotifyAreaInvalidated( 96 const BRect& area) const; 97 BList fListeners; 98 #endif 99 }; 100 101 102 _END_ICON_NAMESPACE 103 104 105 #endif // ICON_H 106