1 /* 2 * Copyright 2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini (burton666@libero.it) 7 */ 8 9 #ifndef __PICTUREDATAWRITER_H 10 #define __PICTUREDATAWRITER_H 11 12 #include <InterfaceDefs.h> 13 #include <Font.h> 14 #include <OS.h> 15 16 #include <stack> 17 18 class BPositionIO; 19 class PictureDataWriter { 20 public: 21 PictureDataWriter(); 22 PictureDataWriter(BPositionIO *data); 23 24 status_t SetTo(BPositionIO *data); 25 26 status_t WriteSetOrigin(const BPoint &point); 27 status_t WriteInvertRect(const BRect &rect); 28 29 status_t WriteSetDrawingMode(const drawing_mode &mode); 30 status_t WriteSetPenSize(const float &penSize); 31 status_t WriteSetLineMode(const cap_mode &cap, const join_mode &join, const float &miterLimit); 32 status_t WriteSetScale(const float &scale); 33 34 status_t WriteDrawRect(const BRect &rect, const bool &fill); 35 status_t WriteDrawRoundRect(const BRect &rect, const BPoint &radius, const bool &fill); 36 status_t WriteDrawEllipse(const BRect &rect, const bool &fill); 37 status_t WriteDrawArc(const BPoint ¢er, const BPoint &radius, 38 const float &startTheta, const float &arcTheta, const bool &fill); 39 status_t WriteStrokeLine(const BPoint &start, const BPoint &end); 40 41 status_t WriteSetHighColor(const rgb_color &color); 42 status_t WriteSetLowColor(const rgb_color &color); 43 44 status_t WriteDrawString(const BPoint &where, const char *string, 45 const int32 &length, const escapement_delta &delta); 46 status_t WriteDrawShape(const int32 &opCount, const void *opList, 47 const int32 &ptCount, const void *ptList, const bool &fill); 48 status_t WriteDrawBitmap(const BRect &srcRect, const BRect &dstRect, const int32 &width, const int32 &height, 49 const int32 &bytesPerRow, const int32 &colorSpace, const int32 &flags, 50 const void *data, const int32 &length); 51 52 status_t WriteSetFontFamily(const font_family &family); 53 status_t WriteSetFontStyle(const font_style &style); 54 status_t WriteSetFontSpacing(const int32 &spacing); 55 status_t WriteSetFontSize(const float &size); 56 status_t WriteSetFontRotation(const float &rotation); 57 status_t WriteSetFontEncoding(const int32 &encoding); 58 status_t WriteSetFontFlags(const int32 &flags); 59 status_t WriteSetFontShear(const int32 &shear); 60 status_t WriteSetFontFace(const int32 &face); 61 62 status_t WritePushState(); 63 status_t WritePopState(); 64 65 66 protected: 67 status_t WriteData(const void *data, size_t size); 68 template <typename T> status_t Write(const T &data) { return WriteData(&data, sizeof(data)); } 69 70 status_t BeginOp(const int16 &op); 71 status_t EndOp(); 72 73 private: 74 BPositionIO *fData; 75 std::stack<off_t> fStack; 76 }; 77 78 #endif // __PICTUREDATAWRITER_H 79