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