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(BPositionIO *data); 22 23 status_t WriteSetOrigin(const BPoint &point); 24 status_t WriteInvertRect(const BRect &rect); 25 26 status_t WriteSetDrawingMode(const drawing_mode &mode); 27 status_t WriteSetPenSize(const float &penSize); 28 status_t WriteSetLineMode(const cap_mode &cap, const join_mode &join, const float &miterLimit); 29 status_t WriteSetScale(const float &scale); 30 31 status_t WriteDrawRect(const BRect &rect, const bool &fill); 32 status_t WriteDrawRoundRect(const BRect &rect, const BPoint &radius, const bool &fill); 33 status_t WriteDrawEllipse(const BRect &rect, const bool &fill); 34 status_t WriteDrawArc(const BPoint ¢er, const BPoint &radius, 35 const float &startTheta, const float &arcTheta, const bool &fill); 36 status_t WriteStrokeLine(const BPoint &start, const BPoint &end); 37 38 status_t WriteSetHighColor(const rgb_color &color); 39 status_t WriteSetLowColor(const rgb_color &color); 40 41 status_t WriteDrawString(const BPoint &where, const char *string, 42 const int32 &length, const escapement_delta &delta); 43 status_t WriteDrawShape(const int32 &opCount, const void *opList, 44 const int32 &ptCount, const void *ptList, const bool &fill); 45 status_t WriteDrawBitmap(const BRect &srcRect, const BRect &dstRect, const int32 &width, const int32 &height, 46 const int32 &bytesPerRow, const int32 &colorSpace, const int32 &flags, 47 const void *data, const int32 &length); 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 int32 &shear); 57 status_t WriteSetFontFace(const int32 &face); 58 59 status_t WritePushState(); 60 status_t WritePopState(); 61 62 63 protected: 64 status_t WriteData(const void *data, size_t size); 65 template <typename T> status_t Write(const T &data) { return WriteData(&data, sizeof(data)); } 66 67 status_t BeginOp(const int16 &op); 68 status_t EndOp(); 69 70 private: 71 BPositionIO *fData; 72 std::stack<off_t> fStack; 73 }; 74 75 #endif // __PICTUREDATAWRITER_H 76