PictureDataWriter.h revision 2c3505de
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
20class BPositionIO;
21class BRegion;
22
23class PictureDataWriter {
24public:
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			WriteSetClipping(const BRegion& region);
44			status_t			WriteClearClipping();
45
46			status_t			WritePushState();
47			status_t			WritePopState();
48
49			status_t			WriteSetFontFamily(const font_family family);
50			status_t			WriteSetFontStyle(const font_style style);
51			status_t			WriteSetFontSpacing(const int32& spacing);
52			status_t			WriteSetFontSize(const float& size);
53			status_t			WriteSetFontRotation(const float& rotation);
54			status_t			WriteSetFontEncoding(const int32& encoding);
55			status_t			WriteSetFontFlags(const int32& flags);
56			status_t			WriteSetFontShear(const float& shear);
57			status_t			WriteSetFontFace(const int32& face);
58
59			status_t			WriteStrokeLine(const BPoint& start,
60									const BPoint& end);
61			status_t			WriteInvertRect(const BRect& rect);
62			status_t			WriteDrawRect(const BRect& rect,
63									const bool& fill);
64			status_t			WriteDrawRoundRect(const BRect& rect,
65									const BPoint& radius, const bool& fill);
66			status_t			WriteDrawEllipse(const BRect& rect,
67									const bool& fill);
68			status_t			WriteDrawArc(const BPoint& center,
69									const BPoint& radius,
70									const float& startTheta,
71									const float& arcTheta, const bool& fill);
72			status_t			WriteDrawPolygon(const int32& numPoints,
73									BPoint* points, const bool& isClosed,
74									const bool& fill);
75			status_t			WriteDrawBezier(const BPoint points[4],
76									const bool& fill);
77			status_t			WriteDrawString(const BPoint& where,
78									const char* string, const int32& length,
79									const escapement_delta& delta);
80			status_t			WriteDrawShape(const int32& opCount,
81									const void* opList, const int32& ptCount,
82									const void* ptList, const bool& fill);
83			status_t			WriteDrawBitmap(const BRect& srcRect,
84									const BRect& dstRect, const int32& width,
85									const int32& height,
86									const int32& bytesPerRow,
87									const int32& colorSpace,
88									const int32& flags,
89									const void* data, const int32& length);
90
91			status_t			WriteDrawPicture(const BPoint& where,
92									const int32& token);
93
94protected:
95	// throw a status_t on error
96			void				BeginOp(const int16& op);
97			void				EndOp();
98			void				WriteData(const void* data, size_t size);
99	template <typename T> void	Write(const T& data)
100									{ WriteData(&data, sizeof(data)); }
101
102private:
103			BPositionIO*		fData;
104			std::stack<off_t>	fStack;
105};
106
107
108#endif // _PICTURE_DATA_WRITER_H
109