xref: /haiku/headers/private/interface/PictureDataWriter.h (revision 002f37b0cca92e4cf72857c72ac95db5a8b09615)
1 /*
2  * Copyright 2006-2007, Haiku Inc.
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 class BPositionIO;
20 class BRegion;
21 
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, const join_mode &join, const float &miterLimit);
38 	status_t WriteSetScale(const float &scale);
39 	status_t WriteSetTransform(BAffineTransform transform);
40 	status_t WriteSetPattern(const pattern &pat);
41 	status_t WriteSetClipping(const BRegion &region);
42 	status_t WriteClearClipping();
43 
44 	status_t WritePushState();
45 	status_t WritePopState();
46 
47 	status_t WriteSetFontFamily(const font_family family);
48 	status_t WriteSetFontStyle(const font_style style);
49 	status_t WriteSetFontSpacing(const int32 &spacing);
50 	status_t WriteSetFontSize(const float &size);
51 	status_t WriteSetFontRotation(const float &rotation);
52 	status_t WriteSetFontEncoding(const int32 &encoding);
53 	status_t WriteSetFontFlags(const int32 &flags);
54 	status_t WriteSetFontShear(const float &shear);
55 	status_t WriteSetFontFace(const int32 &face);
56 
57 	status_t WriteStrokeLine(const BPoint &start, const BPoint &end);
58 	status_t WriteInvertRect(const BRect &rect);
59 	status_t WriteDrawRect(const BRect &rect, const bool &fill);
60 	status_t WriteDrawRoundRect(const BRect &rect, const BPoint &radius, const bool &fill);
61 	status_t WriteDrawEllipse(const BRect &rect, const bool &fill);
62 	status_t WriteDrawArc(const BPoint &center, const BPoint &radius,
63 				const float &startTheta, const float &arcTheta, const bool &fill);
64 	status_t WriteDrawPolygon(const int32 &numPoints, BPoint *points,
65 				const bool &isClosed, const bool &fill);
66 	status_t WriteDrawBezier(const BPoint points[4], const bool &fill);
67 	status_t WriteDrawString(const BPoint &where, const char *string,
68 				 const int32 &length, const escapement_delta &delta);
69 	status_t WriteDrawShape(const int32 &opCount, const void *opList,
70 				const int32 &ptCount, const void *ptList, const bool &fill);
71 	status_t WriteDrawBitmap(const BRect &srcRect, const BRect &dstRect, const int32 &width, const int32 &height,
72 				const int32 &bytesPerRow, const int32 &colorSpace, const int32 &flags,
73 				const void *data, const int32 &length);
74 
75 	status_t WriteDrawPicture(const BPoint &where, const int32 &token);
76 
77 protected:
78 	// throw a status_t on error
79 	void BeginOp(const int16 &op);
80 	void EndOp();
81 	void WriteData(const void *data, size_t size);
82 	template <typename T> void Write(const T &data) { WriteData(&data, sizeof(data)); }
83 
84 private:
85 	BPositionIO *fData;
86 	std::stack<off_t> fStack;
87 };
88 
89 #endif // _PICTURE_DATA_WRITER_H
90