xref: /haiku/headers/private/interface/PictureDataWriter.h (revision b30304acc8c37e678a1bf66976d15bdab103f931)
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 <InterfaceDefs.h>
13 #include <Font.h>
14 #include <OS.h>
15 
16 #include <stack>
17 
18 class BPositionIO;
19 class BRegion;
20 
21 
22 class PictureDataWriter {
23 public:
24 	PictureDataWriter();
25 	PictureDataWriter(BPositionIO *data);
26 
27 	status_t SetTo(BPositionIO *data);
28 
29 	status_t WriteSetHighColor(const rgb_color &color);
30 	status_t WriteSetLowColor(const rgb_color &color);
31 	status_t WriteSetOrigin(const BPoint &point);
32 	status_t WriteSetDrawingMode(const drawing_mode &mode);
33 	status_t WriteSetPenLocation(const BPoint &point);
34 	status_t WriteSetPenSize(const float &penSize);
35 	status_t WriteSetLineMode(const cap_mode &cap, const join_mode &join, const float &miterLimit);
36 	status_t WriteSetScale(const float &scale);
37 	status_t WriteSetPattern(const pattern &pat);
38 	status_t WriteSetClipping(/*const */BRegion &region);
39 	status_t WriteClearClipping();
40 
41 	status_t WritePushState();
42 	status_t WritePopState();
43 
44 	status_t WriteSetFontFamily(const font_family family);
45 	status_t WriteSetFontStyle(const font_style style);
46 	status_t WriteSetFontSpacing(const int32 &spacing);
47 	status_t WriteSetFontSize(const float &size);
48 	status_t WriteSetFontRotation(const float &rotation);
49 	status_t WriteSetFontEncoding(const int32 &encoding);
50 	status_t WriteSetFontFlags(const int32 &flags);
51 	status_t WriteSetFontShear(const float &shear);
52 	status_t WriteSetFontFace(const int32 &face);
53 
54 	status_t WriteStrokeLine(const BPoint &start, const BPoint &end);
55 	status_t WriteInvertRect(const BRect &rect);
56 	status_t WriteDrawRect(const BRect &rect, const bool &fill);
57 	status_t WriteDrawRoundRect(const BRect &rect, const BPoint &radius, const bool &fill);
58 	status_t WriteDrawEllipse(const BRect &rect, const bool &fill);
59 	status_t WriteDrawArc(const BPoint &center, const BPoint &radius,
60 				const float &startTheta, const float &arcTheta, const bool &fill);
61 	status_t WriteDrawPolygon(const int32 &numPoints, BPoint *points,
62 				const bool &isClosed, const bool &fill);
63 	status_t WriteDrawBezier(const BPoint points[4], const bool &fill);
64 	status_t WriteDrawString(const BPoint &where, const char *string,
65 				 const int32 &length, const escapement_delta &delta);
66 	status_t WriteDrawShape(const int32 &opCount, const void *opList,
67 				const int32 &ptCount, const void *ptList, const bool &fill);
68 	status_t WriteDrawBitmap(const BRect &srcRect, const BRect &dstRect, const int32 &width, const int32 &height,
69 				const int32 &bytesPerRow, const int32 &colorSpace, const int32 &flags,
70 				const void *data, const int32 &length);
71 
72 	status_t WriteDrawPicture(const BPoint &where, const int32 &token);
73 
74 protected:
75 	// throw a status_t on error
76 	void BeginOp(const int16 &op);
77 	void EndOp();
78 	void WriteData(const void *data, size_t size);
79 	template <typename T> void Write(const T &data) { WriteData(&data, sizeof(data)); }
80 
81 private:
82 	BPositionIO *fData;
83 	std::stack<off_t> fStack;
84 };
85 
86 #endif // _PICTURE_DATA_WRITER_H
87