1/* 2 3PicturePrinter 4 5Copyright (c) 2001, 2002 Haiku. 6 7Author: 8 Michael Pfeiffer 9 10Permission is hereby granted, free of charge, to any person obtaining a copy of 11this software and associated documentation files (the "Software"), to deal in 12the Software without restriction, including without limitation the rights to 13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14of the Software, and to permit persons to whom the Software is furnished to do 15so, subject to the following conditions: 16 17The above copyright notice and this permission notice shall be included in all 18copies or substantial portions of the Software. 19 20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26THE SOFTWARE. 27 28*/ 29 30#ifndef _PICTURE_PRINTER_H 31#define _PICTURE_PRINTER_H 32 33#include "PictureIterator.h" 34 35#include <Shape.h> 36 37class PicturePrinter : public PictureIterator 38{ 39public: 40 PicturePrinter(int indent = 0); 41 42 // BPicture playback handlers 43 virtual void Op(int number); 44 virtual void MovePenBy(BPoint delta); 45 virtual void StrokeLine(BPoint start, BPoint end); 46 virtual void StrokeRect(BRect rect); 47 virtual void FillRect(BRect rect); 48 virtual void StrokeRoundRect(BRect rect, BPoint radii); 49 virtual void FillRoundRect(BRect rect, BPoint radii); 50 virtual void StrokeBezier(BPoint *control); 51 virtual void FillBezier(BPoint *control); 52 virtual void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta); 53 virtual void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta); 54 virtual void StrokeEllipse(BPoint center, BPoint radii); 55 virtual void FillEllipse(BPoint center, BPoint radii); 56 virtual void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed); 57 virtual void FillPolygon(int32 numPoints, BPoint *points, bool isClosed); 58 virtual void StrokeShape(BShape *shape); 59 virtual void FillShape(BShape *shape); 60 virtual void DrawString(char *string, float escapement_nospace, float escapement_space); 61 virtual void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data); 62 virtual void SetClippingRects(BRect *rects, uint32 numRects); 63 virtual void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture); 64 virtual void PushState(); 65 virtual void PopState(); 66 virtual void EnterStateChange(); 67 virtual void ExitStateChange(); 68 virtual void EnterFontState(); 69 virtual void ExitFontState(); 70 virtual void SetOrigin(BPoint pt); 71 virtual void SetPenLocation(BPoint pt); 72 virtual void SetDrawingMode(drawing_mode mode); 73 virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit); 74 virtual void SetPenSize(float size); 75 virtual void SetForeColor(rgb_color color); 76 virtual void SetBackColor(rgb_color color); 77 virtual void SetStipplePattern(pattern p); 78 virtual void SetScale(float scale); 79 virtual void SetFontFamily(char *family); 80 virtual void SetFontStyle(char *style); 81 virtual void SetFontSpacing(int32 spacing); 82 virtual void SetFontSize(float size); 83 virtual void SetFontRotate(float rotation); 84 virtual void SetFontEncoding(int32 encoding); 85 virtual void SetFontFlags(int32 flags); 86 virtual void SetFontShear(float shear); 87 virtual void SetFontFace(int32 flags); 88 89private: 90 int fIndent; 91 92 void Print(const char* text); 93 void Print(BPoint* point); 94 void Print(BRect* rect); 95 void Print(int numPoints, BPoint* points); 96 void Print(int numRects, BRect* rects); 97 void Print(BShape* shape); 98 void Print(const char* label, float f); 99 void Print(const char* label, BPoint *point); 100 void Print(rgb_color color); 101 void Print(float f); 102 void Cr(); 103 void Indent(int inc = 0); 104 void IncIndent(); 105 void DecIndent(); 106 107 friend class ShapePrinter; 108}; 109 110class ShapePrinter : public BShapeIterator { 111public: 112 ShapePrinter(PicturePrinter* printer); 113 ~ShapePrinter(); 114 115 status_t IterateBezierTo(int32 bezierCount, BPoint *bezierPoints); 116 status_t IterateClose(void); 117 status_t IterateLineTo(int32 lineCount, BPoint *linePoints); 118 status_t IterateMoveTo(BPoint *point); 119 120private: 121 PicturePrinter* fPrinter; 122}; 123 124#endif // _PICTURE_PRINTER_H 125