xref: /haiku/headers/private/interface/PictureDataWriter.h (revision 37e5a036605931f55d82e971f8ab99c48023a5c4)
1 /*
2  * Copyright 2006-2007 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stefano Ceccherini, burton666@libero.it
7  */
8 #ifndef _PICTURE_DATA_WRITER_H
9 #define _PICTURE_DATA_WRITER_H
10 
11 
12 #include <AffineTransform.h>
13 #include <InterfaceDefs.h>
14 #include <Font.h>
15 #include <OS.h>
16 
17 #include <stack>
18 
19 
20 class BPositionIO;
21 class BRegion;
22 
23 class PictureDataWriter {
24 public:
25 								PictureDataWriter();
26 								PictureDataWriter(BPositionIO* data);
27 	virtual						~PictureDataWriter();
28 
29 			status_t			SetTo(BPositionIO* data);
30 
31 			status_t			WriteSetHighColor(const rgb_color& color);
32 			status_t			WriteSetLowColor(const rgb_color& color);
33 			status_t			WriteSetOrigin(const BPoint& point);
34 			status_t			WriteSetDrawingMode(const drawing_mode& mode);
35 			status_t			WriteSetPenLocation(const BPoint& point);
36 			status_t			WriteSetPenSize(const float& penSize);
37 			status_t			WriteSetLineMode(const cap_mode& cap,
38 									const join_mode& join,
39 									const float& miterLimit);
40 			status_t			WriteSetScale(const float& scale);
41 			status_t			WriteSetTransform(BAffineTransform transform);
42 			status_t			WriteSetPattern(const ::pattern& pattern);
43 			status_t			WriteClipToPicture(int32 pictureToken,
44 									const BPoint& origin, bool inverse);
45 			status_t			WriteSetClipping(const BRegion& region);
46 			status_t			WriteClearClipping();
47 
48 			status_t			WritePushState();
49 			status_t			WritePopState();
50 
51 			status_t			WriteSetFontFamily(const font_family family);
52 			status_t			WriteSetFontStyle(const font_style style);
53 			status_t			WriteSetFontSpacing(const int32& spacing);
54 			status_t			WriteSetFontSize(const float& size);
55 			status_t			WriteSetFontRotation(const float& rotation);
56 			status_t			WriteSetFontEncoding(const int32& encoding);
57 			status_t			WriteSetFontFlags(const int32& flags);
58 			status_t			WriteSetFontShear(const float& shear);
59 			status_t			WriteSetFontFace(const int32& face);
60 
61 			status_t			WriteStrokeLine(const BPoint& start,
62 									const BPoint& end);
63 			status_t			WriteInvertRect(const BRect& rect);
64 			status_t			WriteDrawRect(const BRect& rect,
65 									const bool& fill);
66 			status_t			WriteDrawRoundRect(const BRect& rect,
67 									const BPoint& radius, const bool& fill);
68 			status_t			WriteDrawEllipse(const BRect& rect,
69 									const bool& fill);
70 			status_t			WriteDrawArc(const BPoint& center,
71 									const BPoint& radius,
72 									const float& startTheta,
73 									const float& arcTheta, const bool& fill);
74 			status_t			WriteDrawPolygon(const int32& numPoints,
75 									BPoint* points, const bool& isClosed,
76 									const bool& fill);
77 			status_t			WriteDrawBezier(const BPoint points[4],
78 									const bool& fill);
79 			status_t			WriteDrawString(const BPoint& where,
80 									const char* string, const int32& length,
81 									const escapement_delta& delta);
82 			status_t			WriteDrawShape(const int32& opCount,
83 									const void* opList, const int32& ptCount,
84 									const void* ptList, const bool& fill);
85 			status_t			WriteDrawBitmap(const BRect& srcRect,
86 									const BRect& dstRect, const int32& width,
87 									const int32& height,
88 									const int32& bytesPerRow,
89 									const int32& colorSpace,
90 									const int32& flags,
91 									const void* data, const int32& length);
92 
93 			status_t			WriteDrawPicture(const BPoint& where,
94 									const int32& token);
95 
96 protected:
97 	// throw a status_t on error
98 			void				BeginOp(const int16& op);
99 			void				EndOp();
100 			void				WriteData(const void* data, size_t size);
101 	template <typename T> void	Write(const T& data)
102 									{ WriteData(&data, sizeof(data)); }
103 
104 private:
105 			BPositionIO*		fData;
106 			std::stack<off_t>	fStack;
107 };
108 
109 
110 #endif // _PICTURE_DATA_WRITER_H
111