xref: /haiku/src/libs/icon/Icon.h (revision e711e6e42fd7ec3111ba9dc2324fa8efedd6674b)
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 "IconBuild.h"
13 #include "ShapeContainer.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 PathContainer;
31 class StyleContainer;
32 
33 #ifdef ICON_O_MATIC
34 class IconListener {
35  public:
36 								IconListener();
37 	virtual						~IconListener();
38 
39 	virtual	void				AreaInvalidated(const BRect& area) = 0;
40 };
41 #endif
42 
43 #ifdef ICON_O_MATIC
44 class Icon : public ShapeContainerListener,
45 			 public Observer,
46 			 public BReferenceable {
47 #else
48 class Icon {
49 #endif
50 
51  public:
52 								Icon();
53 								Icon(const Icon& other);
54 	virtual						~Icon();
55 
56 			status_t			InitCheck() const;
57 
58 			StyleContainer*		Styles() const
59 									{ return fStyles; }
60 			PathContainer*		Paths() const
61 									{ return fPaths; }
62 			ShapeContainer*		Shapes() const
63 									{ return fShapes; }
64 
65 			Icon*				Clone() const;
66 			void				MakeEmpty();
67 
68  private:
69 
70 			StyleContainer*		fStyles;
71 			PathContainer*		fPaths;
72 			ShapeContainer*		fShapes;
73 
74 #ifdef ICON_O_MATIC
75  public:
76 	// ShapeContainerListener interface
77 	virtual	void				ShapeAdded(Shape* shape, int32 index);
78 	virtual	void				ShapeRemoved(Shape* shape);
79 
80 	// Observer interface
81 	virtual	void				ObjectChanged(const Observable* object);
82 
83 	// Icon
84 			bool				AddListener(IconListener* listener);
85 			bool				RemoveListener(IconListener* listener);
86 
87  private:
88 			void				_NotifyAreaInvalidated(
89 									const BRect& area) const;
90 			BList				fListeners;
91 #endif
92 };
93 
94 
95 _END_ICON_NAMESPACE
96 
97 
98 #endif	// ICON_H
99