xref: /haiku/headers/os/interface/Shape.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2002-2010 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _SHAPE_H
6 #define _SHAPE_H
7 
8 
9 #include <Archivable.h>
10 
11 
12 class BPoint;
13 class BRect;
14 class BShape;
15 
16 namespace BPrivate {
17 	class ServerLink;
18 	class PicturePlayer;
19 };
20 
21 
22 class BShapeIterator {
23 public:
24 								BShapeIterator();
25 	virtual						~BShapeIterator();
26 
27 	virtual	status_t			IterateMoveTo(BPoint* point);
28 	virtual	status_t			IterateLineTo(int32 lineCount,
29 									BPoint* linePoints);
30 	virtual	status_t			IterateBezierTo(int32 bezierCount,
31 									BPoint* bezierPoints);
32 	virtual	status_t			IterateClose();
33 
34 	virtual	status_t			IterateArcTo(float& rx, float& ry,
35 									float& angle, bool largeArc,
36 									bool counterClockWise, BPoint& point);
37 
38 			status_t			Iterate(BShape* shape);
39 
40 private:
41 	virtual	void				_ReservedShapeIterator2();
42 	virtual	void				_ReservedShapeIterator3();
43 	virtual	void				_ReservedShapeIterator4();
44 
45 			uint32				reserved[4];
46 };
47 
48 
49 class BShape : public BArchivable {
50 public:
51 								BShape();
52 								BShape(const BShape& other);
53 								BShape(BMessage* archive);
54 	virtual						~BShape();
55 
56 	static	BArchivable*		Instantiate(BMessage* archive);
57 	virtual	status_t			Archive(BMessage* archive,
58 									bool deep = true) const;
59 
60 			BShape&				operator=(const BShape& other);
61 
62 			bool				operator==(const BShape& other) const;
63 			bool				operator!=(const BShape& other) const;
64 
65 			void				Clear();
66 			BRect				Bounds() const;
67 			BPoint				CurrentPosition() const;
68 
69 			status_t			AddShape(const BShape* other);
70 
71 			status_t			MoveTo(BPoint point);
72 			status_t			LineTo(BPoint linePoint);
73 			status_t			BezierTo(BPoint controlPoints[3]);
74 			status_t			BezierTo(const BPoint& control1,
75 									const BPoint& control2,
76 									const BPoint& endPoint);
77 			status_t			ArcTo(float rx, float ry,
78 									float angle, bool largeArc,
79 									bool counterClockWise,
80 									const BPoint& point);
81 			status_t			Close();
82 
83 private:
84 	// FBC padding
85 	virtual	status_t			Perform(perform_code code, void* data);
86 
87 	virtual	void				_ReservedShape1();
88 	virtual	void				_ReservedShape2();
89 	virtual	void				_ReservedShape3();
90 	virtual	void				_ReservedShape4();
91 
92 private:
93 	friend class BShapeIterator;
94 	friend class BView;
95 	friend class BFont;
96 	friend class BPrivate::PicturePlayer;
97 	friend class BPrivate::ServerLink;
98 
99 			void				GetData(int32* opCount, int32* ptCount,
100 									uint32** opList, BPoint** ptList);
101 			void				SetData(int32 opCount, int32 ptCount,
102 									const uint32* opList,
103 									const BPoint* ptList);
104 			void				InitData();
105 			bool				AllocatePts(int32 count);
106 			bool				AllocateOps(int32 count);
107 
108 private:
109 			uint32				fState;
110 			uint32				fBuildingOp;
111 			void*				fPrivateData;
112 
113 			uint32				reserved[4];
114 };
115 
116 
117 #endif // _SHAPE_H
118