Make UEFI boot-platform build again
[haiku.git] / src / libs / icon / shape / Shape.h
blob8f1e5b15f0821d3fceb1996d390c266451a1f917
1 /*
2 * Copyright 2006-2007, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
8 #ifndef SHAPE_H
9 #define SHAPE_H
12 #ifdef ICON_O_MATIC
13 # include "IconObject.h"
14 # include "Observer.h"
15 #endif
16 #include "IconBuild.h"
17 #include "PathContainer.h"
18 #include "PathSource.h"
19 #include "Transformable.h"
20 #include "VectorPath.h"
22 #include <List.h>
23 #include <Rect.h>
26 _BEGIN_ICON_NAMESPACE
29 class Style;
31 #ifdef ICON_O_MATIC
32 // TODO: merge Observer and ShapeListener interface
33 // ie add "AppearanceChanged(Shape* shape)"
34 class ShapeListener {
35 public:
36 ShapeListener();
37 virtual ~ShapeListener();
39 virtual void TransformerAdded(Transformer* t,
40 int32 index) = 0;
41 virtual void TransformerRemoved(Transformer* t) = 0;
43 virtual void StyleChanged(::Style* oldStyle,
44 ::Style* newStyle) = 0;
46 #endif // ICON_O_MATIC
48 #ifdef 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,
53 public PathListener {
54 #else
55 class Shape : public _ICON_NAMESPACE Transformable {
56 #endif
58 public:
59 Shape(::Style* style);
60 Shape(const Shape& other);
61 virtual ~Shape();
63 // IconObject interface
64 virtual status_t Unarchive(const BMessage* archive);
65 #ifdef ICON_O_MATIC
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();
76 // Observer interface
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();
90 #else
91 inline void Notify() {}
92 #endif // ICON_O_MATIC
94 // Shape
95 status_t InitCheck() const;
97 inline PathContainer* Paths() const
98 { return fPaths; }
100 void SetStyle(::Style* style);
101 inline ::Style* Style() const
102 { return fStyle; }
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,
113 int32 index);
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);
125 bool Hinting() const
126 { return fHinting; }
127 void SetMinVisibilityScale(float scale);
128 float MinVisibilityScale() const
129 { return fMinVisibilityScale; }
130 void SetMaxVisibilityScale(float scale);
131 float MaxVisibilityScale() const
132 { return fMaxVisibilityScale; }
134 #ifdef ICON_O_MATIC
135 bool AddListener(ShapeListener* listener);
136 bool RemoveListener(ShapeListener* listener);
138 private:
139 void _NotifyTransformerAdded(Transformer* t,
140 int32 index) const;
141 void _NotifyTransformerRemoved(Transformer* t) const;
143 void _NotifyStyleChanged(::Style* oldStyle,
144 ::Style* newStyle) const;
146 void _NotifyRerender() const;
147 #endif // ICON_O_MATIC
149 private:
150 PathContainer* fPaths;
151 ::Style* fStyle;
153 PathSource fPathSource;
154 BList fTransformers;
155 mutable bool fNeedsUpdate;
157 mutable BRect fLastBounds;
159 bool fHinting;
160 float fMinVisibilityScale;
161 float fMaxVisibilityScale;
163 #ifdef ICON_O_MATIC
164 BList fListeners;
165 #endif
169 _END_ICON_NAMESPACE
172 #endif // SHAPE_H