2 * Copyright 2006-2007, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
13 # include "IconObject.h"
14 # include "Observer.h"
16 #include "IconBuild.h"
17 #include "PathContainer.h"
18 #include "PathSource.h"
19 #include "Transformable.h"
20 #include "VectorPath.h"
32 // TODO: merge Observer and ShapeListener interface
33 // ie add "AppearanceChanged(Shape* shape)"
37 virtual ~ShapeListener();
39 virtual void TransformerAdded(Transformer
* t
,
41 virtual void TransformerRemoved(Transformer
* t
) = 0;
43 virtual void StyleChanged(::Style
* oldStyle
,
44 ::Style
* newStyle
) = 0;
46 #endif // ICON_O_MATIC
49 class Shape
: public IconObject
,
50 public _ICON_NAMESPACE Transformable
,
51 public Observer
, // observing all the paths and the style
52 public PathContainerListener
,
55 class Shape
: public _ICON_NAMESPACE Transformable
{
59 Shape(::Style
* style
);
60 Shape(const Shape
& other
);
63 // IconObject interface
64 virtual status_t
Unarchive(const BMessage
* archive
);
66 virtual status_t
Archive(BMessage
* into
,
67 bool deep
= true) const;
69 virtual PropertyObject
* MakePropertyObject() const;
70 virtual bool SetToPropertyObject(
71 const PropertyObject
* object
);
73 // Transformable interface
74 virtual void TransformationChanged();
77 virtual void ObjectChanged(const Observable
* object
);
79 // PathContainerListener interface
80 virtual void PathAdded(VectorPath
* path
, int32 index
);
81 virtual void PathRemoved(VectorPath
* path
);
83 // PathListener interface
84 virtual void PointAdded(int32 index
);
85 virtual void PointRemoved(int32 index
);
86 virtual void PointChanged(int32 index
);
87 virtual void PathChanged();
88 virtual void PathClosedChanged();
89 virtual void PathReversed();
91 inline void Notify() {}
92 #endif // ICON_O_MATIC
95 status_t
InitCheck() const;
97 inline PathContainer
* Paths() const
100 void SetStyle(::Style
* style
);
101 inline ::Style
* Style() const
104 inline BRect
LastBounds() const
105 { return fLastBounds
; }
106 BRect
Bounds(bool updateLast
= false) const;
108 ::VertexSource
& VertexSource();
109 void SetGlobalScale(double scale
);
111 bool AddTransformer(Transformer
* transformer
);
112 bool AddTransformer(Transformer
* transformer
,
114 bool RemoveTransformer(Transformer
* transformer
);
116 int32
CountTransformers() const;
118 bool HasTransformer(Transformer
* transformer
) const;
119 int32
IndexOf(Transformer
* transformer
) const;
121 Transformer
* TransformerAt(int32 index
) const;
122 Transformer
* TransformerAtFast(int32 index
) const;
124 void SetHinting(bool hinting
);
127 void SetMinVisibilityScale(float scale
);
128 float MinVisibilityScale() const
129 { return fMinVisibilityScale
; }
130 void SetMaxVisibilityScale(float scale
);
131 float MaxVisibilityScale() const
132 { return fMaxVisibilityScale
; }
135 bool AddListener(ShapeListener
* listener
);
136 bool RemoveListener(ShapeListener
* listener
);
139 void _NotifyTransformerAdded(Transformer
* t
,
141 void _NotifyTransformerRemoved(Transformer
* t
) const;
143 void _NotifyStyleChanged(::Style
* oldStyle
,
144 ::Style
* newStyle
) const;
146 void _NotifyRerender() const;
147 #endif // ICON_O_MATIC
150 PathContainer
* fPaths
;
153 PathSource fPathSource
;
155 mutable bool fNeedsUpdate
;
157 mutable BRect fLastBounds
;
160 float fMinVisibilityScale
;
161 float fMaxVisibilityScale
;